/* The front page: the board with the interrogation, then the journal with the application. */

.home {
  position: relative;
}

/* One sheet of string over the whole page, behind the paper. */
.threads {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 1;
}

/* ---- The hero. */

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-6);
  max-width: var(--content);
  margin: 0 auto;
  padding: var(--s-5) var(--gutter) var(--s-7);
  overflow-x: clip;
}

.pitch {
  position: relative;
  z-index: 2;
  display: grid;
  align-content: center;
  gap: var(--s-4);
}

.pitch h1 {
  font-size: var(--step-display);
}

.pitch h1 span {
  display: block;
}

.lede {
  max-width: 36ch;
  font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem);
}

.pitch__actions {
  display: grid;
  gap: var(--s-3);
  justify-items: start;
  margin-top: var(--s-1);
}

@media (max-width: 599px) {
  .store {
    min-height: 48px;
    padding: var(--s-1) var(--s-3) var(--s-1) var(--s-2);
  }

  .store .icon {
    width: 22px;
    height: 22px;
  }

  .store__name {
    font-size: 1rem;
  }
}

@media (min-width: 960px) {
  .hero {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: var(--s-7);
    align-items: center;
    min-height: min(calc(100svh - 84px), 880px);
    padding-top: var(--s-6);
  }

  .pitch {
    gap: var(--s-5);
  }

  .pitch h1 {
    max-width: 9.5ch;
  }

  .pitch__actions {
    gap: var(--s-4);
  }
}

/* ---- The board: pinned pieces when it is wide enough, a column on a phone. */

.board-wrap {
  position: relative;
  z-index: 2;
  container-type: inline-size;
  display: grid;
}

.board {
  position: relative;
  display: grid;
  gap: var(--s-5);
  padding-top: var(--s-4);
}

.piece {
  position: relative;
  z-index: 2;
}

/* On a phone Elena's photograph is pinned over the corner of her chat. */
.p-elena {
  position: absolute;
  left: -6px;
  top: 0;
  width: 86px;
  padding: 5px 5px 0;
  rotate: -6deg;
  z-index: 4;
}

.p-elena figcaption {
  display: none;
}

.p-elena img {
  margin-bottom: 5px;
}

.chat-card {
  background: var(--paper);
  border: var(--border) solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: var(--lift-shadow);
  rotate: 0.8deg;
}

.chat-card__head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 64px;
  padding: var(--s-3) var(--s-4) var(--s-3) 96px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-phone);
}

.chat-card__back,
.chat-card__avatar {
  display: none;
}

.chat-card__back {
  width: 20px;
  height: 20px;
  color: var(--muted);
}

.chat-card__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--hl-pink);
  outline: 1px solid var(--ink);
  object-fit: cover;
}

.chat-card__who {
  display: grid;
  line-height: 1.2;
}

.chat-card__who strong {
  font-size: 1rem;
}

.chat-card__who span {
  color: var(--muted);
  font-size: 0.8125rem;
}

.chat-card__body {
  --bubble-them: var(--tint-pink);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 236px;
  padding: var(--s-3) var(--s-4);
  overflow: hidden;
  background: #ffe9d1;
}

.chat-card__field {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3);
  border-top: 1px solid var(--line);
}

.field {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper-white);
  font-family: var(--font-phone);
  font-size: 0.9375rem;
  line-height: 1.35;
}

.field:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.field:not(:empty)::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1.1em;
  margin-left: 1px;
  vertical-align: -0.2em;
  background: var(--stamp);
  animation: caret 1s steps(1) infinite;
}

@keyframes caret {
  50% {
    opacity: 0;
  }
}

.send {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
}

.send .icon {
  width: 20px;
  height: 20px;
}

.lower {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: var(--s-4);
  align-items: start;
}

.p-key {
  width: 104px;
  padding: 5px 5px 0;
  rotate: 4deg;
}

.p-key figcaption {
  font-size: 0.75rem;
}

/* Elena's secrets: six marks, and the note of the one found. */
.slip {
  margin-top: var(--s-3);
  padding: var(--s-4);
  background: var(--paper-white);
  box-shadow: var(--paper-shadow);
  rotate: -1.5deg;
}

.slip__label {
  color: var(--muted);
}

.track {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--s-2);
}

.track .secret-mark {
  width: 28px;
  height: 28px;
}

.track .secret-mark .icon {
  width: 16px;
  height: 16px;
}

