/*
  OurSpace landing page — plain CSS, no build step, no framework.
  Colour tokens below are lifted directly from the app's own dark-mode
  palette (nothing invented). Contrast for every pairing used here is
  computed and reported alongside this brick's commit — see the report,
  not this file, for the numbers.
*/

:root {
  --bg: #121212;
  --fill: #1E3327;
  --accent: #2AFEBB;
  --secondary: #C4B5FD;
  --text-body: rgba(255, 255, 255, 0.75);
  --text-body-strong: #FFFFFF;
  --max-width: 1080px;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-body);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

h1, h2, h3 {
  color: var(--accent);
  line-height: 1.15;
  margin: 0 0 0.5em;
}

p {
  margin: 0 0 1em;
}

a {
  color: var(--secondary);
}

a:hover {
  color: var(--accent);
}

/* Visible focus state for every interactive element — keyboard users get a
   clearly-outlined ring in the accent colour, never the default (often
   invisible-on-dark) browser outline alone. */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.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;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--fill);
  color: var(--accent);
  padding: 12px 20px;
  z-index: 100;
  border-radius: 0 0 8px 0;
}

.skip-link:focus {
  left: 0;
}

/* ---------- Header ---------- */

.site-header {
  border-bottom: 1px solid var(--fill);
  padding: 28px 0;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.75rem;
}

.logo-mark {
  display: block;
  width: 80px;
  height: 80px;
}

.logo-word-our {
  color: var(--accent);
}

.logo-word-space {
  color: var(--secondary);
}

.site-header nav {
  display: flex;
  gap: 24px;
}

.site-header nav a {
  text-decoration: none;
  color: var(--text-body-strong);
  font-weight: 500;
  font-size: 1rem;
  letter-spacing: 0.03em;
}

.site-header nav a:hover {
  color: var(--accent);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  padding: 14px 24px;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-primary:hover {
  background: var(--text-body-strong);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Lift + glow on hover/focus. The glow is a box-shadow, which paints outside
   the box without affecting layout, so it stays active even under reduced
   motion — only the transform-based lift and its transition are disabled
   there (see the reduced-motion block below). */
.btn:hover,
.btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(42, 254, 187, 0.35);
}

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

.hero {
  padding: 56px 0;
}

.hero-row {
  display: flex;
  align-items: center;
  gap: 48px;
  flex-wrap: wrap;
}

.hero-copy {
  position: relative;
  flex: 1 1 420px;
  min-width: 280px;
}

/* Static (non-animated) ambient glow behind the hero copy, kept low-alpha
   enough that the recomputed contrast for every text pairing here still
   clears WCAG AA by a wide margin — see the report for the numbers. Not an
   animation, so it isn't gated on prefers-reduced-motion. */
.hero-copy::before {
  content: "";
  position: absolute;
  inset: -32px -40px;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(
    55% 55% at 35% 35%,
    rgba(42, 254, 187, 0.10) 0%,
    rgba(196, 181, 253, 0.06) 45%,
    transparent 72%
  );
}

.hero-media {
  flex: 1 1 320px;
  min-width: 260px;
}

.beta-badge {
  display: inline-block;
  background: var(--fill);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0 0 16px;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin-bottom: 0.4em;
}

.subhead {
  color: var(--secondary);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1em;
}

.beta-note {
  color: var(--text-body);
  max-width: 46ch;
}

.download-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 28px;
}

/* ---------- Screenshots (with graceful missing-image fallback) ---------- */

/* Loaded images are pre-framed transparent WebPs (device bezel + shadow
   baked in), so the wrapper stays visually inert and the phone renders
   free-floating on the page background. The card look (background,
   border, radius, clipping, fixed aspect ratio) only applies in the
   .has-error fallback state below. */
