/* Rtro — landing page. Design: Figma RED Draft / Page 5, 1440×1024. */

/* Tokens and the Cal Sans face live in tokens.css. */

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: "Cal Sans", -apple-system, "SF Pro Text", system-ui, sans-serif;
  font-optical-sizing: none;
  font-variation-settings: "opsz" 45, "GEOM" 25;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { display: block; max-width: 100%; }

a { color: inherit; text-decoration: none; }

a:focus-visible,
button:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 4px;
}

/* Viewport frame — every rule on the page is 1px. */
.frame {
  position: fixed;
  inset: 0;
  border: var(--line) solid var(--fg);
  pointer-events: none;
  z-index: 40;
}

/* ---------- Left rail ---------- */

.rail {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  background: var(--rail);
  border-right: var(--line) solid var(--fg);
  z-index: 10;
}

.rail__mark {
  flex: 1 1 auto;
  min-height: 0;
  padding: 39px 0 0 44px;
}

.rail__mark img { width: 33px; height: 42px; }

.menu { display: none; color: var(--fg); }
.menu svg { fill: currentColor; }
.menu__open,
.menu__close { display: block; }
.menu__close { display: none; }

.rail__panel {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--pad);
  padding: var(--pad) var(--pad) 0;
  border-top: var(--line) solid var(--fg);
}

.rail__foot { flex: 0 1 291px; }

/* Brand */

.brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand__row {
  display: flex;
  align-items: center;
  gap: 2px;
  line-height: 1;
}

.brand__name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand__sub {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0.4;
}

.brand__tag {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.04em;
}

/* Nav */

.nav {
  display: flex;
  flex-direction: column;
  gap: 24px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
}

.nav a {
  width: 120px;
  transition: opacity 0.18s ease;
}

.nav a:hover { opacity: 0.6; }

/* Download strip + social */

.cta {
  display: flex;
  margin: 0 calc(-1 * var(--pad));
  height: 84px;
  border-top: var(--line) solid var(--fg);
  border-bottom: var(--line) solid var(--fg);
}

.cta__store {
  flex: 0 0 210px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 var(--pad);
  border-right: var(--line) solid var(--fg);
  cursor: default;
  transition: background-color 0.18s ease;
}

.cta__store:hover { background: rgba(255, 255, 255, 0.04); }

.cta__apple { width: 24px; height: 24px; }

.cta__store-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  line-height: 1;
  white-space: nowrap;
}

.cta__label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  opacity: 0.6;
}

