/* Landing page: hero, the reader + phone demo, and the sections below it. */

.hero {
  display: grid;
  gap: 2.5rem 3rem;
  align-items: center;
  padding-block: clamp(1.5rem, 5vw, 3.5rem) 1rem;
}
.hero h1 {
  margin: 0 0 1.4rem;
  font-size: clamp(2.5rem, 6.4vw, 4.4rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
}
.hero .lede {
  max-width: 34rem;
  margin: 0 0 1.8rem;
  font-size: 1.2rem;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
@media (min-width: 72rem) {
  .hero {
    grid-template-columns: minmax(19rem, 1fr) minmax(0, 43.5rem);
  }
  .hero h1 {
    font-size: clamp(2.5rem, 4.1vw, 3.5rem);
  }
}

/* Demo: an e-reader and a phone. assets/demo.js moves data-focus between them. */

.demo {
  --reader-w: 24rem;
  --phone-w: 17.5rem;
  width: min(100%, calc(var(--reader-w) + var(--phone-w) + 2rem));
  margin-inline: auto;
}
/* The player: a pause button, and one bar per chapter that fills while it plays. */
.demo-player {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.demo-toggle {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.demo-toggle[hidden] {
  display: none;
}
.demo-toggle:hover {
  background: var(--panel);
}
/* The icon is drawn from the state: two bars to pause, a triangle to play, an arrow to replay. */
.demo-toggle::before {
  content: "";
  width: 0.6rem;
  height: 0.7rem;
  border-inline: 0.2rem solid currentColor;
}
.demo[data-state="paused"] .demo-toggle::before {
  width: 0;
  height: 0;
  margin-left: 0.15rem;
  border-block: 0.4rem solid transparent;
  border-inline: 0.65rem solid currentColor;
  border-inline-end-width: 0;
}
.demo[data-state="ended"] .demo-toggle::before {
  content: "↻";
  width: auto;
  height: auto;
  border: 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}
.demo-beats {
  flex: 1;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.demo-beats button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}
.demo-beats button:hover,
.demo-beats button[aria-current="true"] {
  color: var(--ink);
}
.demo-beats button[aria-current="true"] {
  font-weight: 600;
}
.demo-beats i {
  display: block;
  height: 0.3rem;
  margin-top: 0.4rem;
  border-radius: 0.15rem;
  background: linear-gradient(var(--ink), var(--ink)) no-repeat 0 0 / calc(var(--played, 0) * 100%) 100%, var(--rule);
}
.demo-caption {
  /* Two lines are reserved so the devices don't jump when the narration changes. */
  min-height: 3.1em;
  margin: 0 0 0.9rem;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-style: italic;
  line-height: 1.35;
}
/* The chapter name, shown here only where the bars are too narrow to carry labels. */
.demo-caption b {
  display: none;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-style: normal;
}
.demo-caption button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-family: var(--sans);
  font-size: 0.9em;
  font-style: normal;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
}
.demo-stage {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 2rem;
}

/* The play button in the middle of the stage while the story is paused. Tapping a device
   pauses; this (or the device in front) carries on. It fades back so it hides less. */
.demo-resume {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  opacity: 0.6;
  cursor: pointer;
  animation: resume-in 1.8s ease backwards;
}
.demo-resume[hidden] {
  display: none;
}
.demo-resume::before {
  content: "";
  margin-left: 0.3rem;
  border-block: 0.75rem solid transparent;
  border-inline-start: 1.2rem solid currentColor;
}
@keyframes resume-in {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  12%,
  60% {
    opacity: 0.92;
    transform: none;
  }
}

/* The device the story is about steps forward; the other one steps back. */
.demo [data-device] {
  cursor: pointer;
  transition: transform 0.5s cubic-bezier(0.3, 0.7, 0.2, 1), opacity 0.5s ease;
}
.demo[data-focus="reader"] .phone,
.demo[data-focus="phone"] .reader {
  opacity: 0.55;
  transform: scale(0.95);
}

/* The devices themselves are drawn in devices.css, which the setup guide shares.
   Here: how they sit on the stage, and everything that moves. */

.reader {
  flex: 0 1 var(--reader-w);
}
.phone {
  flex: 0 0 var(--phone-w);
  height: 34rem;
  margin-top: 2.5rem;
}
/* The MCP mark flashes while the assistant is reaching the reader (demo.js sets is-calling). */
.demo.is-calling .reader-mcp {
  animation: mcp-call 0.7s step-end infinite;
}
@keyframes mcp-call {
  0% {
    background: var(--eink-ink);
    color: var(--eink);
  }
  50% {
    background: none;
    color: inherit;
  }
}
/* The note opens a moment after the tap. */
.reader[data-mark="note"] .reader-note {
  transition: visibility 0s 0.9s;
}
/* A selection sweeps across the passage. */
.reader[data-mark="select"] .passage {
  transition: background-size 1.2s 0.5s linear;
}
/* The finger that makes the selection. demo.js puts it at the start of the passage. */
.reader-touch {
  position: absolute;
  width: 9cqw;
  height: 9cqw;
  margin: -4.5cqw 0 0 -4.5cqw;
  border-radius: 50%;
  background: rgb(28 28 28 / 0.35);
  opacity: 0;
  pointer-events: none;
}
.reader-touch.is-pressing {
  animation: press 2.1s ease-out;
  translate: var(--drag-x, 0) var(--drag-y, 0);
  transition: translate 1.2s 0.5s linear;
}
@keyframes press {
  0% {
    opacity: 0;
    transform: scale(1.8);
  }
  15%,
  85% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
  }
}

/* One full e-ink refresh when the page changes. */
.reader.is-refreshing .reader-screen {
  animation: eink-refresh 0.5s steps(1, end);
}
@keyframes eink-refresh {
  0% {
    filter: invert(1);
  }
  45% {
    filter: invert(0) contrast(0.6);
  }
  70% {
    filter: none;
  }
}

/* demo.js sets data-mood on .demo for the face in the header. */
.demo[data-mood="look"] .buddy {
  --face: var(--face-look);
}
.demo[data-mood="think"] .buddy,
.chat .ai.is-typing {
  --face: var(--face-think);
}
.demo[data-mood="joke"] .buddy {
  --face: var(--face-joke);
}
.demo[data-mood="wink"] .buddy {
  --face: var(--face-wink);
}
/* When nothing else is going on, it blinks now and then. */
.demo[data-mood="idle"] .buddy {
  animation: blink 4.5s step-end infinite;
}
@keyframes blink {
  96% {
    --face: var(--face-blink);
  }
}
/* Before it answers, the assistant is "typing": the text is held back and three dots pulse. */
.chat .ai.is-typing {
  font-size: 0;
}
.chat .ai.is-typing::after {
  content: "● ● ●";
  color: var(--chat-soft);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  animation: typing 0.9s ease-in-out infinite;
}
@keyframes typing {
  50% {
    opacity: 0.3;
  }
}
.chat .tool.is-working::before {
  box-sizing: border-box;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  background: none;
  -webkit-mask: none;
  mask: none;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}
.chat li.is-in {
  animation: msg-in 0.25s ease-out;
}
@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(0.4rem);
  }
}
.phone-input span:not(:empty)::after {
  content: "";
  display: inline-block;
  width: 1.5px;
  height: 1.1em;
  margin-left: 1px;
  background: var(--chat-accent);
  vertical-align: text-bottom;
}

