/* forge-ui.css — the app's design system. One file, every page.
 *
 * Loaded by forge-nav.js on every tool page (and by run.html directly), so a page
 * gets the tokens, the two typefaces, base type, focus rings and the shared
 * components without editing its <head>.
 *
 * Rules of the system:
 *   - Two typefaces. Big Shoulders Display for display (titles, numbers, the
 *     timer), Hanken Grotesk for everything else. Nothing else, ever.
 *   - One type scale: 12 13 15 17 22 28 40 64.
 *   - Orange is the ONE primary action per screen. Everything else is bone
 *     white, greys of the ground, and semantic green / amber / red.
 *   - Three surfaces: ground (the page), panel (a section), raised (a card
 *     inside a section, or a control). A thing is not a card unless it needs
 *     to be picked up.
 *   - Components are prefixed .fui-. Pages keep their own classes; as each
 *     page is redone it moves onto these.
 */

:root {
  /* ground and surfaces */
  --fui-ground:  #0c0c0d;
  --fui-panel:   #141416;
  --fui-raised:  #1b1b1e;
  --fui-hover:   #222226;
  --fui-line:    rgba(255,255,255,.08);
  --fui-line2:   rgba(255,255,255,.14);
  /* ink */
  --fui-ink:     #f4f1ec;
  --fui-ink2:    #c9c4bb;
  --fui-mut:     #9a958c;   /* 5.2:1 on panel */
  --fui-faint:   #6b675f;
  /* brand */
  --fui-accent:  #ff6d10;
  --fui-accent2: #e05c00;
  --fui-on-accent:#150900;
  /* semantic (never the accent) */
  --fui-good:    #6fd39a;
  --fui-warn:    #f2c14e;
  --fui-bad:     #ff6b5e;
  /* type */
  --fui-display: "Big Shoulders Display","Barlow Condensed","Arial Narrow",Impact,sans-serif;
  --fui-ui:      "Hanken Grotesk","Helvetica Neue",Helvetica,Arial,sans-serif;
  --fui-mono:    ui-monospace,"SF Mono",Menlo,monospace;
  /* scale */
  --fui-12:12px; --fui-13:13px; --fui-15:15px; --fui-17:17px; --fui-22:22px; --fui-28:28px; --fui-40:40px; --fui-64:64px;
  /* shape */
  --fui-r:  8px;
  --fui-r2: 14px;
  --fui-pill: 999px;
  --fui-shadow: 0 10px 30px rgba(0,0,0,.35);
  --fui-glow:   0 10px 30px rgba(255,109,16,.28);
  /* legacy names pages already use, pointed at the system */
  --orange: var(--fui-accent); --orange2: var(--fui-accent2);
  color-scheme: dark;
}

/* ---------- base ---------- */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--fui-ui) !important;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font-family: inherit; }
h1, h2 {
  font-family: var(--fui-display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .012em;
  line-height: 1;
  text-wrap: balance;
}
h1 { font-size: var(--fui-40); }
h2 { font-size: var(--fui-28); }
h3 { font-family: var(--fui-ui); font-weight: 700; }
::selection { background: rgba(255,109,16,.35); }

/* keyboard users get a ring that looks designed, mouse users see nothing */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--fui-accent); outline-offset: 2px; border-radius: 4px; }
.fnav-item:focus-visible, .fui-btn:focus-visible { outline-offset: 1px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* the inline icon */
svg.fi { display: inline-block; vertical-align: -.18em; flex: none; }

/* ---------- surfaces ---------- */
.fui-panel  { background: var(--fui-panel);  border: 1px solid var(--fui-line);  border-radius: var(--fui-r2); }
.fui-raised { background: var(--fui-raised); border: 1px solid var(--fui-line);  border-radius: var(--fui-r); }
.fui-line   { border-top: 1px solid var(--fui-line); }

/* ---------- type helpers ---------- */
.fui-display { font-family: var(--fui-display); font-weight: 800; text-transform: uppercase; letter-spacing: .012em; line-height: 1; }
.fui-eyebrow { font-size: var(--fui-12); font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--fui-mut); }
.fui-mut { color: var(--fui-mut); }
.fui-num { font-family: var(--fui-display); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .01em; line-height: 1; }

