/* ==========================================================================
   HIMALAYAN OBSERVATORY KAUSANI
   base.css — design tokens, self-hosted fonts, reset, typography, primitives
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. FONTS (self-hosted, latin subset, no third-party runtime requests)
   -------------------------------------------------------------------------- */
@font-face {
  font-family: "Cormorant Garamond";
  src: url("../assets/fonts/cormorant+garamond-300.woff2") format("woff2");
  font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("../assets/fonts/cormorant+garamond-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("../assets/fonts/cormorant+garamond-500.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("../assets/fonts/cormorant+garamond-600.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/inter-300.woff2") format("woff2");
  font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/inter-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/inter-500.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/inter-600.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}

/* --------------------------------------------------------------------------
   2. TOKENS
   -------------------------------------------------------------------------- */
:root {
  /* --- Atmosphere: seven graded environments, never one flat background --- */
  --void:      #02030a;   /* deepest, gallery black */
  --night:     #05070f;   /* hero Himalayan night */
  --abyss:     #070c1a;   /* deep space */
  --deep:      #0a1122;   /* scientific environment */
  --slate:     #0f1830;   /* observatory interior */
  --twilight:  #0c1226;   /* mountain twilight */
  --surface:   rgba(255, 255, 255, 0.028);
  --surface-2: rgba(255, 255, 255, 0.055);
  --surface-3: rgba(255, 255, 255, 0.085);
  --edge:      rgba(214, 226, 255, 0.10);
  --edge-2:    rgba(214, 226, 255, 0.18);
  --edge-3:    rgba(214, 226, 255, 0.30);

  /* --- Text --- */
  --text:      #eef2fa;
  --muted:     #97a2ba;
  --faint:     #67728a;
  --dim:       #454e63;

  /* --- Accent: restrained warm gold, used sparingly --- */
  --gold:      #c9a961;
  --gold-lt:   #e8d4a2;
  --gold-dk:   #8d7440;
  --gold-wash: rgba(201, 169, 97, 0.10);
  --gold-line: rgba(201, 169, 97, 0.34);

  /* --- Type --- */
  --serif: "Cormorant Garamond", "Times New Roman", Georgia, serif;
  --sans:  "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;

  --fs-micro: 0.625rem;
  --fs-xs:    0.75rem;
  --fs-sm:    0.875rem;
  --fs-base:  clamp(1rem, 0.96rem + 0.18vw, 1.0625rem);
  --fs-lg:    clamp(1.125rem, 1.06rem + 0.3vw, 1.25rem);
  --fs-xl:    clamp(1.375rem, 1.24rem + 0.6vw, 1.75rem);
  --fs-2xl:   clamp(1.75rem, 1.48rem + 1.2vw, 2.5rem);
  --fs-3xl:   clamp(2.25rem, 1.78rem + 2.1vw, 3.5rem);
  --fs-4xl:   clamp(2.75rem, 1.95rem + 3.6vw, 5rem);
  --fs-5xl:   clamp(2.5rem, 1.6rem + 4.6vw, 6.5rem);
  /* capped against viewport HEIGHT as well as width: a pure vw cap overflows
     a 900px-tall laptop screen and clips the headline */
  --fs-mega:  min(clamp(3.5rem, 1.1rem + 9vw, 11rem), 12.5vh, 9.5rem);

  --lh-tight: 1.02;
  --lh-snug:  1.14;
  --lh-body:  1.68;
  --lh-loose: 1.9;

  --ls-hair:  0.42em;
  --ls-wide:  0.24em;
  --ls-mid:   0.14em;
  --ls-text:  0.005em;

  /* --- Space --- */
  --s-3xs: 0.25rem;  --s-2xs: 0.5rem;   --s-xs: 0.75rem;
  --s-sm: 1rem;      --s-md: 1.5rem;    --s-lg: 2rem;
  --s-xl: 2.75rem;   --s-2xl: 4rem;     --s-3xl: 6rem;
  --s-4xl: 8.5rem;   --s-5xl: 12rem;

  --pad: clamp(1.15rem, 0.5rem + 2.6vw, 3.25rem);
  --band: clamp(4.5rem, 2.4rem + 8vw, 10rem);
  --wide: 1560px;
  --text-max: 64ch;

  /* --- Radius --- */
  --r-xs: 2px; --r-sm: 4px; --r-md: 8px;
  --r-lg: 14px; --r-xl: 24px; --r-pill: 999px;

  /* --- Motion --- */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-drift: cubic-bezier(0.37, 0, 0.63, 1);
  --d-1: 180ms; --d-2: 340ms; --d-3: 620ms; --d-4: 1000ms; --d-5: 1600ms;

  /* --- Layers --- */
  --z-scene: 0; --z-content: 10; --z-deep: 20;
  --z-nav: 300; --z-menu: 400; --z-cursor: 900; --z-loader: 950; --z-light: 960;

  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   3. RESET
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-color: var(--gold-dk) var(--void);
}

body {
  min-height: 100svh;
  background: var(--night);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--fs-base);
  font-weight: 300;
  line-height: var(--lh-body);
  letter-spacing: var(--ls-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
body.is-locked { overflow: hidden; }

img, svg, video, canvas, picture { display: block; max-width: 100%; }
img, video { height: auto; }

/* Loading placeholder only where an opaque photo is expected. Never blanket-
   applied to every <img>: on a transparent cutout this paints a navy box
   straight through the alpha. */
.frame img,
.plate img,
.shot img { background: var(--deep); }

input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
hr { border: 0; border-top: 1px solid var(--edge); }
::selection { background: var(--gold); color: var(--void); }

/* --------------------------------------------------------------------------
   4. ACCESSIBILITY
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--gold-lt);
  outline-offset: 4px;
  border-radius: var(--r-xs);
}
:focus:not(:focus-visible) { outline: none; }

.skip {
  position: fixed; top: -100vh; left: var(--s-sm); z-index: 1000;
  padding: 0.7rem 1.4rem; background: var(--gold); color: var(--void);
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: var(--ls-wide);
  text-transform: uppercase; border-radius: var(--r-sm);
}
.skip:focus { top: var(--s-sm); }

.sr {
  position: absolute !important; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   5. TYPOGRAPHY
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5 {
  font-family: var(--serif);
  font-weight: 300;
  line-height: var(--lh-snug);
  text-wrap: balance;
}
h1 { font-size: var(--fs-4xl); }
h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-2xl); }
h4 { font-size: var(--fs-xl); }
h5 { font-size: var(--fs-lg); }

p { text-wrap: pretty; }
p + p { margin-top: 1em; }
strong { font-weight: 500; color: #fff; }

/* Editorial label — the site's connective tissue */
.label {
  display: block;
  font-family: var(--sans);
  font-size: var(--fs-micro);
  font-weight: 500;
  letter-spacing: var(--ls-hair);
  text-transform: uppercase;
  color: var(--gold);
  line-height: 1;
}
.label--mute { color: var(--faint); }

.eyebrow {
  display: flex; align-items: center; gap: var(--s-xs);
  font-size: var(--fs-micro); font-weight: 500;
  letter-spacing: var(--ls-hair); text-transform: uppercase;
  color: var(--gold);
}
.eyebrow::before {
  content: ""; width: clamp(20px, 4vw, 48px); height: 1px;
  background: var(--gold-line); flex: none;
}

.lede {
  font-size: var(--fs-lg); line-height: var(--lh-loose);
  color: var(--muted); max-width: 56ch; font-weight: 300;
}

.prose { max-width: var(--text-max); color: var(--muted); }
.prose > * + * { margin-top: 1.2em; }
.prose h3, .prose h4 { color: var(--text); margin-top: 2em; }

/* Oversized editorial headline with a masked line reveal */
.display {
  font-family: var(--serif);
  font-weight: 300;
  line-height: var(--lh-tight);
  letter-spacing: -0.018em;
  font-size: var(--fs-3xl);
}

/* Uppercase display — used for section statements */
.shout {
  font-family: var(--serif);
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: var(--lh-tight);
  font-size: var(--fs-4xl);
}

.gold { color: var(--gold); }
.gold-lt { color: var(--gold-lt); }
.mute { color: var(--muted); }
.faint { color: var(--faint); }
.serif { font-family: var(--serif); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* Line-mask reveal: each line rides up out of an overflow-hidden box.
   Both selectors are needed: the observer may flag the .mask itself, or a
   wrapping [data-reveal] ancestor. */
.mask { display: block; overflow: hidden; }
.mask > span {
  display: block;
  transform: translateY(105%);
  transition: transform var(--d-4) var(--ease);
}
.mask.is-in > span,
.is-in .mask > span { transform: translateY(0); }
.mask--delay > span { transition-delay: 120ms; }

/* --------------------------------------------------------------------------
   6. LAYOUT
   -------------------------------------------------------------------------- */
.wrap {
  width: 100%; max-width: var(--wide);
  margin-inline: auto; padding-inline: var(--pad);
}
.wrap--mid { max-width: 1120px; }
.wrap--text { max-width: 880px; }

.band { position: relative; padding-block: var(--band); }
.band--tight { padding-block: calc(var(--band) * 0.55); }
.band--flush { padding-block: 0; }

.stack > * + * { margin-top: var(--s-md); }
.flow > * + * { margin-top: var(--s-sm); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--s-sm); }
.grid { display: grid; gap: var(--s-lg); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.srcline { height: 1px; background: var(--edge); border: 0; }

/* --------------------------------------------------------------------------
   7. MEDIA — cinematic framing, never a plain rectangle
   -------------------------------------------------------------------------- */
.frame {
  position: relative;
  overflow: hidden;
  background: linear-gradient(155deg, var(--abyss), var(--slate));
  isolation: isolate;
}
.frame > img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform var(--d-4) var(--ease), filter var(--d-4) var(--ease);
}
.frame::after {
  /* cinematic grade: cool shadow lift, warm highlight rolloff */
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(150, 180, 255, 0.10), transparent 60%),
    linear-gradient(to top, rgba(2, 3, 10, 0.72), transparent 58%);
  pointer-events: none; z-index: 1;
}
.frame--tall { aspect-ratio: 3 / 4; }
.frame--sq   { aspect-ratio: 1 / 1; }
.frame--wide { aspect-ratio: 21 / 9; }
.frame--cin  { aspect-ratio: 2.39 / 1; }
.frame--free { aspect-ratio: auto; }

/* --------------------------------------------------------------------------
   8. BUTTONS
   -------------------------------------------------------------------------- */
.btn {
  --b-bg: transparent; --b-fg: var(--text); --b-bd: var(--edge-2);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s-2xs);
  padding: 1rem 2rem;
  background: var(--b-bg); color: var(--b-fg);
  border: 1px solid var(--b-bd);
  border-radius: var(--r-pill);
  font-family: var(--sans);
  font-size: var(--fs-xs); font-weight: 500;
  letter-spacing: var(--ls-wide); text-transform: uppercase;
  text-align: center; white-space: nowrap;
  overflow: hidden;
  transition: color var(--d-2) var(--ease), border-color var(--d-2) var(--ease),
              background-color var(--d-2) var(--ease), transform var(--d-2) var(--ease);
}
.btn:hover { --b-bd: var(--gold); color: var(--gold-lt); }
.btn:active { transform: translateY(1px); }

