/* =========================================================================
   Noematic — landing page
   Dark by design: the page sits on top of video, so there is no light theme.
   ========================================================================= */

:root {
  --ink:        #07090c;
  --paper:      #f2f5f8;
  --paper-dim:  rgba(242, 245, 248, 0.66);
  --paper-faint:rgba(242, 245, 248, 0.40);
  --glow:       #7cb8ff;   /* echoes the glass curtain-wall in the reel */
  --danger:     #ff9c8f;
  --ok:         #8fe3c0;

  /* Glass recipe, reused by the sheet and the fields */
  --glass-bg:     rgba(255, 255, 255, 0.065);
  --glass-bg-lift:rgba(255, 255, 255, 0.105);
  --glass-line:   rgba(255, 255, 255, 0.16);
  --glass-blur:   blur(26px) saturate(165%);

  --gut: clamp(1.25rem, 5vw, 4.5rem);   /* page gutter */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* Safe-area shorthands for notched iPhones */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

/* The UA stylesheet's `[hidden] { display: none }` is a normal declaration, so
   ANY author-level `display` beats it — `.form { display: grid }` silently
   defeated `form.hidden = true`. !important makes the attribute authoritative
   again, for every element, permanently. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Inter", "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--paper);
  background: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;                 /* single viewport, never scrolls */
  overscroll-behavior: none;
  text-rendering: optimizeLegibility;
}

/* Let the sheet scroll on short screens without the page bouncing */
body.is-sheet-open { overflow: hidden; }

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

/* Visible focus, but only for keyboard users */
:focus-visible {
  outline: 2px solid var(--glow);
  outline-offset: 3px;
  border-radius: 4px;
}
:focus:not(:focus-visible) { outline: none; }

/* =========================================================================
   Stage — video + scrim + grain
   ========================================================================= */

.stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--ink);
}

.stage__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 42%;   /* keeps the building mass in frame when cropped */
  /* Fade in once the first frames decode, so we never flash a black box */
  opacity: 0;
  transition: opacity 1.2s var(--ease);
  will-change: opacity;
}
.stage__video.is-ready { opacity: 1; }

/* Cinematic scrim: darkens top and bottom for text, leaves the middle open.
   Two layers — a vertical gradient for legibility, a vignette for depth. */
.stage__scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(125% 105% at 50% 45%,
      rgba(7, 9, 12, 0) 34%,
      rgba(7, 9, 12, 0.42) 74%,
      rgba(7, 9, 12, 0.78) 100%),
    linear-gradient(180deg,
      rgba(7, 9, 12, 0.72) 0%,
      rgba(7, 9, 12, 0.30) 26%,
      rgba(7, 9, 12, 0.34) 52%,
      rgba(7, 9, 12, 0.76) 84%,
      rgba(7, 9, 12, 0.92) 100%);
}

/* Faint film grain — kills gradient banding and adds texture */
.stage__grain {
  position: absolute;
  inset: -50%;
  pointer-events: none;
  opacity: 0.028;
  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='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 6s steps(5) infinite;
}
@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-3%, 2%); }
  40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -2%); }
  80% { transform: translate(3%, 1%); }
}

/* =========================================================================
   Layout shell
   ========================================================================= */

/* Explicit layering, and it matters more than it looks.
   .hero sits in normal flow at 100dvh tall, and .topbar is fixed (so out of
   flow) — meaning the hero's box starts at y=0 and covers the entire viewport,
   the topbar included. With all three sharing z-index:1, later DOM order won
   hit-testing and the hero swallowed every tap aimed at the sound button.
   That hid on desktop (the hero is capped at 60rem, so the right-aligned
   button fell outside it) and broke completely on phones, where the hero
   spans the full width. Keep the topbar above the hero. */