.secret-note {
  display: flex;
  gap: var(--s-3);
  align-items: start;
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 2px solid var(--ink);
}

.secret-note strong {
  display: block;
  font-size: 1.0625rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.secret-note__label {
  color: var(--stamp);
}

.replay {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  justify-self: end;
  min-height: 44px;
  margin-top: var(--s-2);
  padding: 0 var(--s-2);
  border: 0;
  background: none;
  color: var(--ink);
  font: 600 0.875rem var(--font-brand);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.replay .icon {
  width: 16px;
  height: 16px;
}

/* The script replays the conversation: until it takes the board, the printed ending stays out of sight. */
@media (scripting: enabled) and (prefers-reduced-motion: no-preference) {
  .board:not(.is-live) .chat__log,
  .board:not(.is-live) .track,
  .board:not(.is-live) .secret-note {
    visibility: hidden;
  }

  .board.is-live:not(.is-solved) .secret-note {
    display: none;
  }

  .board.is-solved .secret-note,
  .track .secret-mark.is-found {
    animation: stamp 520ms var(--ease-land) both;
  }
}

@keyframes stamp {
  from {
    opacity: 0;
    transform: scale(1.6) rotate(-8deg);
  }
  60% {
    opacity: 1;
  }
}

@container (min-width: 600px) {
  .board {
    display: block;
    min-height: 660px;
    padding: 0;
  }

  .piece {
    position: absolute;
  }

  .lower {
    display: contents;
  }

  .p-elena {
    left: 0;
    top: 48px;
    width: 168px;
    padding: 8px 8px 0;
    rotate: -5deg;
  }

  .p-elena figcaption {
    display: block;
  }

  .p-elena img {
    margin: 0;
  }

  .chat-card {
    left: 188px;
    top: 0;
    width: min(380px, calc(100% - 196px));
    rotate: 1.2deg;
  }

  .chat-card__head {
    padding-left: var(--s-4);
  }

  .chat-card__back,
  .chat-card__avatar {
    display: block;
  }

  .chat-card__body {
    height: 312px;
  }

  .p-key {
    left: 12px;
    top: 340px;
    width: 156px;
    padding: 8px 8px 0;
  }

  .p-key figcaption {
    font-size: 0.875rem;
  }

  .slip {
    left: 216px;
    top: 486px;
    width: 330px;
    margin: 0;
  }

  .replay {
    position: absolute;
    right: 0;
    top: 452px;
    margin: 0;
    z-index: 3;
  }
}

/* ---- The journal: a front page pinned under the board. A headline, three pictures, the coupon. */

.journal-wrap {
  position: relative;
  z-index: 2;
  padding: var(--s-7) var(--gutter) var(--s-8);
  scroll-margin-top: var(--s-4);
  overflow-x: clip;
}

.journal {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(18px, 4vw, 40px);
  background: var(--paper-white);
  box-shadow: var(--lift-shadow);
  rotate: -0.6deg;
}

.journal__nameplate {
  display: grid;
  justify-items: center;
  padding-bottom: var(--s-3);
  border-bottom: 4px solid var(--ink);
}

.journal__nameplate img {
  width: min(300px, 72%);
  height: auto;
}

.journal__dateline {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s-1) var(--s-4);
  padding: var(--s-2) 0;
  border-bottom: 1px solid var(--ink);
  color: var(--muted);
}

.journal__headline {
  padding: var(--s-5) 0 var(--s-2);
  font-size: clamp(2.5rem, 1.5rem + 4.4vw, 4.75rem);
  line-height: 0.95;
  text-align: center;
}

/* The three steps: a chat, the keys, the stamp, on a dashed trail. */
.steps {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-2);
  margin: var(--s-4) 0 var(--s-6);
  padding: 0;
  list-style: none;
}

.steps::before {
  content: '';
  position: absolute;
  top: 44px;
  left: 16.6%;
  right: 16.6%;
  border-top: 2px dashed var(--ink);
}

.step {
  position: relative;
  display: grid;
  justify-items: center;
  gap: var(--s-2);
  text-align: center;
}

.step__picture {
  position: relative;
  display: block;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--paper-white);
}

