/* ============================================================
   BTS Design System — Tokens & Styles
   ============================================================ */

:root {
  /* ---- Core palette ---- */
  --charcoal-900: #0F0F0F;
  --charcoal-800: #1C1C1C;  /* Bundjalung Charcoal - primary */
  --charcoal-700: #2B2B2B;
  --charcoal-600: #3E3E3E;
  --charcoal-500: #5A5A5A;
  --charcoal-400: #838383;
  --charcoal-300: #B0B0B0;
  --charcoal-200: #D5D5D5;
  --charcoal-100: #EDEDED;

  /* Eucalyptus Green */
  --eucalyptus-900: #2E3927;
  --eucalyptus-800: #3F4F34;
  --eucalyptus-700: #566B46;
  --eucalyptus-600: #6E7F58;  /* primary */
  --eucalyptus-500: #869577;
  --eucalyptus-400: #A2AE96;
  --eucalyptus-300: #C4CCBC;
  --eucalyptus-200: #E0E5DB;
  --eucalyptus-100: #F0F2ED;

  /* Clay Ochre */
  --ochre-900: #3D1F0C;
  --ochre-800: #5E3115;
  --ochre-700: #83451F;
  --ochre-600: #A35A2A;  /* primary */
  --ochre-500: #BE7B4E;
  --ochre-400: #D19E79;
  --ochre-300: #E2BFA1;
  --ochre-200: #EED8C3;
  --ochre-100: #F7ECDF;

  /* Red Earth */
  --earth-900: #2D0F0F;
  --earth-800: #4A1C1C;
  --earth-700: #632525;
  --earth-600: #7A2E2E;  /* primary */
  --earth-500: #9A4848;
  --earth-400: #B86E6E;
  --earth-300: #D19898;
  --earth-200: #E5BEBE;
  --earth-100: #F2DCDC;

  /* Warm neutrals */
  --sand-900: #5A4E36;
  --sand-600: #B8A482;
  --sand-500: #D0BF9F;
  --sand-400: #DDCCAE;
  --sand-300: #E8DDC9;
  --sand-200: #F0E8D7;
  --sand-100: #F5EEE0;

  --paper: #FAF6EE;
  --paper-pure: #FFFFFF;

  /* ---- Semantic tokens ---- */
  --bg: var(--paper);
  --bg-surface: var(--paper-pure);
  --bg-inverse: var(--charcoal-800);
  --ink: var(--charcoal-800);
  --ink-muted: var(--charcoal-500);
  --ink-subtle: var(--charcoal-400);
  --ink-inverse: var(--paper);
  --rule: color-mix(in oklab, var(--charcoal-800) 12%, transparent);
  --rule-strong: color-mix(in oklab, var(--charcoal-800) 22%, transparent);

  /* Typography */
  --font-display: 'Montserrat', system-ui, sans-serif;
  --font-body: 'Open Sans', system-ui, sans-serif;

  /* Spacing — 4pt base */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px;  --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px;  --s-8: 64px;
  --s-9: 96px; --s-10: 128px;

  /* Radius — restrained, never playful */
  --r-0: 0;
  --r-1: 2px;
  --r-2: 4px;
  --r-3: 8px;
  --r-pill: 999px;

  /* Content widths */
  --w-prose: 68ch;
  --w-page: 1280px;
  --w-wide: 1440px;
}

/* ============================================================
   Reset + base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  font-weight: 400;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--ochre-700); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--earth-700); }

/* ============================================================
   Typography scale
   ============================================================ */
.t-display {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(48px, 6vw, 84px);
  line-height: 1.02;
  letter-spacing: -0.02em;
}
.t-h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(36px, 4.5vw, 56px);
  line-height: 1.08;
  letter-spacing: -0.015em;
}
.t-h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.t-h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.005em;
}
.t-h4 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: 0;
}
.t-body { font-size: 16px; line-height: 1.65; }
.t-body-lg { font-size: 18px; line-height: 1.6; }
.t-caption { font-size: 13px; line-height: 1.45; color: var(--ink-muted); }
.t-eyebrow {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ochre-700);
}

