/* ---------- Brand tokens ---------- */

@font-face {
  font-family: "Automated Serif";
  src: url("assets/fonts/AutomatedSerif-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: block; /* the splash waits for it anyway; never flash a fallback */
}

:root {
  --paper: #fafaf8;
  --ink: #0b0b0b;
  --green: #1ee89b;
  --forest: #03201a;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.16, 1, 0.3, 1);
  --serif: "Automated Serif", "Times New Roman", serif;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

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

html {
  height: 100%;
  height: -webkit-fill-available;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  min-height: -webkit-fill-available;
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-font-smoothing: antialiased;
}

body.is-booting,
body.contents-open,
html.is-locked body {
  overflow: hidden;
}

/* ---------- Password gate ----------
   Serif "Password:" over a soft grey field and a Submit button (Enter also
   submits). Sized to sit with
   the splash: the title is a step down from the hero headline. */

.gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--paper);
  transition: opacity 0.6s var(--ease-out), visibility 0s linear 0.6s;
}

html.is-locked .gate,
html.is-unlocking .gate {
  display: flex;
}

html.is-unlocking .gate {
  opacity: 0;
  visibility: hidden;
}

html.is-locked #site {
  visibility: hidden;
  pointer-events: none;
}

.gate__form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1rem, 2vh, 1.4rem);
  width: min(19rem, 84vw);
  animation: gate-in 1s var(--ease-soft) both;
}

@keyframes gate-in {
  from { opacity: 0; transform: translateY(14px); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; }
}

.gate__label {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.5rem, 4.2vw, 3.6rem);
  line-height: 1;
  letter-spacing: -0.035em;
  color: var(--ink);
}

.gate__field {
  width: 100%;
}