/* ---------- page header ---------- */
.fui-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px 24px; flex-wrap: wrap; padding: 26px 0 18px; border-bottom: 1px solid var(--fui-line); margin-bottom: 22px; }
.fui-head .t { min-width: 0; }
.fui-head .fui-eyebrow { margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
.fui-head .fui-eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--fui-accent); box-shadow: 0 0 0 4px rgba(255,109,16,.16); }
.fui-head h1 { margin: 0; font-size: clamp(34px, 4.6vw, 52px); }
.fui-head .sub { margin: 8px 0 0; color: var(--fui-ink2); max-width: 62ch; font-size: var(--fui-15); }
.fui-head .a { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
@media (max-width: 640px) { .fui-head { padding-top: 14px; } .fui-head h1 { font-size: 32px; } }

/* ---------- buttons ---------- */
.fui-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-family: var(--fui-ui); font-weight: 700; font-size: var(--fui-15); line-height: 1;
  padding: 12px 18px; border-radius: var(--fui-pill); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none;
  transition: transform .12s ease, box-shadow .12s ease, background .12s, border-color .12s, color .12s;
}
.fui-btn:active { transform: translateY(1px); }
.fui-btn[disabled], .fui-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.fui-btn.primary   { background: var(--fui-accent); color: var(--fui-on-accent); box-shadow: var(--fui-glow); }
.fui-btn.primary:hover { background: #ff7d2b; transform: translateY(-1px); }
.fui-btn.secondary { background: var(--fui-raised); color: var(--fui-ink); border-color: var(--fui-line2); }
.fui-btn.secondary:hover { background: var(--fui-hover); border-color: rgba(255,255,255,.22); }
.fui-btn.ghost     { background: transparent; color: var(--fui-ink2); border-color: var(--fui-line2); }
.fui-btn.ghost:hover { color: var(--fui-ink); background: rgba(255,255,255,.05); }
.fui-btn.quiet     { background: transparent; color: var(--fui-mut); padding-inline: 10px; }
.fui-btn.quiet:hover { color: var(--fui-ink); }
.fui-btn.danger    { background: transparent; color: var(--fui-bad); border-color: rgba(255,107,94,.4); }
.fui-btn.danger:hover { background: rgba(255,107,94,.1); }
.fui-btn.sm { font-size: var(--fui-13); padding: 8px 13px; gap: 7px; }
.fui-btn.lg { font-size: var(--fui-17); padding: 15px 24px; }
.fui-btn.icon { padding: 10px; }
.fui-btn.sm.icon { padding: 7px; }
.fui-btn .fi { vertical-align: 0; }

/* ---------- tabs ---------- */
.fui-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--fui-line); overflow-x: auto; scrollbar-width: none; }
.fui-tabs::-webkit-scrollbar { display: none; }
.fui-tabs > * { background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--fui-mut); font: 700 var(--fui-15)/1 var(--fui-ui); padding: 12px 14px; cursor: pointer; white-space: nowrap; text-decoration: none; transition: color .12s, border-color .12s; }
.fui-tabs > *:hover { color: var(--fui-ink); }
.fui-tabs > .on, .fui-tabs > .active, .fui-tabs > [aria-selected="true"] { color: var(--fui-ink); border-bottom-color: var(--fui-accent); }

