/* =========================================================
   NEORNITO — Base stylesheet
   1. Tokens   2. Reset   3. Base   4. Layout   5. Components
   6. Sections 7. Motion  8. Responsive
   ========================================================= */

/* ---------- 1. Design tokens ---------- */
:root {
  /* Palette — drawn from moodboard: ink black, bone, moss, amber, plumage, slate */
  --ink:        #0b0c0d;
  --ink-2:      #141618;
  --ink-3:      #1d2023;
  --bone:       #ecebe6;
  --bone-dim:   #a9a8a2;
  --mute:       #6d6e6b;
  --line:       rgba(236, 235, 230, 0.12);
  --line-strong:rgba(236, 235, 230, 0.24);

  --moss:       #8fbf6a;
  --moss-deep:  #2f6b3a;
  --amber:      #e7832a;
  --amber-deep: #8a3f0e;
  --plume:      #6b5445;
  --slate:      #1e3a44;
  --mist:       #cfe6e0;

  /* Typography */
  --font-sans:  "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Instrument Serif", Georgia, serif;
  --font-mono:  "JetBrains Mono", ui-monospace, monospace;

  --fs-xs:   0.75rem;
  --fs-sm:   0.875rem;
  --fs-base: 1rem;
  --fs-lg:   1.125rem;
  --fs-xl:   clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  --fs-h2:   clamp(2rem, 1.4rem + 2.6vw, 3.5rem);
  --fs-h1:   clamp(2.75rem, 1.6rem + 5vw, 6.25rem);

  /* Spacing & shape */
  --gutter:     clamp(16px, 4vw, 48px);
  --section-y:  clamp(80px, 10vw, 160px);
  --radius:     14px;
  --radius-lg:  24px;
  --maxw:       1280px;
  --header-h:   72px;

  --ease: cubic-bezier(0.2, 0.7, 0.1, 1);
}

/* ---------- 2. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: var(--header-h); }
img, svg, video { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }

/* ---------- 3. Base ---------- */
body {
  background: var(--ink);
  color: var(--bone);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.nav-open { overflow: hidden; }

h1, h2, h3, h4 { font-weight: 500; line-height: 1.05; letter-spacing: -0.025em; }
em { font-family: var(--font-serif); font-style: italic; font-weight: 400; letter-spacing: -0.01em; }
p  { color: var(--bone-dim); max-width: 62ch; }
p + p { margin-top: 1em; }

.mono { font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0.02em; text-transform: uppercase; }
.small { font-size: var(--fs-sm); }

::selection { background: var(--moss); color: var(--ink); }

:focus-visible { outline: 2px solid var(--moss); outline-offset: 3px; border-radius: 4px; }

.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 200;
  background: var(--bone); color: var(--ink); padding: 10px 16px; border-radius: 8px;
}
.skip-link:focus { top: 16px; }

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

/* ---------- 4. Layout ---------- */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.section   { position: relative; padding-block: var(--section-y); }
.grid-2    { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(32px, 6vw, 96px); }
.align-center { align-items: center; }

/* ---------- 5. Components ---------- */

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; color: var(--bone); }
.brand-name { font-weight: 600; font-size: 1.125rem; letter-spacing: -0.02em; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 22px; border-radius: 999px;
  font-size: var(--fs-sm); font-weight: 600; letter-spacing: 0.01em;
  transition: background .3s var(--ease), color .3s var(--ease), border-color .3s var(--ease), transform .3s var(--ease);
  white-space: nowrap;
}
.btn-light { background: var(--bone); color: var(--ink); }
.btn-light:hover { background: #fff; transform: translateY(-1px); }
.btn-ghost { border: 1px solid var(--line-strong); color: var(--bone); }
.btn-ghost:hover { border-color: var(--bone); background: rgba(236,235,230,.06); }
.btn-ghost span { transition: transform .3s var(--ease); }
.btn-ghost:hover span { transform: translateX(4px); }

/* Labels & headings */
.eyebrow { display: inline-flex; align-items: center; gap: 10px; font-size: var(--fs-sm); color: var(--bone-dim); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--moss); box-shadow: 0 0 0 4px rgba(143,191,106,.18); animation: pulse 2.6s infinite; }

.section-label {
  font-family: var(--font-mono); font-size: var(--fs-xs); text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--mute); margin-bottom: 20px; font-weight: 400;
}
.section-label.center { text-align: center; }
.section-title { font-size: var(--fs-h2); margin-bottom: 24px; max-width: 18ch; }
.section-intro { font-size: var(--fs-lg); }
.section-head { margin-bottom: clamp(40px, 6vw, 72px); }
.section-head-row { display: flex; justify-content: space-between; align-items: end; gap: 24px; flex-wrap: wrap; }

