/* ==========================================================================
   TokForge site.css  ·  v10 ember design system, shared sub-page layer
   Task #916 phase 2. Companion to the #915 landing (which keeps inline CSS).

   Loaded AFTER each page's own <style> block on purpose: this file owns the
   palette tokens, the chrome and the reading layer, while every page keeps
   its own bespoke component layout untouched.

   Palette sampled from the launch art: ember #F5A623 on ground #07090E.
   ========================================================================== */

/* ---------- 1. Tokens -----------------------------------------------------
   The ember set, plus the legacy variable names every sub-page already
   consumes. Redefining them here re-skins ~1,500 existing declarations
   without editing a single component rule.                                  */

:root {
  /* ember core */
  --ink: #07090E;
  --ink-2: #0C1017;
  --ink-3: #121821;
  --line: #1C2431;
  --line-hot: rgba(245, 166, 35, 0.28);
  --ember: #F5A623;
  --ember-hot: #E8621A;
  --ember-lift: #FFC55C;
  --ember-dim: rgba(245, 166, 35, 0.12);

  /* legacy aliases consumed by the existing page stylesheets */
  --bg: #07090E;
  --surface: #0C1017;
  --surface-2: #121821;
  --border: #1C2431;
  --text: #F2F5F8;
  --text-muted: #A9B4C2;
  --text-dim: #7C8797;
  --accent: #F5A623;
  --accent-hover: #FFC55C;
  --white: #FFFFFF;
  --good: #4FD08A;
  --warn: #F5A623;
  --bad: #F0654F;

  /* type */
  --display: 'Bricolage Grotesque', 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --body: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* shape and motion */
  --r: 20px;
  --radius: 16px;
  --radius-sm: 12px;
  --r-sm: 12px;
  --r-pill: 999px;
  --pad: clamp(20px, 4vw, 40px);
  --measure: 72ch;
  --lift: 0 30px 70px -34px rgba(0, 0, 0, 0.95);
  --ease: cubic-bezier(0.22, 0.68, 0.28, 1);
}

/* ---------- 2. Base ------------------------------------------------------ */

html { scroll-behavior: smooth; scroll-padding-top: 96px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Fine forge grain, matching the landing. Decorative only. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Any layout rule below that sets display on a class would otherwise beat the
   UA sheet's [hidden] rule. The docs pages drive their platform toggles with
   the hidden attribute, so make it non-negotiable. */
[hidden] { display: none !important; }

img, video { max-width: 100%; height: auto; }
a { color: var(--ember); text-decoration: none; }
a:hover { color: var(--ember-lift); text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; border-radius: 6px; }
::selection { background: rgba(245, 166, 35, 0.26); color: #FFF; }

h1, h2, h3, h4, h5 { font-family: var(--display); letter-spacing: -0.03em; text-wrap: balance; }
h1 { font-weight: 800; letter-spacing: -0.042em; line-height: 1.03; }
h2 { font-weight: 800; }
h3, h4, h5 { font-weight: 700; }
p, li { text-wrap: pretty; }
strong, b { color: var(--text); font-weight: 700; }

/* ---------- 3. Chrome: header -------------------------------------------
   Namespaced tfx-* so it cannot collide with any page's own .header/.nav.  */

.tfx-header {
  position: sticky;
  top: 0;
  z-index: 200;
  border-bottom: 1px solid transparent;
  background: rgba(7, 9, 14, 0.72);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease);
}
.tfx-header.stuck {
  background: rgba(7, 9, 14, 0.9);
  border-bottom-color: var(--line);
}
.tfx-wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--pad);
}
.tfx-header-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 74px;
}
.tfx-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  font-family: var(--display);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.03em;
  flex: 0 0 auto;
}
.tfx-brand:hover { color: var(--text); text-decoration: none; }
.tfx-brand img { width: 30px; height: 33px; object-fit: contain; display: block; }
.tfx-nav { display: flex; align-items: center; gap: 30px; }
.tfx-nav a {
  color: var(--text-muted);
  font-family: var(--body);
  font-size: 15px;
  font-weight: 600;
  padding: 4px 0;
  border-bottom: 1.5px solid transparent;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.tfx-nav a:hover { color: var(--text); text-decoration: none; }
.tfx-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--ember); }
.tfx-header-cta { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }

/* shared pill button, chrome only */
.tfx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 20px;
  border-radius: var(--r-pill);
  font-family: var(--body);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.25s var(--ease), border-color 0.25s var(--ease);
}
.tfx-btn-primary {
  background: linear-gradient(135deg, var(--ember-lift) 0%, var(--ember) 42%, var(--ember-hot) 100%);
  color: #150C02;
  box-shadow: 0 12px 34px -14px rgba(245, 166, 35, 0.75);
}
.tfx-btn-primary:hover {
  color: #150C02;
  transform: translateY(-2px);
  box-shadow: 0 18px 46px -14px rgba(245, 166, 35, 0.9);
  text-decoration: none;
}
@media (max-width: 940px) { .tfx-nav { display: none; } }
@media (max-width: 380px) { .tfx-brand span { font-size: 17px; } }

/* ---------- 4. Chrome: footer ------------------------------------------- */

.tfx-footer {
  border-top: 1px solid var(--line);
  padding: clamp(46px, 6vw, 72px) 0 40px;
  margin-top: clamp(56px, 8vw, 104px);
  background: var(--ink);
}
.tfx-foot-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr));
  gap: 34px;
}
.tfx-foot-brand p {
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.62;
  max-width: 30ch;
  margin: 14px 0 0;
}
.tfx-foot-col h4 {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ember);
  margin: 0 0 16px;
}
.tfx-foot-col a {
  display: block;
  color: var(--text-muted);
  font-size: 14.5px;
  font-weight: 500;
  margin-bottom: 11px;
}
.tfx-foot-col a:hover { color: var(--text); text-decoration: none; }
.tfx-foot-col a.disc { display: inline-flex; align-items: center; gap: 7px; }
.tfx-foot-col a.disc svg { width: 16px; height: 16px; fill: currentColor; flex: 0 0 auto; }
.tfx-foot-base {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: clamp(34px, 4vw, 52px);
  padding-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 13px;
}
@media (max-width: 760px) { .tfx-foot-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 460px) { .tfx-foot-grid { grid-template-columns: 1fr; gap: 26px; } }

/* ---------- 5. Reading layer --------------------------------------------
   Technical pages keep every word. This is measure, rhythm and hierarchy.  */

.doc-container, .container, main.wrap { max-width: 1180px; }
.doc-container { padding: clamp(34px, 4vw, 56px) var(--pad) 24px; }

.doc-title, .page-header h1, .guide-header h1, .article-header h1 {
  font-size: clamp(2.1rem, 4.6vw, 3.05rem);
  line-height: 1.02;
  margin-bottom: 14px;
}
.doc-meta, .article-meta, .guide-meta {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.doc-body, .guide-body, .article-body, .content { font-size: 17px; line-height: 1.72; }

/* Comfortable measure for running prose only. Direct-child selectors on
   purpose: paragraphs inside cards, callouts and the install band keep the
   width of the box they live in. */
.doc-body > p, .doc-body > ul, .doc-body > ol,
.guide-body > p, .guide-body > ul, .guide-body > ol,
.article-body > p, .content > p,
.container > p, .container > ul, .container > ol,
main > p, main > ul, main > ol,
.plat-view > p, .plat-view > ul,
.faq-answer-inner > p {
  max-width: var(--measure);
}
.container > .lede, main > .lede, .container > .subtitle, main > .subtitle { max-width: 68ch; }

.doc-body h2, .guide-body h2, .article-body h2, .content h2,
.container > h2, main > h2, .plat-view > h2 {
  font-size: clamp(1.55rem, 2.5vw, 1.95rem);
  line-height: 1.16;
  margin-top: 2.4em;
  margin-bottom: 0.6em;
  padding-bottom: 0.42em;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.doc-body h2::after, .guide-body h2::after, .article-body h2::after,
.container > h2::after, main > h2::after, .plat-view > h2::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 46px;
  height: 2px;
  background: linear-gradient(90deg, var(--ember), var(--ember-hot));
}
.doc-body h3, .guide-body h3, .article-body h3, .content h3,
.container > h3, main > h3, .plat-view > h3 {
  font-size: 1.2rem;
  line-height: 1.3;
  margin-top: 2em;
  margin-bottom: 0.5em;
  color: var(--text);
}
.doc-body h4, .guide-body h4 {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ember);
  margin-top: 1.9em;
  margin-bottom: 0.6em;
}
.doc-body p, .guide-body p { color: var(--text-muted); margin-bottom: 1.15em; }
.doc-body li, .guide-body li { color: var(--text-muted); margin-bottom: 0.42em; }
.doc-body ul, .doc-body ol { padding-left: 1.35em; margin-bottom: 1.25em; }
.doc-body li::marker { color: var(--ember); }
.doc-body a, .guide-body a, .article-body a { text-decoration: underline; text-decoration-color: rgba(245, 166, 35, 0.35); text-underline-offset: 3px; }
.doc-body a:hover, .guide-body a:hover { text-decoration-color: var(--ember); }