/* ---------- pills / chips ---------- */
.fui-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; padding: 4px 9px; border-radius: var(--fui-pill); border: 1px solid var(--fui-line2); color: var(--fui-ink2); line-height: 1.4; }
.fui-pill.accent { border-color: rgba(255,109,16,.45); color: var(--fui-accent); }
.fui-pill.good { border-color: rgba(111,211,154,.4); color: var(--fui-good); }
.fui-pill.warn { border-color: rgba(242,193,78,.4); color: var(--fui-warn); }
.fui-pill.bad  { border-color: rgba(255,107,94,.4); color: var(--fui-bad); }

/* ---------- table ---------- */
.fui-table { width: 100%; border-collapse: collapse; font-size: var(--fui-15); }
.fui-table th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--fui-mut); padding: 10px 12px; border-bottom: 1px solid var(--fui-line2); position: sticky; top: 0; background: var(--fui-panel); }
.fui-table td { padding: 11px 12px; border-bottom: 1px solid var(--fui-line); vertical-align: middle; }
.fui-table tr:hover td { background: rgba(255,255,255,.025); }
.fui-table td.num, .fui-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- inputs ---------- */
.fui-input, .fui-select {
  background: var(--fui-raised); color: var(--fui-ink); border: 1px solid var(--fui-line2); border-radius: var(--fui-r);
  font: 500 var(--fui-15)/1.3 var(--fui-ui); padding: 10px 12px; min-height: 40px; width: 100%; box-sizing: border-box;
  transition: border-color .12s, background .12s;
}
.fui-input:hover, .fui-select:hover { border-color: rgba(255,255,255,.22); }
.fui-input:focus, .fui-select:focus { border-color: var(--fui-accent); outline: none; }
.fui-input::placeholder { color: var(--fui-faint); }
.fui-label { display: block; font-size: var(--fui-12); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--fui-mut); margin-bottom: 6px; }

/* ---------- stat tile ---------- */
.fui-stats { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--fui-line2); border-radius: var(--fui-r2); background: rgba(20,20,22,.7); overflow: hidden; }
.fui-stat { padding: 16px 20px; border-right: 1px solid var(--fui-line); }
.fui-stat:last-child { border-right: 0; }
.fui-stat .l { font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--fui-mut); }
.fui-stat .v { font-family: var(--fui-display); font-weight: 800; font-size: var(--fui-40); line-height: 1; margin-top: 6px; }
.fui-stat .v small { font-family: var(--fui-ui); font-weight: 600; font-size: var(--fui-13); color: var(--fui-ink2); margin-left: 6px; }
.fui-stat .s { font-size: 12.5px; color: var(--fui-ink2); margin-top: 4px; }
@media (max-width: 820px) { .fui-stats { grid-template-columns: repeat(2, 1fr); } .fui-stat { border-bottom: 1px solid var(--fui-line); } .fui-stat:nth-child(2n) { border-right: 0; } }

/* ---------- empty state ---------- */
.fui-empty { position: relative; border: 1px dashed var(--fui-line2); border-radius: var(--fui-r2); padding: 34px 28px; text-align: left; display: grid; grid-template-columns: 1fr auto; gap: 18px 28px; align-items: center; overflow: hidden; }
.fui-empty h3 { font-family: var(--fui-display); font-weight: 800; text-transform: uppercase; font-size: var(--fui-28); margin: 0 0 6px; line-height: 1; }
.fui-empty p { margin: 0; color: var(--fui-ink2); max-width: 52ch; }
.fui-empty .a { display: flex; gap: 10px; flex-wrap: wrap; }
.fui-empty .ghost { position: absolute; inset: 0; z-index: -1; opacity: .18; pointer-events: none; -webkit-mask-image: linear-gradient(180deg, #000, transparent 85%); mask-image: linear-gradient(180deg, #000, transparent 85%); }
@media (max-width: 640px) { .fui-empty { grid-template-columns: 1fr; padding: 24px 18px; } }

/* ---------- toast ---------- */
.fui-toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); z-index: 500; background: var(--fui-raised); color: var(--fui-ink); border: 1px solid var(--fui-line2); border-radius: var(--fui-pill); padding: 11px 16px 11px 13px; font-size: var(--fui-13); font-weight: 600; display: inline-flex; align-items: center; gap: 9px; box-shadow: var(--fui-shadow); opacity: 0; transition: transform .22s cubic-bezier(.2,.7,.2,1), opacity .22s; pointer-events: none; max-width: calc(100vw - 32px); }
.fui-toast.show { opacity: 1; transform: translate(-50%, 0); }
.fui-toast .fi { color: var(--fui-good); }
.fui-toast.bad .fi { color: var(--fui-bad); }
@media (max-width: 820px) { .fui-toast { bottom: calc(var(--fnav-tabh, 62px) + 14px + env(safe-area-inset-bottom, 0px)); } }