.topbar, .hero, .footer { position: relative; }
.hero   { z-index: 1; }
.footer { z-index: 2; }
.topbar { z-index: 3; }

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding:
    calc(var(--sat) + clamp(1rem, 2.6vw, 1.75rem))
    calc(var(--sar) + var(--gut))
    0
    calc(var(--sal) + var(--gut));
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--paper);
  text-decoration: none;
  transition: opacity 0.3s var(--ease);
}
.wordmark:hover { opacity: 0.75; }
.wordmark__glyph { width: 22px; height: 22px; flex: none; }
.wordmark__text {
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

/* ---- Sound toggle -------------------------------------------------------- */

.sound {
  -webkit-appearance: none;
  appearance: none;
  position: relative;          /* anchors the clipped label on phones */
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;                    /* touch target */
  padding: 0.5rem 1.05rem;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  color: var(--paper);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  /* Kills the ~300ms double-tap-zoom wait some mobile browsers add before
     firing click, so the toggle responds immediately to a tap. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease), transform 0.2s var(--ease);
}
.sound:hover { background: var(--glass-bg-lift); border-color: rgba(255,255,255,0.28); }
.sound:active { transform: scale(0.97); }

.sound__bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 13px;
  width: 15px;
}
.sound__bars i {
  display: block;
  width: 2px;
  height: 3px;
  border-radius: 1px;
  background: currentColor;
  opacity: 0.5;
  transition: height 0.3s var(--ease), opacity 0.3s var(--ease);
}
/* Bars dance only while audio is actually playing */
.sound.is-on .sound__bars i {
  opacity: 1;
  animation: eq 1.05s ease-in-out infinite;
}
.sound.is-on .sound__bars i:nth-child(1) { animation-delay: -0.85s; }
.sound.is-on .sound__bars i:nth-child(2) { animation-delay: -0.45s; }
.sound.is-on .sound__bars i:nth-child(3) { animation-delay: -0.65s; }
.sound.is-on .sound__bars i:nth-child(4) { animation-delay: -0.15s; }
@keyframes eq {
  0%, 100% { height: 3px; }
  50%      { height: 13px; }
}

/* ---- Hero ---------------------------------------------------------------- */

.hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  min-height: 100dvh;
  max-width: 60rem;
  padding:
    0
    calc(var(--sar) + var(--gut))
    calc(var(--sab) + clamp(5.5rem, 13vh, 8.5rem))
    calc(var(--sal) + var(--gut));
}

.hero__eyebrow {
  margin: 0 0 clamp(1rem, 2.4vw, 1.5rem);
  font-size: clamp(0.6875rem, 1.4vw, 0.8125rem);
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--paper-dim);
}

.hero__title {
  margin: 0;
  font-size: clamp(2.5rem, 8.2vw, 6.5rem);
  font-weight: 300;
  line-height: 0.98;
  letter-spacing: -0.035em;
  text-wrap: balance;
  text-shadow: 0 2px 40px rgba(7, 9, 12, 0.45);
}
.hero__title span { display: block; }
.hero__title span:last-child { color: var(--paper-dim); }

.hero__lede {
  margin: clamp(1.25rem, 3vw, 1.85rem) 0 0;
  max-width: 44ch;
  font-size: clamp(0.9375rem, 1.9vw, 1.125rem);
  line-height: 1.6;
  color: var(--paper-dim);
  text-wrap: pretty;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: clamp(1.85rem, 4.5vw, 2.75rem);
}

/* ---- Footer -------------------------------------------------------------- */

.footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding:
    0
    calc(var(--sar) + var(--gut))
    calc(var(--sab) + clamp(1.25rem, 2.6vw, 1.75rem))
    calc(var(--sal) + var(--gut));
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--paper-faint);
}
.footer__dot { opacity: 0.5; }

/* =========================================================================
   Buttons
   ========================================================================= */