.btn--gold { --b-bg: var(--gold); --b-fg: var(--void); --b-bd: var(--gold); }
.btn--gold:hover { --b-bg: var(--gold-lt); --b-bd: var(--gold-lt); color: var(--void); }

.btn--ghost { --b-bg: rgba(255,255,255,0.02); }
.btn--sm { padding: 0.7rem 1.3rem; font-size: var(--fs-micro); }
.btn--lg { padding: 1.2rem 2.6rem; font-size: var(--fs-sm); }
.btn--block { display: flex; width: 100%; }

/* Understated inline link */
.arrow {
  display: inline-flex; align-items: center; gap: 0.6em;
  font-size: var(--fs-xs); font-weight: 500;
  letter-spacing: var(--ls-wide); text-transform: uppercase;
  color: var(--text);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--edge-2);
  transition: color var(--d-2) var(--ease), border-color var(--d-2) var(--ease);
}
.arrow::after {
  content: "\2192";
  transition: transform var(--d-2) var(--ease);
}
.arrow:hover { color: var(--gold); border-color: var(--gold); }
.arrow:hover::after { transform: translateX(5px); }

/* --------------------------------------------------------------------------
   9. FORMS
   -------------------------------------------------------------------------- */
.field { display: grid; gap: 0.5rem; }
.field__lab {
  font-size: var(--fs-micro); font-weight: 500;
  letter-spacing: var(--ls-wide); text-transform: uppercase; color: var(--muted);
}
.inp {
  width: 100%; padding: 0.95rem 1.1rem;
  background: rgba(255,255,255,0.028);
  border: 1px solid var(--edge); border-radius: var(--r-sm);
  font-size: var(--fs-sm); color: var(--text);
  transition: border-color var(--d-2) var(--ease), background var(--d-2) var(--ease);
}
.inp::placeholder { color: var(--dim); }
.inp:focus {
  outline: none; border-color: var(--gold);
  background: rgba(255,255,255,0.05);
  box-shadow: 0 0 0 3px var(--gold-wash);
}
textarea.inp { min-height: 9rem; resize: vertical; }

