/* Take 02: Most people don't scroll. */

:root {
  /* This tape's label colour: a pale tape blue. */
  --tape: #8ec5d6;
  --device: #c4c3c8;
  --device-deep: #aeadb3;
  --device-edge: #8e8d94;
  --sheet: #f7f7f5;
  --sheet-ink: #18171a;
  --sheet-muted: #5a5860;
}

@media (prefers-color-scheme: dark) {
  :root {
    --device: #4a4950;
    --device-deep: #3a393f;
    --device-edge: #6a6970;
    --sheet: #2a292e;
    --sheet-ink: #ecebe7;
    --sheet-muted: #aba9b0;
  }
}

/* The fold: a dashed line right under the opening. */

.fold-line {
  max-width: calc(var(--wide) + 2 * var(--gutter));
  margin: clamp(1rem, 3vw, 2rem) auto 0;
  padding: 0 var(--gutter);
}

.fold-line__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  padding-top: 0.75rem;
  border-top: 2px dashed var(--rec);
}

.fold-line__label {
  font-size: 1.125rem;
  color: var(--rec);
}

.fold-line__note {
  font-size: 1rem;
  color: var(--ink-muted);
}

/* What happened: the take, set large on footage. */

.statement {
  max-width: var(--wide);
  margin: 2.5rem auto 0;
}

.statement .footage__line {
  max-width: 24ch;
  /* Long words ("understanding.") must fit on a phone, even with large text. */
  font-size: min(clamp(1.75rem, 1.2rem + 1.8vw, 2.75rem), 8.5vw);
}

@media (min-width: 48rem) {
  .statement {
    min-height: 20rem;
  }
}

/* The sheet: a phone with a half-open sheet. There's more if you pull it up. */

.phone {
  width: min(100%, 20rem);
  margin: 0 auto;
  padding: 0.75rem;
  border-radius: 2.5rem;
  background: #0b0b0d;
  box-shadow: 0 0 0 1.5px var(--device-edge), 0 1.5rem 3rem -1.5rem rgb(0 0 0 / 0.45);
}

/* `clip`, not `hidden`: focusing something off screen must not scroll the screen.
   `min-height: 0` keeps the aspect ratio when the content is taller, as in the feed. */
.phone__screen {
  position: relative;
  aspect-ratio: 9 / 19;
  min-height: 0;
  overflow: clip;
  border-radius: 1.85rem;
  background: var(--bg);
}

.phone__app {
  padding: 2.25rem 1rem 1rem;
}

.phone__app-title {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-stretch: 85%;
  font-weight: 750;
}

.phone__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.phone__grid span {
  aspect-ratio: 4 / 3;
  border-radius: 0.5rem;
  background: var(--device);
}

.sheet {
  position: absolute;
  inset: 8% 0 0;
  display: flex;
  flex-direction: column;
  padding: 0 min(1.1rem, 4vw) 1.5rem;
  border-radius: 1.25rem 1.25rem 0 0;
  background: var(--sheet);
  color: var(--sheet-ink);
  box-shadow: 0 -0.5rem 1.5rem rgb(0 0 0 / 0.18);
  transition: transform 450ms cubic-bezier(0.32, 0.72, 0, 1);
}

.sheet-demo[data-state="half"] .sheet { transform: translateY(68%); }
.sheet-demo[data-state="full"] .sheet {
  transform: translateY(0);
  /* With large text the sheet holds more than the screen, so it scrolls. */
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet-demo[data-state="closed"] .sheet { transform: translateY(105%); }

/* Only the top bar takes drags, so a finger anywhere else still scrolls the page.
   The grabber sits in the middle and Close on the right, so they never overlap. */
.sheet__bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  min-height: 2.75rem;
  cursor: grab;
  touch-action: none;
}

.sheet__grabber {
  grid-column: 2;
  width: min(4.5rem, 20vw);
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  background: none;
  cursor: grab;
}

.sheet__grabber::before {
  content: "";
  display: block;
  width: min(2.5rem, 100%);
  height: 0.3rem;
  margin: 0 auto;
  border-radius: 999px;
  background: var(--sheet-muted);
  opacity: 0.6;
}

.sheet__close {
  grid-column: 3;
  justify-self: end;
  margin: 0.5rem -0.25rem 0 0;
  display: grid;
  place-items: center;
  /* Capped by the screen width at large text, still a comfortable tap size. */
  width: min(2.25rem, 12vw);
  height: min(2.25rem, 12vw);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(127 127 127 / 0.18);
  color: var(--sheet-ink);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.sheet__title {
  margin: 0.25rem 2.5rem 0.75rem 0;
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-stretch: 85%;
  font-weight: 750;
  line-height: 1.1;
}

.sheet__facts {
  display: grid;
  gap: 0.4rem;
  margin: 0 0 1.25rem;
  font-size: 0.9375rem;
}

.sheet__facts div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgb(127 127 127 / 0.25);
}

