/* Potato Princess Press. The palette and type are the book cover's
   (tools/book/cover.js): cream ground, brown ink, gold, the potato's skin. */
:root {
  --cream: #fbf3dd;
  --card: #fffaf0;
  --ink: #2b1d12;
  --ink-soft: #6b5644;
  --gold: #f2c14e;
  --skin: #e3b774;
  --blush: #f3a3a0;
  --leaf: #a6cf86;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Avenir Next", "Nunito Sans", "Helvetica Neue", sans-serif;
  --stroke: 3px;
  --gutter: clamp(1rem, 4vw, 2.5rem);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 72rem; margin-inline: auto; padding-inline: var(--gutter); }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 900; letter-spacing: -.015em; margin: 0; }
h2 { font-size: clamp(2rem, 1.4rem + 2.4vw, 3.1rem); line-height: 1.05; }
p { margin: 0; }
a { color: inherit; text-decoration-color: var(--gold); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 4px; }

/* Buttons: the cover's chunky outlined card, with a hard ink shadow. */
.actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.btn {
  display: inline-block; padding: .7rem 1.25rem;
  font: 700 1rem/1.2 var(--sans); color: var(--ink); text-decoration: none; cursor: pointer;
  background: var(--card); border: var(--stroke) solid var(--ink); border-radius: 14px;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn-gold { background: var(--gold); }
.btn-small { padding: .5rem .9rem; font-size: .9375rem; border-radius: 12px; }
.btn[aria-pressed="true"] { background: var(--gold); }

/* ---------- Masthead ---------- */
/* The bar stays at the top while you scroll. Once the page moves under it,
   it slims down: its cream backing shortens and gains an ink rule, and the
   logo and nav slide up into it (the logo shrinks, or fades out where the
   nav sits on a row of its own). The bar's own box never changes size, so
   the page under it doesn't jump; only the backing and the contents move,
   and the empty part lets clicks through.
   site.js measures --lift (how far the contents rise), --shrink (how much
   the backing loses) and --bar (the slim bar's height, so a jump to a
   section lands just below it). */
html { scroll-padding-top: var(--bar, 4rem); }
.topbar { position: sticky; top: 0; z-index: 10; pointer-events: none; }
.topbar::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 100%; z-index: -1;
  background: var(--cream); border-bottom: var(--stroke) solid transparent;
  transition: height .35s cubic-bezier(.3, .8, .3, 1), border-color .25s, box-shadow .25s;
}
.topbar.stuck::before { height: calc(100% - var(--shrink, 0px));
                        border-bottom-color: var(--ink); box-shadow: 0 4px 0 rgba(43, 29, 18, .08); }
.masthead {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem 2rem;
  padding-block: 1.4rem;
  transition: transform .35s cubic-bezier(.3, .8, .3, 1);
}
.topbar.stuck .masthead { transform: translateY(calc(-1 * var(--lift, 0px))); }
.masthead a { pointer-events: auto; }
.logo { display: flex; align-items: center; gap: .6rem; text-decoration: none;
        font: 900 1.35rem/1 var(--serif); letter-spacing: -.01em;
        transform-origin: left center; transition: transform .35s cubic-bezier(.3, .8, .3, 1), opacity .25s; }
.topbar.stuck .logo { transform: scale(.86); }
.topbar.two-row .logo { transform-origin: center; }
.topbar.two-row.stuck .logo { transform: translateY(-.4rem) scale(.9); opacity: 0; pointer-events: none; }
.logo i, .footer-name i { font-weight: 700; }
.logo-crown { width: 2.1rem; flex: none; }
.masthead nav { display: flex; flex-wrap: wrap; gap: .4rem 1.5rem; font-weight: 600; }
.masthead nav a { text-decoration: none; padding-block: .2rem; border-bottom: 2px solid transparent; }
.masthead nav a:hover { border-bottom-color: var(--gold); }

