/* Juntos shared component layer. Authored here, copied verbatim into every vanilla app
 * by scripts/generate-ui-css.js — do not edit the copy in an app's public/, it is
 * overwritten on the next sync.
 *
 * Depends on juntos-tokens.css being linked FIRST (it supplies every custom property
 * used below). Link order in a page's <head>:
 *     <link rel="stylesheet" href="/juntos-tokens.css">
 *     <link rel="stylesheet" href="/juntos-ui.css">
 *
 * EVERY CLASS IS PREFIXED `ju-`, deliberately. These apps already define .card (26
 * occurrences), .btn (13) and .field (38) with their own meanings; an unprefixed
 * component layer would collide on contact and silently restyle pages nobody touched.
 * The token layer is deliberately UNPREFIXED for the opposite reason — those property
 * names already match what the pages reference, so matching them is the point.
 *
 * Nothing here applies until a page opts in by using a class. Adding the file changes no
 * pixels; that separation is what makes adoption reviewable one page at a time.
 */

/* ─────────────────────────────────────────────────────────────────────────────
 * Container — the single highest-value thing in this file.
 *
 * An audit of all five apps found the platform has ONE layout, a phone layout, and it is
 * hard-capped: every vanilla app declares only max-width breakpoints, none above 600px.
 * El Rebaño's care dashboard caps at 560px, so on a 1440px monitor it uses 39% of the
 * screen and the rest is empty margin — on the app staff use at a desk.
 *
 * This container starts at the same comfortable reading width and actually widens. It is
 * mobile-first (min-width), so on a phone it behaves exactly like the max-width rules it
 * replaces — which is why adopting it can't regress the one layout that works today.
 * ───────────────────────────────────────────────────────────────────────────── */
.ju-container {
  width: 100%;
  max-width: 36rem;              /* 576px — today's effective cap, kept as the phone base */
  margin-inline: auto;
  padding-inline: var(--space-4);
}
@media (min-width: 768px)  { .ju-container { max-width: 45rem; padding-inline: var(--space-6); } }
@media (min-width: 1024px) { .ju-container { max-width: 60rem; } }
@media (min-width: 1280px) { .ju-container { max-width: 72rem; } }

/* For pages whose content should NOT use the extra width — single-column forms above all.
 * A prayer request or connect card stretched to 1152px is worse than one at 576px: the
 * label-to-input distance grows, the eye has to track further on every row, and nothing
 * is gained because a form has no second column to fill. Widening is right for lists and
 * dashboards, wrong for a form, and the difference is worth a modifier rather than a
 * per-page override.
 *
 * Declared after the base container's media queries deliberately — same specificity
 * (0,1,0), so source order is what makes these win. */
.ju-container--narrow { max-width: 36rem; }
@media (min-width: 768px) { .ju-container--narrow { max-width: 40rem; } }

/* ── Card ───────────────────────────────────────────────────────────────────
 * Visual rule 7 (2026-10-23): about 82% white, a white edge, and the light rim
 * (--shadow-card: a 1px bright top line plus a soft shadow). On the cream ground the 82%
 * reads as white; it is see-through only over a coloured surface. */
