/* ─────────────────────────────────────────────────────────────────
   TerraBridge — design tokens & base styles
   ───────────────────────────────────────────────────────────────── */

:root {
  /* Forest palette (default) */
  --bg:       #f6f2e9;
  --surface:  #fbf9f3;
  --surface-2:#efe9da;
  --ink:      #1c1f17;
  --ink-2:    #3a3f2f;
  --ink-3:    #6e7261;
  --rule:     rgba(28,31,23,.14);
  --rule-2:   rgba(28,31,23,.08);
  --accent:   #2f3f24;     /* deep forest */
  --accent-2: #6b7d52;     /* moss */
  --accent-3: #b08b4a;     /* warm grain */
  --sand:     #d9d1bf;
  --paper:    #ffffff;

  /* Type stacks (overridden per typography option) */
  --f-display: "Newsreader", "Source Serif 4", Georgia, serif;
  --f-body:    "Manrope", "Söhne", -apple-system, BlinkMacSystemFont, sans-serif;
  --f-mono:    "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;

  /* Density (overridden via .density-{compact,standard,spacious}) */
  --u:        8px;          /* spacing unit */
  --fs-body:  15px;
  --lh-body:  1.55;
  --content-max: 1240px;
  --gutter:   max(24px, 4vw);

  /* Shapes */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;

  --t-fast: 160ms ease;
  --t-med:  260ms cubic-bezier(.2,.6,.2,1);
}

/* Density variants */
.density-compact  { --u: 6px;  --fs-body: 14px; --lh-body: 1.5; }
.density-standard { --u: 8px;  --fs-body: 15px; --lh-body: 1.55; }
.density-spacious { --u: 10px; --fs-body: 16px; --lh-body: 1.65; }

/* Typography variants */
.type-editorial {
  --f-display: "Newsreader", "Source Serif 4", Georgia, serif;
  --f-body:    "Manrope", -apple-system, BlinkMacSystemFont, sans-serif;
  --f-mono:    "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;
}
.type-sans {
  --f-display: "Manrope", -apple-system, sans-serif;
  --f-body:    "Manrope", -apple-system, sans-serif;
  --f-mono:    "JetBrains Mono", ui-monospace, monospace;
}
.type-modern {
  --f-display: "Source Serif 4", Georgia, serif;
  --f-body:    "IBM Plex Sans", -apple-system, sans-serif;
  --f-mono:    "IBM Plex Mono", ui-monospace, monospace;
}

/* Palette variants */
.palette-forest {
  --bg:#f6f2e9; --surface:#fbf9f3; --surface-2:#efe9da;
  --ink:#1c1f17; --ink-2:#3a3f2f; --ink-3:#6e7261;
  --accent:#2f3f24; --accent-2:#6b7d52; --accent-3:#b08b4a;
  --sand:#d9d1bf;
}
.palette-sage {
  --bg:#f3f1e8; --surface:#faf8f0; --surface-2:#e8e7d8;
  --ink:#23291f; --ink-2:#3f4636; --ink-3:#737867;
  --accent:#5f7048; --accent-2:#8d9f6f; --accent-3:#c79a5a;
  --sand:#dad6c4;
}
.palette-clay {
  --bg:#f5efe5; --surface:#fbf6ec; --surface-2:#ebe1cf;
  --ink:#221c14; --ink-2:#3d3225; --ink-3:#766853;
  --accent:#3a4029; --accent-2:#7a8758; --accent-3:#b9582c;
  --sand:#e5cfa9;
}
.palette-slate {
  --bg:#eef0ea; --surface:#f6f7f2; --surface-2:#dfe1d8;
  --ink:#181c18; --ink-2:#363b34; --ink-3:#697066;
  --accent:#293329; --accent-2:#5e6d54; --accent-3:#9a8350;
  --sand:#c9ccbe;
}

/* Dark mode */
.dark {
  --bg:#11140f; --surface:#171a13; --surface-2:#1d2118;
  --ink:#ede7d4; --ink-2:#c7c2af; --ink-3:#8a8775;
  --rule:rgba(237,231,212,.14); --rule-2:rgba(237,231,212,.06);
  --accent:#cfd5a8; --accent-2:#9aab7a; --accent-3:#d6b07d;
  --sand:#3a3f2f; --paper:#1d2118;
}

