/* CodeForge preview: the interface system. Tokens first, then the parts every screen shares.
   Load order in a page: base.css (mechanics, no colours), this file, then the page's own layout.

   The rules of the system (from BRIEF.md section 4):
   - Graphite surfaces, a step apart. Separate things with a surface step OR a hairline, never both.
   - Volt is the only accent and it is scarce: the one main action, the selected item, progress fills,
     a correct tick, the "live" word, an XP number that just changed, and what the program printed.
   - Radius: 6 (small things), 10 (controls and blocks), 14 (cards). Docked panels have none.
   - Type: Geist 400, 500, 600. Geist Mono only for code, program output, key caps and XP numbers.
   - Spacing: 4, 8, 12, 16, 20, 24, 32, 40, 48.
   - Motion: one curve (--ease). 120ms hover, 220ms enter and exit, 340ms open and close, 600ms fills. */

:root {
  color-scheme: dark;

  /* surfaces: neutral graphite, a touch warm, never blue */
  --bg: #17181a;                 /* the app, the top bar, docked footers */
  --surface-1: #1d1e21;          /* cards, the console, dialogs */
  --surface-2: #242528;          /* raised: toast, row hover, hint box */
  --surface-3: #2d2f33;          /* tags, key caps, secondary buttons, inline code */
  --surface-3-hover: #36383d;
  --well: #121314;               /* editor, output, code picture, inputs */
  --stage: #1b1c1f;              /* behind the 3D view. Pages set it from the forge build (CFRoom.stageColour) */
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .12);
  --line-3: rgba(255, 255, 255, .2);

  /* text */
  --text-1: #f2f2f0;
  --text-2: #b6b7b3;
  --text-3: #8f908b;             /* the faintest text that still carries information */
  --text-4: #6f716d;             /* line numbers and disabled things only */

  /* the accent */
  --volt: #c6ff3a;
  --volt-hover: #d4ff66;
  --volt-press: #b4ea2e;
  --volt-ink: #12140c;
  --volt-tint: rgba(198, 255, 58, .08);    /* only the running line in code */

  /* status, always with a word */
  --red: #ff6b6b;
  --red-tint: rgba(255, 107, 107, .1);

  /* code */
  --code-text: #e6e6e3;
  --code-fn: #f2f2f0;
  --code-str: #c9dc8c;
  --code-num: #d9b27c;
  --code-key: #a9b2c3;
  --code-punct: #8f908b;
  --code-com: #6f716d;

  --scrim: rgba(12, 12, 13, .72);

  /* type */
  --sans: "Geist", system-ui, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, Consolas, monospace;

  /* shape */
  --r-1: 6px;
  --r-2: 10px;
  --r-3: 14px;

  /* elevation: on the page (nothing), a card, or floating. Nothing in between */
  --e-1: inset 0 1px 0 rgba(255, 255, 255, .04), 0 1px 2px rgba(0, 0, 0, .28);
  --e-2: 0 12px 32px rgba(0, 0, 0, .42), 0 2px 6px rgba(0, 0, 0, .3);

  /* motion */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t-1: 120ms;
  --t-2: 220ms;
  --t-3: 340ms;
  --t-4: 600ms;

  /* the editor in base.css reads these */
  --caret: var(--text-1);
  --select: rgba(255, 255, 255, .16);
}

/* ------------------------------------------------------------------------------------------ page basics */
html { background: var(--bg); }
body { background: var(--bg); color: var(--text-1); font: 400 15px/24px var(--sans); }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
::selection { background: rgba(255, 255, 255, .18); }
.ic { width: 16px; height: 16px; }

