/* The lead package page: the hero timeline, the missed call simulator, and the game.
   Values come from tokens.css; shared parts (page hero, phone, bench, points, steps, FAQ,
   the ask) from styles.css. */

/* ---------- Hero: one lead, drawn as a timeline ---------- */

.flow {
  position: relative;
  display: grid;
  gap: var(--space-3);
  padding-inline-start: var(--space-6);
}

/* The rail the four events hang on. */
.flow::before {
  content: "";
  position: absolute;
  inset-block: var(--space-5);
  inset-inline-start: calc(var(--space-2) + var(--hair));
  inline-size: var(--hair);
  background: var(--rule);
}

.flow li {
  position: relative;
  display: grid;
  gap: var(--hair-strong);
  padding: var(--space-3) var(--space-4);
  border: var(--hair) solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-weight: 500;
  line-height: var(--leading-snug);
}

.flow li::before {
  content: "";
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: calc(var(--space-1) - var(--space-6));
  inline-size: var(--space-3);
  block-size: var(--space-3);
  border-radius: 50%;
  background: var(--aqua);
  box-shadow: 0 0 0 var(--space-1) var(--bg);
  transform: translateY(-50%);
}

.flow span {
  color: var(--fg-soft);
  font-size: var(--text-xs);
  font-weight: 400;
}

.flow .flow-missed {
  border-style: dashed;
  border-color: var(--err);
}

.flow .flow-missed::before {
  background: var(--err);
}

@media (min-width: 900px) {
  .flow {
    gap: var(--space-4);
  }

  .flow li {
    padding: var(--space-4) var(--space-5);
  }
}

/* ---------- The simulator ----------
   The customer's phone on one side, what the owner sees on the other. On a phone the
   name field sits right above the drawn phone, and the owner's log follows it. */

.sim-body {
  display: grid;
  gap: var(--space-5);
  justify-items: center;
  padding: var(--space-5) var(--space-4);
}

.sim-field {
  display: grid;
  gap: var(--space-2);
  inline-size: 100%;
}

.sim-field label {
  color: var(--fg-soft);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-mono);
}

.sim-field input {
  inline-size: 100%;
  min-height: calc(var(--control-h) + var(--space-2));
  padding: var(--space-3) var(--space-4);
  border: var(--hair) solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--navy-950);
  color: var(--white);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--heading-weight);
  letter-spacing: var(--tracking-heading);
  caret-color: var(--brass);
  transition: border-color var(--fast) var(--ease);
}

.sim-field input::placeholder {
  color: var(--on-navy-soft);
  font-weight: 600;
  opacity: 0.75;
}

.sim-field input:hover,
.sim-field input:focus-visible {
  border-color: var(--brass);
}

.sim-stage {
  display: grid;
  justify-items: center;
  inline-size: 100%;
}

