/* ==========================================================================
   Convalt Energy — shared theme
   One token set drives the 3D landing page and every 2D internal page.
   ========================================================================== */

:root {
  /* Brand tokens (taken from convalt.com) */
  --teal-900: #071719;
  --teal-800: #102629;
  --teal-600: #1c3d39;
  --accent: #00ffea;          /* brand cyan, used on dark surfaces */
  --accent-deep: #0a8f86;     /* readable cyan for light surfaces */
  --fog: #e6e9e4;             /* the neutral "morning fog" background */
  --paper: #f3f5f1;

  /* Tone: light by default, swapped by [data-tone="dark"] */
  --ink: #0b1f21;
  --muted: #56655f;
  --line: rgba(7, 23, 25, .14);
  --hi: var(--accent-deep);

  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --gut: clamp(20px, 4.4vw, 72px);
  --ease: cubic-bezier(.22, .61, .36, 1);
}

[data-tone="dark"] {
  --ink: #f3f6f1;
  --muted: #a7b8b6;
  --line: rgba(255, 255, 255, .16);
  --hi: var(--accent);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-weight: 400;
  color: var(--ink);
  background: var(--fog);
  -webkit-font-smoothing: antialiased;
  transition: color .9s var(--ease);
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; color: inherit; }
em { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: 0; }

.skip {
  position: absolute; left: -999px; top: 8px; z-index: 50;
  background: var(--teal-900); color: #fff; padding: 10px 14px; border-radius: 4px;
}
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--hi); outline-offset: 3px; }

