/* Emoji Tales: a page of the storyteller's notebook. */

:root {
  --paper: #faf5e6;
  --paper-deep: #f1e9d2;
  --ink: #2b2638;
  --ink-soft: #5d586b;
  --coral: #fa735c;
  --coral-deep: #c74e3a;
  --gold: #f8b821;
  --rule: rgba(107, 140, 184, 0.2);
  --who: #f56b54;
  --place: #45b05c;
  --does: #388cf2;
  --feels: #f7b821;
  --thing: #8f63e8;

  --line: 34px; /* the distance between the notebook's rules */
  --book: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --round: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --hand: "Bradley Hand", "Segoe Print", "Marker Felt", cursive;
  --page: 1080px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  /* Faint rules, like the page the game is played on. */
  background-image: linear-gradient(to bottom, transparent calc(var(--line) - 1px), var(--rule) calc(var(--line) - 1px));
  background-size: 100% var(--line);
  font-family: var(--round);
  font-size: 19px;
  line-height: var(--line);
  font-weight: 500;
}

img, video { display: block; max-width: 100%; height: auto; }

a { color: var(--coral-deep); text-underline-offset: 3px; text-decoration-thickness: 2px; }
a:hover { color: var(--ink); }

:focus-visible { outline: 3px solid var(--does); outline-offset: 3px; border-radius: 6px; }

.wrap { max-width: var(--page); margin: 0 auto; padding: 0 24px; }

h1, h2, h3 { font-family: var(--book); font-weight: 900; margin: 0; letter-spacing: -0.01em; }

h2 { font-size: clamp(34px, 5vw, 50px); line-height: calc(var(--line) * 2); }
h3 { font-size: 27px; line-height: var(--line); }

p { margin: 0 0 var(--line); max-width: 34em; }

.lede { font-size: 22px; }

/* ---------- The top of the page ---------- */

.top {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 48px;
  align-items: center;
  padding-top: calc(var(--line) * 2);
  padding-bottom: calc(var(--line) * 2);
}

.masthead {
  font-size: clamp(76px, 13.5vw, 164px);
  line-height: 0.86;
  letter-spacing: -0.03em;
  /* Printed a little off register, in coral, like the game's own name. */
  text-shadow: 0.035em 0.035em 0 var(--coral);
  margin-bottom: 0.12em;
}

.masthead span { display: block; width: max-content; }

.masthead .marked {
  /* A highlighter pulled across the second word. */
  background: linear-gradient(to top, transparent 0.1em, var(--gold) 0.1em, var(--gold) 0.4em, transparent 0.4em);
  padding: 0 0.1em;
  margin-left: -0.1em;
  border-radius: 0.2em;
}

.tagline {
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(26px, 3.4vw, 36px);
  line-height: var(--line);
  color: var(--coral-deep);
  margin: var(--line) 0 calc(var(--line) * 1.5);
}

/* The dice: the most saturated thing on the page. */
.dice { display: flex; gap: 0; margin: 0 0 var(--line) -6px; padding: 0; list-style: none; }