.sim-owner {
  display: grid;
  gap: var(--space-3);
  align-content: start;
  inline-size: 100%;
  padding: var(--space-5);
  border: var(--hair) solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.sim-empty {
  color: var(--fg-soft);
  font-size: var(--text-sm);
}

/* On a narrow phone the time sits above its line; from 480px they share a row. */
.sim-log li {
  display: grid;
  gap: var(--hair-strong) var(--space-3);
  align-items: baseline;
  padding-block: var(--space-3);
  border-top: var(--hair) solid var(--rule);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  animation: sim-in var(--medium) var(--ease) both;
}

.sim-time {
  color: var(--live);
  font-size: var(--text-xs);
}

@media (min-width: 480px) {
  .sim-log li {
    grid-template-columns: calc(var(--space-9) + var(--space-2)) minmax(0, 1fr);
  }
}

@keyframes sim-in {
  from {
    opacity: 0;
    transform: translateY(var(--space-2));
  }
}

@media (min-width: 720px) {
  .sim-body {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    gap: var(--space-5) var(--space-7);
    align-items: start;
    justify-items: stretch;
    padding: var(--space-6);
  }

  .sim-stage {
    grid-area: 1 / 1 / -1 / 2;
    inline-size: var(--phone-w);
  }

  .sim-field {
    grid-area: 1 / 2;
  }

  /* The log panel runs to the foot of the phone, so it fills as the demo goes. */
  .sim-owner {
    grid-area: 2 / 2;
    align-self: stretch;
  }

  /* Without the name field (no JavaScript) the log takes the whole column. */
  .sim-body:not(:has(.sim-field:not([hidden]))) .sim-owner {
    grid-area: 1 / 2 / -1 / 3;
  }
}

@media (min-width: 1180px) {
  .sim-body {
    column-gap: var(--space-9);
    padding: var(--space-7) var(--space-8);
  }
}

/* ---------- Inside the simulator's phone ---------- */

.sim-screen {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.sim-avatar,
.sim-logo {
  display: grid;
  flex: none;
  place-items: center;
  background: var(--navy);
  color: var(--white);
  font-family: var(--font-display);
  font-weight: 800;
}

.sim-avatar {
  inline-size: calc(var(--space-8) + var(--space-2));
  block-size: calc(var(--space-8) + var(--space-2));
  border-radius: var(--radius-lg);
  font-size: var(--text-xl);
}

.sim-logo {
  inline-size: calc(var(--space-6) + var(--space-1));
  block-size: calc(var(--space-6) + var(--space-1));
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
}

.sim-callbtn,
.sim-linkcard,
.sim-skip,
.sim-pick,
.sim-slot,
.sim-confirm,
.sim-star {
  font-family: var(--font-body);
  cursor: pointer;
  transition:
    background-color var(--fast) var(--ease),
    border-color var(--fast) var(--ease),
    color var(--fast) var(--ease);
}

/* 1. The contact card */

.sim-card {
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-5);
  text-align: center;
}

.sim-card-name {
  max-inline-size: 100%;
  margin-block-start: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--display-weight);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-heading);
  overflow-wrap: anywhere;
}

.sim-card-sub {
  color: var(--ink-soft);
}

.sim-callbtn {
  inline-size: 100%;
  min-height: var(--control-h-sm);
  margin-block-start: var(--space-5);
  padding: var(--space-2) var(--space-4);
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--call-green);
  color: var(--white);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: var(--leading-snug);
  overflow-wrap: anywhere;
}

.sim-callbtn:hover {
  background: color-mix(in srgb, var(--call-green) 85%, var(--ink));
}

/* 2. The call nobody answers */

.sim-call {
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-block-start: calc((var(--space-7) - var(--space-2)) * -1);
  padding: var(--space-8) var(--space-5) var(--space-5);
  background: var(--navy-950);
  color: var(--white);
  text-align: center;
}

.sim-call .sim-avatar {
  margin-block-end: var(--space-4);
  border-radius: 50%;
  background: var(--navy-700);
}

.sim-call[data-state="ringing"] .sim-avatar {
  animation: sim-ring 1.2s var(--ease-fade) infinite;
}

@keyframes sim-ring {
  0% {
    box-shadow:
      0 0 0 0 color-mix(in srgb, var(--aqua) 55%, transparent),
      0 0 0 0 color-mix(in srgb, var(--aqua) 35%, transparent);
  }

  100% {
    box-shadow:
      0 0 0 var(--space-4) transparent,
      0 0 0 var(--space-6) transparent;
  }
}

.sim-call-status {
  max-inline-size: 100%;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--heading-weight);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-heading);
  overflow-wrap: anywhere;
  outline: 0;
}

.sim-call-sub {
  color: var(--on-navy-soft);
}

.sim-call[data-state="missed"] .sim-call-status {
  color: var(--error-on-navy);
}

/* The time and battery sit on the dark call screen while it is up. */
.phone-screen:has(.sim-call:not([hidden])) .phone-status {
  position: relative;
  z-index: 1;
  color: var(--white);
}

/* 3. The thread */

.sim-head {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1) var(--space-4) var(--space-3);
  border-bottom: var(--hair) solid var(--line);
}

.sim-head > div {
  min-width: 0;
}