/* ---------- Header (shared) ---------- */
.site-head {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px var(--gut);
}
.brand img {
  width: 130px; height: auto;
  filter: brightness(0) opacity(.86);      /* logo is white; darken on light tone */
  transition: filter .9s var(--ease);
}
[data-tone="dark"] .brand img { filter: none; }
.site-nav { display: flex; align-items: center; gap: clamp(14px, 2.2vw, 34px); }
.site-nav a {
  text-decoration: none; font-size: 14px; letter-spacing: .02em;
  opacity: .78; transition: opacity .2s;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { opacity: 1; }
.site-nav .nav-cta {
  opacity: 1; padding: 9px 18px; border: 1px solid var(--line); border-radius: 999px;
  transition: background .25s, border-color .25s;
}
.site-nav .nav-cta:hover { border-color: var(--ink); }

/* ---------- Buttons (shared) ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 24px; border-radius: 999px; cursor: pointer;
  font-size: 14px; letter-spacing: .02em; text-decoration: none;
  border: 1px solid transparent; background: none;
  transition: background .25s, color .25s, border-color .25s, transform .25s var(--ease);
}
.btn::after { content: "→"; transition: transform .25s var(--ease); }
.btn:hover::after { transform: translateX(4px); }
.btn--solid { background: var(--ink); color: var(--fog); }
[data-tone="dark"] .btn--solid { background: var(--ink); color: var(--teal-900); }
.btn--line { border-color: var(--line); }
.btn--line:hover { border-color: var(--ink); }

.eyebrow {
  margin: 0 0 18px; font-size: 12px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--muted);
}
.eyebrow b { color: var(--hi); font-weight: 500; margin-right: 10px; }

/* ==========================================================================
   3D story page
   ========================================================================== */
body.story { overflow: hidden; height: 100svh; overscroll-behavior: none; touch-action: none; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 5; opacity: .07; mix-blend-mode: multiply;
  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='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-tone="dark"] .grain { mix-blend-mode: screen; opacity: .05; }

.loader {
  position: fixed; inset: 0; z-index: 60; display: grid; place-content: center; gap: 22px;
  justify-items: center; background: var(--fog); transition: opacity .9s var(--ease), visibility .9s;
}
.loader img { width: 160px; filter: brightness(0) opacity(.8); }
.loader__bar { width: 120px; height: 1px; background: rgba(7,23,25,.12); overflow: hidden; }
.loader__bar i { display: block; height: 100%; width: 0; background: var(--teal-900); transition: width .4s var(--ease); }
.loader.is-done { opacity: 0; visibility: hidden; }

.status {
  position: fixed; z-index: 10; left: var(--gut); top: 96px;
  font-size: 12px; letter-spacing: .14em; color: var(--muted); font-variant-numeric: tabular-nums;
}
.status__sep { margin: 0 6px; opacity: .5; }
.status__name { margin-left: 14px; text-transform: uppercase; color: var(--ink); transition: color .9s; }

.chapters { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.chap {
  position: absolute; left: var(--gut); bottom: clamp(110px, 17vh, 190px);
  width: min(460px, calc(100vw - 2 * var(--gut)));
  opacity: 0; visibility: hidden; transform: translateY(18px);
  transition: opacity .6s var(--ease), transform .8s var(--ease), visibility 0s .6s;
}
.chap.is-active {
  opacity: 1; visibility: visible; transform: none; pointer-events: auto;
  transition: opacity 1s var(--ease) .45s, transform 1.2s var(--ease) .45s, visibility 0s;
}
.chap h1, .chap h2 {
  margin: 0 0 22px; font-weight: 300; letter-spacing: -.025em; line-height: 1.02;
  font-size: clamp(40px, 5vw, 76px);
}
.chap--hero { width: min(760px, calc(100vw - 2 * var(--gut))); }
.chap--hero h1 { font-size: clamp(46px, 7vw, 112px); line-height: .98; }
.chap .lede { margin: 0 0 30px; max-width: 400px; font-size: 16px; line-height: 1.6; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }

.layers {
  list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0 26px;
  font-size: 13px; max-width: 400px;
}
.layers li { padding: 9px 0; border-top: 1px solid var(--line); }
.layers span { color: var(--hi); margin-right: 10px; font-variant-numeric: tabular-nums; }

.stats { display: flex; gap: 40px; margin: 0; }
.stats dt { font-size: clamp(26px, 2.6vw, 36px); font-weight: 300; letter-spacing: -.02em; }
.stats dd { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); max-width: 170px; line-height: 1.45; }

.regions { list-style: none; margin: 0 0 18px; padding: 0; max-width: 400px; }
.regions li {
  display: flex; justify-content: space-between; gap: 16px; padding: 11px 0;
  border-top: 1px solid var(--line); font-size: 13.5px;
}
.regions b { font-weight: 500; }
.regions span { color: var(--muted); text-align: right; }
.hint-inline { margin: 0; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--hi); }

/* Chapter rail */
.rail {
  position: fixed; z-index: 10; right: var(--gut); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 4px;
}
.rail button {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-direction: row-reverse;
  background: none; border: 0; padding: 6px 0; cursor: pointer;
}
.rail i {
  width: 18px; height: 1px; background: var(--ink); opacity: .3;
  transition: width .5s var(--ease), opacity .5s;
}
.rail span {
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
  opacity: 0; transform: translateX(6px); transition: opacity .3s, transform .3s var(--ease);
}
.rail button:hover span, .rail button.is-active span { opacity: 1; transform: none; }
.rail button.is-active i { width: 40px; opacity: 1; }
.rail button:hover i { opacity: .8; }

/* Bottom cue */
.cue {
  position: fixed; z-index: 10; left: 50%; bottom: 30px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px;
}
.cue__text { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.cue__btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: none;
  display: grid; place-items: center; cursor: pointer; transition: border-color .25s, opacity .3s;
}
.cue__btn:hover { border-color: var(--ink); }
.cue__btn:disabled { opacity: .25; cursor: default; }
.cue__btn--next svg { animation: nudge 2.4s var(--ease) infinite; }
@keyframes nudge { 0%, 60%, 100% { transform: none; } 30% { transform: translateY(3px); } }

.progress { position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; height: 2px; background: var(--line); }
.progress i { display: block; height: 100%; width: 0; background: var(--hi); }

/* ---------- Lite mode: no WebGL / low power. Chapters become a normal scrolling page ---------- */
html.lite body.story { overflow: auto; height: auto; touch-action: auto; }
html.lite #stage, html.lite .rail, html.lite .cue, html.lite .progress, html.lite .status, html.lite .loader { display: none; }
html.lite body.story {
  background:
    radial-gradient(ellipse 60% 40% at 70% 30%, #f6ead3 0%, transparent 60%),
    linear-gradient(180deg, #e6e9e4 0%, #d9dfda 60%, #cfd7d2 100%) fixed;
}
html.lite .chapters { position: static; pointer-events: auto; padding: 140px var(--gut) 60px; }
html.lite .chap {
  position: static; opacity: 1; visibility: visible; transform: none; width: auto; max-width: 720px;
  padding: 0 0 18vh;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .rail { display: none; }
  .site-nav a:not(.nav-cta):not([aria-current]) { display: none; }
}
@media (max-width: 640px) {
  .site-head { padding: 16px 20px; }
  .brand img { width: 108px; }
  .status { top: 70px; }
  .chap { bottom: 96px; }
  .chap h1, .chap h2 { font-size: clamp(34px, 10vw, 46px); margin-bottom: 14px; }
  .chap--hero h1 { font-size: clamp(40px, 12vw, 56px); }
  .chap .lede { font-size: 14.5px; margin-bottom: 20px; }
  .eyebrow { margin-bottom: 12px; }
  .layers { font-size: 12px; }
  .layers li { padding: 6px 0; }
  .stats { gap: 24px; }
  .regions li { padding: 8px 0; font-size: 12.5px; }
  .cue { bottom: 22px; gap: 12px; }
  .cue__text { display: none; }
  .cue { left: auto; right: 20px; transform: none; }
}
@media (max-height: 640px) and (min-width: 641px) {
  .chap { bottom: 90px; }
  .chap h1, .chap h2 { font-size: clamp(34px, 4vw, 54px); }
  .layers { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
}

/* ==========================================================================
   2D internal pages (Projects, Contact) — same tokens, no WebGL
   ========================================================================== */
body.page { background: var(--fog); }
body.page .site-head { position: sticky; background: rgba(230, 233, 228, .86); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.page-hero { padding: clamp(70px, 12vh, 140px) var(--gut) 50px; max-width: 1200px; }
.page-hero h1 { margin: 0 0 20px; font-weight: 300; letter-spacing: -.025em; line-height: 1.02; font-size: clamp(42px, 6vw, 92px); }
.page-hero p.lede { max-width: 520px; color: var(--muted); font-size: 17px; line-height: 1.6; margin: 0; }
.wrap { padding: 0 var(--gut) 100px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 34px; }
.filters button {
  border: 1px solid var(--line); background: none; border-radius: 999px; padding: 9px 16px;
  font-size: 13px; cursor: pointer; transition: all .2s;
}
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--fog); border-color: var(--ink); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 34px 26px; }
.card { text-decoration: none; display: block; }
.card figure { margin: 0 0 16px; aspect-ratio: 16 / 10; overflow: hidden; border-radius: 4px; background: #d5dbd6; }
.card img { width: 100%; height: 100%; object-fit: cover; filter: saturate(.78); transition: transform 1s var(--ease), filter .6s; }
.card:hover img { transform: scale(1.04); filter: saturate(1); }
.tag { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-deep); }
.card h3 { margin: 8px 0 6px; font-size: 22px; font-weight: 400; letter-spacing: -.01em; }
.card p { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.card .loc { display: block; margin-bottom: 4px; }

.contact-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: clamp(30px, 6vw, 90px); align-items: start; }
.contact-info dl { margin: 0; }
.contact-info div { padding: 18px 0; border-top: 1px solid var(--line); }
.contact-info dt { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.contact-info dd { margin: 0; font-size: 16px; }
.form { display: grid; gap: 18px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form label { display: grid; gap: 8px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.form input, .form select, .form textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: transparent;
  border: 0; border-bottom: 1px solid var(--line); padding: 10px 0; border-radius: 0; letter-spacing: 0; text-transform: none;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-bottom-color: var(--ink); }
.form textarea { min-height: 120px; resize: vertical; }
.form .btn { justify-self: start; border: 0; }
.form-note { font-size: 14px; color: var(--accent-deep); min-height: 1.4em; margin: 0; }

.site-foot {
  padding: 50px var(--gut) 40px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px; font-size: 13px; color: var(--muted);
}
.site-foot img { width: 110px; filter: brightness(0) opacity(.8); margin-bottom: 12px; }
.site-foot nav { display: flex; gap: 22px; flex-wrap: wrap; }
.site-foot a { text-decoration: none; }
.site-foot a:hover { color: var(--ink); }

@media (max-width: 760px) {
  .contact-grid, .form .row { grid-template-columns: 1fr; }
}