/* ─────────────────────────────────────────────────────────────────
   Base
   ───────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-feature-settings: "ss01","cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 250ms ease, color 250ms ease;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button { font-family: inherit; }
img { display: block; max-width: 100%; }
h1,h2,h3,h4,h5 { font-family: var(--f-display); font-weight: 400; margin: 0; letter-spacing: -0.01em; color: var(--ink); }

.mono { font-family: var(--f-mono); font-size: 0.78em; letter-spacing: 0.06em; text-transform: uppercase; }
.eyebrow { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.serif-it { font-family: var(--f-display); font-style: italic; font-weight: 400; }

/* ─────────────────────────────────────────────────────────────────
   Layout primitives
   ───────────────────────────────────────────────────────────────── */

.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.stack-1 > * + * { margin-top: calc(var(--u) * 1); }
.stack-2 > * + * { margin-top: calc(var(--u) * 2); }
.stack-3 > * + * { margin-top: calc(var(--u) * 3); }

.rule { height: 1px; background: var(--rule); width: 100%; }
.rule-strong { height: 1px; background: var(--ink); width: 100%; }

/* ─────────────────────────────────────────────────────────────────
   Nav + header
   ───────────────────────────────────────────────────────────────── */

.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklab, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--rule);
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand {
  display: flex; align-items: baseline; gap: 0;
  font-family: var(--f-display);
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.brand .it { font-style: italic; font-weight: 400; }
.brand .bd { font-weight: 500; }
.brand .dot { display:inline-block; width:6px; height:6px; border-radius:50%; background: var(--accent); margin: 0 6px 3px; }

.nav-links { display: flex; gap: calc(var(--u) * 3); }
.nav-links a {
  font-size: 13px; color: var(--ink-2);
  position: relative;
  transition: color var(--t-fast);
}
.nav-links a.active { color: var(--accent); }
.nav-links a.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -22px;
  height: 1px; background: var(--accent);
}

.lang-toggle {
  display: inline-flex; gap: 1px; border: 1px solid var(--rule);
  border-radius: 999px; padding: 2px; background: var(--surface);
}
.lang-toggle button {
  appearance: none; border: 0; background: transparent;
  padding: 4px 10px; font-size: 11px; letter-spacing: 0.1em;
  font-family: var(--f-mono); color: var(--ink-3);
  border-radius: 999px; cursor: pointer;
}
.lang-toggle button.on { background: var(--ink); color: var(--bg); }

.nav-cta {
  font-size: 13px;
  padding: 8px 14px;
  border: 1px solid var(--ink);
  color: var(--ink);
  border-radius: 999px;
  transition: all var(--t-fast);
}
.nav-cta:hover { background: var(--ink); color: var(--bg); }

/* ─────────────────────────────────────────────────────────────────
   Buttons
   ───────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 20px;
  font-size: 13px;
  font-family: var(--f-body);
  border-radius: 2px;
  border: 1px solid var(--ink);
  background: var(--ink); color: var(--bg);
  cursor: pointer;
  transition: all var(--t-fast);
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost {
  background: transparent; color: var(--ink); border: 1px solid var(--ink);
}
.btn-ghost:hover { background: var(--ink); color: var(--bg); }
.btn .arrow { transition: transform var(--t-fast); }
.btn:hover .arrow { transform: translateX(3px); }

/* ─────────────────────────────────────────────────────────────────
   Sections
   ───────────────────────────────────────────────────────────────── */

.section { padding: calc(var(--u) * 10) 0; }
.section-tight { padding: calc(var(--u) * 6) 0; }
.section-num {
  display: inline-block; margin-right: 16px; color: var(--ink-3);
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.16em;
}
.section-head {
  display: flex; align-items: baseline; gap: 12px;
  padding-bottom: calc(var(--u) * 2);
  margin-bottom: calc(var(--u) * 4);
  border-bottom: 1px solid var(--rule);
}
.section-head h2 { font-size: clamp(28px, 3.2vw, 42px); line-height: 1.05; flex: 1; }