/* ---------- Hero: the playable cover card ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  gap: clamp(2rem, 5vw, 4.5rem); align-items: center;
  padding-block: clamp(1.5rem, 5vw, 4rem) clamp(3rem, 8vw, 6rem);
}
.hero h1 { font-size: clamp(2.8rem, 1.5rem + 4.8vw, 5.4rem); line-height: .95; letter-spacing: -.025em; }
.hero .lede { font-size: 1.1875rem; max-width: 34em; margin-top: 1.5rem; }
.hint {
  margin: 1.5rem 0 1.75rem; padding-left: 1.6rem; position: relative;
  font: italic 400 1.125rem/1.45 var(--serif);
}
.hint::before {
  content: ""; position: absolute; left: .15rem; top: .45em; width: .6rem; height: .6rem;
  background: var(--gold); outline: 2px solid var(--ink); transform: rotate(45deg);
}
.hint.done::before { background: var(--ink); }
.hero-art { margin: 0; }
.hero-art > svg { display: block; width: 100%; height: auto; overflow: visible; }
.bubble { font-family: var(--serif); font-style: italic; }

/* The hero potato. Its drawing is shared with the cover through <use>, so
   the blink is switched on with custom properties, which inherit into the
   copy: the cover potato never blinks.
   - It hops when a word is found or it is clicked, and action lines burst
     out beside it: a layer of their own that rises with it but doesn't fall.
   - It blinks now and then (once, and a double blink later, on a 16s loop),
     and once more when the mouse moves onto it. */
.hero-potato { cursor: pointer; --blink: blink 16s 4s infinite; }
.hero-art.hop .hero-potato { animation: hop .6s cubic-bezier(.3, 1.6, .5, 1) both; }
.hero-art.peek .hero-potato { --blink-now: blink-once .24s ease-in-out; }

/* The lines rise with the potato, so they never touch it, then stay at the
   top of the jump as it falls. Each grows out from its inner end
   (dashoffset 1 to 0, with pathLength 1), drifts outward, then drains away
   from the back (0 to -1). */
.hero-sparks { pointer-events: none; }
.hero-art.hop .hero-sparks { animation: rise .6s cubic-bezier(.3, 1.6, .5, 1) both; }
.hero-sparks path { opacity: 0; stroke-width: 3.2; stroke-dasharray: 1 1; stroke-dashoffset: 1; }
.hero-art.hop .hero-sparks path { animation: action .6s cubic-bezier(.2, .7, .3, 1) both; }
.hero-art.hop .hero-sparks path:nth-child(2) { animation-delay: .03s; }
.hero-art.hop .hero-sparks path:nth-child(3) { animation-delay: .06s; }
.eyes { animation: var(--blink, none), var(--blink-now, none); transform-box: fill-box; transform-origin: center; }

/* Arms and crown, also through the shared drawing: on a jump both arms
   swing and settle while the crown lifts off the head and lands a beat late. Each part
   turns about its own joint: the shoulders, and the crown's base. */
.hero-art.hop .hero-potato { --arm-r-jump: arm-r-jump .6s ease-in-out; --arm-l-jump: arm-l-jump .6s ease-in-out;
                             --crown-jump: crown-jump .65s ease-in-out; }
.arm-r { animation: var(--arm-r-jump, none); transform-box: fill-box; transform-origin: 0% 100%; }
.arm-l { animation: var(--arm-l-jump, none); transform-box: fill-box; transform-origin: 100% 0%; }
.crown { animation: var(--crown-jump, none); transform-box: fill-box; transform-origin: 50% 100%; }