.ju-card {
  background: rgba(255,255,255,.82);
  border: 1px solid #ffffff;
  border-radius: var(--r-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-card, inset 0 1px 0 #ffffff, 0 1px 2px rgba(6,29,45,.04), 0 6px 20px rgba(6,29,45,.06));
}
/* A dark content card an app draws itself (Serving's assignment card, the hub's Next Up):
 * add .ju-on-dark and keyboard focus inside it becomes a white ring (visual rule 13). */
.ju-on-dark { --focus-ring: #ffffff; }

/* ── Button ───────────────────────────────────────────────────────────────────
 * min-height 44px is not decorative. Three of the four screens audited declare NO minimum
 * control height at all, and the heights present (28/30/36px) sit under the 44x44 target
 * guideline — on apps used one-handed, on a phone, mid-service.
 * ───────────────────────────────────────────────────────────────────────────── */
.ju-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font: inherit;
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  background: var(--accent);
  /* NOT #ffffff. --accent is overwritten at runtime with the CHURCH's own colour by each
     app's branding.js, so the ink on top cannot be a constant: white on The Gathering New
     Jersey's #bad415 is 1.68:1, measured in production. juntos-ink.js computes --accent-ink
     beside the colour (white, or Core's navy where that reads better -- navy on that lime is
     10.25:1). The #fff fallback is exactly the old behaviour wherever that script is absent. */
  color: var(--accent-ink, #ffffff);
  transition: background-color .15s ease, border-color .15s ease;
}
.ju-btn:hover  { background: var(--accent-dark); }
.ju-btn:disabled, .ju-btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

.ju-btn--secondary { background: var(--surface); color: var(--text-1); border-color: var(--line-strong); }
.ju-btn--secondary:hover { background: var(--surface-raised); }

/* --text-3, NOT --border. --border is rgba/near-white and composites to ~1.2:1, which is
   fine for a card edge (1.4.11 exempts non-interactive elements) and fails outright for a
   control boundary, which needs 3:1. Same defect shipped in The Huddle four times over. */
.ju-btn--quiet { background: transparent; color: var(--accent); }
.ju-btn--quiet:hover { background: var(--accent-light); }

/* Destructive actions read as destructive BEFORE the confirm dialog, not after. */
/* --coral-dark, NOT --status-critical: coral cannot carry readable text at ANY ink -- 4.13:1
   with white and 4.16:1 with navy, both under AA's 4.5:1. This is the only role where that
   matters, because a chip or a left border carries no text ON the colour. --status-critical
   is unchanged everywhere else. Hover lightens within the same ramp, with computed ink. */
.ju-btn--danger { background: var(--coral-dark); color: #ffffff; }
/* Hover DARKENS. The first attempt sent it to --coral, which is lighter: white on coral is
   4.13:1, so hovering a destructive button would have made it LESS readable, and nothing
   sets a --coral-ink for it to fall back to. Core's ramp has no step below coral-dark, so
   the darken is computed -- toward --navy rather than pure black, because this file's own
   test forbids a hardcoded hex and the palette's own ink is the better mix anyway. Where
   color-mix is unsupported the declaration is simply dropped
   and the button keeps its base colour -- no hover change, never an unreadable one. */
.ju-btn--danger:hover { background: color-mix(in srgb, var(--coral-dark) 82%, var(--navy)); }

/* ── Form controls ────────────────────────────────────────────────────────────
 * font-size 16px on inputs is deliberate and NOT a design preference: iOS Safari zooms the
 * viewport on focus for anything smaller, which on a kiosk or a phone check-in flow throws
 * the user into a zoomed layout they then have to pinch back out of.
 * ───────────────────────────────────────────────────────────────────────────── */
.ju-field { display: flex; flex-direction: column; gap: var(--space-1); }
/* 14px semibold, never uppercase: one field-label style platform-wide (cohesion audit 2026-10-09). */
.ju-field__label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.ju-field__hint  { font-size: var(--text-xs); color: var(--text-3); }
.ju-field__error { font-size: var(--text-xs); color: var(--status-critical); font-weight: 600; }

.ju-input, .ju-select, .ju-textarea {
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-1);
  font: inherit;
  font-size: 16px;
  /* No `outline: none` here, deliberately. 42 of those across three apps are why the
     shared focus ring needed !important to work at all — this layer will not add a 43rd. */
}
.ju-input:focus, .ju-select:focus, .ju-textarea:focus { border-color: var(--accent); }
.ju-textarea { min-height: 6rem; resize: vertical; line-height: 1.5; }
.ju-field--invalid .ju-input,
.ju-field--invalid .ju-select,
.ju-field--invalid .ju-textarea { border-color: var(--status-critical); }

/* Visually hidden but available to screen readers — for a label a sighted user gets from
 * context and a screen-reader user otherwise wouldn't get at all. */
.ju-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ── Loading (2026-11-09): one look for "this is still coming" in every app ──
 *   <div class="ju-loading" role="status" aria-live="polite">
 *     <span class="ju-loading__spinner" aria-hidden="true"></span>
 *     <span class="ju-loading__text">Loading your work…</span></div>
 * The text is the page's own sentence saying WHAT is loading, never a bare "Loading". Add
 * .ju-loading--block for a whole list: centred in a card-height area. No skeleton boxes.
 * It fades in after 300ms, so a fast load never flashes it. Plain teal ring on a pale track,
 * no glow (visual rule 8). With reduced motion: no spin, no fade, a static ring at once. */
.ju-loading {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1.4;
  animation: ju-loading-in 200ms ease-out 300ms both;
}
.ju-loading--block { min-height: 160px; padding: var(--space-6) var(--space-4); text-align: center; }
.ju-loading__spinner {
  width: 24px; height: 24px; flex-shrink: 0; box-sizing: border-box;
  border-radius: 50%;
  border: 3px solid var(--teal-pale);
  border-top-color: var(--teal-2);
  animation: ju-loading-spin 800ms linear infinite;
}
.ju-loading__text { font-size: 16px; color: var(--text-2); }
@keyframes ju-loading-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes ju-loading-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .ju-loading { animation: none; opacity: 1; }
  .ju-loading__spinner { animation: none; }
}

/* ═════════════════════════════════════════════════════════════════════════════
 * THE PREMIUM LAYER (2026-10-23, the owner's decision: "A + B with C's touches")
 *
 * First drawn as a navy header with light glowing behind it and a jewel icon per app; since
 * option B and the visual rules it is a plain cream page, a light header card, soft shadows
 * and close-colour gradient buttons, with no glows (rule 8). Mockup:
 * the "Juntos Premium Look Ideas" canvas, board "Chosen". Every rule is opt-in, like the
 * rest of this file: nothing changes until a page uses one of these classes.
 *
 * WHICH APP A PAGE BELONGS TO is one class on any ancestor (usually <body>):
 * `ju-app-care`, `ju-app-serving`, `ju-app-groups`, `ju-app-kids`; none means My Work's
 * teal. It sets --ju-glow, the light behind the header, so Care glows coral and Serving
 * gold while everything else stays the same. The gradients are built HERE rather than as
 * finished token strings because a custom property holding var() is resolved where it is
 * declared -- a gradient built on :root could never pick up the app's glow.
 *
 * TEXT ON THE DARK HEADER is white, --on-dark-muted or --on-dark-alert: past 10:1 on navy,
 * past 6:1 inside a glass panel. The glows, glass and "-hi" colours are fills only and
 * never carry words. White words never sit on --teal-3 (3.9:1): buttons end on --teal-2.
 * ═════════════════════════════════════════════════════════════════════════════ */
.ju-app-care    { --ju-glow: var(--glow-coral); }
.ju-app-serving { --ju-glow: var(--glow-amber); }
.ju-app-groups  { --ju-glow: var(--glow-sage); }
.ju-app-kids    { --ju-glow: var(--glow-purple); }

/* ── The page ground: plain cream (visual rule 8: no glows, no washes). The class name is kept
 *    because many pages carry it. ── */
.ju-page-glow {
  background: var(--cream);
}

/* ── The page header: a light see-through card (option B, 2026-10-23) ──
 * The navy top bar is the ONLY dark band on a page; a header under it is a light card standing
 * apart from it, never a second navy block. Text is navy and slate, so it reads on cream or white.
 * `ju-hero--card` rounds all four corners where it sits inside the page; plain `ju-hero` stands a
 * little apart from the top bar. --ju-glow is kept (each app still sets it) for anything that
 * wants the app's colour, but the header itself draws no glow. */
.ju-hero {
  position: relative;
  display: flex; flex-direction: column; gap: var(--space-4);
  padding: var(--space-5) var(--space-4) var(--space-6);
  border-radius: 24px;
  color: var(--text-1);
  background-color: rgba(255,255,255,.78);
  border: 1px solid rgba(255,255,255,.95);
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 2px rgba(6,29,45,.04), 0 6px 20px rgba(6,29,45,.06);
}
/* No blur on purpose: a header card sits in the page, so nothing passes behind it, and a backdrop-filter would make it the
   containing block for any position:fixed element inside (the round + on My Work, a phone menu). 2026-10-23. */
.ju-hero--card { border-radius: 24px; padding: var(--space-6) var(--space-8); }
.ju-hero:not(.ju-hero--card) { margin: var(--space-3, 12px) var(--space-3, 12px) 0; }
.ju-hero__eyebrow {
  margin: 0; font-size: var(--text-xs); font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-2);
}
.ju-hero__title {
  margin: 0; font-size: var(--text-xl); font-weight: 800;
  letter-spacing: -.015em; line-height: 1.2; color: var(--navy);
}
/* One page-title size on every screen and in every app: 24px (cohesion audit 2026-11-09; it grew to 30px from 768px). */
.ju-hero__meta  { margin: 0; font-size: var(--text-sm); color: var(--text-2); }
/* A word in the title set apart: the person's name in "Good morning, Pastor". Plain teal words. */
.ju-hero__glow-text {
  color: var(--teal-2);
}