.btn {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 48px;
  padding: 0.8rem 1.6rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.3s var(--ease),
              border-color 0.3s var(--ease), box-shadow 0.3s var(--ease), opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn svg { width: 15px; height: 15px; flex: none; transition: transform 0.3s var(--ease); }
.btn:active { transform: scale(0.975); }

.btn--primary {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 12px 32px rgba(7, 9, 12, 0.36);
}
.btn--primary:hover { background: #fff; box-shadow: 0 1px 0 rgba(255,255,255,0.7) inset, 0 16px 40px rgba(7,9,12,0.46); }
.btn--primary:hover svg { transform: translateX(3px); }

.btn--ghost {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-color: var(--glass-line);
  color: var(--paper);
}
.btn--ghost:hover { background: var(--glass-bg-lift); border-color: rgba(255,255,255,0.3); }

.btn--block { width: 100%; }

.btn[disabled], .btn[aria-busy="true"] { cursor: default; opacity: 0.7; }
.btn[disabled]:active, .btn[aria-busy="true"]:active { transform: none; }

/* Spinner swaps in for the label while submitting */
.btn__spinner {
  position: absolute;
  width: 17px; height: 17px;
  border: 2px solid rgba(7, 9, 12, 0.22);
  border-top-color: var(--ink);
  border-radius: 50%;
  opacity: 0;
  animation: spin 0.7s linear infinite;
}
.btn[aria-busy="true"] .btn__spinner { opacity: 1; }
.btn[aria-busy="true"] .btn__text { opacity: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================================
   Contact sheet (native <dialog>: free focus trap + Esc)
   ========================================================================= */

.sheet {
  width: min(30rem, 100%);
  max-height: 100dvh;
  margin: auto;                       /* centred on desktop */
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--paper);
  overflow: visible;
}
.sheet::backdrop {
  background: rgba(4, 6, 9, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

/* Enter/exit transition. allow-discrete lets display/overlay animate;
   browsers without it simply pop the sheet in, which is fine. */
.sheet, .sheet::backdrop {
  opacity: 0;
  transition:
    opacity 0.45s var(--ease),
    transform 0.45s var(--ease),
    overlay 0.45s var(--ease) allow-discrete,
    display 0.45s var(--ease) allow-discrete;
}
.sheet { transform: translateY(14px) scale(0.985); }
.sheet[open] { opacity: 1; transform: none; }
.sheet[open]::backdrop { opacity: 1; }
@starting-style {
  .sheet[open] { opacity: 0; transform: translateY(14px) scale(0.985); }
  .sheet[open]::backdrop { opacity: 0; }
}

/* ---- The glass panel itself --------------------------------------------- */

.sheet__panel {
  position: relative;
  max-height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: clamp(1.75rem, 5vw, 2.5rem);
  border: 1px solid var(--glass-line);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.075);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.22) inset,      /* top light catch */
    0 -1px 0 rgba(255, 255, 255, 0.05) inset,
    0 40px 90px -20px rgba(0, 0, 0, 0.7),
    0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Specular sheen across the top edge — what sells it as glass */
.sheet__panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 45%;
  border-radius: 26px 26px 0 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0));
  pointer-events: none;
}

/* Fallback for browsers with no backdrop-filter: go opaque so text stays readable */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .sheet__panel { background: rgba(14, 17, 22, 0.94); }
  .sound, .btn--ghost { background: rgba(14, 17, 22, 0.8); }
}

.sheet__close {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  top: clamp(0.9rem, 2.4vw, 1.15rem);
  right: clamp(0.9rem, 2.4vw, 1.15rem);
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--paper-dim);
  cursor: pointer;
  transition: color 0.25s, background 0.25s, border-color 0.25s;
}
.sheet__close svg { width: 15px; height: 15px; }
.sheet__close:hover {
  color: var(--paper);
  background: rgba(255,255,255,0.09);
  border-color: var(--glass-line);
}

.sheet__head { margin: 0 2.5rem 1.75rem 0; }
.sheet__title {
  margin: 0;
  font-size: clamp(1.5rem, 4.6vw, 1.875rem);
  font-weight: 300;
  letter-spacing: -0.025em;
}
.sheet__sub {
  margin: 0.55rem 0 0;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--paper-dim);
  text-wrap: pretty;
}

/* =========================================================================
   Form
   ========================================================================= */

.form { display: grid; gap: 1.05rem; }

.field { display: grid; gap: 0.45rem; }

.field__label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-dim);
}

.field__input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-height: 48px;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--paper);
  font: inherit;
  font-size: 1rem;              /* 16px minimum — stops iOS zoom-on-focus */
  line-height: 1.5;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.field__input::placeholder { color: rgba(242, 245, 248, 0.34); }
.field__input:hover { border-color: rgba(255, 255, 255, 0.22); }
.field__input:focus {
  outline: none;
  border-color: rgba(124, 184, 255, 0.65);
  background: rgba(255, 255, 255, 0.085);
  box-shadow: 0 0 0 3px rgba(124, 184, 255, 0.16);
}
.field__input--area {
  min-height: 118px;
  resize: vertical;
  field-sizing: content;        /* grows with content where supported */
  max-height: 40vh;
}