/* one focus style for everything you can tab to. Inputs change their border instead */
:where(a, button, [role="button"], [tabindex]):focus-visible { outline: 2px solid rgba(242, 242, 240, .85); outline-offset: 2px; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.num { font-variant-numeric: tabular-nums; }

/* a slim scrollbar that stays visible */
.scroll::-webkit-scrollbar { width: 12px; height: 12px; }
.scroll::-webkit-scrollbar-track, .scroll::-webkit-scrollbar-corner { background: transparent; }
.scroll::-webkit-scrollbar-thumb { border: 4px solid transparent; border-radius: 6px; background: var(--surface-3) content-box; }
.scroll::-webkit-scrollbar-thumb:hover { background-color: var(--surface-3-hover); }
@supports not selector(::-webkit-scrollbar) { .scroll { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; } }

/* ------------------------------------------------------------------------------------------ top bar */
.bar { position: relative; z-index: 30; display: flex; align-items: center; gap: 24px; height: 52px; padding: 0 24px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; border-radius: var(--r-1); font: 600 15px/20px var(--sans); letter-spacing: -.01em; color: var(--text-1); }
.brand img { display: block; width: 24px; height: 24px; border-radius: var(--r-1); box-shadow: 0 0 0 1px var(--line-2); }
.bar-nav { display: flex; align-self: stretch; }
.bar-nav a { position: relative; display: flex; align-items: center; padding: 0 12px; font: 500 14px/20px var(--sans); color: var(--text-3); transition: color var(--t-1) var(--ease); }
.bar-nav a:hover { color: var(--text-1); }
.bar-nav a:focus-visible { outline-offset: -4px; }
.bar-nav a[aria-current] { color: var(--text-1); }
.bar-nav a[aria-current]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--volt); }
.bar-nav a[aria-disabled="true"] { color: var(--text-4); cursor: default; }
.bar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.bar-sep { flex: none; width: 1px; height: 16px; background: var(--line-2); }

/* chips: the quiet items in the bar. Facts are plain text, controls get a hover */
.chip { display: inline-flex; align-items: center; gap: 8px; font: 500 13px/18px var(--sans); color: var(--text-2); white-space: nowrap; }
.chip .ic { color: var(--text-3); transition: color var(--t-1) var(--ease); }
.chip b { font-weight: 500; color: var(--text-1); font-variant-numeric: tabular-nums; }
button.chip, a.chip { height: 36px; margin: 0 -10px; padding: 0 10px; border: 0; border-radius: var(--r-2); background: none; cursor: pointer; transition: background var(--t-1) var(--ease), color var(--t-1) var(--ease); }
button.chip:hover, a.chip:hover { background: var(--surface-2); color: var(--text-1); }
button.chip:hover .ic, a.chip:hover .ic { color: var(--text-1); }
/* the sound switch shows which state it is in with its icon and its word */
.chip .ic-off, .chip.is-off .ic-on { display: none; }
.chip.is-off .ic-off { display: block; }

/* the way back to the LockedFlow site (the site build puts it before the brand) */
.bar-back { display: inline-flex; align-items: center; gap: 6px; height: 32px; margin: 0 -12px 0 -8px; padding: 0 8px; border-radius: var(--r-2); font: 500 13px/18px var(--sans); color: var(--text-3); white-space: nowrap; transition: color var(--t-1) var(--ease), background var(--t-1) var(--ease); }
.bar-back:hover { color: var(--text-1); background: var(--surface-2); }
.bar-back .ic { width: 16px; height: 16px; }
@media (max-width: 760px) { .bar-back span { display: none; } }

