/* Rainlight landing. One full-screen photo behind fogged, rain-beaded glass.
   Tokens are taken from the photo itself: near-black night, warm paper white,
   sodium-lamp amber for the few accents. */
:root {
  --ink: #07090c;
  --paper: #f3eee7;
  --paper-soft: rgba(243, 238, 231, 0.88);
  --paper-quiet: rgba(243, 238, 231, 0.78);
  --amber: #e7ad66;
  --amber-deep: #c98a43;
  --line: rgba(243, 238, 231, 0.42);
  --serif: "Instrument Serif", "Iowan Old Style", "Times New Roman", serif;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --edge: clamp(20px, 3.2vw, 48px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  /* Where the photo is anchored when it is cropped to fill the screen.
     main.js reads the same values so the glass lines up with the image. */
  --focus-x: 20%;
  --focus-y: 38%;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Stage: photo, glass canvas, contrast shade ---------- */
.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--ink);
}

.stage picture, .stage__photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stage__photo {
  object-fit: cover;
  object-position: var(--focus-x) var(--focus-y);
}

.stage__glass {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 700ms var(--ease-out);
  touch-action: none;
}

.glass-ready .stage__glass { opacity: 1; }

.stage__shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to top, rgba(4, 6, 9, 0.78) 0%, rgba(4, 6, 9, 0.38) 30%, rgba(4, 6, 9, 0) 52%),
    linear-gradient(to left, rgba(4, 6, 9, 0.62) 0%, rgba(4, 6, 9, 0.22) 36%, rgba(4, 6, 9, 0) 56%),
    radial-gradient(ellipse 340px 150px at 0% 0%, rgba(4, 6, 9, 0.55), rgba(4, 6, 9, 0) 100%),
    linear-gradient(to bottom, rgba(4, 6, 9, 0.55) 0%, rgba(4, 6, 9, 0) 18%);
}

/* ---------- Header ---------- */
.top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(var(--edge) + env(safe-area-inset-top, 0px)) calc(var(--edge) + env(safe-area-inset-right, 0px)) 0 calc(var(--edge) + env(safe-area-inset-left, 0px));
  pointer-events: none;
}

.top > * { pointer-events: auto; }

.brand {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--paper);
  text-decoration: none;
  border-radius: 4px;
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.5);
}

.brand em { font-style: italic; color: var(--amber); }

.top__meta {
  margin: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper-soft);
}

.top__meta span { color: var(--amber); padding: 0 0.35em; }

/* ---------- Story block ---------- */
.story {
  position: fixed;
  right: calc(var(--edge) + env(safe-area-inset-right, 0px));
  bottom: calc(clamp(28px, 7vh, 80px) + env(safe-area-inset-bottom, 0px));
  width: min(35rem, 44vw);
  pointer-events: none;
}

.story > * { pointer-events: auto; }

.story__eyebrow {
  margin: 0 0 18px;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.55);
}

.story__eyebrow span { color: var(--amber); padding: 0 0.4em; }

.story__title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(52px, 2.2rem + 3.6vw, 108px);
  line-height: 0.92;
  letter-spacing: -0.015em;
  text-wrap: balance;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.35);
}

.story__title em { font-style: italic; color: var(--paper); }

.story__lede {
  margin: 22px 0 0;
  max-width: 30rem;
  font-size: 17px;
  line-height: 1.55;
  color: var(--paper-soft);
  text-wrap: pretty;
  text-shadow: 0 1px 16px rgba(0, 0, 0, 0.45);
}

.story__actions {
  margin-top: 30px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
}

.story__hint {
  margin: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--paper-quiet);
}

.hint--touch { display: none; }
@media (hover: none), (pointer: coarse) {
  .hint--pointer { display: none; }
  .hint--touch { display: inline; }
}

/* ---------- Buttons ---------- */
.btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  border-radius: 999px;
  transition: background-color 220ms var(--ease-out), color 220ms var(--ease-out), border-color 220ms var(--ease-out), transform 220ms var(--ease-out);
}

.btn:focus-visible, .brand:focus-visible, .skip:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 4px;
}

.btn--primary {
  min-height: 50px;
  padding: 0 24px 0 20px;
  background: var(--paper);
  color: var(--ink);
  font-size: 15.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
}

.btn--primary:hover { background: var(--amber); }
.btn--primary:active { transform: scale(0.97); }
.btn--primary[aria-busy="true"] { background: var(--amber); cursor: progress; }

.btn--ghost {
  min-height: 44px;
  padding: 0 18px 0 16px;
  background: rgba(7, 9, 12, 0.42);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.btn--ghost:hover { border-color: var(--paper); background: rgba(7, 9, 12, 0.6); }
.btn--ghost:active { transform: scale(0.97); }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 0 rgba(231, 173, 102, 0.6);
  animation: drip 2.4s var(--ease-out) infinite;
}