/* Film grain (moodboard texture) */
.grain {
  position: absolute; inset: 0; pointer-events: none; z-index: 1;
  opacity: .22; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Placeholder media — replace with field photography */
.media-feather { background:
  repeating-linear-gradient(115deg, rgba(0,0,0,.25) 0 2px, transparent 2px 9px),
  radial-gradient(120% 90% at 30% 20%, #8a6f5c, var(--plume) 45%, #2a211b); }
.media-moss { background: radial-gradient(90% 80% at 40% 60%, var(--moss), var(--moss-deep) 45%, #0f1a12); }
.media-amber { background: radial-gradient(80% 80% at 60% 30%, var(--amber), var(--amber-deep) 45%, #191412); }
.media-slate { background: linear-gradient(180deg, var(--mist) 0%, #6f9a9a 40%, var(--slate) 75%, #10232a); }

/* ---------- 6. Sections ---------- */

/* Header */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 100; height: var(--header-h);
  transition: background .4s var(--ease), border-color .4s var(--ease), transform .4s var(--ease);
  border-bottom: 1px solid transparent;
}
.site-header.is-scrolled {
  background: rgba(11,12,13,.72); backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%); border-color: var(--line);
}
.site-header.is-hidden { transform: translateY(-100%); }
.header-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; }

.nav { display: flex; align-items: center; gap: 36px; }
.nav-list { display: flex; gap: 28px; }
.nav-list a { font-size: var(--fs-sm); color: var(--bone-dim); position: relative; transition: color .25s; }
.nav-list a::after {
  content: ""; position: absolute; left: 0; bottom: -6px; height: 1px; width: 100%;
  background: var(--bone); transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease);
}
.nav-list a:hover, .nav-list a.is-active { color: var(--bone); }
.nav-list a:hover::after, .nav-list a.is-active::after { transform: scaleX(1); }
.nav-cta { padding: 10px 18px; }

.nav-toggle { display: none; width: 44px; height: 44px; position: relative; z-index: 110; }
.nav-toggle span { position: absolute; left: 11px; right: 11px; height: 1.5px; background: var(--bone); transition: transform .35s var(--ease), top .35s var(--ease); }
.nav-toggle span:first-child { top: 17px; }
.nav-toggle span:last-child  { top: 26px; }
.nav-toggle[aria-expanded="true"] span:first-child { top: 21px; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:last-child  { top: 21px; transform: rotate(-45deg); }

/* Hero */
.hero {
  position: relative; min-height: 100svh; display: flex; flex-direction: column;
  justify-content: flex-end; overflow: hidden; padding-top: var(--header-h);
}
.hero-bg { position: absolute; inset: 0; }
.blob { position: absolute; border-radius: 50%; filter: blur(80px); will-change: transform; }
.blob-green { width: 60vw; height: 60vw; left: -10vw; top: -5vw; background: radial-gradient(circle, var(--moss) 0%, var(--moss-deep) 45%, transparent 70%); opacity: .75; animation: drift 22s ease-in-out infinite alternate; }
.blob-amber { width: 50vw; height: 50vw; right: -12vw; top: 10vw; background: radial-gradient(circle, var(--amber) 0%, var(--amber-deep) 45%, transparent 70%); opacity: .7; animation: drift 26s ease-in-out infinite alternate-reverse; }
.blob-bone  { width: 34vw; height: 34vw; left: 38%; bottom: -14vw; background: radial-gradient(circle, #cfd2d0 0%, transparent 65%); opacity: .28; animation: drift 30s ease-in-out infinite alternate; }
.hero::after { /* fade into page */
  content: ""; position: absolute; inset: auto 0 0 0; height: 40%; z-index: 1;
  background: linear-gradient(to bottom, transparent, var(--ink));
}
.hero-inner { position: relative; z-index: 2; padding-bottom: clamp(48px, 8vw, 96px); }
.hero-title { font-size: var(--fs-h1); margin: 24px 0 28px; max-width: 14ch; font-weight: 500; }
.hero-lead  { font-size: var(--fs-xl); color: var(--bone); opacity: .8; max-width: 44ch; line-height: 1.45; }
.hero-actions { display: flex; gap: 12px; margin-top: 40px; flex-wrap: wrap; }
.hero-meta {
  position: relative; z-index: 2; display: flex; justify-content: space-between;
  padding-block: 20px; border-top: 1px solid var(--line); color: var(--mute);
}

/* About */
.about-body p:first-child { color: var(--bone); font-size: var(--fs-xl); line-height: 1.45; }
.values { margin-top: 36px; border-top: 1px solid var(--line); }
.values li { display: flex; gap: 20px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.values .mono { color: var(--moss); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: clamp(64px, 8vw, 120px); border-top: 1px solid var(--line); }
.stat { padding: 32px 24px 0 0; display: flex; flex-direction: column; gap: 8px; }
.stat + .stat { padding-left: 24px; border-left: 1px solid var(--line); }
.stat-num { font-size: clamp(2.5rem, 1.8rem + 3vw, 4.5rem); font-weight: 400; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: var(--fs-sm); color: var(--bone-dim); }

/* Research cards */
.research { background: var(--ink-2); }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.card {
  background: var(--ink-3); border: 1px solid var(--line); border-radius: var(--radius-lg);
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform .5s var(--ease), border-color .5s var(--ease);
}
.card:hover { transform: translateY(-6px); border-color: var(--line-strong); }
.card-media { aspect-ratio: 4 / 3; transition: transform .8s var(--ease); }
.card:hover .card-media { transform: scale(1.05); }
.card-body { padding: 24px; display: flex; flex-direction: column; gap: 10px; flex: 1; position: relative; background: var(--ink-3); }
.card-index { color: var(--mute); }
.card h3 { font-size: var(--fs-xl); }
.card p { font-size: var(--fs-sm); }

/* Instruments */
.instrument-visual {
  position: relative; aspect-ratio: 1; border-radius: var(--radius-lg); overflow: hidden;
  background: radial-gradient(70% 60% at 50% 40%, #2a2d30, #070808);
  display: grid; place-items: center; border: 1px solid var(--line);
}
.device {
  width: 38%; aspect-ratio: 0.52; border-radius: 28% / 16%; position: relative;
  background: linear-gradient(100deg, #3a3d40 0%, #9aa0a4 22%, #53585c 45%, #d7dadc 62%, #474b4f 85%, #2a2c2e 100%);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.08), inset 0 -20px 40px rgba(0,0,0,.5), 0 40px 80px rgba(0,0,0,.6);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 12% 0;
  animation: float 7s ease-in-out infinite;
}
.device-slot { width: 44%; height: 5%; border-radius: 99px; background: #0d0e0f; box-shadow: inset 0 1px 2px rgba(0,0,0,.8), 0 1px 0 rgba(255,255,255,.15); }
.device-lens { width: 16%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #555, #050505 60%); margin-top: -40%; }
.device-ring { position: absolute; top: 50%; left: 50%; width: 52%; aspect-ratio: 1; transform: translate(-50%, -30%); border-radius: 50%; border: 3px solid var(--amber); box-shadow: 0 0 24px var(--amber), inset 0 0 12px rgba(231,131,42,.5); opacity: .9; }

.spec-list { margin: 32px 0; border-top: 1px solid var(--line); }
.spec-list div { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.spec-list dt { color: var(--bone); }
.spec-list dd { color: var(--bone-dim); font-family: var(--font-mono); font-size: var(--fs-xs); text-align: right; }

/* Open data */
.data { overflow: hidden; }
.data-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 70% at 85% 10%, rgba(143,191,106,.35), transparent 60%),
    linear-gradient(180deg, var(--slate) 0%, #0f1f25 60%, var(--ink) 100%);
}
.data-inner { position: relative; z-index: 2; }
.dataset-table { margin: 48px 0 40px; border-top: 1px solid var(--line-strong); }
.row { display: grid; grid-template-columns: 2.4fr 1fr 1fr 1fr; gap: 16px; padding: 20px 0; border-bottom: 1px solid var(--line); align-items: center; transition: padding .35s var(--ease), background .35s; }
.row-head { color: var(--mute); font-family: var(--font-mono); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; padding-block: 14px; }
a.row:hover { padding-inline: 12px; background: rgba(236,235,230,.04); }
a.row span:first-child { color: var(--bone); }
a.row span { color: var(--bone-dim); }

/* Journal */
.posts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.post-media { aspect-ratio: 4 / 3; border-radius: var(--radius); margin-bottom: 20px; transition: transform .6s var(--ease), filter .6s; }
.post:hover .post-media { transform: scale(0.98); filter: brightness(1.1); }
.post-meta { display: flex; justify-content: space-between; color: var(--mute); margin-bottom: 10px; }
.post h3 { font-size: var(--fs-xl); line-height: 1.25; }
.post h3 a { background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size .4s var(--ease); }
.post:hover h3 a { background-size: 100% 1px; }

/* Partners */
.partners { padding-block: 64px; border-block: 1px solid var(--line); }
.partner-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px 56px; margin-top: 12px; }
.partner-list li { color: var(--mute); font-weight: 600; letter-spacing: -0.01em; font-size: var(--fs-lg); transition: color .3s; }
.partner-list li:hover { color: var(--bone); }

/* Contact */
.contact-details { margin-top: 32px; }
.contact-details li { display: flex; gap: 20px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.contact-details .mono { width: 60px; color: var(--mute); padding-top: 3px; }
.contact-details a:hover { color: var(--moss); }

.form { display: flex; flex-direction: column; gap: 20px; background: var(--ink-2); padding: clamp(24px, 4vw, 40px); border-radius: var(--radius-lg); border: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: var(--fs-sm); color: var(--bone-dim); }
.field input, .field textarea, .field select {
  background: var(--ink); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 13px 14px; transition: border-color .25s, box-shadow .25s; resize: vertical;
}
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--bone-dim) 50%), linear-gradient(135deg, var(--bone-dim) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--moss); box-shadow: 0 0 0 3px rgba(143,191,106,.18); }
.field.has-error input, .field.has-error textarea { border-color: #e2685a; }
.error { font-size: var(--fs-xs); color: #e2685a; min-height: 1em; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: var(--fs-sm); color: var(--bone-dim); cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--moss); width: 16px; height: 16px; flex-shrink: 0; }
.form .btn { align-self: flex-start; }
.form-status { font-size: var(--fs-sm); color: var(--moss); min-height: 1.2em; }

/* Footer */
.site-footer { background: var(--ink-2); border-top: 1px solid var(--line); padding-top: 80px; }
.footer-top { display: grid; grid-template-columns: 1.2fr 2fr; gap: 48px; padding-bottom: 64px; }
.footer-brand p { margin-top: 16px; font-size: var(--fs-sm); }
.footer-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
.footer-cols h4 { font-family: var(--font-mono); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--mute); font-weight: 400; margin-bottom: 16px; }
.footer-cols li + li { margin-top: 10px; }
.footer-cols a { font-size: var(--fs-sm); color: var(--bone-dim); transition: color .25s; }
.footer-cols a:hover { color: var(--bone); }
.newsletter { display: flex; margin-top: 14px; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; }
.newsletter input { flex: 1; min-width: 0; background: transparent; border: 0; padding: 10px 16px; font-size: var(--fs-sm); }
.newsletter input:focus { outline: none; }
.newsletter:focus-within { border-color: var(--moss); }
.newsletter button { padding: 0 16px; background: var(--bone); color: var(--ink); font-weight: 600; }
.newsletter-status { margin-top: 8px; color: var(--moss); }
.footer-bottom { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding-block: 24px; border-top: 1px solid var(--line); font-size: var(--fs-xs); color: var(--mute); }
.legal, .social { display: flex; gap: 20px; }
.legal a:hover, .social a:hover { color: var(--bone); }
.social a { font-family: var(--font-mono); }

/* ---------- 7. Motion ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .9s var(--ease), transform .9s var(--ease); transition-delay: var(--delay, 0s); }
.reveal.is-visible { opacity: 1; transform: none; }
.no-js .reveal { opacity: 1; transform: none; }

@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(4vw, 3vw) scale(1.08); }
  100% { transform: translate(-3vw, 5vw) scale(0.96); }
}
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-12px) rotate(1deg); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 4px rgba(143,191,106,.18); } 50% { box-shadow: 0 0 0 8px rgba(143,191,106,0); } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- 8. Responsive ---------- */
@media (max-width: 1080px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .footer-top { grid-template-columns: 1fr; }
}

@media (max-width: 880px) {
  .nav-toggle { display: block; }
  .nav {
    position: fixed; inset: 0; z-index: 105; flex-direction: column; justify-content: center; align-items: flex-start;
    gap: 40px; padding: var(--header-h) var(--gutter) 40px; background: var(--ink);
    opacity: 0; visibility: hidden; transition: opacity .4s var(--ease), visibility .4s;
  }
  .nav.is-open { opacity: 1; visibility: visible; }
  .nav-list { flex-direction: column; gap: 8px; }
  .nav-list a { font-size: 2rem; color: var(--bone); letter-spacing: -0.02em; }
  .nav-list a::after { display: none; }

  .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: 0; padding-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); margin-top: 32px; }
  .posts { grid-template-columns: 1fr; gap: 40px; }
  .hero-meta span:nth-child(2) { display: none; }
}

@media (max-width: 600px) {
  .cards { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr auto; row-gap: 4px; }
  .row > span:nth-child(2) { display: none; }
  .row > span:nth-child(4) { grid-column: 1 / -1; order: 3; font-size: 11px; }
  .row-head > span:nth-child(4) { display: none; }
  .footer-cols { grid-template-columns: 1fr 1fr; }
  .footer-cols > div:last-child { grid-column: 1 / -1; }
  .hero-actions .btn { flex: 1; justify-content: center; }
}