/* the LockedFlow account (shared/cloud.js): who is signed in, and whether their progress is saved, in a word */
.acct b { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.acct-st { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: var(--r-1); background: var(--surface-3); color: var(--text-3); font: 500 12px/16px var(--sans); }
.acct-st.is-bad { background: var(--red-tint); color: var(--red); }
/* a laptop half a screen wide, a tablet on its side: the bar drops the sound's word, the level's meter and numbers,
   and keeps a long name short, so everything fits on one row (up to 1200 px: a 20 letter name with Level 10 and a
   long streak needs that much) */
@media (max-width: 1200px) {
  .bar .chip [data-sound-label], .bar .level .meter, .bar .level .xpn { display: none; }
  .acct b { max-width: 96px; }
}
@media (max-width: 900px) { .acct b { display: none; } }
/* phones: the bar keeps the logo, the flame with the streak's number, the level, and the account. The account's
   word shows only when something needs saying (offline, not saved) */
.chip .sm { display: none; }
@media (max-width: 520px) {
  .bar .brand span, .bar-right .bar-sep, .chip .lg, .acct-st.is-quiet { display: none; }
  .chip .sm { display: inline; }
  /* the logo alone is the way to the course: a full size target (the row keeps its width) */
  .bar .brand { padding: 4px; margin: -4px; }
}
/* The live site shows Netlify's "Powered by Netlify" badge: an iframe fixed in the bottom right corner (197 x 64)
   above everything, which takes the clicks there. While it is on the page, the pages keep their controls out of that
   corner: --host-badge-h is its height, --host-badge-w its width plus a gap. Without :has() the layout stays as it is. */
html:has(> body > #nl-badge-frame) { --host-badge-h: 64px; --host-badge-w: 212px; }

/* the site's own toast (lockin.js, a daily bonus), in CodeForge's colours */
#li-toast { position: fixed; left: 50%; bottom: 24px; z-index: 90; width: max-content; max-width: min(360px, calc(100vw - 32px)); padding: 10px 16px; border: 1px solid var(--line-2); border-radius: var(--r-2);
  background: var(--surface-2); box-shadow: var(--e-2); color: var(--text-1); font: 500 13px/18px var(--sans); text-align: center;
  opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: opacity 160ms var(--ease), transform 160ms var(--ease); }
#li-toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 900px) { #li-toast { bottom: calc(24px + var(--host-badge-h, 0px)); } }

.level { display: inline-flex; align-items: center; gap: 12px; font: 500 13px/18px var(--sans); color: var(--text-2); white-space: nowrap; }
.level .meter { width: 96px; }
.avatar { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); font: 600 12.5px/1 var(--sans); color: var(--text-2); }

/* XP is the one number set in mono. It turns volt for a moment when it changes */
.xpn { font: 500 12.5px/16px var(--mono); color: var(--text-3); white-space: nowrap; }
.xpn b { font-weight: 500; color: var(--text-1); transition: color var(--t-3) var(--ease); }
.xpn.is-new, .xpn.is-new b { color: var(--volt); transition-duration: var(--t-1); }

/* ------------------------------------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: none; height: 40px; padding: 0 16px; border: 0; border-radius: var(--r-2);
  background: var(--surface-3); color: var(--text-1); font: 600 14px/20px var(--sans); white-space: nowrap; text-decoration: none; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
  transition: background var(--t-1) var(--ease), color var(--t-1) var(--ease), transform var(--t-1) var(--ease), opacity var(--t-1) var(--ease); }
.btn:hover { background: var(--surface-3-hover); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--volt); color: var(--volt-ink); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .38), inset 0 -1px 0 rgba(0, 0, 0, .16); }
.btn-primary:hover { background: var(--volt-hover); }
.btn-primary:active { background: var(--volt-press); }
.btn-ghost { background: none; color: var(--text-2); font-weight: 500; box-shadow: none; }
.btn-ghost:hover, .btn-ghost[aria-expanded="true"] { background: var(--surface-2); color: var(--text-1); }
.btn-lg { height: 44px; padding: 0 20px; }
.btn-bar { height: 36px; padding: 0 12px; }
.btn-sm { height: 28px; padding: 0 8px; gap: 6px; border-radius: var(--r-1); font-size: 13px; line-height: 18px; }
.btn[disabled], .btn[aria-disabled="true"] { background: var(--surface-3); color: var(--text-3); box-shadow: none; cursor: default; pointer-events: none; }
.btn[aria-busy="true"] { opacity: .7; }
.icon-btn { display: grid; place-items: center; flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--r-1); background: none; color: var(--text-3); cursor: pointer; transition: background var(--t-1) var(--ease), color var(--t-1) var(--ease); }
.icon-btn:hover { background: var(--surface-2); color: var(--text-1); }

/* ------------------------------------------------------------------------------------------ tags, key caps, ticks */
/* a tag is a status word. It is never a button and never a bare dot */
.tag { display: inline-flex; align-items: center; flex: none; height: 24px; padding: 0 8px; border-radius: var(--r-1); background: var(--surface-3); color: var(--text-2); font: 500 12.5px/16px var(--sans); white-space: nowrap; transition: color var(--t-1) var(--ease), background var(--t-1) var(--ease); }
.tag.is-live { color: var(--volt); }
.tag.is-bad { background: var(--red-tint); color: var(--red); }
.key { display: inline-flex; align-items: center; flex: none; height: 24px; padding: 0 8px; border-radius: var(--r-1); background: var(--surface-3); color: var(--text-2); font: 500 12.5px/16px var(--mono); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), inset 0 -1px 0 rgba(0, 0, 0, .4); }
.tick { display: inline-grid; place-items: center; flex: none; width: 16px; height: 16px; border-radius: 50%; background: var(--volt); color: var(--volt-ink); }
.tick .ic { width: 10px; height: 10px; stroke-width: 3.2; }

