/* The start page of dokay.dev, on top of site.css. Without scroll-driven
   animations, and with reduced motion, every scene stands in the page as it
   is; the block at the end turns them into a scrolled story where the browser
   can. */

@media (max-width: 560px) {
  .pill-link[href="#agents"] {
    display: none;
  }
}

@media (max-width: 380px) {
  .pill-link[href="#how"] {
    display: none;
  }
}

.hero {
  position: relative;
  isolation: isolate;
  overflow: clip;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  align-content: end;
  gap: 32px;
  padding: 120px var(--gutter) clamp(96px, 12vh, 128px);
  background: var(--field);
  color: var(--on-field);
}

.hero h1 {
  max-width: 11.5ch;
  font-size: var(--title-xl);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.hero-side {
  display: grid;
  justify-items: start;
  gap: 20px;
  max-width: 30rem;
  font-size: var(--lead);
  line-height: 1.42;
}

.hero-meta {
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Keeps the shapes of the motif out from under the small text. */
.hero-side {
  position: relative;
}

.hero-side::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -64px -80px;
  background: radial-gradient(closest-side, var(--field) 68%, rgba(19, 128, 107, 0));
}

@media (min-width: 960px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 25rem);
    align-items: end;
    column-gap: 6vw;
  }
}

.stage {
  background: var(--field);
  color: var(--on-field);
  padding: clamp(56px, 10vh, 120px) var(--gutter) clamp(96px, 16vh, 180px);
}

.stage-pin {
  display: grid;
  justify-items: center;
  gap: clamp(32px, 6vh, 64px);
}

.stage-title {
  max-width: 16ch;
  font-size: var(--title-l);
  line-height: 1.02;
  letter-spacing: -0.04em;
  text-align: center;
}

/* The window of the app, rebuilt in app.css. It is the container its
   pixels are zoomed to. */
.frame {
  position: relative;
  overflow: hidden;
  width: min(1180px, 100%);
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-window);
  container: frame / inline-size;
}

@media (max-width: 640px) {
  .frame {
    aspect-ratio: 2 / 3;
  }
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 24px 40px;
  width: min(1180px, 100%);
  margin: 0;
  padding: 0;
  list-style: none;
}

.step {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  align-content: start;
  column-gap: 14px;
  row-gap: 4px;
}

.step-n {
  grid-row: span 2;
  align-self: start;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.875rem;
  font-weight: 700;
}

