/* ==========================================================================
   PropHop app tokens (v1), derived from board D.
   SCOPED to `.ph-app`, except --ph-brand-gradient shared with the shell.
   static/css/style.css defines its
   own :root variables and 8 of the 10 names shared with this file have
   different values (--border, --danger, --success, --text-muted,
   --text-secondary, --radius-lg, --radius-pill, --shadow-xs). Scoping means
   the other app values apply only inside an element with class `ph-app`,
   whatever the load order. Only the shared gradient reaches the shell. Load this file AFTER
   style.css (templates/base.html does). Keep dialogs, popovers and toast
   containers inside `.ph-app`, because top-layer elements inherit custom
   properties from their DOM ancestors. At the final rollout, when the old CSS
   is deleted, `.ph-app` becomes `:root` in one line.
   Do not load on the TAB forms pages: they use static/css/tokens.css, which
   defines different values for names such as --radius-sm.
   Source of truth: docs/design-system/app/APP-DESIGN-SYSTEM.md
   ========================================================================== */

/* Fonts: self-hosted. DISABLED until the fonts brief adds the .woff2 files to
   static/fonts/ (otherwise these rules would hijack the "Inter" name and break
   the Google Fonts version still loaded by base.html). Uncomment both blocks in
   that brief, adjust the file names, and remove the Google Fonts <link>.
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-variable.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/static/fonts/bricolage-grotesque-variable.woff2") format("woff2");
  font-weight: 600 700;
  font-style: normal;
  font-display: swap;
}
*/

/* The only global app token: shared with the shell outside .ph-app.
   All other app tokens remain scoped. Preserve the approved three-stop gradient. */