.sheet__facts dt { color: var(--sheet-muted); }
.sheet__facts dd { margin: 0; font-weight: 600; }

.sheet__more h4 {
  margin: 0 0 0.25rem;
  font-size: 0.9375rem;
}

.sheet__more p {
  margin: 0 0 1rem;
  font-size: 0.9375rem;
  line-height: 1.45;
  color: var(--sheet-muted);
}

.sheet__more .sheet__payoff {
  margin-top: 1.5rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-stretch: 85%;
  font-weight: 750;
  line-height: 1.15;
  color: var(--sheet-ink);
}

.phone__reopen {
  position: absolute;
  inset: auto 1rem 1.5rem;
  min-height: 2.75rem;
  border: 0;
  border-radius: 999px;
  background: var(--shell);
  color: #f2f1ee;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
}

.sheet-demo figcaption,
.sitemap figcaption {
  text-align: center;
}

/* The homepage: a map of 21 pages where only Home is lit, and a red button. */

.sitemap__map {
  display: grid;
  gap: 1rem;
}

.sitemap__home {
  display: grid;
  justify-items: start;
  gap: 0.5rem;
  padding: 1.25rem clamp(0.75rem, 4vw, 1.5rem) 1.5rem;
  border-radius: 0.6rem;
  background: var(--screen);
  color: var(--screen-ink);
}

.sitemap__name {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 1.3rem + 1.5vw, 2.5rem);
  font-stretch: 85%;
  font-weight: 800;
  line-height: 1;
}

.sitemap__blurb {
  margin: 0 0 0.5rem;
  color: var(--screen-muted);
}

/* Literally the red button. */
.sitemap__button {
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: 999px;
  background: var(--paper-rec);
  box-shadow: 0 0 0 0 rgb(255 70 50 / 0.5), 0 2px 0 #7a160e;
  color: #fff;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.sitemap__button:active {
  transform: translateY(2px);
  box-shadow: none;
}

.sitemap__button:focus-visible {
  outline: 3px solid var(--screen-ink);
  outline-offset: 3px;
}

.sitemap[data-explored="true"] .sitemap__button {
  background: #7a160e;
  box-shadow: none;
}

.sitemap__pages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 7.5rem), 1fr));
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sitemap__page {
  display: flex;
  align-items: end;
  min-height: 3.5rem;
  padding: 0.5rem 0.65rem;
  border: 1.5px dashed var(--line);
  border-radius: 0.4rem;
  font-size: 0.875rem;
  color: var(--ink-muted);
}

.sitemap__page--article {
  min-height: 2.75rem;
}

/* Each page lights up in turn. `--i` is its place in the list, set by the script. */
.sitemap[data-explored="true"] .sitemap__page {
  transition:
    background-color 300ms ease calc(var(--i) * 60ms),
    color 300ms ease calc(var(--i) * 60ms),
    border-color 300ms ease calc(var(--i) * 60ms);
  border-style: solid;
  border-color: var(--shell-edge);
  background: var(--screen);
  color: var(--screen-ink);
}

.sitemap__caption {
  display: grid;
  gap: 0.25rem;
}

.sitemap__count {
  color: var(--ink);
  font-weight: 600;
}

.sitemap__seen {
  font-family: var(--font-osd);
  font-weight: 400;
  font-size: 1.25em;
  font-variant-numeric: tabular-nums;
}

/* The video: Nick's clip in a footage frame, with what's on screen in words
   underneath, and a reveal once it has played to the end. */

.video-slot {
  max-width: var(--wide);
  margin: 2.5rem auto 0;
}

.video-slot__video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 0.25rem;
  background: #000;
}

/* A lighter red, so it reads on the warm footage behind it in both themes. */
.video-slot[data-state="playing"] .video-slot__state {
  color: #ff8275;
}

.video-after {
  max-width: var(--wide);
  margin: 1rem auto 0;
}

.video-after > * {
  max-width: var(--measure);
}

.video-after__transcript summary {
  min-height: 2.75rem;
  padding-block: 0.5rem;
  font-weight: 600;
  cursor: pointer;
}

.video-after__transcript p {
  margin: 0.5rem 0 1rem;
  color: var(--ink-muted);
}

.video-after__readout {
  font-family: var(--font-osd);
  font-size: 1rem;
  line-height: 1.5;
}

.video-after__reveal-line {
  margin: 1rem 0 0;
}

.video-after__answer {
  margin: 1rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.375rem, 1.1rem + 1vw, 2rem);
  font-stretch: 85%;
  font-weight: 750;
  line-height: 1.15;
}

/* The load screen: five seconds before the good part shows. It only loads
   while it's on screen, so scrolling past means never seeing it. */