h1,h2,h3,h4,h5 { margin: 0; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

/* ============================================================
   Page scaffold
   ============================================================ */
.sg-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}
@media (max-width: 920px) {
  .sg-shell { grid-template-columns: 1fr; }
}

/* Sidebar */
.sg-side {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--charcoal-800);
  color: var(--ink-inverse);
  padding: var(--s-6) var(--s-5);
  border-right: 1px solid var(--charcoal-700);
}
.sg-side-logo { display: flex; align-items: center; gap: 10px; margin-bottom: var(--s-7); }
.sg-side-logo svg { width: 40px; height: 40px; color: var(--paper); }
.sg-side-logo-text { font-family: var(--font-display); font-weight: 700; font-size: 15px; line-height: 1.15; letter-spacing: -0.01em; }
.sg-side-logo-text small { display:block; font-weight: 400; font-size: 11px; opacity: 0.65; letter-spacing: 0.15em; text-transform: uppercase; margin-top: 2px; }

.sg-nav-group { margin-bottom: var(--s-6); }
.sg-nav-group-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--eucalyptus-400);
  padding-left: 12px;
  margin-bottom: 10px;
}
.sg-nav a {
  display: block;
  padding: 7px 12px;
  border-left: 2px solid transparent;
  color: var(--sand-300);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
  transition: all 0.15s;
}
.sg-nav a:hover { color: var(--paper); border-left-color: var(--eucalyptus-500); background: rgba(255,255,255,0.03); }
.sg-nav a.active { color: var(--paper); border-left-color: var(--ochre-500); background: rgba(255,255,255,0.04); }

/* Main content */
.sg-main {
  max-width: 100%;
  padding: 0;
}
.sg-section {
  padding: var(--s-9) var(--s-8);
  max-width: var(--w-page);
  border-bottom: 1px solid var(--rule);
}
@media (max-width: 720px) {
  .sg-section { padding: var(--s-8) var(--s-5); }
}

.sg-section-head { margin-bottom: var(--s-7); max-width: 72ch; }
.sg-section-head .t-eyebrow { margin-bottom: var(--s-3); }
.sg-section-head .lede { font-size: 19px; line-height: 1.55; color: var(--ink-muted); margin-top: var(--s-3); max-width: 64ch; }

/* ============================================================
   Components
   ============================================================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  padding: var(--s-5);
}
.card-flat { background: transparent; border: 1px solid var(--rule); padding: var(--s-5); border-radius: var(--r-2); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
  border-radius: var(--r-1);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.18s ease;
  line-height: 1;
}
.btn--primary { background: var(--charcoal-800); color: var(--paper); }
.btn--primary:hover { background: var(--charcoal-700); }
.btn--secondary { background: var(--ochre-600); color: var(--paper); }
.btn--secondary:hover { background: var(--ochre-700); }
.btn--ghost { background: transparent; color: var(--charcoal-800); border-color: var(--charcoal-800); }
.btn--ghost:hover { background: var(--charcoal-800); color: var(--paper); }
.btn--link { background: none; border: none; color: var(--ochre-700); padding: 4px 0; }
.btn--link:hover { color: var(--earth-700); }
.btn--sm { padding: 8px 14px; font-size: 12px; }
.btn--lg { padding: 16px 28px; font-size: 15px; }

/* Form */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink); font-family: var(--font-display); }
.field-hint { font-size: 12px; color: var(--ink-muted); }
.input, .textarea, .select {
  font: inherit;
  padding: 11px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-1);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--ochre-600);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ochre-600) 20%, transparent);
}
.textarea { resize: vertical; min-height: 100px; }

/* Badge / tag */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: var(--r-pill);
  background: var(--sand-200);
  color: var(--charcoal-700);
}
.badge--ochre { background: var(--ochre-200); color: var(--ochre-800); }
.badge--green { background: var(--eucalyptus-200); color: var(--eucalyptus-800); }
.badge--earth { background: var(--earth-200); color: var(--earth-800); }
.badge--dark { background: var(--charcoal-800); color: var(--paper); }