.sim-head-name {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--heading-weight);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sim-head-sub {
  color: var(--ink-soft);
  font-size: var(--text-2xs);
}

.sim-thread {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 0;
  padding: var(--space-3);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

/* The ring would be clipped by the screen, so it is drawn inside the thread. */
.sim-thread:focus-visible {
  outline-offset: calc(var(--focus-w) * -1);
}

.sim-chip,
.sim-divider {
  align-self: center;
  color: var(--ink-soft);
  font-size: var(--text-2xs);
}

.sim-chip {
  padding: var(--hair-strong) var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--panel);
  font-family: var(--font-mono);
}

.sim-chip--missed {
  background: color-mix(in srgb, var(--error) 10%, var(--white));
  color: var(--error);
}

.sim-divider {
  margin-block: var(--space-2) var(--space-1);
  font-weight: 600;
}

.sim-bubble {
  display: grid;
  gap: var(--space-2);
  align-self: flex-start;
  max-inline-size: 90%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  border-end-start-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  line-height: 1.4;
  overflow-wrap: anywhere;
  transform-origin: left bottom;
}

/* Only what the script adds arrives with a pop; the finished thread in the HTML sits still. */
.sim-thread > .is-new {
  animation: sim-pop var(--medium) var(--ease-pop) both;
}

@keyframes sim-pop {
  from {
    opacity: 0;
    transform: translateY(var(--space-2)) scale(0.9);
  }
}

/* The link in the text: a small card, the way a phone previews a web page. */
.sim-linkcard {
  display: grid;
  gap: var(--hair);
  padding: var(--space-2) var(--space-3);
  border: var(--hair) solid var(--line);
  border-inline-start: var(--focus-w) solid var(--teal);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--ink);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
  text-align: start;
}

span.sim-linkcard {
  cursor: default;
}

.sim-linkcard strong {
  color: var(--teal);
  font-weight: 600;
}

.sim-linkcard span {
  color: var(--ink-soft);
  font-size: var(--text-2xs);
}

button.sim-linkcard:hover {
  border-color: var(--teal);
  background: var(--teal-tint);
}

.sim-linkcard[disabled] {
  border-inline-start-color: var(--line);
  cursor: default;
}

.sim-linkcard[disabled] strong {
  color: var(--ink-soft);
}

.sim-linkcard[disabled]:hover {
  border-color: var(--line);
  border-inline-start-color: var(--line);
  background: var(--white);
}

/* Five stars, each one a drawn shape. Hovering or tabbing to a star fills it and the ones before it. */
.sim-stars {
  display: flex;
  gap: var(--hair-strong);
}

.sim-star {
  display: grid;
  place-items: center;
  inline-size: var(--space-6);
  block-size: var(--space-6);
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
}

.sim-star::before {
  content: "";
  inline-size: var(--space-5);
  block-size: var(--space-5);
  background: color-mix(in srgb, var(--ink-soft) 70%, var(--panel));
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  transition: background-color var(--fast) var(--ease);
}

.sim-stars:not([data-rated]):hover .sim-star::before,
.sim-stars:not([data-rated]):has(:focus-visible) .sim-star::before,
.sim-star[data-on]::before {
  background: var(--brass-deep);
}

.sim-stars:not([data-rated]) .sim-star:hover ~ .sim-star::before,
.sim-stars:not([data-rated]) .sim-star:focus-visible ~ .sim-star::before {
  background: color-mix(in srgb, var(--ink-soft) 70%, var(--panel));
}

.sim-star[disabled] {
  cursor: default;
}

i.sim-star {
  cursor: default;
}

.sim-foot {
  display: grid;
  flex: none;
  padding: var(--space-2) var(--space-3) var(--space-4);
  border-top: var(--hair) solid var(--line);
}

.sim-compose {
  padding: var(--space-1) var(--space-3);
  border: var(--hair) solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--ink-soft);
  font-size: var(--text-2xs);
}

.sim-skip {
  min-height: calc(var(--space-6) + var(--space-1));
  padding-inline: var(--space-4);
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--navy);
  color: var(--white);
  font-size: var(--text-xs);
  font-weight: 600;
}