.loader__screen {
  display: grid;
  align-content: space-between;
  gap: 1.5rem;
  min-height: 15rem;
  /* Padding follows the screen width, not the text size, so large text keeps its room. */
  padding: min(max(clamp(1.25rem, 4vw, 2.25rem), 1.75rem), 6vw);
}

.loader__osd {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
  font-size: 1.125rem;
}

.loader__percent {
  font-variant-numeric: tabular-nums;
}

.loader__bar {
  height: 0.6rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.12);
}

.loader__fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: var(--stamp);
  box-shadow: 0 0 0.6rem rgb(255 170 50 / 0.6);
  transform: scaleX(var(--progress, 0));
  transform-origin: left;
}

.loader__payoff {
  margin: 0;
  font-family: var(--font-display);
  font-size: min(clamp(1.75rem, 1.2rem + 1.8vw, 2.75rem), 9vw);
  font-stretch: 85%;
  font-weight: 750;
  line-height: 1.08;
}

.loader[data-state="done"] .loader__bar {
  display: none;
}

.loader figcaption {
  text-align: center;
}

/* The feed: a phone full of identical posts, scrolling by. One of them is yours. */

.feed__screen {
  aspect-ratio: 9 / 16;
}

/* Only moves while it's on screen, not paused, and not found. Stopping freezes
   the posts where they are rather than jumping back to the top. */
.feed__strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  margin: 0;
  /* Side padding follows the screen width, so posts fit and stay centred at large text. */
  padding: 0.75rem min(0.75rem, 3.2vw);
  list-style: none;
  animation: feed-scroll 9s linear infinite paused;
}

.feed[data-moving="true"] .feed__strip {
  animation-play-state: running;
}

@keyframes feed-scroll {
  to { transform: translateY(-50%); }
}

.feed__post,
.feed__catch {
  display: grid;
  grid-template-columns: 1.75rem 1fr;
  gap: 0.5rem 0.6rem;
  align-items: center;
  padding: 0.65rem;
  border-radius: 0.75rem;
  background: var(--sheet);
}

.feed__avatar {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--device);
}

.feed__lines {
  height: 0.5rem;
  width: 70%;
  border-radius: 999px;
  background: var(--device);
}

.feed__image {
  grid-column: 1 / -1;
  aspect-ratio: 4 / 3;
  border-radius: 0.5rem;
  background: var(--device);
}

/* Yours: the REC light as its avatar. The button inside is the whole post. */
.feed__post--yours {
  display: block;
  padding: 0;
  background: none;
}

.feed__catch {
  width: 100%;
  border: 0;
  color: var(--sheet-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.feed__post--yours .feed__avatar {
  background: none;
  box-shadow: inset 0 0 0 0.25rem var(--rec);
}

.feed__name {
  font-size: 0.875rem;
  font-weight: 700;
}

.feed[data-found="true"] .feed__catch {
  box-shadow: 0 0 0 3px var(--rec);
}

.feed[data-found="true"] .feed__post--yours .feed__avatar {
  background: var(--rec);
}

/* While your post has keyboard focus, the phone shows the focus ring. */
.feed:has(.feed__catch:focus-visible) .feed__screen {
  outline: 3px solid var(--pen);
  outline-offset: 3px;
}

/* With keyboard focus, and once caught, your post holds still where it can be seen
   (the script sets the offset). */
.feed[data-focused="true"] .feed__strip {
  animation: none;
  transform: translateY(var(--focus-offset, 0));
}

.feed__controls {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

.feed figcaption {
  text-align: center;
}

/* The tape's progress line across the top of the screen. */

.progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 15;
  height: 3px;
  pointer-events: none;
}

.progress__fill {
  display: block;
  height: 100%;
  background: var(--rec);
  transform: scaleX(var(--read, 0));
  transform-origin: left;
}

/* The report on the STOP screen: what this reader did, worked out on their device. */

.report {
  display: grid;
  gap: 0.35rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
  font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  text-transform: uppercase;
}

.report li {
  display: flex;
  gap: 0.75em;
}

.report__mark {
  width: 1.25em;
  color: var(--screen-muted);
}

.report li[data-done="true"] .report__mark {
  color: var(--stamp);
  text-shadow: 0 0 0.35em rgb(255 170 50 / 0.55);
}

.report__note {
  max-width: 34rem;
  margin: 1.25rem 0 0;
  font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  color: var(--screen-ink);
}

@media (prefers-reduced-motion: reduce) {
  .sheet,
  .sitemap[data-explored="true"] .sitemap__page {
    transition: none;
  }

  /* The feed stays still, so readers scroll it themselves to find their post. */
  .feed__strip {
    animation: none;
  }

  .feed__screen {
    overflow-y: auto;
  }

  .feed__strip > [aria-hidden="true"],
  .feed__pause {
    display: none;
  }
}