/* heading anchor affordance, added by site.js */
.tfx-anchor {
  margin-left: 0.4em;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.62em;
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.18s var(--ease), color 0.18s var(--ease);
  text-decoration: none;
}
h2:hover > .tfx-anchor, h3:hover > .tfx-anchor, h4:hover > .tfx-anchor { opacity: 1; }
.tfx-anchor:hover { color: var(--ember); text-decoration: none; }
.tfx-anchor:focus-visible { opacity: 1; }

/* breadcrumbs */
.doc-breadcrumb, .breadcrumb {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 26px;
}
.doc-breadcrumb a, .breadcrumb a { color: var(--text-muted); text-decoration: none; }
.doc-breadcrumb a:hover, .breadcrumb a:hover { color: var(--ember); text-decoration: none; }

/* ---------- 6. Code ------------------------------------------------------
   Docs and API pages are code-heavy. Mono, generous leading, ember rule,
   internal horizontal scroll so a long curl never widens the page.         */

code, kbd, samp { font-family: var(--mono); }

:not(pre) > code {
  font-size: 0.855em;
  background: rgba(245, 166, 35, 0.075);
  border: 1px solid rgba(245, 166, 35, 0.2);
  border-radius: 6px;
  padding: 0.12em 0.42em;
  color: var(--ember-lift);
  word-break: break-word;
}

pre {
  position: relative;
  background: linear-gradient(180deg, #0D1219 0%, #0A0E15 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 20px 22px;
  margin: 0 0 1.5em;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
pre::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--ember), rgba(232, 98, 26, 0.15));
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
pre code {
  display: block;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.78;
  color: #DCE3EC;
  background: none;
  border: none;
  padding: 0;
  white-space: pre;
  tab-size: 2;
}

/* thin ember scrollbars inside code and tables */
pre::-webkit-scrollbar, .tfx-scroll::-webkit-scrollbar { height: 8px; }
pre::-webkit-scrollbar-track, .tfx-scroll::-webkit-scrollbar-track { background: transparent; }
pre::-webkit-scrollbar-thumb, .tfx-scroll::-webkit-scrollbar-thumb {
  background: rgba(245, 166, 35, 0.28);
  border-radius: 999px;
}
pre::-webkit-scrollbar-thumb:hover, .tfx-scroll::-webkit-scrollbar-thumb:hover { background: rgba(245, 166, 35, 0.5); }
pre, .tfx-scroll { scrollbar-width: thin; scrollbar-color: rgba(245, 166, 35, 0.3) transparent; }