.die {
  --rim: var(--who);
  width: clamp(58px, 15.5vw, 98px);
  aspect-ratio: 1;
  margin-right: -6px;
  border: clamp(3px, 0.8vw, 5px) solid var(--rim);
  border-radius: 23%;
  background: linear-gradient(to bottom, #fff, #ededed);
  box-shadow: 0 clamp(4px, 0.9vw, 6px) 0 #c7c7c7, 0 12px 14px rgba(43, 38, 56, 0.22);
  font-size: clamp(32px, 8.6vw, 56px);
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transform: rotate(var(--tilt, 0deg)) translateY(var(--lift, 0px));
  -webkit-tap-highlight-color: transparent;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

.dice li:nth-child(1) .die { --rim: var(--who); --tilt: -8deg; --lift: 3px; }
.dice li:nth-child(2) .die { --rim: var(--place); --tilt: 5deg; --lift: -5px; }
.dice li:nth-child(3) .die { --rim: var(--does); --tilt: -3deg; --lift: 2px; }
.dice li:nth-child(4) .die { --rim: var(--feels); --tilt: 7deg; --lift: -3px; }
.dice li:nth-child(5) .die { --rim: var(--thing); --tilt: -5deg; --lift: 4px; }

.die.rolling { animation: hop 0.62s cubic-bezier(0.3, 0.7, 0.3, 1); }

@keyframes hop {
  0% { transform: rotate(var(--tilt)) translateY(var(--lift)) rotateY(0); }
  35% { transform: rotate(var(--tilt)) translateY(calc(var(--lift) - 46px)) rotateY(180deg); }
  70% { transform: rotate(var(--tilt)) translateY(calc(var(--lift) + 4px)) rotateY(352deg); }
  100% { transform: rotate(var(--tilt)) translateY(var(--lift)) rotateY(360deg); }
}

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 18px 20px; margin-top: calc(var(--line) * 1.5); }

/* A solid button with a darker lip that presses down, as in the game. */
.chunky {
  font: 700 21px/1 var(--round);
  color: #fff;
  background: var(--coral);
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 16px;
  padding: 18px 26px;
  min-height: 58px;
  box-shadow: 0 4px 0 var(--coral-deep), 0 8px 10px rgba(43, 38, 56, 0.18);
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.08s, box-shadow 0.08s;
}

a.chunky { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
a.chunky:hover { color: #fff; }

.chunky .mark { width: 24px; height: 24px; flex: none; margin-top: -3px; }

/* The App Store button asks to be noticed: a band of light crosses it, and every few
   seconds it fidgets from side to side. */
.chunky.store { position: relative; overflow: hidden; animation: fidget 4.6s ease-in-out 1.2s infinite; }

.chunky.store::after {
  content: "";
  position: absolute;
  top: -60%;
  bottom: -60%;
  left: 0;
  width: 34%;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: translateX(-160%) rotate(18deg);
  animation: shimmer 4.6s ease-in-out infinite;
  pointer-events: none;
}

.chunky.store:hover, .chunky.store:focus-visible { animation-play-state: paused; }

@keyframes shimmer {
  0%, 62% { transform: translateX(-160%) rotate(18deg); }
  90%, 100% { transform: translateX(460%) rotate(18deg); }
}

@keyframes fidget {
  0%, 84%, 100% { transform: translateX(0) rotate(0); }
  87% { transform: translateX(-5px) rotate(-1.2deg); }
  90% { transform: translateX(5px) rotate(1.2deg); }
  93% { transform: translateX(-4px) rotate(-0.8deg); }
  96% { transform: translateX(3px) rotate(0.5deg); }
}

/* The second button on a page is the quiet cream one, as in the game. */
.chunky.quiet { color: var(--ink); background: #fdf6e3; border-color: rgba(43, 38, 56, 0.08); box-shadow: 0 4px 0 #d1c4ad, 0 8px 10px rgba(43, 38, 56, 0.14); }
.chunky.quiet:active { box-shadow: 0 1px 0 #d1c4ad, 0 3px 5px rgba(43, 38, 56, 0.14); }

.chunky:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--coral-deep), 0 3px 5px rgba(43, 38, 56, 0.18); }

.soon { font-weight: 700; color: var(--ink-soft); margin: var(--line) 0 0; }

.film { justify-self: end; width: min(100%, 360px); }

.step video { cursor: pointer; }

.film video, .step video {
  width: 100%;
  border-radius: 28px;
  background: var(--paper-deep);
  box-shadow: 0 0 0 1px rgba(43, 38, 56, 0.1), 0 16px 30px rgba(43, 38, 56, 0.16);
}

/* ---------- Sections ---------- */

section { padding: calc(var(--line) * 2) 0; }

section > .wrap > h2 { margin-bottom: var(--line); }

/* How a story gets told: four beats, in order. */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px; counter-reset: beat; }

.step { counter-increment: beat; }

.step h3 { display: flex; align-items: center; gap: 10px; margin: var(--line) 0 0; }

.step h3::before {
  /* The numbered stone a die sits on in the game. */
  content: counter(beat);
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--coral-deep);
  color: #fff;
  font: 800 17px/30px var(--round);
  text-align: center;
}

.step p { margin: 0; font-size: 17px; line-height: var(--line); }

/* The worlds. */
.worlds { list-style: none; margin: 0 0 var(--line); padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }

.world { position: relative; border-radius: 14px; overflow: hidden; aspect-ratio: 3 / 2; background: var(--paper-deep); }

.world img { width: 100%; height: 100%; object-fit: cover; }

.world span {
  position: absolute;
  left: 12px;
  bottom: 6px;
  font: 900 24px/var(--line) var(--book);
  color: #fff;
  text-shadow: 2px 2px 0 rgba(43, 38, 56, 0.55), 0 2px 12px rgba(43, 38, 56, 0.5);
}

/* A world that comes with Premium says so, in the gold of the game's Premium button. */
.world em {
  position: absolute;
  top: 10px;
  right: 10px;
  font: 700 14px/1 var(--round);
  font-style: normal;
  color: var(--ink);
  background: #ffcc40;
  border-radius: 999px;
  padding: 6px 10px;
  box-shadow: 0 2px 0 #d1941a;
}

/* What is in it: each thing under a picture of it. */
.facts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: calc(var(--line) * 1.5) 32px; }