.step__word {
  font-size: clamp(1.125rem, 1rem + 0.6vw, 1.5rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

/* Ask: the player's message in ink, the answer on its way. */
.mini-bubble {
  position: absolute;
}

.mini-bubble--me {
  top: 16px;
  right: 6px;
  width: 50px;
  height: 26px;
  border-radius: 13px 13px 4px 13px;
  background: var(--bubble-out);
}

.mini-bubble--me::before,
.mini-bubble--me::after {
  content: '';
  position: absolute;
  left: 10px;
  height: 3px;
  border-radius: 2px;
  background: var(--on-bubble-out);
}

.mini-bubble--me::before {
  top: 8px;
  right: 10px;
}

.mini-bubble--me::after {
  top: 15px;
  right: 22px;
}

.mini-bubble--them {
  bottom: 14px;
  left: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 52px;
  height: 28px;
  border: 1.5px solid var(--ink);
  border-radius: 14px 14px 14px 4px;
  background: var(--tint-pink);
}

.mini-bubble--them span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink);
  animation: typing 1.2s infinite ease-in-out;
}

.mini-bubble--them span:nth-child(2) {
  animation-delay: 160ms;
}

.mini-bubble--them span:nth-child(3) {
  animation-delay: 320ms;
}

/* Uncover: two secrets still hidden, one found. */
.step__picture--uncover .secret-mark {
  position: absolute;
  width: 32px;
  height: 32px;
}

.step__picture--uncover .secret-mark:nth-child(1) {
  left: 4px;
  top: 12px;
  rotate: -10deg;
}

.step__picture--uncover .secret-mark:nth-child(2) {
  right: 4px;
  top: 12px;
  rotate: 10deg;
}

.step__picture--uncover .secret-mark:nth-child(3) {
  left: 50%;
  bottom: 6px;
  width: 52px;
  height: 52px;
  translate: -50% 0;
  box-shadow: 0 0 0 4px var(--paper-white);
}

.step__picture--uncover .secret-mark:nth-child(3) .icon {
  width: 28px;
  height: 28px;
}

/* Close it: the Yard's stamp. */
.step__picture--close img {
  position: absolute;
  left: 50%;
  top: 50%;
  width: auto;
  height: 82px;
  translate: -50% -50%;
  rotate: -8deg;
}

/* The application: a coupon to cut out, dashed all round. */
.application {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  padding: clamp(14px, 3vw, 22px);
  border: 2px dashed var(--ink);
  background: var(--paper);
}

.application__form {
  display: grid;
  gap: var(--s-3);
}

.application__row {
  display: grid;
  gap: var(--s-3);
}

.application__field {
  position: relative;
  display: block;
}

.application__mail {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 20px;
  height: 20px;
  translate: 0 -50%;
  color: var(--muted);
  pointer-events: none;
}

.application__input {
  width: 100%;
  min-height: 52px;
  padding: 0 var(--s-4) 0 44px;
  border: var(--border) solid var(--ink);
  border-radius: var(--radius-md);
  background: var(--paper-white);
  color: var(--ink);
  font: 400 1.0625rem var(--font-brand);
  caret-color: var(--stamp);
}

.application__input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.application__input:focus-visible {
  outline: 3px solid var(--stamp);
  outline-offset: 2px;
}

.application__input[aria-invalid='true'] {
  border-color: var(--danger);
}

.application__send {
  width: 100%;
}

.application__send .button__face {
  justify-content: center;
}

@media (min-width: 520px) {
  .application__row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .application__send {
    width: auto;
  }

  .application__send .button__face {
    min-width: 8.5rem;
  }
}

.consent {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: var(--s-3);
  align-items: center;
  min-height: 44px;
  font-size: 0.9375rem;
  line-height: 1.4;
  cursor: pointer;
}

.consent__box {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--ink);
  cursor: pointer;
}

.consent a {
  color: var(--stamp);
}

.trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form-error {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  padding: var(--s-2) var(--s-3);
  border: var(--border) solid var(--danger);
  border-radius: var(--radius-md);
  background: var(--paper-white);
  color: var(--danger);
  font-size: 0.9375rem;
  font-weight: 600;
}

.application__fine a {
  color: var(--ink);
}

.application__done {
  display: grid;
  gap: var(--s-3);
  justify-items: center;
  padding: var(--s-2) 0;
  text-align: center;
  font-weight: 600;
  outline: none;
}

.received-stamp {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  border: 3px solid var(--stamp);
  border-radius: var(--radius-sm);
  color: var(--stamp);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  rotate: -5deg;
  animation: stamp 520ms var(--ease-land) both;
}

/* On a wider page the three pictures are the size of a headline. */
@media (min-width: 720px) {
  .step__picture {
    zoom: 1.4;
  }

  .steps::before {
    top: calc(44px * 1.4);
  }
}