.gate__input {
  display: block;
  width: 100%;
  height: 3rem;
  padding: 0 1.1rem;
  font-family: var(--sans);
  font-weight: 400;
  font-size: 16px; /* iOS won't zoom at 16px+ */
  color: var(--ink);
  background: #ececed;
  border: 1px solid transparent;
  border-radius: 8px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.gate__input::placeholder {
  color: #b4b4b6;
}

.gate__input:focus {
  background: #e7e7e8;
  border-color: rgba(11, 11, 11, 0.08);
}

.gate__submit {
  display: block;
  width: 100%;
  height: 3rem;
  margin-top: -0.35rem; /* sit closer to the field than the title gap */
  font-family: var(--sans);
  font-weight: 400;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  color: var(--paper);
  background: var(--ink);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.gate__submit:hover,
.gate__submit:focus-visible {
  background: #2a2a2a;
  outline: none;
}

.gate__submit:active {
  transform: scale(0.985);
}

.gate__error {
  font-family: var(--sans);
  font-weight: 300;
  font-size: 0.8rem;
  color: rgba(11, 11, 11, 0.5);
  margin-top: -0.4rem;
}

.gate__form.is-wrong .gate__input {
  animation: gate-shake 0.4s ease;
}

@keyframes gate-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@media (prefers-reduced-motion: reduce) {
  .gate__form { animation: none; }
}

/* ---------- Landing splash ----------
   Three layers, each with its own entrance, all gated on body.is-loaded so
   nothing moves until the font and both images are decoded:
     1. headline letters un-blur and rise one after another as the tracking settles
     2. the gradient band fills upward from its bottom edge
     3. the phone lifts in from below, tilts upright, then breathes
   script.js adds is-loaded; --px/--py drive a small pointer parallax. */

.landing {
  --px: 0;
  --py: 0;
  --scroll: 0;
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  min-height: 560px;
  overflow: hidden;
  background: var(--paper);
  isolation: isolate;
}

.landing__title {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  top: 13vh;
  top: 13svh;
  padding: 0 4vw;
  text-align: center;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3rem, 9.4vw, 11rem);
  line-height: 1;
  letter-spacing: -0.035em;
  color: var(--ink);
  translate: calc(var(--px) * -6px) calc(var(--py) * -4px + var(--scroll) * -0.18px);
  opacity: calc(1 - var(--scroll) / 700);
}

/* Words stay whole so lines only break between them. */
.word {
  white-space: nowrap;
}

.br-mobile { display: none; }

/* Letter-by-letter entrance. script.js wraps each glyph in .char and sets --i.
   The spans stay inline (not inline-block) so the font keeps its kerning and
   ligatures across letters; the lift uses relative `top`, which inline boxes
   honour where transforms are ignored. Each letter clears its own blur and
   rises a hair, staggered left to right, while the whole line settles from
   loose to final tracking underneath. */
.char {
  position: relative;
  top: 0.22em;
  opacity: 0;
  filter: blur(10px);
  transition:
    opacity 1.1s var(--ease-out),
    filter 1.3s var(--ease-out),
    top 1.5s var(--ease-soft);
  transition-delay: calc(0.2s + var(--i) * 52ms);
}

body.is-loaded .char {
  top: 0;
  opacity: 1;
  filter: blur(0);
}

/* Hide the unsplit headline so it can't flash in full before script.js runs. */
.js .landing__title:not(.is-split) {
  visibility: hidden;
}

.landing__title.is-split {
  letter-spacing: 0.01em;
  transition: letter-spacing 2.6s var(--ease-soft) 0.2s;
}

body.is-loaded /* Hide the unsplit headline so it can't flash in full before script.js runs. */
.js .landing__title:not(.is-split) {
  visibility: hidden;
}

.landing__title.is-split {
  letter-spacing: -0.035em;
}

/* Gradient band: same placement as the cover slide, inset from the sides. */
.landing__band {
  position: absolute;
  z-index: 1;
  left: 2.6vw;
  right: 2.6vw;
  top: 47%;
  bottom: 0;
  translate: 0 calc(var(--scroll) * 0.12px);
  clip-path: inset(100% 0 0 0 round 22px);
  transition: clip-path 1.6s var(--ease-soft) 0.55s;
}

body.is-loaded .landing__band {
  clip-path: inset(0 0 0 0 round 22px);
}

.landing__band-img {
  display: block;
  width: 100%;
  height: 100%;
  /* The PNG is already a top-down green -> white fade with rounded corners;
     stretching it keeps the fade landing on the page edge at any ratio. */
  object-fit: fill;
  transform: scale(1.06);
  transform-origin: 50% 100%;
  transition: transform 2.2s var(--ease-soft) 0.55s;
}

body.is-loaded .landing__band-img {
  transform: scale(1);
}

/* Phone: lifted from below, settles upright, then floats. */
.landing__phone {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 0;
  height: min(64vh, 62vw);
  height: min(64svh, 62vw);
  aspect-ratio: 1081 / 1679;
  translate: calc(-50% + var(--px) * 14px) calc(var(--py) * 8px + var(--scroll) * -0.32px);
  transform: translateY(70%) rotate(9deg);
  transform-origin: 60% 100%;
  opacity: 0;
  transition:
    transform 1.9s var(--ease-soft) 0.75s,
    opacity 0.8s var(--ease-out) 0.75s;
}

body.is-loaded .landing__phone {
  /* Negative lift raises the phone so it sits well over the band's top edge. */
  transform: translateY(-5%) rotate(0deg);
  opacity: 1;
}

.landing__phone-float {
  width: 100%;
  height: 100%;
}

body.is-settled .landing__phone-float {
  animation: phone-float 6.5s ease-in-out infinite;
}

@keyframes phone-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-1.6%) rotate(-0.8deg); }
}

.landing__phone-img {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 30px 40px rgba(3, 32, 26, 0.12));
}

/* Corner captions, as on the cover slide. */
.landing__meta {
  position: absolute;
  z-index: 3;
  bottom: clamp(1rem, 3vh, 2rem);
  font-family: var(--sans);
  font-weight: 300;
  font-size: clamp(0.78rem, 1.1vw, 0.95rem);
  letter-spacing: 0.01em;
  color: rgba(11, 11, 11, 0.55);
  opacity: 0;
  translate: 0 8px;
  transition: opacity 0.9s var(--ease-out) 1.9s, translate 0.9s var(--ease-out) 1.9s;
}

.landing__meta--left { left: calc(2.6vw + 1rem); }
.landing__meta--right { right: calc(2.6vw + 1rem); }

body.is-loaded .landing__meta {
  opacity: 1;
  translate: 0 0;
}

/* Scroll cue: a thin line that draws downward on a loop. */
.landing__cue {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: clamp(0.9rem, 2.6vh, 1.8rem);
  width: 1px;
  height: 38px;
  translate: -50% 0;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.9s var(--ease-out) 2.3s;
}