/* On a phone the two devices overlap, and the one in focus comes to the front,
   so the whole exchange fits on one screen. */
@media (max-width: 46rem) {
  .demo-player {
    gap: 0.6rem;
  }
  /* Five labels don't fit above five short bars, so the caption names the chapter instead. */
  .demo-beats span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .demo-beats button {
    padding-block: 0.75rem;
  }
  .demo-beats i {
    margin-top: 0;
  }
  .demo-player {
    align-items: center;
    margin-bottom: 0.4rem;
  }
  .demo-caption {
    min-height: 4.6em;
  }
  .demo-caption b {
    display: block;
  }
  .phone-bar small span {
    display: none;
  }
  .demo-caption {
    font-size: 1.05rem;
  }
  .demo-stage {
    display: block;
  }
  .reader {
    position: relative;
    width: 80%;
    transform-origin: left center;
  }
  .phone {
    position: absolute;
    inset: 0 0 0 auto;
    width: 66%;
    height: auto;
    margin-top: 0;
    border-width: 0.4rem;
    border-radius: 1.8rem;
    font-size: 0.8rem;
    transform-origin: right center;
  }
  /* Here one device is always in front. When the story shows both, it is the reader. */
  .demo:not([data-focus="phone"]) .reader,
  .demo[data-focus="phone"] .phone {
    z-index: 1;
  }
  .demo:not([data-focus="phone"]) .phone,
  .demo[data-focus="phone"] .reader {
    opacity: 0.5;
    transform: scale(0.86);
  }
}

@media (prefers-reduced-motion: reduce) {
  .demo [data-device],
  .reader[data-mark="select"] .passage {
    transition: none;
  }
  .reader.is-refreshing .reader-screen,
  .reader-touch.is-pressing,
  .chat li.is-in,
  .chat .ai.is-typing::after,
  .chat .tool.is-working::before,
  .demo[data-mood="idle"] .buddy,
  .demo.is-calling .reader-mcp {
    animation: none;
  }
}

/* Sections below the demo */

.dither-rule {
  height: 0.75rem;
  margin-block: clamp(3rem, 8vw, 5rem) 0;
  border: 0;
  background: conic-gradient(var(--ink) 25%, transparent 0) 0 0 / 4px 4px;
  opacity: 0.55;
  -webkit-mask-image: linear-gradient(to right, #000, transparent 85%);
  mask-image: linear-gradient(to right, #000, transparent 85%);
}

.section {
  padding-top: clamp(3rem, 8vw, 5rem);
}
.section > h2 {
  margin: 0 0 1.5rem;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
}
.section > p {
  max-width: 40rem;
}

.asks {
  columns: 2 22rem;
  column-gap: 3rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--serif);
  font-size: 1.3rem;
  font-style: italic;
  line-height: 1.35;
}
.asks li {
  break-inside: avoid;
  padding-block: 0.7rem;
  border-top: 1px solid var(--rule);
}

.reasons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.5rem 3rem;
}
.reasons h3 {
  margin: 0 0 0.4rem;
  font-size: 1.25rem;
  font-weight: 600;
}
.reasons p {
  margin: 0;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.5rem 3rem;
  margin: 0 0 2rem;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.steps li {
  counter-increment: step;
  padding-top: 0.8rem;
  border-top: 2px solid var(--ink);
}
.steps li::before {
  content: counter(step);
  display: block;
  font-family: var(--serif);
  font-size: 2.2rem;
  line-height: 1.1;
}
.steps h3 {
  margin: 0.3rem 0 0.4rem;
  font-size: 1.25rem;
  font-weight: 600;
}
.steps p {
  margin: 0;
}

.notes {
  max-width: 44rem;
  margin: 0;
  padding-left: 1.2rem;
}
.notes li {
  margin-bottom: 0.7rem;
}