.sim-skip:hover {
  background: var(--ink);
}

/* 4. The booking page */

.sim-book-body {
  display: grid;
  flex: 1 1 auto;
  gap: var(--space-2);
  align-content: start;
  padding: var(--space-3) var(--space-4);
}

.sim-book-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--display-weight);
  letter-spacing: var(--tracking-display);
  outline: 0;
}

.sim-label {
  margin-block-start: var(--space-1);
  color: var(--ink-soft);
  font-size: var(--text-2xs);
  font-weight: 600;
}

.sim-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.sim-pick {
  min-height: var(--space-6);
  padding-inline: var(--space-3);
  border: var(--hair) solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--white);
  color: var(--ink);
  font-size: var(--text-2xs);
  font-weight: 500;
}

.sim-pick[aria-pressed="true"] {
  border-color: var(--teal);
  background: var(--teal-tint);
  box-shadow: inset 0 0 0 var(--hair) var(--teal);
}

.sim-slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-1);
}

.sim-slot {
  display: grid;
  padding: var(--space-2) var(--space-1);
  border: var(--hair) solid var(--line);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.sim-slot span {
  color: var(--ink-soft);
  font-size: var(--text-2xs);
  font-weight: 400;
}

.sim-slot[aria-pressed="true"] {
  border-color: var(--teal);
  background: var(--teal);
  color: var(--white);
}

.sim-slot[aria-pressed="true"] span {
  color: var(--white);
}

.sim-confirm {
  min-height: var(--control-h-sm);
  margin-block-start: var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: var(--teal);
  color: var(--white);
  font-size: var(--text-sm);
  font-weight: 600;
}

.sim-confirm:hover {
  background: var(--teal-deep);
}

/* ---------- The game: After hours ---------- */

.play-grid {
  display: grid;
  gap: var(--space-7);
  align-items: center;
}

.play-copy {
  display: grid;
  gap: var(--space-5);
  justify-items: start;
}

.play-copy > p:not(.kicker, .play-hint) {
  max-width: var(--measure);
  color: var(--fg-soft);
  font-size: var(--text-lg);
  line-height: var(--leading-lead);
}

.play-hint {
  color: var(--fg-soft);
  font-size: var(--text-xs);
}

.play-stage {
  inline-size: 100%;
  max-inline-size: calc(var(--space-10) * 3 + var(--space-6));
  justify-self: center;
}

.game {
  position: relative;
  display: grid;
  gap: var(--space-3);
}

/* Focus rests on the game itself while the software plays. It is not a control, so no ring. */
.game:focus-visible {
  outline: 0;
}

.game-hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  font-family: var(--font-mono);
  letter-spacing: var(--tracking-mono);
}

.game-hud p {
  display: grid;
  gap: var(--hair-strong);
  padding: var(--space-2) var(--space-3);
  border: var(--hair) solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--fg-soft);
  font-size: var(--text-xs);
}

.game-hud b {
  color: var(--white);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--heading-weight);
  letter-spacing: var(--tracking-heading);
  line-height: var(--leading-snug);
  font-variant-numeric: tabular-nums;
}

/* The software's turn: the counters go aqua so the two rounds read differently. */
.game[data-mode="auto"] .game-hud p {
  border-color: var(--aqua);
}

.game[data-mode="auto"] .game-hud b {
  color: var(--aqua);
}

.game-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
}

/* One phone line. Its edge is drawn as a background, so a ringing line can run its
   countdown around the edge: --left goes from 1 to 0 and the brass ring drains with it. */
.line {
  --left: 1;
  --edge: var(--rule);

  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-inline-size: 0;
  padding: var(--space-2);
  border: var(--focus-w) solid transparent;
  border-radius: var(--radius-md);
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(var(--edge), var(--edge)) border-box;
  color: var(--fg-soft);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-mono);
  line-height: var(--leading-snug);
  text-align: center;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* During a round a touch that lands on a line answers it, so it must not also start a scroll. */
.game[data-playing] .line {
  touch-action: none;
}