:root {
  --ph-brand-gradient: linear-gradient(135deg, #FF4F9E 0%, #FF8F39 55%, #FFCC36 100%);
}

.ph-app {
  /* ---- Text ---- */
  --ink: #0B0D1A;               /* headings, main text, primary button fill (19.3:1) */
  --text-secondary: #39404E;    /* body text in cards (10.4:1) */
  --text-muted: #626A77;        /* meta, hints, placeholders (5.46:1 white, 5.09:1 on page) */
  --text-completed: #69717F;    /* completed tasks only (4.92:1 white, 4.58:1 on page) */
  --icon-muted: #858D99;        /* icons and rings only, never text (3.35:1) */
  --on-ink: #FFFFFF;

  /* ---- Surfaces and lines ---- */
  --surface: #FFFFFF;
  --page: #F5F7FA;
  --surface-hover: #F8F9FB;
  --fill: #EDF0F4;              /* tags, count badges, hovered cells */
  --divider: #F2F4F7;           /* lines between rows */
  --border: #E6E9EE;            /* card and rail outlines */
  --border-strong: #D9DEE5;     /* button and dropdown outlines */

  /* ---- Meaning ---- */
  --link: #1F4FCC;              /* 6.89:1 */
  --info: #2456DC;              /* focus ring, selected, in progress (6.11:1) */
  --brand-deep: #B3205F;        /* deep brand pink: text and halos only (6.39:1 white, 5.95:1 on page) */
  --info-tint: #E8F0FF;
  --success: #0F7A54;           /* done icon (5.34:1) */
  --success-text: #0B6B49;      /* on --success-tint (5.77:1) */
  --success-tint: #E6F4EE;
  --attention: #A8470F;         /* current stage, overdue (5.88:1) */
  --warning-text: #8F5C00;      /* on --warning-tint (5.33:1) */
  --warning-tint: #FFF7E8;
  --danger: #D23B2E;            /* icons, borders, destructive fill (4.77:1) */
  --danger-text: #B42318;       /* text on --danger-tint (5.76:1) */
  --danger-tint: #FDECEC;

  /* ---- Progress and people ---- */
  --gradient: var(--ph-brand-gradient); /* progress, logo, title tab, page glow, active menu bar */
  --gradient-tab-w: 36px;
  --gradient-tab-h: 3px;
  --page-glow-height: 200px;
  --page-glow-opacity: 0.06;
  --page-glow-fade: linear-gradient(180deg, #000 0%, transparent 100%);
  --z-page-decoration: 0;
  --workspace-max: 1440px;      /* the content cap of a brand page; the working area itself is as wide as the window */
  --workspace-gutter: var(--space-8);
  --avatar-1: #6453E8;          /* white initials 5.32:1 */
  --avatar-2: #0E7C86;          /* 4.95:1 */
  --avatar-3: #C2417A;          /* 4.85:1 */

  /* ---- Type ---- */
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
  --text-caption: 12px;         /* chips, markers (600) */
  --text-meta: 13px;
  --text-ui: 14px;              /* rows, controls, menus */
  --text-body: 15px;
  --text-card-title: 16px;      /* 600 */
  --text-section-title: 20px;   /* 600 */
  --text-key-line: 23px;        /* display, 700 */
  --text-number: 26px;          /* display, 700 */
  --text-page-title: 28px;      /* display, 700 */
  /* Line heights per role (px, from board D) */
  --lh-page-title: 35px;
  --lh-key-line: 30px;
  --lh-number: 29px;
  --lh-section-title: 26px;
  --lh-card-title: 22px;
  --lh-body: 22px;
  --lh-ui: 20px;
  --lh-meta: 18px;
  --lh-caption: 16px;
  --tracking-tight: -0.02em;    /* page title */
  --tracking-snug: -0.01em;     /* section titles */

  /* ---- Shape and depth ---- */
  --radius-sm: 8px;             /* buttons, inputs, hoverable cells */
  --radius-md: 10px;            /* popovers, menus */
  --radius-lg: 12px;            /* cards, rail, icon tiles */
  --radius-pill: 999px;         /* chips */
  --shadow-xs: 0 1px 2px rgba(11, 13, 26, 0.05);
  --shadow-pop: 0 8px 24px rgba(11, 13, 26, 0.12);
  --shadow-overlay: 0 24px 80px rgba(11, 13, 26, 0.22);
  --focus: 2px solid var(--info);
  --focus-offset: 2px;

  /* ---- Space and size (n x 4px) ---- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --control-h: 36px;            /* buttons, selects, tabs: 36px with a mouse, 44px on touch (pointer: coarse rule below) */
  --control-h-sm: 32px;         /* filter chips, compact toolbars */
  --content-max: 1160px;

  /* ---- Layers ---- */
  --z-raised: 1;
  --z-sticky: 10;
  --z-dropdown: 100;
  --z-overlay: 200;
  --z-modal: 300;
  --z-toast: 400;

  /* ---- Motion ---- */
  --motion: 150ms ease;
  --busy-opacity: 0.6;          /* the old list while a slow swap is in flight */

  /* ---- Legacy aliases (phase 1: identical values only, so nothing changes visually) ----
     these aliases live inside `.ph-app`, so they only affect `.ph-app` content until the
     final rollout moves the scope to :root and the old definitions are removed. Phase 1 checks each value matches, then
     removes the old definition. Delete each alias once nothing references the old name. */
  --pd-ink: var(--ink);
  --shell-ink: var(--ink);
  --login-ink: var(--ink);
  --task-drawer-ink: var(--ink);
  /* Phase 2, after a visual check on each page:
     --pd-line / --shell-line / --login-line / --task-drawer-line -> var(--border)
     --pd-muted / --shell-ink-4 / --login-ink-4 / --task-drawer-muted -> var(--text-muted)
     --radius -> var(--radius-lg); --radius-pill already matches */
}

/* Fingers need bigger targets: 44px for buttons and selects on touch screens. */
@media (pointer: coarse) {
  .ph-app { --control-h: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .ph-app { --motion: 0ms; }
}

/* Narrow windows use the smaller page gutter (the old 16px main padding). */
@media (max-width: 768px) {
  .ph-app { --workspace-gutter: var(--space-4); }
}

/* Focus is never removed. Components may restyle it but must keep it visible. */
.ph-app :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: var(--focus);
  outline-offset: var(--focus-offset);
}

/* Breakpoints (media queries cannot read variables): 480px, 880px, 1180px. */