body.is-loaded .landing__cue {
  opacity: 1;
}

.landing__cue-line {
  position: absolute;
  inset: 0;
  background: rgba(11, 11, 11, 0.45);
  animation: cue 2.4s var(--ease-out) infinite;
}

@keyframes cue {
  0% { transform: translateY(-100%); }
  55% { transform: translateY(0); }
  100% { transform: translateY(100%); }
}

/* Before JS runs (or with JS off) show the finished frame. */
html:not(.js) .landing__phone,
html:not(.js) .landing__meta {
  transform: none;
  filter: none;
  opacity: 1;
}
html:not(.js) .landing__band { clip-path: none; }

@media (prefers-reduced-motion: reduce) {
  .char,
  .landing__title.is-split,
  .landing__band,
  .landing__band-img,
  .landing__phone,
  .landing__meta,
  .landing__cue {
    transition-duration: 0.01s !important;
    transition-delay: 0s !important;
  }
  .char { filter: none; top: 0; }
  body.is-settled .landing__phone-float,
  .landing__cue-line { animation: none; }
}

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

.slides {
  --slide-width: 72vw;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.65rem, 4.4vh, 3.03rem);
  padding: clamp(4rem, 10vh, 7rem) clamp(1rem, 4vw, 2rem) clamp(5rem, 12vh, 8rem);
}

.slide {
  width: var(--slide-width);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.85rem;
  scroll-margin-top: 5.5rem;
  opacity: 0;
  translate: 0 28px;
  transition: opacity 0.9s var(--ease-out), translate 0.9s var(--ease-out);
}

.slide.is-visible {
  opacity: 1;
  translate: 0 0;
}

.slide__title {
  font-family: var(--sans);
  font-weight: 300;
  font-size: clamp(0.8rem, 1.35vw, 0.95rem);
  letter-spacing: 0.02em;
  line-height: 1.2;
  color: rgba(11, 11, 11, 0.6);
}

.slide__img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 8px 28px 4px rgba(0, 0, 0, 0.07);
}

/* ---------- Overview grid ---------- */

.overview {
  position: relative;
  z-index: 1;
  padding: clamp(2rem, 5vh, 3.5rem) clamp(1rem, 4vw, 2rem) clamp(4rem, 9vh, 6rem);
}

.overview__inner {
  width: var(--overview-width, 72vw);
  margin: 0 auto;
}

.overview__heading {
  font-family: var(--sans);
  font-weight: 300;
  font-size: clamp(0.8rem, 1.35vw, 0.95rem);
  letter-spacing: 0.02em;
  color: rgba(11, 11, 11, 0.6);
  margin-bottom: 1.1rem;
}

.overview__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: clamp(0.6rem, 1.2vw, 1rem);
}

.overview__item {
  position: relative;
  display: block;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(11, 11, 11, 0.05);
  box-shadow: 0 4px 14px 2px rgba(0, 0, 0, 0.06);
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}

.overview__thumb {
  display: block;
  width: 100%;
  height: auto;
}

.overview__meta {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.15rem;
  padding: 0.5rem 0.55rem;
  background: linear-gradient(180deg, rgba(3, 32, 26, 0) 45%, rgba(3, 32, 26, 0.85) 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.overview__num,
.overview__label {
  font-family: var(--sans);
  color: #fff;
  line-height: 1.2;
}

.overview__num {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--green);
}

.overview__label {
  font-weight: 300;
  font-size: 0.72rem;
}

.overview__item:hover,
.overview__item:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px 4px rgba(0, 0, 0, 0.12);
}

.overview__item:hover .overview__meta,
.overview__item:focus-visible .overview__meta {
  opacity: 1;
}

.overview__item:focus-visible {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
}

/* ---------- Contents toggle (sticky + / x) ---------- */

.contents-toggle {
  position: sticky;
  top: 1.25rem;
  align-self: flex-start;
  margin-bottom: -44px;
  margin-left: max(1rem, calc((100% - var(--slide-width)) / 2 - 44px - 1.1rem));
  z-index: 90;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--forest);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(3, 32, 26, 0.22);
  transition: transform 0.45s var(--ease-out), box-shadow 0.35s ease;
}

.contents-toggle:hover {
  transform: scale(1.04);
}

.contents-toggle:active {
  transform: scale(0.96);
}

.contents-toggle__icon {
  position: relative;
  width: 14px;
  height: 14px;
}