/* Invalid only after we've actually validated, never while typing fresh */
.field__input[aria-invalid="true"] {
  border-color: rgba(255, 156, 143, 0.7);
  background: rgba(255, 156, 143, 0.07);
}
.field__input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgba(255, 156, 143, 0.16);
}

.field__error {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--danger);
  min-height: 0;
}
.field__error:empty { display: none; }

/* Honeypot — off-screen rather than display:none, which some bots skip */
.decoy {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.field--turnstile { gap: 0.5rem; }
.turnstile { min-height: 65px; }
/* Turnstile renders a fixed 300px iframe; scale it down on narrow phones */
@media (max-width: 22rem) {
  .turnstile { transform: scale(0.92); transform-origin: left top; }
}

.form__status {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--danger);
}
.form__status:empty { display: none; }

.form__fineprint {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--paper-faint);
}

/* ---- Success state ------------------------------------------------------ */

.sent { text-align: center; padding: 1.25rem 0 0.5rem; }
.sent__mark { color: var(--ok); margin-bottom: 1.15rem; }
.sent__mark svg { width: 52px; height: 52px; }
.sent__title {
  margin: 0;
  font-size: clamp(1.375rem, 4.4vw, 1.75rem);
  font-weight: 300;
  letter-spacing: -0.02em;
}
.sent__sub {
  margin: 0.6rem auto 1.75rem;
  max-width: 30ch;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--paper-dim);
}

/* =========================================================================
   Responsive — phones
   ========================================================================= */

/* Below 40rem the sheet becomes a bottom sheet: thumb-reachable, and it
   survives the on-screen keyboard shrinking the viewport. */
@media (max-width: 40rem) {
  .sheet {
    width: 100%;
    max-width: none;
    margin: auto 0 0;             /* pin to the bottom edge */
    max-height: 92dvh;
  }
  .sheet { transform: translateY(28px); }
  .sheet[open] { transform: none; }
  @starting-style {
    .sheet[open] { transform: translateY(28px); }
  }

  .sheet__panel {
    max-height: 92dvh;
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
    padding: 1.6rem clamp(1.1rem, 5vw, 1.5rem) calc(1.6rem + var(--sab));
  }
  .sheet__panel::before { border-radius: 24px 24px 0 0; }

  /* Grab handle, so it reads as a sheet you can dismiss */
  .sheet__panel::after {
    content: "";
    position: absolute;
    top: 0.6rem; left: 50%;
    transform: translateX(-50%);
    width: 36px; height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.28);
  }
  .sheet__head { margin-top: 0.6rem; margin-bottom: 1.4rem; }

  .hero { justify-content: flex-end; }
  .hero__actions { width: 100%; }
  .hero__actions .btn { flex: 1 1 auto; }

  /* Icon-only to save width — but clipped rather than display:none, so the
     button keeps its accessible name for screen readers. */
  .sound__label {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .sound { padding: 0.5rem; width: 44px; justify-content: center; }
}

/* Very short viewports (landscape phones): tighten vertical rhythm */
@media (max-height: 34rem) and (orientation: landscape) {
  .hero { padding-bottom: calc(var(--sab) + 3.25rem); }
  .hero__lede { display: none; }
  .hero__title { font-size: clamp(1.75rem, 6vh, 2.75rem); }
  .footer { display: none; }
  .sheet__panel { padding-top: 1.25rem; padding-bottom: calc(1.25rem + var(--sab)); }
}

/* Portrait phones crop a 16:9 reel hard — bias the framing higher */
@media (orientation: portrait) {
  .stage__video { object-position: center 38%; }
}

/* =========================================================================
   Accessibility & preference queries
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .stage__grain { animation: none; }
  .stage__video { opacity: 1; transition: none; }
}

@media (prefers-contrast: more) {
  :root {
    --paper-dim: rgba(242, 245, 248, 0.88);
    --paper-faint: rgba(242, 245, 248, 0.72);
    --glass-line: rgba(255, 255, 255, 0.45);
  }
  .sheet__panel { background: rgba(9, 12, 16, 0.96); }
  .stage__scrim { background: rgba(7, 9, 12, 0.72); }
}

/* Data-saver / reduced-data: don't autoplay heavy video, keep the poster */
@media (prefers-reduced-data: reduce) {
  .stage__video { display: none; }
  .stage {
    background: var(--ink) url("/assets/poster.jpg") center 42% / cover no-repeat;
  }
}