.step h3 {
  font-size: clamp(1.25rem, 2vw, 1.625rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.step p {
  line-height: 1.5;
}

.stage-progress {
  display: none;
}

.agents {
  position: relative;
  z-index: 1;
  margin-top: -28px;
  padding: clamp(80px, 14vh, 160px) var(--gutter);
  border-radius: 28px 28px 0 0;
  background: var(--bg);
}

.agents-head {
  display: grid;
  justify-items: center;
  gap: 18px;
  max-width: 46rem;
  margin: 0 auto clamp(48px, 8vh, 96px);
  text-align: center;
}

.kicker {
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.agents h2,
.bundle h2 {
  color: var(--accent);
  font-size: var(--title-l);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.lead,
.bundle-head p {
  max-width: 36rem;
  color: var(--muted);
  font-size: var(--lead);
  line-height: 1.45;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  align-items: start;
  gap: 20px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.card {
  padding: 10px 10px 20px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), 0 24px 48px -28px rgba(16, 24, 40, 0.35);
}

/* A part of dokay, rebuilt in app.css and zoomed to the card's width. */
.card .shot {
  position: relative;
  overflow: hidden;
  max-height: min(52vh, 34rem);
  border-radius: 12px;
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--line);
  container-type: inline-size;
}

.card h3 {
  margin: 16px 8px 6px;
  color: var(--strong);
  font-size: 1.125rem;
  letter-spacing: -0.01em;
}

.card p {
  margin: 0 8px;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.bundle {
  padding: clamp(64px, 10vh, 120px) var(--gutter);
  background: var(--bg);
}

.bundle-head {
  display: grid;
  justify-items: center;
  gap: 16px;
  max-width: 44rem;
  margin: 0 auto clamp(40px, 7vh, 72px);
  text-align: center;
}

.tiles {
  display: grid;
  grid-template-areas: "seq" "class" "plan" "gloss" "pages";
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.tile-seq {
  grid-area: seq;
}

.tile-pages {
  grid-area: pages;
}

.tile-class {
  grid-area: class;
}

.tile-plan {
  grid-area: plan;
}

.tile-gloss {
  grid-area: gloss;
}

.tile .shot {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: var(--bg);
  box-shadow: var(--shadow-shot);
  container-type: inline-size;
}

@media (min-width: 600px) {
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "seq seq"
      "class pages"
      "plan pages"
      "gloss gloss";
  }

  .tile-pages {
    display: grid;
  }

  .tile-pages .shot {
    height: 100%;
  }
}

@media (min-width: 900px) {
  .tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "seq seq pages"
      "class plan pages"
      "gloss gloss gloss";
  }
}

.download {
  display: grid;
  justify-items: center;
  gap: 22px;
  padding: clamp(80px, 14vh, 160px) var(--gutter) clamp(64px, 10vh, 120px);
  background: var(--bg);
  text-align: center;
}

.download-icon {
  width: clamp(96px, 12vw, 148px);
  filter: drop-shadow(0 18px 30px rgba(19, 128, 107, 0.35));
}

.download h2 {
  color: var(--strong);
  font-size: var(--title-l);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.download-note {
  max-width: 34rem;
  color: var(--muted);
}

.download-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 24px;
}

.download-links a {
  color: var(--accent);
  font-weight: 650;
  text-underline-offset: 3px;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  .hero h1 {
    animation: intro-rise 0.9s var(--ease) 0.1s both;
  }

  .hero-side {
    animation: intro-rise 0.9s var(--ease) 0.25s both;
  }

  .motif i {
    animation: intro-grow 1.1s var(--ease) both;
  }

  .motif-line-2 {
    animation-delay: 0.08s;
  }

  .motif-box-a,
  .motif-link-1 {
    animation-delay: 0.16s;
  }

  .motif-link-2,
  .motif-link-3,
  .motif-box-b {
    animation-delay: 0.24s;
  }
}

@keyframes intro-rise {
  from {
    opacity: 0;
    translate: 0 32px;
  }
}

@keyframes intro-grow {
  from {
    opacity: 0;
    scale: 0.6;
  }
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .hero {
      view-timeline: --hero block;
    }

    .hero h1,
    .hero-side {
      animation: intro-rise 0.9s var(--ease) 0.1s both, hero-out linear both;
      animation-timeline: auto, --hero;
      animation-range: normal, exit 15% exit 95%;
    }

    .motif i {
      animation: intro-grow 1.1s var(--ease) both, drift-apart linear both;
      animation-timeline: auto, --hero;
      animation-range: normal, exit 0% exit 100%;
    }

    .motif-line-1 {
      --to: -18% 0;
    }

    .motif-line-2 {
      --to: 26% 0;
    }

    .motif-box-a {
      --to: -12% 70%;
    }

    .motif-box-b {
      --to: 18% -60%;
    }

    .motif-link-1,
    .motif-link-2,
    .motif-link-3 {
      --to: 0 40%;
    }

    .stage {
      height: 520vh;
      padding: 0;
      view-timeline: --stage block;
    }

    .stage-pin {
      position: sticky;
      top: 0;
      height: 100vh;
      height: 100svh;
      grid-template-rows: auto minmax(0, 1fr) auto auto;
      align-content: center;
      gap: clamp(14px, 2.6vh, 28px);
      padding: clamp(24px, 4.5vh, 48px) var(--gutter) clamp(76px, 9vh, 92px);
      overflow: clip;
    }

    .stage-title {
      max-width: none;
      margin-bottom: 8px;
      font-size: clamp(1.75rem, 3.6vw, 3.25rem);
    }

    .frame {
      align-self: center;
      width: min(1180px, 100%, calc((100svh - 360px) * 1.6));
      animation: window-in linear both;
      animation-timeline: --stage;
      animation-range: entry 10% entry 100%;
    }

    /* One step at a time, in the same place under the window. */
    .steps {
      grid-template-columns: none;
      justify-self: center;
      width: min(40rem, 100%);
      min-height: 5.5rem;
    }

    .step {
      grid-area: 1 / 1;
      animation-duration: auto;
      animation-timing-function: linear;
      animation-fill-mode: both;
      animation-timeline: --stage;
      animation-range: contain 0% contain 100%;
    }

    .step-book {
      animation-name: step-book;
    }

    .step-point {
      animation-name: step-point;
    }

    .step-answer {
      animation-name: step-answer;
    }

    .stage-progress {
      display: block;
      width: min(240px, 50vw);
      height: 3px;
      overflow: hidden;
      border-radius: 3px;
      background: rgba(255, 255, 255, 0.22);
    }

    .stage-progress i {
      display: block;
      height: 100%;
      background: #ffffff;
      transform-origin: left;
      animation: progress linear both;
      animation-timeline: --stage;
      animation-range: contain 0% contain 100%;
    }

    /* Wide screens: the steps beside the window, which takes the height. */
    @media (min-width: 1000px) and (min-aspect-ratio: 5 / 4) {
      .stage-pin {
        grid-template-columns: minmax(0, 1fr) minmax(240px, 300px);
        grid-template-rows: auto 1fr auto auto 1fr;
        grid-template-areas:
          "title title"
          "frame ."
          "frame steps"
          "frame progress"
          "frame .";
        column-gap: clamp(28px, 3vw, 56px);
        row-gap: 20px;
        max-width: 1640px;
        margin: 0 auto;
      }

      .stage-title {
        grid-area: title;
      }

      .frame {
        grid-area: frame;
        justify-self: end;
        width: min(100%, calc((100svh - 240px) * 1.6));
      }

      .steps {
        grid-area: steps;
        justify-self: start;
        width: 100%;
        min-height: 0;
      }

      .stage-progress {
        grid-area: progress;
      }
    }

    .agents {
      padding-top: 0;
      padding-bottom: 14vh;
    }

    .agents-head {
      position: sticky;
      top: 0;
      height: 100vh;
      height: 100svh;
      align-content: center;
      margin: 0 auto;
    }

    /* The list lies over the standing title; only its cards take clicks, so the
       title and its text stay reachable between them. */
    .cards {
      position: relative;
      z-index: 1;
      display: block;
      max-width: 1240px;
      margin-top: -50vh;
      pointer-events: none;
    }

    .card {
      pointer-events: auto;
    }

    .card {
      width: min(21rem, 74vw);
      margin-bottom: 6vh;
      animation: card-drift linear both;
      animation-timeline: view();
      animation-range: cover 0% cover 100%;
    }

    .card:nth-child(even) {
      margin-top: -34vh;
      margin-left: auto;
    }

    .card:nth-child(1) {
      --drift: 14vh;
    }

    .card:nth-child(2) {
      --drift: -6vh;
    }

    .card:nth-child(3) {
      --drift: 22vh;
    }

    .card:nth-child(4) {
      --drift: 4vh;
    }

    .download-icon {
      animation: icon-pop linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 40%;
    }

    .wordmark {
      animation: wordmark-rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 100%;
    }
  }

  /* Phones: a taller window, see app.css, as high as the screen allows. */
  @media (prefers-reduced-motion: no-preference) and (max-width: 640px) {
    .frame {
      width: min(100%, calc((100svh - 330px) * 2 / 3));
    }

    .card:nth-child(n) {
      --drift: 6vh;
    }

    .card:nth-child(even) {
      margin-top: 0;
    }
  }
}

@keyframes hero-out {
  to {
    transform: translateY(-14vh);
  }
}

@keyframes drift-apart {
  to {
    translate: var(--to);
  }
}

@keyframes window-in {
  from {
    transform: translateY(16%) scale(0.84) rotate(-3deg);
  }
}

/* A step that is not to be seen is hidden too, so it takes no clicks from the
   one shown in the same place. */
@keyframes step-book {
  0%,
  13% {
    opacity: 1;
    transform: none;
    visibility: visible;
  }

  17%,
  100% {
    opacity: 0;
    transform: translateY(-10px);
    visibility: hidden;
  }
}

@keyframes step-point {
  0%,
  18% {
    opacity: 0;
    transform: translateY(10px);
    visibility: hidden;
  }

  22%,
  52% {
    opacity: 1;
    transform: none;
    visibility: visible;
  }

  56%,
  100% {
    opacity: 0;
    transform: translateY(-10px);
    visibility: hidden;
  }
}

@keyframes step-answer {
  0%,
  57% {
    opacity: 0;
    transform: translateY(10px);
    visibility: hidden;
  }

  61%,
  100% {
    opacity: 1;
    transform: none;
    visibility: visible;
  }
}

@keyframes progress {
  from {
    transform: scaleX(0);
  }
}

@keyframes card-drift {
  from {
    transform: translateY(var(--drift));
  }

  to {
    transform: translateY(calc(var(--drift) * -1));
  }
}

@keyframes icon-pop {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.7) rotate(-12deg);
  }
}

@keyframes wordmark-rise {
  from {
    transform: translateY(45%);
  }
}