@keyframes hop { 0% { transform: translateY(0); } 40% { transform: translateY(-34px); } 100% { transform: translateY(0); } }
@keyframes rise { 0% { transform: translateY(0); } 40%, 100% { transform: translateY(-34px); } }
@keyframes action {
  0% { opacity: 0; stroke-dashoffset: 1; stroke-width: 2.4; transform: translate(0, 0); }
  10% { opacity: 1; }
  45% { stroke-dashoffset: 0; stroke-width: 4.2; }
  85% { opacity: 1; }
  100% { opacity: 0; stroke-dashoffset: -1; stroke-width: 2; transform: translate(var(--dx), var(--dy)); }
}
@keyframes blink {
  0%, 44%, 45.6%, 93%, 94.4%, 95.8%, 100% { transform: scaleY(1); }
  44.8%, 93.7%, 95.1% { transform: scaleY(.1); }
}
@keyframes arm-r-jump {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(14deg); }
  45% { transform: rotate(-9deg); }
  72% { transform: rotate(6deg); }
  88% { transform: rotate(-2deg); }
}
@keyframes arm-l-jump {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-6deg); }
  45% { transform: rotate(20deg); }
  72% { transform: rotate(-5deg); }
  88% { transform: rotate(2deg); }
}
@keyframes crown-jump {
  0%, 100% { transform: translateY(0) rotate(0); }
  20% { transform: translateY(2px) rotate(3deg); }
  45% { transform: translateY(-9px) rotate(-9deg); }
  70% { transform: translateY(1px) rotate(5deg); }
  85% { transform: translateY(0) rotate(-2deg); }
}
@keyframes blink-once { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.1); } }
@media (prefers-reduced-motion: reduce) {
  .hero-art.hop .hero-potato, .hero-art.hop .hero-sparks, .hero-art.hop .hero-sparks path { animation: none; }
  .hero-potato, .hero-art.peek .hero-potato, .hero-art.hop .hero-potato {
    --blink: none; --blink-now: none; --arm-r-jump: none; --arm-l-jump: none; --crown-jump: none;
  }
}