/* ------------------------------------------------------------------------------------------ cards, wells, inputs, progress */
.card { border-radius: var(--r-3); background: var(--surface-1); box-shadow: var(--e-1); }
.well { border-radius: var(--r-2); background: var(--well); }
.input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--well); color: var(--text-1); font: 500 14px/20px var(--mono); outline: none; transition: border-color var(--t-1) var(--ease); }
.input::placeholder { color: var(--text-3); letter-spacing: .12em; opacity: 1; }
.input:hover { border-color: var(--line-3); }
.input:focus { border-color: rgba(255, 255, 255, .45); }
.input:disabled { color: var(--text-4); }
.meter { display: block; height: 4px; border-radius: 2px; background: var(--line-2); overflow: hidden; }
.meter > i { display: block; width: 0; height: 100%; border-radius: 2px; background: var(--volt); transition: width var(--t-4) var(--ease); }

/* ------------------------------------------------------------------------------------------ code colours */
.t-s { color: var(--code-str); }
.t-f { color: var(--code-fn); font-weight: 600; }
.t-n { color: var(--code-num); }
.t-c { color: var(--code-com); }
.t-p { color: var(--code-punct); }
.t-k { color: var(--code-key); }

/* ------------------------------------------------------------------------------------------ toast */
.toast { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 20px 10px 12px; border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--surface-2); box-shadow: var(--e-2);
  white-space: nowrap; pointer-events: none; opacity: 0; transform: translateY(8px); transition: opacity 160ms var(--ease), transform 160ms var(--ease); }
.toast.on { opacity: 1; transform: none; transition-duration: var(--t-2); }
.toast .tick { width: 32px; height: 32px; }
.toast .tick .ic { width: 16px; height: 16px; stroke-width: 2.8; }
.toast-t { display: grid; }
.toast-t b { font: 600 14px/20px var(--sans); color: var(--text-1); }
.toast-t span { font: 400 13px/18px var(--sans); color: var(--text-2); }
.toast-pts { margin-left: 12px; font: 600 13px/18px var(--mono); color: var(--volt); }

/* ------------------------------------------------------------------------------------------ dialog */
.scrim { position: fixed; inset: 0; z-index: 80; display: none; place-items: center; padding: 16px 16px calc(16px + var(--host-badge-h, 0px)); background: var(--scrim); overflow: auto; }
.scrim.on { display: grid; animation: ui-fade var(--t-2) var(--ease) both; }
.dialog { width: min(480px, 100%); padding: 32px; border: 1px solid var(--line-2); border-radius: var(--r-3); background: var(--surface-1); box-shadow: var(--e-2); text-align: center; animation: ui-rise 240ms var(--ease) both; }

@keyframes ui-fade { from { opacity: 0; } }
@keyframes ui-rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes ui-badge { from { opacity: 0; transform: scale(.92); } }

/* ------------------------------------------------------------------------------------------ the Run nudge
   Kept from the first builds: a ring on the Run button and a "Press Run" arrow, until the first run. */
.run-nudge { gap: 8px; font: 600 13px/18px var(--sans); color: var(--text-1); animation: ui-poke 1s var(--ease) infinite alternate; }
.btn.nudge { position: relative; animation: none; }
.btn.nudge::after { content: ""; position: absolute; inset: 0; border-radius: 10px; box-shadow: 0 0 0 2px var(--volt); pointer-events: none; animation: ui-ring 1.6s var(--ease) infinite; }
@keyframes ui-poke { from { transform: none; } to { transform: translateX(4px); } }
@keyframes ui-ring { 0% { inset: 0; border-radius: 10px; opacity: .9; } 70%, 100% { inset: -8px; border-radius: 18px; opacity: 0; } }
