
/* ═══════════════════════════════════════════════
   TOKENS
═══════════════════════════════════════════════ */
:root {
  --primary:      #c84b31;
  --primary-dk:   #b03d25;
  --primary-lt:   rgba(200,75,49,.1);
  --secondary:    #1a1a2e;
  --accent:       #c9a84c;
  --blue:         #2563eb;
  --blue-lt:      #dbeafe;
  --green:        #16a34a;
  --green-lt:     #dcfce7;

  --ink:          #0d0d0d;
  --paper:        #faf9f6;
  --cream:        #f4f1ea;
  --white:        #ffffff;
  --muted:        #6b6560;
  --dim:          #aaa59f;
  --border:       #e2ddd6;
  --border-dk:    #d4cec7;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'DM Mono', 'Courier New', monospace;

  --sidebar-w:    272px;
  --header-h:     56px;
  --content-max:  760px;

  --radius-sm:    4px;
  --radius-md:    8px;
  --radius-lg:    12px;

  --shadow-sm:    0 2px 8px rgba(0,0,0,.06);
  --shadow-md:    0 8px 24px rgba(0,0,0,.10);
}

/* ═══════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.65;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
code, kbd, pre { font-family: var(--font-mono); }
img { max-width: 100%; display: block; }
button { font-family: var(--font-body); cursor: pointer; }

/* ═══════════════════════════════════════════════
   TOP HEADER BAR
═══════════════════════════════════════════════ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(250,249,246,.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem 0 0;
  z-index: 200;
}
.topbar__brand {
  width: var(--sidebar-w);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 1.5rem;
  border-right: 1px solid var(--border);
  height: 100%;
  flex-shrink: 0;
}
.topbar__logo {
  font-family: var(--font-display);
  font-size: 1.35rem; font-weight: 800; color: var(--ink);
  letter-spacing: -.02em;
}
.topbar__logo span { color: var(--primary); }
.topbar__badge {
  font-family: var(--font-mono);
  font-size: .62rem; font-weight: 500;
  background: var(--cream);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: .04em;
}
.topbar__nav {
  display: flex; align-items: center; gap: 1.5rem; flex: 1; padding-left: 2rem;
}
.topbar__nav a {
  font-size: .84rem; color: var(--muted); font-weight: 500;
  transition: color .15s;
}
.topbar__nav a:hover { color: var(--ink); text-decoration: none; }
.topbar__actions { display: flex; align-items: center; gap: .75rem; }
.topbar__btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .42rem 1rem; border-radius: var(--radius-sm);
  font-size: .82rem; font-weight: 600;
  border: none; text-decoration: none; transition: all .15s;
}
.topbar__btn--outline {
  border: 1px solid var(--border); color: var(--muted); background: transparent;
}
.topbar__btn--outline:hover { border-color: var(--ink); color: var(--ink); text-decoration: none; }
.topbar__btn--primary { background: var(--primary); color: white; }
.topbar__btn--primary:hover { background: var(--primary-dk); text-decoration: none; }
.topbar__toggle {
  display: none; background: none; border: none;
  color: var(--ink); font-size: 1.3rem; padding: .4rem;
}

/* ═══════════════════════════════════════════════
   LAYOUT: SIDEBAR + CONTENT
═══════════════════════════════════════════════ */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
}

/* ── Sidebar ── */
.sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--white);
  padding: 1.75rem 0 3rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-group { margin-bottom: 1.75rem; }
.nav-group__label {
  font-family: var(--font-mono);
  font-size: .6rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--dim); font-weight: 600;
  padding: 0 1.5rem; margin-bottom: .5rem;
  display: block;
}
.nav-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .42rem 1.5rem;
  font-size: .84rem; color: var(--muted); font-weight: 400;
  border-left: 2px solid transparent;
  transition: all .15s;
  cursor: pointer;
  text-decoration: none;
}
.nav-link:hover { color: var(--ink); background: var(--paper); text-decoration: none; }
.nav-link.is-active {
  color: var(--primary); font-weight: 600;
  border-left-color: var(--primary);
  background: var(--primary-lt);
}
.nav-link__icon { font-size: .78rem; flex-shrink: 0; opacity: .65; }
.nav-sub { padding: 0 1.5rem 0 3rem; display: flex; flex-direction: column; gap: 1px; }
.nav-sub a {
  font-size: .8rem; color: var(--dim); padding: .3rem 0;
  display: block; transition: color .15s; text-decoration: none;
}
.nav-sub a:hover { color: var(--primary); text-decoration: none; }