.contents-toggle__bar {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 1.5px;
  background: var(--green);
  border-radius: 999px;
  transition: transform 0.45s var(--ease-out);
}

.contents-toggle__bar--a { transform: translate(-50%, -50%) rotate(0deg); }
.contents-toggle__bar--b { transform: translate(-50%, -50%) rotate(90deg); }
body.contents-open .contents-toggle__bar--a { transform: translate(-50%, -50%) rotate(45deg); }
body.contents-open .contents-toggle__bar--b { transform: translate(-50%, -50%) rotate(-45deg); }

body.contents-open .contents-toggle {
  position: fixed;
  top: calc(1.1rem + 12px);
  left: calc(1.1rem + 12px);
  margin: 0;
  z-index: 95;
}

/* ---------- Contents panel ---------- */

.contents-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(3, 32, 26, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s var(--ease-out);
}

body.contents-open .contents-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.contents-panel {
  position: fixed;
  top: 1.1rem;
  left: 1.1rem;
  bottom: 1.1rem;
  z-index: 80;
  width: min(320px, calc(100vw - 2.2rem));
  background: var(--forest);
  color: #fff;
  border-radius: 10px;
  overflow: hidden;
  transform: translate3d(-110%, 0, 0);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.55s var(--ease-out), opacity 0.4s var(--ease-out);
  box-shadow: 0 24px 60px rgba(3, 32, 26, 0.35);
}

body.contents-open .contents-panel {
  transform: translate3d(0, 0, 0);
  opacity: 1;
  pointer-events: auto;
}

.contents-panel__inner {
  height: 100%;
  overflow-y: auto;
  padding: 1.35rem 1.25rem 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.contents-panel__header {
  margin-bottom: 1.35rem;
  padding-left: 2.6rem;
}

.contents-panel__brand {
  font-family: var(--serif);
  font-size: 1.7rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--green);
}

.contents-panel__label {
  margin-top: 0.45rem;
  font-family: var(--sans);
  font-weight: 300;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.6);
}

.contents-panel__nav {
  display: flex;
  flex-direction: column;
  gap: 0.72rem;
}

.contents-link {
  display: grid;
  grid-template-columns: 1.7rem 1fr;
  gap: 0.65rem;
  align-items: baseline;
  text-decoration: none;
  color: #fff;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.contents-link:hover { opacity: 0.72; }
.contents-link:active { transform: translateX(2px); }

.contents-link__num {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--green);
}

.contents-link__label {
  font-family: var(--sans);
  font-weight: 300;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.92);
}

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

.site-footer {
  position: relative;
  z-index: 1;
  width: 100%;
  background: var(--forest);
  overflow: hidden;
  line-height: 0;
}

.site-footer__inner {
  display: flex;
  justify-content: center;
  padding: clamp(3rem, 7vw, 6rem) clamp(1rem, 3vw, 3rem) 0;
}

/* Tracer logo, near full width, in the same green the wordmark used. Its
   fills are currentColor, so `color` sets them. The negative margin pushes
   the lower edge past the footer so overflow: hidden crops it, as on Clyx;
   percentage margins resolve against width, and the logo is ~9.7:1, so -2%
   trims about a fifth of its height. */
.site-footer__logo {
  display: block;
  width: 100%;
  height: auto;
  color: var(--green);
  margin-bottom: -2%;
}

/* ---------- Phones ---------- */

@media (max-width: 720px) {
  .landing__title {
    top: 15svh;
    font-size: clamp(3rem, 15vw, 5.5rem);
    line-height: 0.98;
  }

  /* Stack the headline: "The Internet's" / "IPO." */
  .br-mobile { display: inline; }

  .landing__band {
    left: 1rem;
    right: 1rem;
    top: 43%;
  }

  /* Lifted off the page bottom so the phone clears the band's top edge
     instead of starting at it. */
  .landing__phone {
    height: 56svh;
    bottom: 9svh;
  }

  .landing__cue { display: none; }

  .landing__meta--left { left: 1.5rem; }
  .landing__meta--right { right: 1.5rem; }

  .slides { --slide-width: 88vw; }
  .overview__inner { --overview-width: 88vw; }

  .overview__grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }

  .contents-toggle {
    margin-left: max(0.65rem, calc((100% - var(--slide-width)) / 2 - 44px - 0.65rem));
  }
}