.line-label {
  overflow-wrap: anywhere;
}

/* The number key that answers this line, shown only where there is likely a keyboard. */
.line-key {
  position: absolute;
  inset-block-start: var(--space-1);
  inset-inline-start: var(--space-2);
  display: none;
  color: var(--fg-soft);
  font-size: var(--text-2xs);
}

@media (hover: hover) and (pointer: fine) {
  .line-key {
    display: block;
  }
}

.line[data-state="ring"] {
  background:
    linear-gradient(var(--navy-700), var(--navy-700)) padding-box,
    conic-gradient(var(--brass) calc(var(--left) * 1turn), var(--navy-950) 0) border-box;
  color: var(--white);
  font-weight: 500;
  animation: line-ring 0.9s var(--ease-fade) infinite;
}

/* The last third of a ring goes red. */
.line[data-state="ring"][data-urgent] {
  background:
    linear-gradient(var(--navy-700), var(--navy-700)) padding-box,
    conic-gradient(var(--err) calc(var(--left) * 1turn), var(--navy-950) 0) border-box;
}

.line[data-state="ring"] .line-key {
  color: var(--brass);
}

.line[data-state="answered"],
.line[data-state="sent"] {
  --edge: var(--ok);

  color: var(--ok);
  animation: line-pop var(--medium) var(--ease-pop);
}

.line[data-state="sent"] {
  --edge: var(--aqua);

  color: var(--aqua);
}

.line[data-state="missed"] {
  border: var(--focus-w) dashed var(--err);
  background: var(--surface);
  color: var(--err);
  animation: line-shake var(--slow) var(--ease);
}

@keyframes line-ring {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--brass) 50%, transparent);
  }

  50% {
    box-shadow: 0 0 0 var(--space-2) transparent;
  }
}

@keyframes line-pop {
  from {
    transform: scale(0.92);
  }
}

@keyframes line-shake {
  20% {
    transform: translateX(calc(var(--space-1) * -1));
  }

  40% {
    transform: translateX(var(--space-1));
  }

  60% {
    transform: translateX(calc(var(--hair-strong) * -1));
  }

  80% {
    transform: translateX(var(--hair-strong));
  }
}

/* The still board shown before Play is pressed, and when there is no JavaScript. */
.game-board--still .line {
  cursor: default;
}

.line--still {
  --left: 0.7;
}

.line--late {
  --left: 0.28;
}

/* "Get ready", over the board, before the first call. */
.game-ready {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--navy-950) 70%, transparent);
  color: var(--white);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--display-weight);
  font-stretch: var(--heading-stretch);
  letter-spacing: var(--tracking-display);
  text-align: center;
  pointer-events: none;
}

/* The result, over the whole game. */
.game-result {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  gap: var(--space-3);
  align-content: center;
  justify-items: start;
  padding: var(--space-4);
  border: var(--hair) solid var(--rule);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--navy-950) 95%, transparent);
  overflow-y: auto;
  animation: sim-in var(--medium) var(--ease) both;
}

.game-result h3 {
  font-size: var(--text-xl);
  font-weight: var(--display-weight);
  line-height: 1.1;
  letter-spacing: var(--tracking-display);
}

.game-result p {
  color: var(--fg-soft);
}

.game-result .game-best {
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-mono);
}

.game-result .actions {
  gap: var(--space-2) var(--space-3);
  margin-block-start: var(--space-2);
}

@media (min-width: 640px) {
  .game {
    gap: var(--space-4);
  }

  .game-hud,
  .game-board {
    gap: var(--space-3);
  }

  .game-hud p {
    padding: var(--space-3) var(--space-4);
  }

  .line {
    font-size: var(--text-sm);
  }

  .game-result {
    padding: var(--space-6);
  }
}

@media (min-width: 900px) {
  .play-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--space-5);
  }

  .play-copy {
    grid-column: 1 / span 6;
  }

  .play-stage {
    grid-column: 8 / -1;
    justify-self: end;
  }
}

/* ---------- Then it grows with you ---------- */

.grows {
  margin-block-end: 0;
}