/* ── Main content ── */
.content {
  padding: 3rem 4rem 6rem 3.5rem;
  max-width: calc(var(--content-max) + 8rem);
}

/* ═══════════════════════════════════════════════
   CONTENT TYPOGRAPHY
═══════════════════════════════════════════════ */
.doc-section {
  margin-bottom: 4.5rem;
  padding-bottom: 4.5rem;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: calc(var(--header-h) + 2rem);
}
.doc-section:last-child { border-bottom: none; }

/* Section breadcrumb label */
.doc-eyebrow {
  font-family: var(--font-mono);
  font-size: .65rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--primary); font-weight: 700; margin-bottom: .6rem;
  display: flex; align-items: center; gap: .5rem;
}
.doc-eyebrow::before { content: '§'; opacity: .5; }

.doc-h1 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 3vw, 2.6rem);
  font-weight: 800; letter-spacing: -.03em;
  line-height: 1.1; color: var(--ink);
  margin-bottom: .9rem;
}
.doc-h2 {
  font-family: var(--font-display);
  font-size: 1.55rem; font-weight: 700;
  letter-spacing: -.025em; line-height: 1.2;
  color: var(--ink); margin: 2.5rem 0 .8rem;
  display: flex; align-items: center; gap: .6rem;
}
.doc-h2::before {
  content: '';
  width: 3px; height: 1.2em;
  background: var(--primary); border-radius: 2px;
  flex-shrink: 0;
}
.doc-h3 {
  font-family: var(--font-body);
  font-size: 1rem; font-weight: 700;
  color: var(--ink); margin: 1.8rem 0 .55rem;
}
.doc-lead {
  font-size: 1.05rem; color: var(--muted);
  line-height: 1.75; font-weight: 300;
  max-width: 620px; margin-bottom: 1.5rem;
}
.doc-p {
  font-size: .93rem; color: #444;
  line-height: 1.8; margin-bottom: 1.1rem;
}
.doc-p:last-child { margin-bottom: 0; }

/* Inline code */
.ic {
  font-family: var(--font-mono);
  font-size: .82em;
  background: var(--cream);
  border: 1px solid var(--border);
  color: var(--primary);
  padding: 1px 6px;
  border-radius: 3px;
}

/* ═══════════════════════════════════════════════
   HERO INTRO BLOCK
═══════════════════════════════════════════════ */
.doc-hero {
  background: linear-gradient(135deg, var(--secondary) 0%, #2d1a40 100%);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2.5rem 2rem;
  margin-bottom: 3rem;
  position: relative;
  overflow: hidden;
}
.doc-hero::before {
  content: '';
  position: absolute; top: -60px; right: -60px;
  width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(200,75,49,.18) 0%, transparent 70%);
  pointer-events: none;
}
.doc-hero::after {
  content: 'FORMA';
  position: absolute; bottom: -1rem; right: 1.5rem;
  font-family: var(--font-display);
  font-size: 6rem; font-weight: 900;
  color: rgba(255,255,255,.03); letter-spacing: -.04em;
  pointer-events: none; user-select: none;
}
.doc-hero__tag {
  font-family: var(--font-mono);
  font-size: .65rem; letter-spacing: .14em; text-transform: uppercase;
  color: rgba(200,75,49,.8); margin-bottom: .8rem; display: block;
}
.doc-hero__title {
  font-family: var(--font-display);
  font-size: 2rem; font-weight: 800;
  color: white; letter-spacing: -.03em; line-height: 1.1;
  margin-bottom: .75rem;
}
.doc-hero__sub {
  font-size: .9rem; color: rgba(255,255,255,.5);
  line-height: 1.7; font-weight: 300; max-width: 520px;
}
.doc-hero__meta {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin-top: 1.4rem;
}
.doc-hero__chip {
  font-family: var(--font-mono); font-size: .68rem;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.45);
  padding: 3px 10px; border-radius: 999px;
}