/* ─────────────────────────────────────────────────────────────────
   Hero variants
   ───────────────────────────────────────────────────────────────── */

.hero { position: relative; }

/* Variant: split */
.hero-split {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  min-height: 78vh;
}
.hero-split .text {
  background: var(--accent);
  color: var(--bg);
  padding: calc(var(--u) * 8) calc(var(--u) * 6) calc(var(--u) * 6);
  display: flex; flex-direction: column; justify-content: space-between;
}
.hero-split .text h1 {
  color: var(--bg);
  font-size: clamp(40px, 5.2vw, 76px);
  line-height: 1.0;
  letter-spacing: -0.02em;
}
.hero-split .text .eyebrow { color: color-mix(in oklab, var(--bg) 70%, transparent); }
.hero-split .image { background: var(--surface-2); position: relative; overflow: hidden; }

/* Variant: stacked */
.hero-stack {
  padding: calc(var(--u) * 10) 0 calc(var(--u) * 4);
}
.hero-stack h1 {
  font-size: clamp(48px, 7vw, 112px);
  line-height: 0.92;
  letter-spacing: -0.025em;
  max-width: 12ch;
}
.hero-stack .image {
  margin-top: calc(var(--u) * 5);
  height: 56vh; background: var(--surface-2);
}

/* Variant: overlay */
.hero-over {
  position: relative;
  height: 84vh;
  background: var(--accent);
  overflow: hidden;
}
.hero-over .image {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(0,0,0,.05) 0%, rgba(0,0,0,.55) 90%),
    var(--surface-2);
}
.hero-over .text {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: var(--gutter);
  color: #fff;
}
.hero-over .text h1 {
  color: #fff;
  font-size: clamp(48px, 6vw, 96px);
  line-height: 0.95;
  max-width: 16ch;
}

/* ─────────────────────────────────────────────────────────────────
   Placeholder photos
   ───────────────────────────────────────────────────────────────── */

.photo {
  position: relative; overflow: hidden;
  background: var(--surface-2);
  color: var(--ink-3);
  display: flex; align-items: center; justify-content: center;
}
.photo::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, color-mix(in oklab, var(--accent-2) 18%, transparent), transparent 60%),
    radial-gradient(ellipse at 70% 80%, color-mix(in oklab, var(--accent-3) 14%, transparent), transparent 60%);
  opacity: .85;
}
.photo svg.placeholder-art {
  position: relative; z-index: 1;
  width: 38%; height: auto; opacity: .35;
  color: var(--ink-2);
}
.photo img { display: block; }
.photo::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,.18) 100%);
  opacity: .35;
}
.photo .photo-label {
  position: absolute; left: 12px; bottom: 12px;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  padding: 4px 8px;
  border-radius: 2px;
  border: 1px solid var(--rule);
  z-index: 2;
}
.photo.inverted { background: var(--accent); }
.photo.inverted::before {
  background:
    radial-gradient(ellipse at 30% 30%, color-mix(in oklab, var(--accent-2) 50%, transparent), transparent 60%),
    radial-gradient(ellipse at 70% 70%, color-mix(in oklab, var(--accent-3) 30%, transparent), transparent 60%);
}
.photo.inverted svg.placeholder-art { color: var(--bg); opacity: .5; }
.photo.inverted .photo-label {
  background: rgba(0,0,0,.35); color: rgba(255,255,255,.85); border-color: rgba(255,255,255,.15);
}