.cta__name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.cta__social {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.cta__social a {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.18s ease;
}

.cta__social a:hover { opacity: 0.6; }

.social-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: conic-gradient(from 90deg, #fff, rgba(255, 255, 255, 0));
}

/* ---------- Slides ---------- */

.deck {
  margin-left: var(--rail-w);
  background: var(--pane);
}

.slide {
  position: relative;
  height: 100vh;
}

.slide:nth-of-type(2) { --accent: #ff9900; }
.slide:nth-of-type(3) { --accent: #2ed803; }
.slide:nth-of-type(4) { --accent: #ffd400; }

.slide__media {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: var(--rail-w);
  overflow: hidden;
  pointer-events: none;
  background: var(--pane);
  opacity: 0;
}

/* No-JS and first paint: only the active photo is shown. */
.slide.is-active .slide__media { opacity: 1; }

/* Each photo is exported at the pane's own 1020×1024 ratio, so it fills it exactly. */
.slide__photo {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
}

/* Transition atmosphere: exposure breath + grain, both peaking mid-dissolve. */
.pane-exposure,
.pane-grain {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: var(--rail-w);
  pointer-events: none;
  opacity: 0;
}

.pane-exposure {
  z-index: 2;
  background: #fff;
}

.pane-grain {
  z-index: 3;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncR type='linear' slope='1.6' intercept='-0.555'/%3E%3CfeFuncG type='linear' slope='1.6' intercept='-0.555'/%3E%3CfeFuncB type='linear' slope='1.6' intercept='-0.555'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23g)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

/* Copy — sits in the rail on desktop, over the page bottom.
   Opacity is scroll-driven (app.js); no time-based transition here. */
.slide__copy {
  position: fixed;
  left: var(--pad);
  bottom: calc(var(--pad) + 3px);
  z-index: 20;
  width: calc(var(--rail-w) - var(--pad) * 2);
  opacity: 0;
  pointer-events: none;
}

/* No-JS: the first copy stays readable. On mobile the copies live in the rail,
   so they carry the active class themselves. */
.slide.is-active .slide__copy,
.slide__copy.is-active { opacity: 1; }

.copy__title {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.slide:not(:first-of-type) .copy__title { opacity: 0.8; }

.copy__num {
  display: block;
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 64px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
  font-variation-settings: "opsz" 45, "GEOM" 100;
}

.slide:not(:first-of-type) .copy__title { margin-bottom: 12px; }

.copy__poem {
  margin: 24px 0 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 2.2;
  letter-spacing: 0.02em;
  opacity: 0.6;
}

.copy__body {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.02em;
  opacity: 0.6;
}

/* Short viewports: tighten the rail so the copy never collides with the strip. */
@media (min-width: 901px) and (max-height: 900px) {
  .rail__mark { padding-top: 32px; }
  .rail__panel { padding-top: 32px; gap: 32px; }
  .rail__foot { flex-basis: 270px; }
  .cta { height: 80px; }
}

@media (min-width: 901px) and (max-height: 660px) {
  .rail__mark { padding-top: 24px; }
  .rail__panel { padding-top: 24px; gap: 24px; }
  .rail__foot { flex-basis: 250px; }
  .cta { height: 72px; }
}

/* ---------- Small screens: photo full-bleed, desktop column overlaid ---------- */

@media (max-width: 900px) {
  /* The column is an overlay now: logo top, copy at the bottom of its block, store strip at the bottom. */
  /* Stretch to the live viewport — 100svh left a gap when the iOS toolbar collapsed. */
  .rail {
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    background: transparent;
    border: 0;
  }


  /* Logo and control stay above the sheet that slides under them. */
  .rail__mark {
    position: relative;
    z-index: 4;
    padding: 39px 0 0 44px;
  }

  .rail__panel {
    padding: 40px 40px 0;
    gap: 40px;
    border-top: 0;
  }

  /* Nav folds into one control, level with the mark; 44px touch target. */
  .menu {
    display: grid;
    place-items: center;
    position: absolute;
    top: 38px;
    right: 30px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
  }

  .rail.is-open .menu__open { display: none; }
  .rail.is-open .menu__close { display: block; }

  .rail__panel > .brand { display: none; }

  /* The nav pushes down from the top edge, full width. */
  .nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 121px 40px 16px;
    background: var(--rail);
    border-bottom: var(--line) solid var(--fg);
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.26s ease, opacity 0.26s ease, visibility 0.26s;
  }

  .rail.is-open {
    z-index: 30;
  }

  .rail.is-open .nav {
    transform: none;
    opacity: 1;
    visibility: visible;
  }

  .nav a {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 44px;
    padding: 0;
    font-size: 14px;
  }

  .cta {
    margin: 0 -40px;
    height: 84px;
  }

  .cta__store { flex: 0 0 auto; }

  .cta__social { gap: 8px; }

  .cta__social a { width: 44px; height: 44px; }

  .rail__foot { display: none; }

  .deck { margin-left: 0; }

  .slide {
    height: 100vh;
    height: 100svh;
    position: relative;
  }

  /* Photo is the full-screen background, cross-fading between chapters. */
  .slide__media {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    height: auto;
  }

  /* Copy sits at the bottom of the mark block, right above the store strip. */
  .slide__copy {
    position: absolute;
    left: 40px;
    right: 40px;
    width: auto;
    bottom: calc(40px + 84px + var(--line));
  }

  .rail.is-open .slide__copy { z-index: 1; }

  /* Roomier leading than the fixed desktop block allows. */
  .copy__body { line-height: 1.5; }
  .copy__poem { line-height: 1.8; }

  .pane-exposure,
  .pane-grain { display: none; }
}

/* Short phones: keep the mark clear of the panel. */
@media (max-width: 900px) and (max-height: 640px) {
  .rail__mark { padding-top: 24px; }
  .menu { top: 23px; }
  .nav { padding-top: 106px; }
}

/* Narrow phones: keep the store and three 40px targets on one line. */
@media (max-width: 360px) {
  /* Keep "Spectral Science" on one line at 32px. */
  .slide__copy { left: 32px; right: 32px; }
  .cta__store { padding: 0 24px; }
  .cta__social { gap: 4px; }
  .cta__social a { width: 40px; height: 40px; }
  .cta__social img { width: 28px; height: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .nav,
  .nav a,
  .cta__store,
  .cta__social a { transition: none; }
}
