@import "tokens.css";

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.05;
  letter-spacing: -.02em; margin: 0; color: var(--text); }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }
img, svg, video { max-width: 100%; display: block; }

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

.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto;
  padding-inline: clamp(1.1rem, 4vw, 2.5rem); }
.mono { font-family: var(--font-mono); font-variant-ligatures: none; }

/* Skip link */
.skip {
  position: absolute; left: -999px; top: .5rem; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: .5rem .9rem; border-radius: 8px; font-weight: 500;
}
.skip:focus { left: .75rem; }

/* Backdrop canvas */
#backdrop {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}
.page { position: relative; z-index: 1; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
  backdrop-filter: saturate(140%) blur(9px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease, background .2s ease;
}
.site-header.is-scrolled { border-bottom-color: var(--border); }
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 4.25rem; gap: 1rem;
}
.header-actions { display: flex; align-items: center; gap: .35rem; }

/* Wordmark */
.wordmark {
  font-family: var(--font-display); font-weight: 700;
  font-size: 1.42rem; letter-spacing: -.03em; line-height: 1;
  color: var(--text); display: inline-flex; align-items: baseline;
}
/* Italic, echoing the app icon's slanted Y / S */
.wordmark .y, .wordmark .s { font-style: italic; }
.wordmark .y { color: var(--brand-red); }
.wordmark .s { color: var(--brand-grey); margin-left: -.01em; }
.wordmark:hover { color: var(--text); }

/* Icon button (theme toggle) */
.icon-btn {
  display: inline-grid; place-items: center;
  width: 2.5rem; height: 2.5rem; border-radius: 10px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-2); cursor: pointer;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.icon-btn:hover { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.icon-btn svg { width: 1.15rem; height: 1.15rem; }
.icon-btn .moon { display: none; }
[data-theme="dark"] .icon-btn .sun { display: none; }
[data-theme="dark"] .icon-btn .moon { display: block; }

.ghost-link {
  font-family: var(--font-mono); font-size: var(--step--1);
  color: var(--muted); padding: .55rem .7rem; border-radius: 9px;
}
.ghost-link:hover { color: var(--text); background: var(--surface); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: var(--font-body); font-weight: 500; font-size: var(--step-0);
  padding: .8rem 1.3rem; border-radius: 11px; border: 1px solid transparent;
  cursor: pointer; transition: transform .12s ease, background .18s ease,
    border-color .18s ease, color .18s ease; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); color: var(--accent-ink); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border-2); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* Hero */
.hero { padding: clamp(3.5rem, 8vw, 7rem) 0 clamp(2.5rem, 5vw, 4rem); }
.hero-grid {
  display: grid; gap: clamp(2rem, 5vw, 4rem);
  grid-template-columns: 1fr;
  align-items: center;
}
@media (min-width: 940px) {
  .hero-grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
}