.facts img, .facts .drawn {
  width: 100%;
  aspect-ratio: 2 / 1;
  object-fit: cover;
  border-radius: 16px;
  box-shadow: 0 0 0 1px rgba(43, 38, 56, 0.1), 0 8px 16px rgba(43, 38, 56, 0.12);
  margin-bottom: calc(var(--line) / 2);
}

.facts h3 { font-size: 24px; }

.facts p { margin: 0; font-size: 17px; }

/* Two pictures that are drawn here, on the game's own paper. */
.drawn { display: grid; place-content: center; background: #fdf6e3; padding: 18px; }

.drawn.stars p { font: 500 22px/1.45 var(--book); color: var(--ink); max-width: 13em; }

.drawn.stars b { color: var(--coral-deep); letter-spacing: 0.04em; }

.drawn.nots { grid-template-columns: repeat(2, auto); gap: 12px 22px; font: 700 15px/1.2 var(--round); color: var(--ink-soft); }

.drawn.nots span { display: flex; align-items: center; gap: 8px; }

.drawn.nots b {
  position: relative;
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-content: center;
  border: 3px solid var(--coral-deep);
  border-radius: 50%;
  font: 22px/1 "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

/* The line through each one. */
.drawn.nots b::after { content: ""; position: absolute; left: -2px; right: -2px; top: 50%; height: 3px; margin-top: -1.5px; background: var(--coral-deep); transform: rotate(-45deg); }

/* Screens. */
.screens { display: flex; gap: 18px; overflow-x: auto; padding: 0 24px var(--line); margin: 0 -24px; scroll-snap-type: x proximity; }

.screens img {
  flex: none;
  height: 480px;
  width: auto;
  border-radius: 26px;
  border: 6px solid var(--ink);
  background: var(--ink);
  scroll-snap-align: center;
}

.screens.wide img { border-radius: 20px; }

footer { padding: calc(var(--line) * 2) 0; font-size: 16px; color: var(--ink-soft); }

footer nav { display: flex; flex-wrap: wrap; gap: 6px 24px; margin-bottom: var(--line); font-weight: 700; font-size: 19px; }

footer p { max-width: 46em; margin-bottom: 0; }

/* ---------- The pages of plain words ---------- */

.words { padding-top: calc(var(--line) * 2); padding-bottom: calc(var(--line) * 2); max-width: 760px; }

.words .back { font-weight: 700; display: inline-block; margin-bottom: var(--line); }

.words h1 { font-size: clamp(40px, 7vw, 62px); line-height: calc(var(--line) * 2); margin-bottom: var(--line); }

.words h2 { font-size: 27px; line-height: var(--line); margin-top: var(--line); }

.words ul { margin: 0 0 var(--line); padding-left: 1.1em; }

/* ---------- Narrow screens ---------- */

@media (max-width: 900px) {
  .top { grid-template-columns: 1fr; gap: var(--line); padding-top: var(--line); }
  .film { justify-self: start; width: min(100%, 320px); }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--line) 20px; }
  .worlds { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .actions { margin-top: var(--line); }
}

@media (max-width: 560px) {
  body { font-size: 18px; }
  .worlds { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts { grid-template-columns: 1fr; }
  .screens img { height: 400px; }

  /* On a phone the name fills the width, the dice fill the row, and the buttons stack. */
  .masthead { font-size: 27.5vw; }
  .tagline { font-size: 6.7vw; white-space: nowrap; margin-bottom: var(--line); }
  .dice { margin-left: 0; margin-right: 6px; }
  .dice li { flex: 1 1 0; min-width: 0; }
  .die { width: calc(100% + 6px); margin-right: 0; font-size: 10.5vw; }
  .actions { flex-direction: column; align-items: stretch; gap: 16px; }
  .chunky { font-size: 20px; padding: 18px 20px; justify-content: center; }
  .soon { text-align: center; }
  .steps { gap: var(--line) 14px; }
  .step h3 { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .die.rolling { animation: none; }
  .chunky.store, .chunky.store::after { animation: none; }
  .chunky { transition: none; }
}
