/* ==========================================================================
   X-DRAGON Brandbook — draft stylesheet
   Design tokens live in :root and are the single source of truth.
   ========================================================================== */

:root {
  --color-base: #0d1011;
  --color-surface: #161a1d;
  --color-surface-2: #22272b;
  --color-border: #3b444b;
  --color-text: #f1f2f3;
  --color-pigeon: #8b959c;
  --muted: var(--color-pigeon);

  --brand-violet: #321467;
  --brand-navy: #263aba;
  --brand-ocean: #4389e5;
  --brand-azure: #a2c9f6;
  --brand-flame: #fe9b22;
  --brand-coral: #f86570;

  /* Core only: Flame stays an accent, not a stop in the brand gradient. */
  --gradient-brand: linear-gradient(120deg, #321467 0%, #263aba 42%, #4389e5 100%);

  /* Display is small-caps serif and carries H1 only; H2-H3 use --font-heading.
     Second name in each stack is the approved fallback for environments
     without the webfonts (email, office docs, offline export).
     Heading weights stay at 500/600 so the fallback resolves to
     Georgia Regular and Arial Bold instead of their heaviest faces. */
  --font-display: "Cormorant SC", Georgia, "Times New Roman", serif;
  --font-heading: "Montserrat", Arial, Helvetica, sans-serif;
  --font-body: "Inter", Arial, Helvetica, sans-serif;
  --font-mono: "JetBrains Mono", "Courier New", ui-monospace, monospace;


  --sidebar-w: 268px;
  --container: 1200px;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 32px; }

body {
  margin: 0;
  background: var(--color-base);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Fine grain texture over the flat background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

.bg-glow {
  position: fixed;
  top: -220px;
  right: -160px;
  width: 720px;
  height: 720px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(38, 58, 186, .28), rgba(67, 137, 229, .12) 45%, transparent 70%);
  filter: blur(30px);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--brand-azure); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: var(--font-mono);
  font-size: .9em;
  background: var(--color-surface-2);
  padding: 1px 6px;
}

:focus-visible {
  outline: 2px solid var(--brand-azure);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 16px;
  top: 16px;
  z-index: 100;
  background: var(--color-surface);
  padding: 10px 16px;
}

/* ---------- Layout ---------- */

.layout {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 48px;
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 32px;
}

.main {
  flex: 1;
  min-width: 0;
  max-width: var(--container);
  padding: 56px 0 96px;
}

/* ---------- Sidebar ---------- */

.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  height: 100vh;
  padding: 40px 0 32px;
  display: flex;
  flex-direction: column;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
}

.sidebar__mark {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.sidebar__name {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: .06em;
  font-size: 15px;
}

.sidebar__sub {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav__list a {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 14px;
  border-left: 2px solid transparent;
  transition: color .15s, background .15s, border-color .15s;
}

.nav__list a:hover {
  color: var(--color-text);
  background: var(--color-surface);
  text-decoration: none;
}

.nav__list a.is-active {
  color: var(--color-text);
  background: var(--color-surface);
  border-left-color: var(--brand-azure);
}

/* Violet is a fill colour, not a text colour: on the dark shell it reads at
   1.2:1. The number stays one step quieter than the label at 5.1:1. */
.nav__num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: #7c868d;
}

.sidebar__foot { margin-top: auto; }

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 48px;
  align-items: center;
  padding: 40px 0 88px;
  border-bottom: 1px solid var(--color-border);
}

.eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--brand-azure);
  margin-bottom: 20px;
}

.hero__title {
  font-family: var(--font-display);
  font-size: clamp(42px, 5.6vw, 72px);
  line-height: 1.08;
  letter-spacing: .02em;
  font-weight: 500;
  margin: 0 0 20px;
}

.grad-text {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__lead {
  font-size: 19px;
  color: var(--muted);
  max-width: 46ch;
  margin: 0 0 32px;
}

.hero__actions { display: flex; gap: 12px; flex-wrap: wrap; }

.hero__logo { margin: 0; }

.hero__logo img {
  width: 100%;
  border: 1px solid var(--color-border);
  box-shadow: 0 24px 70px rgba(38, 58, 186, .22);
}

/* ---------- Sections ---------- */

.section {
  padding: 80px 0;
  border-bottom: 1px solid var(--color-border);
}

.section__head { margin-bottom: 36px; }

.section__num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--brand-flame);
  letter-spacing: .1em;
}

.section__head h2 {
  font-family: var(--font-heading);
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1.15;
  font-weight: 600;
  margin: 8px 0 10px;
}

.section__desc {
  color: var(--muted);
  margin: 0;
  max-width: 62ch;
}

.sub {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 44px 0 16px;
}

/* ---------- Grid helpers ---------- */

.grid { display: grid; gap: 20px; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Cards, panels, notes ---------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 24px;
}

.card h3 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 600;
  margin: 16px 0 8px;
}

.card p { margin: 0; color: var(--muted); font-size: 15px; }

.card__icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(50, 20, 103, .35), rgba(38, 58, 186, .22));
  border: 1px solid var(--color-border);
  color: var(--brand-azure);
}

.ico {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.note {
  margin-top: 24px;
  padding: 18px 20px;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--brand-violet);
  background: var(--color-surface);
  color: var(--muted);
  font-size: 15px;
}