.status-pill {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--font-mono); font-size: var(--step--1);
  color: var(--text-2); background: var(--surface);
  border: 1px solid var(--border); border-radius: 100px;
  padding: .4rem .85rem .4rem .7rem; margin-bottom: 1.5rem;
}
.status-pill .dot {
  width: .5rem; height: .5rem; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 0 var(--accent);
  animation: pulse 2.6s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  70%  { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .status-pill .dot { animation: none; } }

.hero h1 {
  font-size: var(--step-2); font-weight: 300; letter-spacing: -.035em;
  margin-bottom: 1.1rem;
}
.hero .lede {
  font-size: var(--step-1); color: var(--text-2); line-height: 1.5;
  max-width: 32ch; margin-bottom: 2rem;
}

/* Newsletter form */
.subscribe { max-width: 30rem; }
.subscribe .field {
  display: flex; gap: .5rem; flex-wrap: wrap;
}
.subscribe input[type="email"] {
  flex: 1 1 14rem; min-width: 0;
  font: inherit; color: var(--text);
  padding: .8rem 1rem; border-radius: 11px;
  background: var(--bg); border: 1px solid var(--border-2);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.subscribe input::placeholder { color: var(--muted); }
.subscribe input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.subscribe .hint {
  font-size: var(--step--1); color: var(--muted); margin-top: .7rem;
}
.subscribe .form-msg {
  font-size: var(--step--1); margin-top: .7rem; min-height: 1.2em;
}
.subscribe .form-msg.ok  { color: var(--accent); }
.subscribe .form-msg.err { color: #d14343; }
[data-theme="dark"] .subscribe .form-msg.err { color: #ff8a80; }

/* Honeypot (own-form mode): off-screen, not display:none, so bots still see it */
.hp { position: absolute; left: -5000px; width: 1px; height: 1px; overflow: hidden; }
.subscribe button[disabled] { opacity: .6; cursor: wait; }

/* EmailOctopus script embed (mode 1): match the native .subscribe look */
.subscribe--embed .emailoctopus-form {
  background: transparent !important;
  padding: 0 !important;
  color: var(--text) !important;
}

/* Layout: input and button sit in one row and stretch to equal height */
.subscribe--embed .emailoctopus-form .main-form {
  display: flex !important;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: stretch !important;
}
.subscribe--embed .emailoctopus-form [eo-form-fields-container] {
  flex: 1 1 14rem;
  min-width: 0;
  display: flex;
}
.subscribe--embed .emailoctopus-form .emailoctopus-form-row {
  flex: 1;
  margin: 0 !important;
}

/* Shared sizing so input and button always match */
.subscribe--embed .emailoctopus-form input.form-control,
.subscribe--embed .emailoctopus-form input.btn-primary {
  box-sizing: border-box !important;
  height: 3rem !important;
  line-height: 1.2 !important;
  margin: 0 !important;
  border-radius: 11px !important;
}

/* Email input */
.subscribe--embed .emailoctopus-form input.form-control {
  width: 100% !important;
  font: inherit !important;
  color: var(--text) !important;
  background: var(--bg) !important;
  border: 1px solid var(--border-2) !important;
  padding: 0 1rem !important;
  box-shadow: none !important;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.subscribe--embed .emailoctopus-form input.form-control::placeholder { color: var(--muted) !important; }
.subscribe--embed .emailoctopus-form input.form-control:focus {
  outline: none !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent) !important;
}
.subscribe--embed .emailoctopus-form input.form-control:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  box-shadow: 0 0 0 1000px var(--bg) inset !important;
}

/* Submit button */
.subscribe--embed .emailoctopus-form input.btn-primary {
  width: auto !important;
  font-family: var(--font-body) !important;
  font-weight: 500;
  font-size: var(--step-0);
  color: var(--accent-ink) !important;
  background: var(--accent) !important;
  border: 1px solid transparent !important;
  padding: 0 1.3rem !important;
  cursor: pointer;
  transition: background .18s ease, transform .12s ease;
}
.subscribe--embed .emailoctopus-form input.btn-primary:hover,
.subscribe--embed .emailoctopus-form input.btn-primary:focus,
.subscribe--embed .emailoctopus-form input.btn-primary:active {
  background: var(--accent-strong) !important;
  color: var(--accent-ink) !important;
  border-color: transparent !important;
  box-shadow: none !important;
}
.subscribe--embed .emailoctopus-form input.btn-primary:active { transform: translateY(1px); }
.subscribe--embed .emailoctopus-form input.btn-primary:disabled { opacity: .6; cursor: wait; }

/* Hide the "Powered by EmailOctopus" credit */
.subscribe--embed a[href*="powered_by_form"] { display: none !important; }
.subscribe--embed :has(> a[href*="powered_by_form"]) { display: none !important; }

/* Instrument viewport (hero media) */
.viewport {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.viewport-bar {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .9rem; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-family: var(--font-mono); font-size: var(--step--1); color: var(--muted);
}
.viewport-bar .lamp { width: .58rem; height: .58rem; border-radius: 50%;
  background: var(--accent); flex: none; }
.viewport-bar .sep { color: var(--border-2); }
.viewport-bar .right { margin-left: auto; color: var(--text-2); }
.viewport-media {
  position: relative; aspect-ratio: 16 / 10; background: var(--bg-tint);
  display: grid; place-items: center;
}
.viewport-media video, .viewport-media img { width: 100%; height: 100%; object-fit: cover; }

/* Section framing */
.section { padding: clamp(3rem, 7vw, 6rem) 0; position: relative; }
.section-head { max-width: 46rem; margin-bottom: clamp(2rem, 4vw, 3rem); }
.section-head h2 { font-size: var(--step-3); margin-bottom: .8rem; }
.section-head p { color: var(--text-2); font-size: var(--step-1); line-height: 1.5; }
.rule { height: 1px; background: var(--border); border: 0; margin: 0; }

/* Feature bento */
.bento {
  display: grid; gap: 1.1rem;
  grid-template-columns: 1fr;
}
@media (min-width: 720px)  { .bento { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .bento { grid-template-columns: repeat(6, 1fr); } }

.feature {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
  transition: border-color .2s ease, transform .2s ease;
}
.feature:hover { border-color: var(--border-2); }
@media (min-width: 1000px) {
  .feature { grid-column: span 2; }            /* three medium tiles = 6 cols */
  .feature.is-half  { grid-column: span 3; }   /* two half tiles = 6 cols     */
  .feature.is-large { grid-column: span 6; }   /* flagship spans full row      */
}
.feature.is-large { }

.feature-shot {
  position: relative; border-bottom: 1px solid var(--border);
  background: var(--bg-tint);
}
.feature.is-large .feature-shot { border-bottom: 1px solid var(--border); }
.feature-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.feature.is-large .shot-inner { aspect-ratio: 21 / 9; }
.feature.is-half .shot-inner { aspect-ratio: 16 / 9; }
.shot-inner { aspect-ratio: 16 / 10; }

.feature-body { padding: 1.4rem 1.4rem 1.5rem; display: flex; flex-direction: column; gap: .55rem; }
.feature-meta {
  display: flex; align-items: center; gap: .6rem;
  font-family: var(--font-mono); font-size: var(--step--1); color: var(--muted);
}
.feature-tag { color: var(--accent); }
.feature-meta .coord { margin-left: auto; }
.feature h3 { font-size: var(--step-2); letter-spacing: -.025em; }
.feature .f-lede { color: var(--text); font-weight: 500; }
.feature .f-body { color: var(--text-2); font-size: var(--step-0); }

/* Large flagship: media beside text on wide screens */
@media (min-width: 1000px) {
  .feature.is-large { display: grid; grid-template-columns: 1.15fr 1fr; }
  .feature.is-large .feature-shot { border-bottom: 0; border-right: 1px solid var(--border); }
  .feature.is-large .shot-inner { aspect-ratio: auto; height: 100%; min-height: 22rem; }
  .feature.is-large .feature-body { justify-content: center; padding: 2.2rem; gap: .7rem; }
}

/* Credibility strip */
.creds { background: var(--surface); border-block: 1px solid var(--border); }
.creds .wrap {
  display: grid; gap: 1.5rem 2.5rem; padding-block: clamp(2rem, 4vw, 3rem);
  grid-template-columns: 1fr;
}
@media (min-width: 760px) { .creds .wrap { grid-template-columns: 1.3fr 1fr 1fr; } }
.cred h3 { font-family: var(--font-body); font-weight: 600; font-size: var(--step-0);
  color: var(--text); margin-bottom: .35rem; }
.cred p { color: var(--muted); font-size: var(--step--1); line-height: 1.55; }
.cred a { color: var(--text-2); text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: var(--border-2); }
.cred a:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* Footer */
.site-footer {
  padding: clamp(2.5rem, 5vw, 4rem) 0 calc(2.5rem + env(safe-area-inset-bottom, 0px));
  color: var(--muted);
}
.footer-top {
  display: flex; flex-wrap: wrap; gap: 1.5rem;
  align-items: flex-start; justify-content: space-between;
  padding-bottom: 2rem; border-bottom: 1px solid var(--border);
}
.footer-links { display: flex; flex-wrap: wrap; gap: 1.2rem; }
.footer-links a { color: var(--text-2); font-size: var(--step--1); }
.footer-links a:hover { color: var(--accent); }
.footer-bottom {
  display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: space-between;
  padding-top: 1.5rem; font-size: var(--step--1);
}
.footer-bottom .mono { color: var(--muted); }

/* Motion entrance (single orchestrated reveal) */
.reveal { opacity: 0; transform: translateY(14px); }
.reveal.in { opacity: 1; transform: none; transition: opacity .6s ease, transform .6s ease; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
  .reveal.in { transition: none; }
}

/* Utilities */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Contributors */
.contributor-grid { list-style:none; margin:0; padding:0; display:grid; gap:1.1rem; grid-template-columns:1fr; }
@media (min-width:640px){ .contributor-grid{ grid-template-columns:repeat(2,1fr);} }
@media (min-width:980px){ .contributor-grid{ grid-template-columns:repeat(3,1fr);} }
.contributor { display:flex; gap:1rem; align-items:flex-start; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:1.2rem; transition:border-color .2s ease; }
.contributor:hover { border-color:var(--border-2); }
.portrait { flex:none; width:64px; height:64px; border-radius:50%; overflow:hidden; background:var(--surface-2); border:1px solid var(--border); display:grid; place-items:center; }
.portrait img { width:100%; height:100%; object-fit:cover; }
.portrait-fallback { font-family:var(--font-display); font-weight:600; color:var(--muted); font-size:1.15rem; letter-spacing:-.02em; }
.contributor-body h3 { font-family:var(--font-display); font-size:var(--step-1); margin:0 0 .15rem; }
.contributor-body .role { color:var(--accent); font-size:var(--step--1); margin:0 0 .5rem; }
.contributor-body .bio { color:var(--text-2); font-size:var(--step-0); line-height:1.55; }
.contributor-body .bio p { margin:0; }
.contributor-body .bio a { text-decoration:underline; text-underline-offset:3px; text-decoration-color:var(--border-2); }
.contributor-body .bio a:hover { text-decoration-color:var(--accent); }
.contributor-link { display:inline-block; margin-top:.6rem; font-size:var(--step--1); }