/* ── A small panel inside the header: a count, a note ── */
.ju-glass {
  background: rgba(6,29,45,.035);
  border: 1px solid rgba(6,29,45,.07);
  border-radius: 18px;
  padding: var(--space-3) var(--space-4);
  color: var(--text-1);
}
.ju-glass--alert { border-color: var(--coral); background: var(--coral-light); }
/* A row of numbers on the header: "5 Open · 2 Overdue · 3 This week". */
.ju-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.ju-stat__value { display: block; font-size: var(--text-xl); font-weight: 800; line-height: 1.15; color: var(--navy); }
.ju-stat__label { display: block; font-size: var(--text-xs); color: var(--text-2); }
.ju-stat--alert .ju-stat__value { color: var(--coral-dark); }

/* ── Soft labels: "Care", "Serving", "Kids", "Groups" on a card ── */
.ju-pill {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 3px 10px; border-radius: 999px;
  font-size: var(--text-xs); font-weight: 700; line-height: 1.5; white-space: nowrap;
  background: linear-gradient(135deg, var(--soft), var(--surface-raised));
  color: var(--text-2);
}
.ju-pill--care    { background: linear-gradient(135deg, var(--coral-light), var(--coral-light-2));   color: var(--coral-dark); }
.ju-pill--serving { background: linear-gradient(135deg, var(--amber-light), var(--amber-light-2));   color: var(--amber-dark); }
.ju-pill--groups  { background: linear-gradient(135deg, var(--sage-light), var(--sage-light-2));     color: var(--sage-dark); }
.ju-pill--kids    { background: linear-gradient(135deg, var(--purple-light), var(--purple-light-2)); color: var(--purple-deep); }
.ju-pill--work    { background: linear-gradient(135deg, var(--teal-pale), var(--teal-pale-2));       color: var(--teal); }