/* ─────────────────────────────────────────────────────────────────
   Cards / grids
   ───────────────────────────────────────────────────────────────── */

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: calc(var(--u) * 4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: calc(var(--u) * 4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: calc(var(--u) * 3); }

.card { padding: calc(var(--u) * 3) calc(var(--u) * 3); background: var(--surface); border: 1px solid var(--rule); }
.card-bare { padding: 0; background: transparent; border: 0; }

/* Spec table */
.spec {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.spec th, .spec td {
  text-align: left; padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.spec th {
  width: 38%; font-weight: 400; color: var(--ink-3);
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
}
.spec td { color: var(--ink); }

/* Numbered/lettered lists */
.list-num { list-style: none; padding: 0; margin: 0; }
.list-num li {
  display: grid; grid-template-columns: 48px 1fr; gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--rule);
}
.list-num li:last-child { border-bottom: 1px solid var(--rule); }
.list-num .n { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.1em; color: var(--ink-3); padding-top: 4px; }
.list-num h4 { font-family: var(--f-display); font-size: 20px; margin-bottom: 4px; }
.list-num p { margin: 0; color: var(--ink-2); }

/* ─────────────────────────────────────────────────────────────────
   Footer
   ───────────────────────────────────────────────────────────────── */

.footer {
  background: var(--ink);
  color: var(--bg);
  padding: calc(var(--u) * 8) 0 calc(var(--u) * 4);
  margin-top: calc(var(--u) * 10);
}
.footer .brand { color: var(--bg); }
.footer .brand .dot { background: var(--accent-3); }
.footer .col-link a { color: color-mix(in oklab, var(--bg) 75%, transparent); display: block; padding: 4px 0; font-size: 13px; }
.footer .col-link a:hover { color: var(--bg); }
.footer .colophon {
  margin-top: calc(var(--u) * 6);
  padding-top: calc(var(--u) * 3);
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: 11px;
  color: color-mix(in oklab, var(--bg) 55%, transparent);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  font-family: var(--f-mono); letter-spacing: 0.08em; text-transform: uppercase;
}

/* ─────────────────────────────────────────────────────────────────
   Marquee / ticker
   ───────────────────────────────────────────────────────────────── */

.marquee {
  overflow: hidden;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  padding: 14px 0;
}
.marquee-track {
  display: inline-flex; gap: 64px;
  white-space: nowrap;
  animation: marquee 40s linear infinite;
  padding-left: 64px;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-2);
}
.marquee-track .sep { color: var(--accent); }
@keyframes marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ─────────────────────────────────────────────────────────────────
   Brochure
   ───────────────────────────────────────────────────────────────── */

.brochure-stage {
  background: var(--surface-2);
  padding: calc(var(--u) * 4) 0 calc(var(--u) * 10);
}
.brochure-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--u) * 2) 0;
  font-size: 12px; color: var(--ink-3);
}
.brochure-pages {
  display: flex; flex-direction: column;
  gap: calc(var(--u) * 4);
  align-items: center;
}
.page-a4 {
  /* A4 portrait at ~0.75 of natural size; aspect 1:1.414 */
  width: min(800px, 92vw);
  aspect-ratio: 1 / 1.4142;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 24px 60px rgba(0,0,0,.18);
  position: relative;
  overflow: hidden;
  font-size: 12px;
}
.page-a4 .pad {
  position: absolute; inset: 36px;
  display: flex; flex-direction: column;
}
.page-a4 .pad-tight { inset: 0; }
.page-a4 .pg-num {
  position: absolute; bottom: 18px; right: 24px;
  font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.12em; color: var(--ink-3);
}
.page-a4 .pg-foot {
  position: absolute; bottom: 18px; left: 36px; right: 64px;
  font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3);
  display: flex; justify-content: space-between; gap: 24px;
}

/* ─────────────────────────────────────────────────────────────────
   Util
   ───────────────────────────────────────────────────────────────── */

.kbd {
  display: inline-block; padding: 2px 6px; border: 1px solid var(--rule);
  border-radius: 4px; font-family: var(--f-mono); font-size: 10px;
  background: var(--surface);
}
.tag {
  display: inline-block; padding: 4px 8px;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  border: 1px solid var(--rule); border-radius: 999px;
  color: var(--ink-3);
}
.tag.solid { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* Page transitions */
.page-fade { animation: fade 320ms ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Responsive */
@media (max-width: 860px) {
  .nav-links { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .hero-split { grid-template-columns: 1fr; min-height: auto; }
  .hero-split .text { padding: calc(var(--u) * 5) calc(var(--u) * 4); }
  .hero-split .image { height: 50vh; }
}