/* ---------- motion ---------- */
.fui-in { opacity: 0; transform: translateY(8px); animation: fui-rise .5s cubic-bezier(.2,.7,.2,1) forwards; }
.fui-in.d1 { animation-delay: .05s } .fui-in.d2 { animation-delay: .12s } .fui-in.d3 { animation-delay: .2s } .fui-in.d4 { animation-delay: .28s }
@keyframes fui-rise { to { opacity: 1; transform: none; } }
.fui-lift { transition: transform .2s ease, border-color .2s, box-shadow .2s; }
.fui-lift:hover { transform: translateY(-2px); border-color: var(--fui-line2); }

/* ---------- skeleton ---------- */
.fui-skel { background: linear-gradient(90deg, var(--fui-raised) 25%, var(--fui-hover) 50%, var(--fui-raised) 75%); background-size: 200% 100%; animation: fui-shimmer 1.4s infinite; border-radius: 6px; color: transparent; }
@keyframes fui-shimmer { to { background-position: -200% 0; } }

/* ---------- legacy bridge ----------
 * The tool pages were written with their own .btn / .chip / .card / .hero
 * classes. Until each page moves onto .fui-*, these map the shared names onto
 * the tokens. Loaded after the page's own styles, so equal specificity wins. */
.hero > h1, .hero h1 { font-size: clamp(34px, 4.6vw, 52px); margin: 0 0 8px; }
.hero p.lead, p.lead { color: var(--fui-ink2); font-size: var(--fui-15); max-width: 66ch; }
.btn, a.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--fui-ui); font-weight: 700; font-size: 14px; line-height: 1; border-radius: var(--fui-pill);
  padding: 10px 16px; border: 1px solid transparent; cursor: pointer; text-decoration: none;
  background: var(--fui-raised); color: var(--fui-ink); border-color: var(--fui-line2);
  transition: background .12s, border-color .12s, transform .12s, box-shadow .12s;
}
.btn:hover { background: var(--fui-hover); color: var(--fui-ink); }
.btn.o, .btn.primary { background: var(--fui-accent); color: var(--fui-on-accent); border-color: transparent; box-shadow: var(--fui-glow); }
.btn.o:hover, .btn.primary:hover { background: #ff7d2b; }
.btn.ghost { background: transparent; color: var(--fui-ink2); }
.btn.ghost:hover { background: rgba(255,255,255,.05); color: var(--fui-ink); }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.danger { background: transparent; color: var(--fui-bad); border-color: rgba(255,107,94,.4); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.chip, .lchip { border-radius: var(--fui-pill); font-family: var(--fui-ui); font-weight: 600; }
.chip { background: var(--fui-raised); color: var(--fui-ink2); border: 1px solid var(--fui-line2); }
.chip:hover { background: var(--fui-hover); color: var(--fui-ink); }
.chip.on { background: var(--fui-ink); color: var(--fui-ground); border-color: var(--fui-ink); }
.empty { border: 1px dashed var(--fui-line2); border-radius: var(--fui-r2); color: var(--fui-ink2); }
.tag { border-radius: var(--fui-pill); letter-spacing: .08em; }