/* ============================================================
   Helpers
   ============================================================ */
.grid { display: grid; gap: var(--s-5); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 840px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stack > * + * { margin-top: var(--s-5); }
.row { display: flex; gap: var(--s-4); align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: var(--s-4); align-items: center; justify-content: space-between; flex-wrap: wrap; }

.rule { height: 1px; background: var(--rule); border: 0; margin: var(--s-6) 0; }

/* ============================================================
   Specialised: swatch cards
   ============================================================ */
.swatch {
  border-radius: var(--r-2);
  overflow: hidden;
  border: 1px solid var(--rule);
  background: var(--bg-surface);
}
.swatch-chip { aspect-ratio: 16/10; display: flex; align-items: flex-end; padding: 16px; color: white; font-family: var(--font-display); font-weight: 600; font-size: 14px; }
.swatch-meta { padding: 14px 16px; font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
.swatch-meta .name { font-weight: 600; font-family: var(--font-display); font-size: 13px; color: var(--ink); }
.swatch-meta .hex { font-family: 'SF Mono', ui-monospace, monospace; color: var(--ink-muted); font-size: 12px; }
.swatch-meta .use { color: var(--ink-muted); font-size: 12px; line-height: 1.4; }

.ramp { display: grid; grid-template-columns: repeat(9, 1fr); border-radius: var(--r-2); overflow: hidden; border: 1px solid var(--rule); }
.ramp-cell { padding: 10px 8px; font-size: 10px; font-family: 'SF Mono', ui-monospace, monospace; min-height: 72px; display: flex; flex-direction: column; justify-content: flex-end; }
.ramp-cell small { display: block; font-size: 9px; opacity: 0.75; margin-top: 2px; }

/* ============================================================
   Specialised: pillar tiles
   ============================================================ */
.pillar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
@media (max-width: 840px) { .pillar-grid { grid-template-columns: repeat(2, 1fr); } }
.pillar-tile {
  background: var(--bg-surface);
  padding: var(--s-5) var(--s-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s-3);
  min-height: 220px;
  justify-content: space-between;
  transition: background 0.2s;
}
.pillar-tile:hover { background: var(--sand-100); }
.pillar-tile svg { width: 96px; height: 96px; color: var(--charcoal-800); }
.pillar-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--ink); }
.pillar-desc { font-size: 12px; color: var(--ink-muted); line-height: 1.4; }

/* ============================================================
   Hero with line-painting motif
   ============================================================ */
.hero {
  background: var(--charcoal-800);
  color: var(--ink-inverse);
  padding: var(--s-10) var(--s-8) var(--s-9);
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--charcoal-700);
}
.hero-motif {
  position: absolute;
  inset: auto 0 -20px 0;
  color: var(--eucalyptus-700);
  opacity: 0.4;
  height: 280px;
  pointer-events: none;
}
.hero-motif svg { height: 100%; width: 100%; }
.hero-inner { position: relative; max-width: 1040px; }
.hero .t-display { color: var(--paper); margin-bottom: var(--s-4); }
.hero-tag {
  font-family: var(--font-display);
  color: var(--ochre-400);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-bottom: var(--s-5);
}
.hero-meta {
  display: flex; gap: var(--s-7);
  margin-top: var(--s-7);
  padding-top: var(--s-5);
  border-top: 1px solid var(--charcoal-700);
  max-width: 800px;
  flex-wrap: wrap;
}
.hero-meta-item { font-size: 13px; }
.hero-meta-item .label { color: var(--eucalyptus-400); font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; font-size: 11px; margin-bottom: 4px; }
.hero-meta-item .val { color: var(--paper); font-family: var(--font-display); font-weight: 500; font-size: 15px; }

/* ============================================================
   Do / Don't boxes
   ============================================================ */