.is-paused .dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--amber); animation: none; }

@keyframes drip {
  0% { box-shadow: 0 0 0 0 rgba(231, 173, 102, 0.55); }
  70%, 100% { box-shadow: 0 0 0 7px rgba(231, 173, 102, 0); }
}

/* ---------- Footer ---------- */
.foot {
  position: fixed;
  left: calc(var(--edge) + env(safe-area-inset-left, 0px));
  bottom: calc(clamp(28px, 7vh, 80px) + env(safe-area-inset-bottom, 0px));
}

.no-glass .foot, .no-glass .story__hint, .no-glass #wipe { display: none; }

/* ---------- Utilities ---------- */
.skip {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  padding: 10px 14px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 500;
  transform: translateY(-160%);
}
.skip:focus { transform: none; }

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

/* ---------- Entrance ---------- */
.reveal .top, .reveal .story > *, .reveal .foot {
  opacity: 0;
  transform: translateY(14px);
}

.is-in .top, .is-in .story > *, .is-in .foot {
  opacity: 1;
  transform: none;
  transition: opacity 900ms var(--ease-out), transform 900ms var(--ease-out);
}

.is-in .story__eyebrow { transition-delay: 120ms; }
.is-in .story__title { transition-delay: 200ms; }
.is-in .story__lede { transition-delay: 320ms; }
.is-in .story__actions { transition-delay: 420ms; }
.is-in .foot { transition-delay: 520ms; }

/* ---------- Narrow and portrait screens: text sits on the dark coat ---------- */
@media (max-width: 820px), (orientation: portrait) {
  :root { --focus-x: 24%; --focus-y: 40%; }

  .stage__shade {
    background:
      linear-gradient(to top, rgba(4, 6, 9, 0.86) 0%, rgba(4, 6, 9, 0.55) 34%, rgba(4, 6, 9, 0) 58%),
      linear-gradient(to bottom, rgba(4, 6, 9, 0.55) 0%, rgba(4, 6, 9, 0) 18%);
  }

  .story {
    left: calc(var(--edge) + env(safe-area-inset-left, 0px));
    right: calc(var(--edge) + env(safe-area-inset-right, 0px));
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    width: auto;
  }

  .story__title { font-size: clamp(46px, 11vw, 84px); }
  .story__lede { font-size: 16px; margin-top: 16px; }
  .story__actions { margin-top: 22px; }

  .foot {
    left: auto;
    right: calc(var(--edge) + env(safe-area-inset-right, 0px));
    top: calc(var(--edge) + env(safe-area-inset-top, 0px) - 8px);
    bottom: auto;
  }

  .top__meta { display: none; }
}

/* Small portrait phones: more shade, tighter type. */
@media (orientation: portrait) and (max-height: 680px) {
  .stage__shade {
    background:
      linear-gradient(to top, rgba(4, 6, 9, 0.9) 0%, rgba(4, 6, 9, 0.66) 45%, rgba(4, 6, 9, 0) 72%),
      linear-gradient(to bottom, rgba(4, 6, 9, 0.55) 0%, rgba(4, 6, 9, 0) 18%);
  }
  .story__title { font-size: clamp(40px, 12vw, 56px); }
  .story__lede { font-size: 15px; line-height: 1.5; }
}

/* Short landscape screens (phones sideways, or a laptop at 200% zoom):
   text on the right over a side shade, rain toggle bottom left. */
@media (max-height: 520px) and (orientation: landscape) {
  .story { left: auto; right: calc(var(--edge) + env(safe-area-inset-right, 0px)); width: min(30rem, 52vw); bottom: 18px; }
  .story__title { font-size: 44px; }
  .story__lede { font-size: 15px; margin-top: 10px; }
  .story__eyebrow { margin-bottom: 10px; }
  .story__actions { margin-top: 14px; }
  .foot { top: auto; right: auto; left: calc(var(--edge) + env(safe-area-inset-left, 0px)); bottom: 18px; }
  .stage__shade {
    background:
      linear-gradient(to left, rgba(4, 6, 9, 0.8) 0%, rgba(4, 6, 9, 0.35) 45%, rgba(4, 6, 9, 0) 70%),
      radial-gradient(ellipse 340px 150px at 0% 0%, rgba(4, 6, 9, 0.6), rgba(4, 6, 9, 0) 100%),
      linear-gradient(to bottom, rgba(4, 6, 9, 0.55) 0%, rgba(4, 6, 9, 0) 22%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal .top, .reveal .story > *, .reveal .foot { opacity: 1; transform: none; }
  .is-in .top, .is-in .story > *, .is-in .foot { transition: none; }
  .dot { animation: none; }
  .btn, .stage__glass { transition: none; }
}