/* ---------- Boards (hero, cover, play) ---------- */
.board { touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
.board text { font-family: var(--sans); font-weight: 600; fill: var(--ink);
              text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.board .trail { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.board .trail.found { stroke: var(--gold); }
.board .trail.live { stroke: var(--ink); stroke-opacity: .16; }
.board .trail.miss { stroke: var(--blush); stroke-opacity: .9; animation: fade .5s ease-in .1s forwards; }
.board .trail.shown { stroke: var(--ink); stroke-opacity: .13; }
.board .trail.secret { stroke: var(--blush); }
.board .trail.leaf { stroke: var(--leaf); }
.board .ring { fill: none; stroke: var(--ink); }
/* The letter under the mouse, before a drag starts: a touch bolder, on a
   faint disc. */
.board .hover-dot { fill: var(--ink); fill-opacity: .07; pointer-events: none; }
.board .hover-dot:not(.on) { display: none; }
.board text.lit { font-weight: 700; }
.board .trail.draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw .45s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { to { stroke-opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .topbar::before, .masthead, .logo { transition: none; }
  .board .trail.draw { animation: none; stroke-dashoffset: 0; }
  .board .trail.miss { animation-duration: .01s; animation-delay: .4s; }
}

/* ---------- The book ---------- */
.book {
  display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1fr);
  gap: clamp(2rem, 6vw, 5.5rem); align-items: center;
  padding-block: clamp(3rem, 7vw, 5rem);
  border-top: var(--stroke) solid var(--ink);
}
.book-cover { display: flex; justify-content: center; container-type: inline-size; --u: min(1cqw, .25rem); }

.cover {
  width: calc(100 * var(--u)); aspect-ratio: 6 / 9;
  display: flex; flex-direction: column; align-items: center;
  padding: calc(8 * var(--u)) calc(6 * var(--u)) calc(6 * var(--u)) calc(8 * var(--u)); position: relative;
  background: var(--cream);
  border-radius: 3px 10px 10px 3px;
  box-shadow: inset calc(4 * var(--u)) 0 0 calc(-2.6 * var(--u)) var(--gold), inset calc(5 * var(--u)) 0 calc(3 * var(--u)) calc(-3 * var(--u)) rgba(43, 29, 18, .18),
              0 1px 0 var(--ink), 14px 18px 0 -2px var(--skin), 14px 18px 0 0 var(--ink);
  outline: var(--stroke) solid var(--ink);
  transform: rotate(-2deg);
}
.cover-eyebrow { font: 600 calc(2.6 * var(--u))/1 var(--sans); letter-spacing: .24em; text-transform: uppercase; }
.cover-title { font-family: var(--serif); text-align: center; line-height: 1; margin-top: calc(4 * var(--u)); }
.cover-title span { display: block; }
.t-top { font-size: calc(13.5 * var(--u)); font-weight: 400; letter-spacing: -.01em; }
.t-joint { display: flex !important; align-items: center; justify-content: center; gap: calc(3 * var(--u));
           font-size: calc(8.5 * var(--u)); font-style: italic; font-weight: 700; margin-top: calc(1 * var(--u)); }
.t-joint::before, .t-joint::after { content: ""; width: calc(16 * var(--u)); height: calc(.6 * var(--u)); background: var(--gold); }
/* POTATOES rides an arch, as on the printed cover. */
.cover-potatoes { width: calc(100% + 4 * var(--u)); display: block; margin-top: calc(3 * var(--u)); overflow: visible; }
.cover-potatoes text { font-family: var(--serif); font-weight: 900; font-size: 112px; fill: var(--ink); letter-spacing: -1px; }
.cover-art { width: 100%; margin-top: calc(1 * var(--u)); }
.cover-imprint { margin-top: auto; padding-top: calc(2 * var(--u)); display: grid; font: 400 calc(2.3 * var(--u))/1.15 var(--sans); }
.cover-imprint span:first-child { text-transform: uppercase; }

.series { font: italic 400 1.125rem/1.4 var(--serif); color: var(--ink-soft); margin-bottom: .4rem; }
.book .blurb { font-size: 1.1875rem; margin-top: 1.25rem; max-width: 34em; }
.specs { margin: 1.75rem 0; display: grid; gap: 0; border-top: 2px solid var(--ink); }
.specs div { display: grid; grid-template-columns: 7rem 1fr; gap: 1rem; padding-block: .6rem;
             border-bottom: 1px solid rgba(43, 29, 18, .22); }
.specs dt { font-family: var(--serif); font-weight: 700; }
.specs dd { margin: 0; }
.promise { font: italic 400 1.125rem/1.5 var(--serif); margin-bottom: 1.75rem; max-width: 32em; }

/* ---------- Coming next ---------- */
.next { padding-bottom: clamp(3rem, 7vw, 5rem); }
.next h3 { font-size: 1.5rem; margin-bottom: 1.25rem; }
.next-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.25rem; }
.ghost {
  padding: 1.5rem 1.5rem 1.25rem; border: 2px dashed var(--ink); border-radius: 18px;
  display: flex; flex-direction: column; gap: .6rem;
}
.ghost h4 { font-size: 1.3rem; line-height: 1.15; }
.ghost .status { margin-top: auto; padding-top: .5rem; font: italic 400 1.0625rem/1.4 var(--serif); color: var(--ink-soft); }

/* ---------- Play a page ---------- */
.play { background: var(--card); border-block: var(--stroke) solid var(--ink); padding-block: clamp(3rem, 7vw, 5rem); }
.play-head { max-width: 44rem; }
.play-head p { margin-top: 1rem; font-size: 1.125rem; }
.play-body {
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(15rem, 1fr);
  gap: clamp(1.5rem, 4vw, 3.5rem); align-items: start; margin-top: 2.25rem;
}
.board-card {
  background: #fff; border: var(--stroke) solid var(--ink); border-radius: 22px;
  padding: clamp(.5rem, 2vw, 1.25rem); box-shadow: 6px 6px 0 var(--ink);
}
#playBoard { display: block; width: 100%; height: auto; }
.progress { font: 900 1.6rem/1.2 var(--serif); margin-bottom: 1rem; }
.wordlist {
  list-style: none; margin: 0 0 1.5rem; padding: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .15rem 1.25rem;
}
.wordlist li { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem;
               padding-block: .3rem; border-bottom: 1px solid rgba(43, 29, 18, .18);
               font-weight: 600; letter-spacing: .04em; }
.wordlist li span { font: italic 400 .875rem/1 var(--serif); color: var(--ink-soft); letter-spacing: 0; }
.wordlist li.found b { text-decoration: line-through; text-decoration-color: var(--gold);
                       text-decoration-thickness: 4px; font-weight: 600; }
.aside-note { margin-top: 1.25rem; font: italic 400 1rem/1.5 var(--serif); color: var(--ink-soft); }
.aside-note.found { color: var(--ink); }

.rules {
  list-style: none; counter-reset: r; padding: 0; margin: clamp(2rem, 5vw, 3rem) 0 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1.25rem 2rem;
}
.rules li { counter-increment: r; position: relative; padding-left: 2.4rem; font-size: 1rem; }
.rules li::before {
  content: counter(r); position: absolute; left: 0; top: -.1rem;
  width: 1.7rem; height: 1.7rem; display: grid; place-items: center; border-radius: 50%;
  background: var(--gold); border: 2px solid var(--ink); font: 700 .95rem/1 var(--serif);
}

/* ---------- Themes ---------- */
.themes { padding-block: clamp(3rem, 7vw, 5rem); }
.themes > p:not(.theme-list) { margin-top: 1rem; max-width: 40rem; font-size: 1.125rem; }
.theme-list { margin-top: 2rem; font: 400 clamp(1.15rem, 1rem + .6vw, 1.5rem)/1.75 var(--serif); }
.theme-list span { white-space: nowrap; }
.theme-list span:not(:last-child)::after {
  content: ""; display: inline-block; width: .38em; height: .38em; margin: 0 .55em .12em;
  background: var(--gold); outline: 1.5px solid var(--ink); transform: rotate(45deg);
}
.theme-list .first { font-style: italic; font-weight: 700; }

/* ---------- About ---------- */
.about {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: clamp(2rem, 5vw, 4rem); align-items: center;
  padding-block: clamp(3rem, 7vw, 5rem); border-top: var(--stroke) solid var(--ink);
}
.about-copy p { margin-top: 1rem; font-size: 1.125rem; max-width: 36em; }
.about-potato { width: 100%; max-width: 22rem; justify-self: center; }

/* ---------- Get a copy ---------- */
.buy { background: var(--gold); border-block: var(--stroke) solid var(--ink); }
.buy-inner { padding-block: clamp(3rem, 7vw, 4.5rem); max-width: 48rem; text-align: center; }
.buy-inner p { margin-top: 1rem; font-size: 1.125rem; }
.buy .email { margin-top: 1.5rem; font: 900 clamp(1.25rem, 1rem + 1.6vw, 2rem)/1.2 var(--serif); overflow-wrap: anywhere; }
.buy .email a { text-decoration-color: var(--ink); }
.buy .small { font-size: 1rem; margin-top: 1.5rem; }
.buy a:hover { text-decoration-color: var(--card); }

/* ---------- Footer ---------- */
.footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5rem 2rem;
          padding-block: 2rem 2.5rem; color: var(--ink-soft); font-size: .9375rem; }
.footer-name { font: 900 1.15rem/1 var(--serif); color: var(--ink); }

/* ---------- Narrow screens ---------- */
@media (max-width: 52rem) {
  .hero, .book, .about, .play-body { grid-template-columns: minmax(0, 1fr); }
  .hero-art { max-width: 34rem; margin-inline: auto; width: 100%; }
  .book-cover { order: -1; }
  .book-cover { --u: min(.8cqw, .2rem); }
}
@media (max-width: 30rem) {
  .masthead { justify-content: center; text-align: center; gap: .5rem 2rem; padding-block: .8rem; }
  .masthead nav { justify-content: center; gap: .3rem 1rem; }
  .specs div { grid-template-columns: 5.5rem 1fr; gap: .75rem; }
  .wordlist { gap: .1rem .9rem; }
}