.ddt { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
@media (max-width: 720px) { .ddt { grid-template-columns: 1fr; } }
.ddt-box { padding: var(--s-5); border-radius: var(--r-2); border: 1px solid; }
.ddt-do { border-color: var(--eucalyptus-400); background: var(--eucalyptus-100); }
.ddt-dont { border-color: var(--earth-400); background: var(--earth-100); }
.ddt-label { font-family: var(--font-display); font-weight: 700; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: var(--s-3); display: flex; align-items: center; gap: 8px; }
.ddt-do .ddt-label { color: var(--eucalyptus-800); }
.ddt-dont .ddt-label { color: var(--earth-800); }
.ddt-box ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.6; color: var(--charcoal-700); }
.ddt-box li { margin-bottom: 6px; }

/* ============================================================
   Type specimen
   ============================================================ */
.specimen { padding: var(--s-6); background: var(--bg-surface); border: 1px solid var(--rule); border-radius: var(--r-2); }
.specimen-row { display: grid; grid-template-columns: 160px 1fr; gap: var(--s-5); padding: var(--s-4) 0; border-bottom: 1px solid var(--rule); align-items: baseline; }
.specimen-row:last-child { border-bottom: 0; }
.specimen-label { font-family: 'SF Mono', ui-monospace, monospace; font-size: 11px; color: var(--ink-muted); letter-spacing: 0.05em; }
.specimen-label small { display: block; font-size: 10px; margin-top: 2px; }
@media (max-width: 640px) { .specimen-row { grid-template-columns: 1fr; gap: var(--s-2); } }

/* ============================================================
   Mockup frames
   ============================================================ */
.mockup {
  background: var(--bg-surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 12px 32px -12px rgba(0,0,0,0.12);
}
.mockup-browser-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--charcoal-100);
  border-bottom: 1px solid var(--rule);
}
.mockup-dots { display: flex; gap: 6px; }
.mockup-dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--charcoal-300); }
.mockup-url {
  flex: 1;
  padding: 4px 12px;
  background: var(--bg-surface);
  border-radius: var(--r-pill);
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--ink-muted);
  text-align: center;
}

/* ============================================================
   Logo display boxes
   ============================================================ */
.logo-display {
  padding: var(--s-7) var(--s-5);
  border-radius: var(--r-2);
  border: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
}
.logo-display--light { background: var(--paper); color: var(--charcoal-800); }
.logo-display--dark { background: var(--charcoal-800); color: var(--paper); }
.logo-display--sand { background: var(--sand-300); color: var(--charcoal-800); }
.logo-display--ochre { background: var(--ochre-600); color: var(--paper); }
.logo-display svg, .logo-display object { max-width: 80%; max-height: 180px; }

/* ============================================================
   Inline svg color helper
   ============================================================ */
.svg-ink { color: var(--charcoal-800); }
.svg-ochre { color: var(--ochre-600); }
.svg-green { color: var(--eucalyptus-600); }
.svg-paper { color: var(--paper); }

/* ============================================================
   Tweaks panel (added when --tweaks-on)
   ============================================================ */
#tweaks-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 280px;
  background: var(--charcoal-800);
  color: var(--paper);
  border-radius: var(--r-3);
  padding: var(--s-5);
  font-size: 13px;
  z-index: 1000;
  box-shadow: 0 20px 48px -12px rgba(0,0,0,0.4);
  display: none;
}
#tweaks-panel.on { display: block; }
#tweaks-panel h4 { font-family: var(--font-display); font-size: 12px; letter-spacing: 0.15em; text-transform: uppercase; margin-bottom: var(--s-4); color: var(--ochre-400); }
#tweaks-panel label { display: block; margin-bottom: var(--s-3); font-size: 12px; }
#tweaks-panel select, #tweaks-panel input[type=color] { width: 100%; margin-top: 4px; padding: 6px; background: var(--charcoal-700); color: var(--paper); border: 1px solid var(--charcoal-600); border-radius: 3px; font: inherit; }

/* print friendly */
@media print {
  .sg-side { display: none; }
  .sg-shell { grid-template-columns: 1fr; }
}