/* conservative token accents, applied by site.js */
.tfx-t-str { color: #E9B872; }
.tfx-t-com { color: #5F6C7E; font-style: italic; }
.tfx-t-num { color: #7FD1B9; }
.tfx-t-kw  { color: var(--ember); font-weight: 500; }
.tfx-t-key { color: #9FB3C8; }

/* copy affordance */
.tfx-copy {
  position: absolute;
  top: 9px;
  right: 9px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(12, 16, 23, 0.9);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease);
}
pre:hover .tfx-copy, .tfx-copy:focus-visible { opacity: 1; }
.tfx-copy:hover { color: var(--ember); border-color: var(--line-hot); }
.tfx-copy.done { color: var(--ember); border-color: var(--line-hot); opacity: 1; }
@media (hover: none) { .tfx-copy { opacity: 1; } }

/* ---------- 7. Tables ---------------------------------------------------- */

.tfx-scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  margin: 0 0 1.6em;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.tfx-scroll > table { margin: 0 !important; border: none !important; min-width: 520px; }

/* Pages that ship their own .scroll box hold dense data tables with nowrap
   cells. Without this the table is pinned to 100% of a narrow phone viewport
   and the columns are clipped rather than scrolled, so rows silently lose
   their right-hand values. Let it take its natural width and scroll. */
.scroll > table { min-width: max-content; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th {
  text-align: left;
  padding: 12px 16px;
  background: var(--ink-3);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 14.5px;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.16s var(--ease); }
tbody tr:hover td { background: rgba(245, 166, 35, 0.035); }
td strong, th strong { color: var(--text); }

/* ---------- 8. Component re-skin ----------------------------------------
   Solid-accent buttons need dark ink on ember, never white on ember.       */

.btn-primary, .cta-btn-primary, .play-btn, .play-button, .cta-button,
.google-play-btn, .btn-play, .dl-btn.primary, .cta-btn, .nav-cta,
.cta-link, .cta-button-primary, .plat-toggle button.active {
  background: linear-gradient(135deg, var(--ember-lift) 0%, var(--ember) 42%, var(--ember-hot) 100%) !important;
  color: #150C02 !important;
  border-color: transparent !important;
  font-weight: 700;
  box-shadow: 0 12px 30px -16px rgba(245, 166, 35, 0.8);
  transition: transform 0.24s var(--ease), box-shadow 0.24s var(--ease);
}
.btn-primary:hover, .cta-btn-primary:hover, .play-btn:hover, .play-button:hover,
.cta-button:hover, .google-play-btn:hover, .btn-play:hover, .dl-btn.primary:hover,
.cta-btn:hover, .nav-cta:hover, .cta-link:hover, .cta-button-primary:hover {
  color: #150C02 !important;
  transform: translateY(-2px);
  box-shadow: 0 18px 40px -16px rgba(245, 166, 35, 0.92);
  text-decoration: none;
}
.step-number, .guide-number, .badge {
  background: linear-gradient(135deg, var(--ember-lift) 0%, var(--ember) 45%, var(--ember-hot) 100%) !important;
  color: #150C02 !important;
  font-family: var(--display);
  font-weight: 800;
  border-color: transparent !important;
}

/* cards, callouts and panels pick up the ember edge */
.card, .doc-cards .card, .cta-card, .device-card, .character-card,
.info-box, .callout, .note, .highlight, .analogy, .example-box,
.feature-highlight, .cta-box, .cta-section, .faq-item, .endpoint {
  border-radius: var(--radius);
}
.info-box, .callout, .note, .highlight, .analogy, .feature-highlight {
  border-left: 2px solid var(--ember) !important;
  background: linear-gradient(90deg, rgba(245, 166, 35, 0.06), rgba(245, 166, 35, 0.015) 60%, transparent) !important;
}
.card:hover, .cta-card:hover, .device-card:hover, .character-card:hover, .doc-cards .card:hover {
  border-color: var(--line-hot);
}
.pill, .pillrow span, .tag, .character-tags span {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
}

/* the shared install band that sits above the fold on every sub-page */
.tf-install {
  border: 1px solid var(--line-hot) !important;
  border-radius: var(--radius) !important;
  background: linear-gradient(135deg, rgba(245, 166, 35, 0.075) 0%, rgba(232, 98, 26, 0.04) 55%, rgba(255, 255, 255, 0.015) 100%) !important;
}
.tf-install strong { font-family: var(--display); font-weight: 800; letter-spacing: -0.02em; }

/* API endpoint blocks on /docs/api/ */
.endpoint-path, .endpoint-header, .method { font-family: var(--mono); }

/* the sticky "on this page" rail */
.doc-toc h4 {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ember);
}
.doc-toc a {
  font-size: 13.5px;
  color: var(--text-dim);
  border-left: 1.5px solid transparent;
  padding-left: 12px;
  margin-left: -12px;
  transition: color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.doc-toc a:hover, .doc-toc a.active {
  color: var(--text);
  border-left-color: var(--ember);
  text-decoration: none;
}

/* ---------- 9. Mobile ---------------------------------------------------- */

/* On a phone the table of contents must not eat the whole first screen, so it
   collapses from a tall rail into a compact wrapped chip flow. Every link is
   still visible; nothing is hidden behind a nested scroll. */
@media (max-width: 900px) {
  .doc-toc {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: 14px 16px 16px;
    margin-bottom: 30px;
  }
  .doc-toc h4 { margin-bottom: 12px; }
  .doc-toc ul { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
  .doc-toc ul:last-child { margin-bottom: 0; }
  .doc-toc li { margin: 0; }
  .doc-toc a {
    display: block;
    border: 1px solid var(--line);
    border-left: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 13px;
    margin-left: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
  }
  .doc-toc a:hover, .doc-toc a.active {
    border-color: var(--line-hot);
    border-left-color: var(--line-hot);
    color: var(--ember);
    background: rgba(245, 166, 35, 0.07);
  }
}

@media (max-width: 720px) {
  body { font-size: 16.5px; }
  .doc-body, .guide-body, .article-body { font-size: 16.5px; }
  pre { padding: 16px 16px; border-radius: 10px; }
  pre code { font-size: 12.5px; line-height: 1.72; }
  .doc-container, .container { padding-left: 20px; padding-right: 20px; }
  .tfx-header-in { height: 62px; }
  .doc-body h2 { margin-top: 2em; }
}

@media (max-width: 420px) {
  .tfx-btn { padding: 10px 16px; font-size: 14px; }
}

/* nothing decorative should ever be able to widen the document */
html, body { max-width: 100%; }