.screenshot-frame {
  position: relative;
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screenshot-frame img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

.hero-media .screenshot-frame {
  max-width: 420px;
}

.feature-media .screenshot-frame {
  max-width: 380px;
}

.screenshot-fallback {
  display: none;
  position: absolute;
  inset: 0;
  margin: 0;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: var(--secondary);
  font-weight: 600;
}

/* When the image 404s, script.js's onerror handler adds .has-error to this
   wrapper — the broken <img> is hidden and this styled placeholder takes
   its place, so a missing screenshot-N.png never renders as a broken-image
   icon. The card styling (background, border, radius, clipping, fixed
   aspect ratio) is scoped to this state only. */
.screenshot-frame.has-error {
  aspect-ratio: 9 / 16;
  background: var(--fill);
  border-radius: 28px;
  overflow: hidden;
  border: 1px solid rgba(196, 181, 253, 0.25);
}

.screenshot-frame.has-error img {
  display: none;
}

.screenshot-frame.has-error .screenshot-fallback {
  display: flex;
}

/* ---------- Tiles ---------- */

.tiles {
  padding: 40px 0;
}

.tile-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.tile {
  background: var(--fill);
  border-radius: var(--radius);
  padding: 24px;
}

.tile h3 {
  font-size: 1.1rem;
  margin-bottom: 0.4em;
}

.tile p {
  color: var(--text-body);
  margin: 0;
}

/* ---------- Feature blocks ---------- */

.feature-blocks {
  padding: 40px 0;
}

.feature-block {
  display: flex;
  align-items: center;
  gap: 48px;
  padding: 40px 0;
  flex-wrap: wrap;
}

.feature-block-reverse {
  flex-direction: row-reverse;
}

.feature-media,
.feature-copy {
  flex: 1 1 320px;
  min-width: 260px;
}

.feature-copy h3 {
  font-size: 1.6rem;
}

/* Padlock icon beside the E2EE feature heading. pathLength="100" on the
   rect/path normalizes both shapes to the same dash unit regardless of
   their actual geometric length, so one dasharray/dashoffset value draws
   both. Static and fully drawn by default; the scroll-driven wipe is
   layered on in the Motion section below, gated behind feature support
   and prefers-reduced-motion. */
.lock-draw {
  display: block;
  margin-bottom: 8px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lock-draw rect,
.lock-draw path {
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
}

.feature-copy p {
  color: var(--text-body);
  font-size: 1.05rem;
  max-width: 44ch;
}

/* ---------- Waitlist ---------- */

.waitlist {
  padding: 56px 0;
  background: var(--fill);
}

.waitlist-inner {
  max-width: 520px;
  text-align: left;
}

.waitlist h2 {
  font-size: 1.75rem;
}

.waitlist-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.waitlist-field label {
  color: var(--text-body-strong);
  font-weight: 600;
}

.waitlist-field input {
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid rgba(196, 181, 253, 0.4);
  background: var(--bg);
  color: var(--text-body-strong);
  font-size: 1rem;
}

.waitlist-field input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.waitlist-status {
  margin-top: 14px;
  color: var(--text-body-strong);
  font-weight: 600;
  min-height: 1.3em;
}

.waitlist-status[data-state="ok"] {
  color: var(--accent);
}

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

.site-footer {
  padding: 32px 0 48px;
  border-top: 1px solid var(--fill);
}

.footer-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.9rem;
}

.made-by {
  color: var(--secondary);
  margin: 0;
}

.site-footer p {
  margin: 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .tile-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .tile-grid {
    grid-template-columns: 1fr;
  }

  .hero-row,
  .feature-block,
  .feature-block-reverse {
    flex-direction: column;
  }

  .site-header nav {
    gap: 16px;
  }

  .download-row {
    flex-direction: column;
  }

  .btn {
    text-align: center;
  }
}

@media (max-width: 480px) {
  .site-header {
    padding: 20px 0;
  }

  .logo {
    font-size: 1.4rem;
  }

  .logo-mark {
    width: 64px;
    height: 64px;
  }

  .site-header nav {
    gap: 16px;
  }

  .site-header nav a {
    font-size: 0.9rem;
  }

  /* night-wave-1[12]: clamp the wordmark back to its pre-2.4rem inherited scale (matching .logo's
     own 1.4rem at this breakpoint) so it can't crowd the nav on small screens. site-motion-1's
     unconditional .logo-word-our/.logo-word-space rule sits later in the file and would otherwise
     win the cascade at this viewport despite this being the more specific mobile rule — the
     .site-header ancestor raises specificity above that plain single-class rule so this wins
     regardless of source order. Additive only: the desktop 2.4rem rule is untouched. */
  .site-header .logo-word-our,
  .site-header .logo-word-space {
    font-size: 1.4rem;
  }
}

@media (max-width: 400px) {
  .wrap {
    padding: 0 16px;
  }

  .hero {
    padding: 36px 0;
  }

  .tile {
    padding: 18px;
  }
}

/* ---------- Motion ----------
   CSS only — no JavaScript animation library, no Lottie, no GSAP, no
   external anything. This page's entire pitch is that it loads nothing
   from a third party; a dependency here would break the claim it exists
   to make. Every effect below is driven by the browser's own CSS engine.

   Every animation in this section is wrapped in
   @media (prefers-reduced-motion: no-preference), so it is fully disabled
   under prefers-reduced-motion: reduce. Nothing here animates width,
   height, top, or margin — only transform and opacity, so nothing can
   cause layout shift. */

@media (prefers-reduced-motion: no-preference) {

  /* Slow, low-amplitude opacity breath on the header mark. 6s period and a
     small opacity range keep it barely noticeable, not a beacon. */
  .logo-mark {
    animation: logo-pulse 6s ease-in-out infinite;
  }

  @keyframes logo-pulse {
    0%, 100% {
      opacity: 1;
    }
    50% {
      opacity: 0.82;
    }
  }

  /* Scroll reveal via the browser's native scroll-driven animations
     (animation-timeline: view()), gated behind @supports so browsers
     without it never receive the opacity: 0 starting state below — those
     visitors see tiles and feature blocks fully visible, no scroll
     interaction required. Chromium (115+) is the current implementation;
     Firefox and Safari fall through to the always-visible default. */
  @supports (animation-timeline: view()) {
    .tile,
    .feature-block {
      opacity: 0;
      transform: translateY(16px);
      animation: reveal linear forwards;
      animation-timeline: view();
      animation-range: entry 0% cover 30%;
    }

    @keyframes reveal {
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    /* Padlock draws itself as the E2EE feature scrolls into view. Starts
       hidden (dashoffset back to full length) only here, inside the
       feature-support guard — browsers without animation-timeline: view()
       never receive this starting state, so they keep the fully-drawn
       static lock set in the Feature blocks section above. */
    .lock-draw rect,
    .lock-draw path {
      stroke-dashoffset: 100;
      animation: lock-draw linear forwards;
      animation-timeline: view();
      animation-range: entry 0% cover 40%;
    }

    @keyframes lock-draw {
      to {
        stroke-dashoffset: 0;
      }
    }

    /* Hero phone drifts a few pixels on scroll. Transform-only, so it
       never affects layout or the CLS of anything around it. */
    .hero-media .screenshot-frame {
      animation: hero-parallax linear;
      animation-timeline: scroll(root);
      animation-range: 0 400px;
    }

    @keyframes hero-parallax {
      from {
        transform: translateY(0);
      }
      to {
        transform: translateY(24px);
      }
    }
  }

  /* Waitlist submit button: conic-gradient shimmer ring on hover/focus.
     The ring itself (::after) only exists inside this reduced-motion
     guard at all — under prefers-reduced-motion: reduce the button gets
     no ring, animated or static, per the brief. Everything up to the
     nested @supports below is the non-conic-gradient fallback: a plain
     solid-color ring, revealed on hover/focus, not spinning. */
  .waitlist .btn-primary {
    position: relative;
  }

  .waitlist .btn-primary::after {
    content: "";
    position: absolute;
    inset: -3px;
    z-index: -1;
    border-radius: inherit;
    padding: 2px;
    background: var(--secondary);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  .waitlist .btn-primary:hover::after,
  .waitlist .btn-primary:focus-visible::after {
    opacity: 1;
  }

  /* Browsers that also support conic-gradient upgrade the static ring
     above to a spinning conic-gradient shimmer. */
  @supports (background: conic-gradient(from 0deg, red, blue)) {
    @property --angle {
      syntax: '<angle>';
      initial-value: 0deg;
      inherits: false;
    }

    .waitlist .btn-primary::after {
      background: conic-gradient(from var(--angle), var(--accent), var(--secondary), var(--accent));
    }

    .waitlist .btn-primary:hover::after,
    .waitlist .btn-primary:focus-visible::after {
      animation: shimmer-spin 2s linear infinite;
    }

    @keyframes shimmer-spin {
      to {
        --angle: 360deg;
      }
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }

  .btn:hover,
  .btn:focus-visible {
    transform: none;
  }
}

/* site-motion-1: wordmark scaled to sit nearly as tall as the mark */
.logo-word-our, .logo-word-space { font-size: 2.4rem; line-height: 1; }

/* site-motion-1: hero-style halo behind the header logo + wordmark */
.logo { position: relative; }
.logo::before {
  content: "";
  position: absolute;
  inset: -160% -50% -160% -35%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(
    55% 45% at 47% 50%,
    rgba(42, 254, 187, 0.09) 0%,
    rgba(196, 181, 253, 0.05) 35%,
    rgba(196, 181, 253, 0.02) 50%,
    transparent 62%
  );
}

/* site-motion-1: soft halo behind each feature heading block */
.feature-copy { position: relative; }
.feature-copy::before {
  content: "";
  position: absolute;
  inset: -60% -25%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(
    50% 45% at 45% 35%,
    rgba(42, 254, 187, 0.07) 0%,
    rgba(196, 181, 253, 0.04) 45%,
    transparent 65%
  );
}

/* site-motion-1: faint wash behind the phone mockups */
.screenshot-frame::before {
  content: "";
  position: absolute;
  inset: -12% -18%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(
    60% 55% at 50% 48%,
    rgba(42, 254, 187, 0.26) 0%,
    rgba(196, 181, 253, 0.16) 45%,
    transparent 68%
  );
}
.screenshot-frame.has-error::before { display: none; }