.note strong { color: var(--color-text); }

.panel {
  padding: 22px 24px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.panel h3 {
  font-family: var(--font-heading);
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 0 0 14px;
}

.panel--do { border-top: 2px solid var(--brand-azure); }
.panel--do h3 { color: var(--brand-azure); }
.panel--dont { border-top: 2px solid var(--brand-coral); }
.panel--dont h3 { color: var(--brand-coral); }

.list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 15px; }
.list li { margin-bottom: 6px; }

.quote { margin: 0; font-size: 17px; line-height: 1.5; }

.hint { color: var(--muted); font-size: 14px; margin-top: 14px; }

.dont {
  padding: 16px;
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  font-size: 14px;
  color: var(--muted);
}

.dont__mark { color: var(--brand-coral); margin-inline-end: 6px; font-weight: 600; }

.spec {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-size: 14px;
}

.spec__k { color: var(--muted); }
.spec__v { text-align: right; }

.showcase { margin: 0; }

.showcase img {
  width: 100%;
  border: 1px solid var(--color-border);
}

.showcase figcaption {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Logo pack ---------- */

.logo-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

/* Column + flexible plate: square and horizontal lock-ups sit in the same row,
   so the plates have to stretch to match or the captions come out ragged. */
.logo-tile { margin: 0; display: flex; flex-direction: column; }

.logo-tile__plate {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  padding: 28px;
}

/* The mark separates its facets with transparent gaps, so the plate colour
   shows through the artwork — every background needs its own check. */
.logo-tile--dark    { background: var(--color-base); }
.logo-tile--surface { background: var(--color-surface-2); }
.logo-tile--light   { background: #f1f2f3; }
.logo-tile--brand   { background: var(--gradient-brand); }

.logo-tile__plate img { display: block; max-width: 100%; height: auto; }

.logo-tile figcaption {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.logo-sizes {
  display: flex;
  align-items: flex-end;
  gap: 40px;
  flex-wrap: wrap;
  padding: 28px 32px;
  background: var(--color-surface);
}

.logo-sizes figure { margin: 0; text-align: center; }
.logo-sizes img { display: block; margin: 0 auto 10px; }

.logo-sizes figcaption {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.logo-sizes .is-under img { opacity: .45; }
.logo-sizes .is-under figcaption { color: var(--brand-coral); }

.files { width: 100%; border-collapse: collapse; font-size: 14px; }

.files th {
  padding: 8px 12px;
  text-align: left;
  font: 500 11px/1 var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--color-border);
}

.files td { padding: 12px; border-bottom: 1px solid var(--color-border); vertical-align: top; }
.files tr:last-child td { border-bottom: 0; }
.files__n { color: var(--color-text); }
.files a { font-family: var(--font-mono); font-size: 12px; white-space: nowrap; }
.files a + a { margin-inline-start: 14px; }

/* ---------- Color swatches ---------- */

.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.swatch {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 0 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  cursor: pointer;
  overflow: hidden;
  font: inherit;
  color: inherit;
  text-align: left;
  transition: border-color .15s, transform .15s;
}

.swatch:hover { border-color: var(--brand-azure); transform: translateY(-2px); }

.swatch__box {
  height: 76px;
  background: var(--sw);
  border-bottom: 1px solid var(--color-border);
}

.swatch__name { padding: 10px 14px 0; font-size: 14px; font-weight: 500; }
.swatch__hex { padding: 0 14px; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

/* The foreground token shows itself: its own colour on its own 14% tint. */
.swatch__fg {
  align-self: flex-start;
  margin: 8px 14px 0;
  padding: 3px 8px;
  background: var(--fgbg);
  color: var(--fgc);
  font-family: var(--font-mono);
  font-size: 11px;
}

.gradient-bar {
  height: 96px;
  background: var(--gradient-brand);
  border: 1px solid var(--color-border);
}

/* ---------- Typography specimen ---------- */

.type-list { display: flex; flex-direction: column; }

.type-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 32px;
  padding: 22px 0;
  border-top: 1px solid var(--color-border);
}

.type-sample { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.type-meta {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- UI components ---------- */

/* Buttons, fields and the grid demo now come from ui.css: the interface
   speaks one language on every page of the brandbook. */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  background: var(--color-surface-2);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.badge--draft { color: var(--brand-flame); }

.code {
  margin: 0;
  padding: 22px 24px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--color-text);
}

.code code { background: none; border: 0; padding: 0; font-size: inherit; }

/* ---------- Footer & toast ---------- */

.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 40px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translate(-50%, 20px);
  padding: 10px 20px;
  background: var(--color-surface-2);
  border: 1px solid var(--brand-azure);
  font-family: var(--font-mono);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .layout { flex-direction: column; gap: 0; padding: 0 20px; }
  .sidebar {
    position: static;
    width: auto;
    flex: none;
    height: auto;
    padding: 24px 0 8px;
  }
  .nav__list { flex-direction: row; flex-wrap: wrap; }
  .sidebar__foot { margin: 16px 0 0; }
  .hero { grid-template-columns: 1fr; padding: 16px 0 64px; }
  .hero__logo { order: -1; max-width: 420px; }
}

@media (max-width: 720px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .section { padding: 56px 0; }
  .type-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