/* ═══════════════════════════════════════════════
   CALLOUT / ALERT BOXES
═══════════════════════════════════════════════ */
.callout {
  display: flex; gap: .9rem;
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  font-size: .88rem; line-height: 1.7;
}
.callout__icon { font-size: 1rem; flex-shrink: 0; margin-top: .1rem; }
.callout--tip    { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.callout--note   { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.callout--warn   { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.callout--info   { background: var(--cream); border: 1px solid var(--border); color: var(--muted); }
.callout strong  { font-weight: 700; }

/* ═══════════════════════════════════════════════
   CODE BLOCKS
═══════════════════════════════════════════════ */
.code-block {
  background: var(--secondary);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 1.25rem 0;
  box-shadow: var(--shadow-md);
}
.code-block__header {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.04);
  border-bottom: 1px solid rgba(255,255,255,.06);
  padding: .55rem 1rem;
}
.code-block__dots { display: flex; gap: 5px; }
.code-dot { width: 9px; height: 9px; border-radius: 50%; }
.code-dot--r { background: #ff5f57; }
.code-dot--y { background: #ffbd2e; }
.code-dot--g { background: #28ca41; }
.code-block__filename {
  font-family: var(--font-mono); font-size: .7rem;
  color: rgba(255,255,255,.3); letter-spacing: .04em;
}
.code-block__copy {
  font-family: var(--font-mono); font-size: .65rem;
  color: rgba(255,255,255,.25); background: none; border: none;
  cursor: pointer; padding: 2px 6px; border-radius: 3px;
  transition: all .15s;
}
.code-block__copy:hover { color: white; background: rgba(255,255,255,.08); }
.code-block pre {
  padding: 1.2rem 1.25rem;
  font-size: .8rem; line-height: 1.9;
  color: rgba(255,255,255,.65);
  overflow-x: auto;
  white-space: pre;
}
/* Syntax tokens */
.t-comment { color: #4a5568; font-style: italic; }
.t-sel     { color: #8be9fd; }
.t-prop    { color: #bd93f9; }
.t-val     { color: #50fa7b; }
.t-num     { color: #ffb86c; }
.t-str     { color: #f1fa8c; }
.t-key     { color: #ff79c6; }
.t-tag     { color: #ff79c6; }
.t-attr    { color: #8be9fd; }
.t-op      { color: rgba(255,255,255,.35); }

/* ═══════════════════════════════════════════════
   FILE TREE
═══════════════════════════════════════════════ */
.file-tree {
  background: var(--secondary);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.4rem;
  font-family: var(--font-mono);
  font-size: .8rem;
  line-height: 2;
  color: rgba(255,255,255,.55);
  margin: 1.25rem 0;
}
.ft-dir    { color: rgba(255,255,255,.85); font-weight: 600; }
.ft-html   { color: #ff79c6; }
.ft-css    { color: #8be9fd; }
.ft-js     { color: #f1fa8c; }
.ft-note   { color: rgba(255,255,255,.2); font-style: italic; margin-left: .5rem; }
.ft-indent { padding-left: 1.2rem; }
.ft-indent2 { padding-left: 2.4rem; }
.file-tree { overflow-x: auto; }

/* ═══════════════════════════════════════════════
   TABLES
═══════════════════════════════════════════════ */
.doc-table-wrap { overflow-x: auto; margin: 1.25rem 0; }
.doc-table {
  width: 100%; border-collapse: collapse;
  font-size: .85rem;
}
.doc-table th {
  text-align: left; font-weight: 700;
  font-family: var(--font-mono); font-size: .72rem;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
  background: var(--cream); border: 1px solid var(--border);
  padding: .6rem .9rem;
}
.doc-table td {
  padding: .65rem .9rem;
  border: 1px solid var(--border);
  vertical-align: top; line-height: 1.55;
  color: #333;
}
.doc-table tr:nth-child(even) td { background: rgba(244,241,234,.4); }
.doc-table code { font-family: var(--font-mono); font-size: .82em; color: var(--primary); }

/* ═══════════════════════════════════════════════
   TEMPLATE CARDS (gallery)
═══════════════════════════════════════════════ */
.template-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .9rem;
  margin: 1.25rem 0;
}
.t-card {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  overflow: hidden; transition: all .2s;
}
.t-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.t-card__swatch { height: 72px; display: flex; align-items: center; justify-content: center; }
.t-card__body { padding: .7rem .9rem; }
.t-card__name { font-size: .88rem; font-weight: 700; margin-bottom: .2rem; }
.t-card__desc { font-size: .76rem; color: var(--muted); line-height: 1.5; margin-bottom: .5rem; }
.t-card__link {
  font-family: var(--font-mono); font-size: .7rem;
  color: var(--primary); display: inline-flex; align-items: center; gap: .3rem;
}

/* ═══════════════════════════════════════════════
   STEP BOXES
═══════════════════════════════════════════════ */
.steps { display: flex; flex-direction: column; gap: 0; margin: 1.5rem 0; }
.step {
  display: flex; gap: 1.2rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.step:last-child { border-bottom: none; }
.step__num {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary); color: white;
  font-family: var(--font-mono); font-size: .75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: .1rem;
}
.step__title { font-size: .93rem; font-weight: 700; margin-bottom: .3rem; }
.step__desc { font-size: .85rem; color: var(--muted); line-height: 1.65; }

/* ═══════════════════════════════════════════════
   BADGES / TAGS
═══════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: .65rem; font-weight: 600;
  letter-spacing: .04em; padding: 2px 8px; border-radius: 3px;
}
.badge--green  { background: var(--green-lt); color: var(--green); }
.badge--blue   { background: var(--blue-lt); color: var(--blue); }
.badge--red    { background: rgba(200,75,49,.1); color: var(--primary); }
.badge--gold   { background: #fffbeb; color: #92400e; }
.badge--gray   { background: var(--cream); color: var(--muted); border: 1px solid var(--border); }

/* ═══════════════════════════════════════════════
   TOKEN SWATCH
═══════════════════════════════════════════════ */
.token-grid { display: flex; flex-direction: column; gap: 0; margin: 1rem 0; }
.token-row {
  display: grid; grid-template-columns: 1.5rem 9rem 1fr 1fr;
  align-items: center; gap: 1rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .84rem;
}
.token-row:last-child { border-bottom: none; }
.token-swatch { width: 22px; height: 22px; border-radius: 4px; border: 1px solid var(--border); flex-shrink: 0; }
.token-name { font-family: var(--font-mono); font-size: .78rem; color: var(--primary); }
.token-val  { font-family: var(--font-mono); font-size: .76rem; color: var(--muted); }
.token-desc { font-size: .8rem; color: var(--muted); }

/* ═══════════════════════════════════════════════
   DIVIDER
═══════════════════════════════════════════════ */
.doc-divider {
  height: 1px; background: var(--border);
  margin: 2rem 0;
}

/* ═══════════════════════════════════════════════
   ANCHOR LINKS
═══════════════════════════════════════════════ */
.anchor {
  display: block;
  scroll-margin-top: calc(var(--header-h) + 1.5rem);
}

/* ═══════════════════════════════════════════════
   PRINT PREVIEW ILLUSTRATION
═══════════════════════════════════════════════ */
.print-preview {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem; margin: 1.25rem 0;
  display: flex; gap: 1.5rem; align-items: flex-start;
  flex-wrap: wrap;
}
.print-preview__page {
  width: 90px; height: 127px; /* A4 ratio */
  background: white;
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0,0,0,.1);
  border-radius: 2px;
  flex-shrink: 0;
  position: relative; overflow: hidden;
}
.print-preview__page::before {
  content: '';
  position: absolute; inset: 6px;
  background: repeating-linear-gradient(
    transparent, transparent 7px,
    rgba(0,0,0,.05) 7px, rgba(0,0,0,.05) 8px
  );
}
.print-preview__page::after {
  content: '';
  position: absolute; top: 6px; left: 6px; right: 6px; height: 10px;
  background: var(--primary); opacity: .15; border-radius: 1px;
}
.print-preview__info { flex: 1; min-width: 200px; }
.print-preview__title { font-size: .9rem; font-weight: 700; margin-bottom: .4rem; }
.print-preview__desc  { font-size: .82rem; color: var(--muted); line-height: 1.65; }

/* ═══════════════════════════════════════════════
   TABLE OF CONTENTS (on-page)
═══════════════════════════════════════════════ */
.toc-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 1.2rem 1.4rem;
  margin: 1.5rem 0 2.5rem;
}
.toc-box__title {
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); margin-bottom: .8rem;
}
.toc-box ol { list-style: decimal; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .3rem; }
.toc-box li { font-size: .85rem; }
.toc-box a { color: var(--muted); transition: color .15s; }
.toc-box a:hover { color: var(--primary); text-decoration: none; }

/* ═══════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════ */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .topbar { padding: 0 1rem; }
  .topbar__brand { display: none; }
  .topbar__toggle { display: flex; align-items: center; justify-content: center; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: var(--header-h); left: 0; bottom: 0;
    width: 280px; z-index: 150;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: var(--shadow-md);
  }
  .sidebar.is-open { transform: translateX(0); }
  /* Dim backdrop when sidebar is open */
  .sidebar-backdrop {
    position: fixed; inset: 0; top: var(--header-h);
    background: rgba(0,0,0,.35);
    z-index: 140;
    opacity: 0; pointer-events: none;
    transition: opacity .25s ease;
  }
  .sidebar-backdrop.is-visible { opacity: 1; pointer-events: auto; }
  .content { padding: 2rem 1.5rem 4rem; }
}

@media (max-width: 600px) {
  .template-grid { grid-template-columns: 1fr 1fr; }
  .token-row { grid-template-columns: 1.5rem 8rem 1fr; }
  .token-row .token-desc { display: none; }
  .topbar__nav { display: none; }
  .topbar__btn--primary { display: none; }
}

/* ── Very small phones (< 420px) ── */
@media (max-width: 420px) {
  .topbar { padding: 0 .75rem; }
  .topbar__btn--outline { padding: .38rem .75rem; font-size: .78rem; }

  .content { padding: 1.5rem 1rem 3rem; }

  .doc-hero { padding: 1.5rem 1.25rem 1.25rem; }
  .doc-hero::after { font-size: 4rem; }
  .doc-hero__title { font-size: 1.5rem; }

  .doc-h1 { font-size: clamp(1.5rem, 7vw, 1.9rem); }
  .doc-h2 { font-size: 1.25rem; }

  .template-grid { grid-template-columns: 1fr; }

  /* Token row: swatch + name only */
  .token-row { grid-template-columns: 1.5rem 1fr; }
  .token-row .token-val { display: none; }

  .callout { padding: .75rem .9rem; gap: .6rem; }

  .print-preview { padding: 1rem; gap: 1rem; }

  .step { gap: .9rem; }
  .step__num { width: 24px; height: 24px; font-size: .7rem; }
}

/* ═══════════════════════════════════════════════
   SCROLL PROGRESS
═══════════════════════════════════════════════ */
.scroll-progress {
  position: fixed; top: var(--header-h); left: 0; right: 0;
  height: 2px; background: transparent; z-index: 300;
}
.scroll-progress__bar {
  height: 100%; background: var(--primary);
  width: 0%; transition: width .1s linear;
}