/* --------------------------------------------------------------------------
   10. REVEAL (base state; driven by IntersectionObserver in ui.js)
   -------------------------------------------------------------------------- */
[data-reveal] {
  opacity: 0;
  transition: opacity var(--d-4) var(--ease), transform var(--d-4) var(--ease);
  transition-delay: var(--rd, 0ms);
}
[data-reveal="up"]    { transform: translate3d(0, 34px, 0); }
[data-reveal="down"]  { transform: translate3d(0, -22px, 0); }
[data-reveal="left"]  { transform: translate3d(-40px, 0, 0); }
[data-reveal="right"] { transform: translate3d(40px, 0, 0); }
[data-reveal="scale"] { transform: scale(0.94); }
[data-reveal="blur"]  { filter: blur(14px); transform: scale(1.02); }
.is-in[data-reveal] { opacity: 1; transform: none; filter: none; }

.no-js [data-reveal] { opacity: 1; transform: none; filter: none; }

/* --------------------------------------------------------------------------
   11. FILM GRAIN
   A single fixed overlay carrying a fractal-noise texture. This is what stops
   large flat gradients from banding on 8-bit panels and reads as photographic
   rather than vector. Inline SVG, so it costs no request.
   -------------------------------------------------------------------------- */
.grain {
  position: fixed; inset: 0;
  z-index: 8;
  pointer-events: none;
  mix-blend-mode: overlay;
  opacity: 0.05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='220' height='220' filter='url(%23n)'/></svg>");
  background-size: 220px 220px;
}

/* a faint vignette that pulls the eye inward without darkening the type */
.vignette {
  position: fixed; inset: 0;
  z-index: 7;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(2, 3, 9, 0.55) 100%);
}

/* --------------------------------------------------------------------------
   12. INSTRUMENT DETAIL — tick marks and rules used across the site to give
   sections the feel of a scientific plate rather than a web page
   -------------------------------------------------------------------------- */
.ticks {
  display: flex; gap: 3px; align-items: flex-end;
  height: 9px;
}
.ticks i {
  display: block; width: 1px; height: 4px;
  background: var(--edge-2);
}
.ticks i:nth-child(3n) { height: 9px; background: var(--gold-line); }

.coords {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.5625rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}

/* --------------------------------------------------------------------------
   13. PRINT
   -------------------------------------------------------------------------- */
@media print {
  .nav, .cursor, .grain, .vignette, [data-loader], .to-top, .scene { display: none !important; }
  body { background: #fff; color: #000; }
  .frame, .plate { break-inside: avoid; }
}