/* The jewel icons (`ju-app-icon`) and the glow button (`ju-btn--glow`) were removed 2026-11-09: no app used them, and
 * a glow under a control breaks visual rules 8 and 10. A ministry's colour is a thin edge, a tag or a plain icon tile.
 * Also removed 2026-11-09 because no app's own files used them: the layout primitives (ju-stack, ju-cluster, ju-grid,
 * ju-scroll-x, ju-container--wide), ju-chip, ju-muted / ju-label / ju-prose, ju-card--raised / --quiet / --premium /
 * --alert / --warm, ju-card__head / __title, ju-btn--block / --gradient / --glass, ju-hero__alert, ju-progress and
 * ju-dot. Bring one back here (not in an app) if a page needs it. */

/* ── The ring: how much of the open work is overdue ──
 * Set the share as --ju-ring (a percentage) and put the number inside. The ring is a
 * picture; give it role="img" and an aria-label that says it in words. */
.ju-ring {
  width: 68px; height: 68px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  /* Two plain segments, no bright highlights (visual rule 9). */
  background: conic-gradient(var(--coral) 0 var(--ju-ring, 0%), var(--teal-2) var(--ju-ring, 0%) 100%);
}
.ju-ring__inner {
  width: 80%; height: 80%; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #ffffff; color: var(--navy); line-height: 1.1;
  font-size: var(--text-lg); font-weight: 800;
}
.ju-ring__inner small { font-size: .6875rem; font-weight: 600; color: var(--text-2); white-space: nowrap; max-width: 92%; }

/* Keyboard focus in the (light) header is a teal ring, like every light surface. */
.ju-hero :focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ── The round + button (New Care Need) ──
 * Shown only to people who may use it -- the page decides that, not this class. It has
 * no words, so it MUST carry aria-label. 56px, past the 44px floor. */
.ju-fab {
  width: 56px; height: 56px; min-height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 4px solid var(--cream); padding: 0; cursor: pointer;
  color: #ffffff;
  background: linear-gradient(135deg, var(--teal-3) 0%, var(--teal) 100%);
  box-shadow: var(--shadow-glow), inset 0 1px 0 var(--glass-shine);
}
.ju-fab svg { width: 24px; height: 24px; }
.ju-fab:hover { background: linear-gradient(135deg, var(--teal-3) 0%, var(--teal) 100%); }
