/* Layout: one fixed full-screen stage (no document scroll). Copy sits left on wide
   screens and on top on tall screens; the 3D scene is fitted into whatever space is left. */
:root {
  /* World palette. main.js tweens these when a bean is chosen. */
  --bg: #F3EBDD;
  --sun: #EAD8BF;
  --ink: #4A3328;
  --accent: #B07D55;
  --btn: #5A3A2C;
  --btn-ink: #F7EFE3;
  --steam: #FFFFFF;

  --display: "Fraunces", "Cooper Black", "Georgia", serif;
  --sans: "DM Sans", "Avenir Next", "Segoe UI", system-ui, sans-serif;

  --gutter: clamp(20px, 4.6vw, 64px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* Space to keep clear at the bottom (the home indicator on phones). */
  --edge-bottom: var(--safe-bottom);

  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* Pressing and holding is part of the experience (pouring, turning the crank,
     swiping), so a long press must not select the page or open the iOS callout.
     Text that is meant to be copied opts back in below. */
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 999px; }

/* ---------- stage ---------- */
.stage { position: fixed; inset: 0; }
#gl { display: block; width: 100%; height: 100%; touch-action: none; }
.fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.fx path.steam { fill: none; stroke: url(#steamFade); stroke-linecap: round; stroke-linejoin: round; }
.fx path.sparkle { fill: var(--steam); }

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  opacity: .32; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .45 0 0 0 0 .35 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- header ---------- */
.top {
  position: fixed; z-index: 5; left: 0; right: 0; top: 0;
  padding: calc(var(--safe-top) + clamp(16px, 3.4vh, 40px)) var(--gutter) 0;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  pointer-events: none;
}
.top > * { pointer-events: auto; }

.logo {
  display: inline-flex; align-items: center; gap: .32em;
  font-family: var(--display);
  font-variation-settings: "SOFT" 100, "WONK" 0, "opsz" 72;
  font-weight: 800;
  font-size: clamp(21px, 2.3vw, 31px);
  letter-spacing: -0.015em;
  color: var(--ink); text-decoration: none;
}
.logo-bean { width: .72em; height: .96em; transform: rotate(28deg); color: var(--ink); }

.nav { display: flex; gap: clamp(22px, 2.6vw, 40px); margin-left: auto; }
.nav button { font-weight: 500; font-size: 15.5px; letter-spacing: .045em; padding: 6px 0; position: relative; }
.nav button::after {
  content: ""; position: absolute; left: 50%; right: 50%; bottom: 0; height: 2px; border-radius: 2px;
  background: var(--accent); transition: left .35s cubic-bezier(.3,1.4,.5,1), right .35s cubic-bezier(.3,1.4,.5,1);
}
.nav button:hover::after { left: 0; right: 0; }

.top-icons { display: flex; gap: 10px; }

/* On small screens the menu folds into a button with a short dropdown. */
.round.menu-button { display: none; }  /* .round sets display too, so match its weight */
.menu-button[aria-expanded="true"] { background: var(--btn); color: var(--btn-ink); }
.menu-sheet {
  position: fixed; z-index: 7; right: var(--gutter);
  top: calc(var(--safe-top) + clamp(16px, 3.4vh, 40px) + 52px);
  display: grid; min-width: 180px; padding: 8px; border-radius: 18px;
  background: color-mix(in srgb, var(--bg) 55%, white);
  box-shadow: 0 22px 50px -24px rgba(40,20,10,.5);
  visibility: hidden; opacity: 0; translate: 0 -6px;
  transition: opacity .25s, translate .3s, visibility 0s .3s;
}
body.is-dark .menu-sheet { background: color-mix(in srgb, var(--sun) 75%, var(--bg)); }
.menu-sheet.show { visibility: visible; opacity: 1; translate: 0 0; transition: opacity .25s, translate .4s cubic-bezier(.3,1.5,.5,1); }
.menu-sheet button { min-height: 46px; padding: 0 14px; border-radius: 12px; text-align: left; font-size: 16px; font-weight: 500; color: var(--ink); }
.menu-sheet button:hover, .menu-sheet button:focus-visible { background: color-mix(in srgb, var(--sun) 70%, transparent); }
.round {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--sun); color: var(--ink);
  transition: scale .4s cubic-bezier(.3,1.6,.5,1);
}
.round:hover { scale: 1.08; }
.round:active { scale: .94; }
.round svg { width: 21px; height: 21px; }
#sound .wave, #sound .mute { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; transition: opacity .3s; }
#sound .wave { opacity: 0; }
#sound[aria-pressed="true"] .wave { opacity: 1; }
#sound[aria-pressed="true"] .mute { opacity: 0; }

/* ---------- copy ---------- */
.copy {
  position: fixed; z-index: 3;
  left: var(--gutter); top: 50%;
  width: min(44vw, 640px);
  transform: translateY(-52%);
  pointer-events: none;
}
.eyebrow {
  margin: 0 0 clamp(14px, 2.4vh, 26px);
  font-weight: 600; font-size: clamp(11.5px, 1vw, 14px);
  letter-spacing: .22em; text-transform: uppercase;
  color: var(--accent);
}
.headline {
  margin: 0;
  font-family: var(--display);
  font-variation-settings: "SOFT" 100, "WONK" 0, "opsz" 144;
  font-weight: 800;
  font-size: clamp(42px, min(6.2vw, 11vh), 112px);
  line-height: .98;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
.lede {
  margin: clamp(16px, 2.6vh, 28px) 0 0;
  max-width: 34em;
  font-size: clamp(15.5px, 1.32vw, 19px);
  line-height: 1.5;
  opacity: .9;
}

/* Headings and descriptions can be selected and copied. Only the text itself
   takes the pointer, so the 3D scene around it stays interactive. */
.copy .eyebrow, .copy .headline, .copy .lede,
.gallery-copy .eyebrow, .gallery-copy .headline, .gallery-copy .lede,
.bean-notes {
  pointer-events: auto;
  -webkit-user-select: text; user-select: text;
  -webkit-touch-callout: default;
  cursor: text;
}
.copy .eyebrow, .copy .headline, .copy .lede,
.gallery-copy .eyebrow, .gallery-copy .headline, .gallery-copy .lede { width: fit-content; max-width: 100%; }
.gallery-copy .eyebrow, .gallery-copy .headline, .gallery-copy .lede { margin-left: auto; margin-right: auto; }
::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); color: inherit; }

/* split words for the text transitions */
/* The mask is padded on every side (and the padding cancelled with negative margins)
   so swashes and tails that reach past a letter's box, like the y, are never clipped. */
.w { display: inline-block; overflow: hidden; vertical-align: top; padding: .12em .2em .26em; margin: -.12em -.2em -.26em; }
.w > span { display: inline-block; will-change: transform; }

/* ---------- buttons ---------- */
.actions {
  display: flex; align-items: center; gap: clamp(16px, 2vw, 28px);
  margin-top: clamp(24px, 5vh, 48px);
  pointer-events: auto;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 52px; border-radius: 999px;
  font-weight: 600; font-size: clamp(15px, 1.2vw, 17px); letter-spacing: .01em;
  transition: scale .45s cubic-bezier(.3,1.6,.5,1), translate .45s cubic-bezier(.3,1.6,.5,1), background-color .4s, color .4s;
  white-space: nowrap;
}
.btn:active { scale: .95; }
.btn.primary {
  padding: 0 clamp(24px, 2.4vw, 34px);
  background: var(--btn); color: var(--btn-ink);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.16), inset 0 2px 0 rgba(255,255,255,.12), 0 10px 22px -12px rgba(40,20,10,.55);
}
.btn.primary:hover { translate: 0 -2px; scale: 1.02; }
.btn.ghost { padding: 0 6px; color: var(--ink); }
.btn.ghost:hover .play, .btn.ghost:hover .arrow-left { scale: 1.12; }
.play, .arrow-left {
  width: 34px; height: 34px; border-radius: 50%; background: var(--sun); position: relative;
  transition: scale .4s cubic-bezier(.3,1.6,.5,1);
}
.play::after {
  content: ""; position: absolute; left: 13px; top: 11px;
  border-left: 10px solid var(--ink); border-top: 6px solid transparent; border-bottom: 6px solid transparent;
}
.arrow-left::after {
  content: ""; position: absolute; left: 13px; top: 12px; width: 9px; height: 9px;
  border-left: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(45deg);
}

/* ---------- hint (anchored to the cup by main.js on wide screens) ---------- */
.hint {
  position: fixed; z-index: 4; left: 0; top: 0;
  display: inline-flex; align-items: flex-end; gap: 4px;
  font-size: 14.5px; font-weight: 500; letter-spacing: .02em; color: var(--ink);
  padding: 8px 4px;
  opacity: 0;
  transition: opacity .5s;
}
.hint:not(.show) { pointer-events: none; transition-duration: .15s; }
.hint.show { opacity: .85; }
/* The arrow from a hint to its target, drawn in the overlay. It draws itself on
   once the hint appears. */
.callout path { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.callout .callout-line { stroke-dasharray: 1; stroke-dashoffset: 1; opacity: .8; transition: stroke-dashoffset .55s cubic-bezier(.4,0,.2,1) .1s; }
.callout .callout-head { opacity: 0; transition: opacity .2s .55s; }
.callout.show .callout-line { stroke-dashoffset: 0; }
.callout.show .callout-head { opacity: .8; }
/* Leave instantly (only the arrival is drawn), and fully: an undrawn line with
   round caps would still paint a dot. */
.callout:not(.show) path { opacity: 0; transition: none; }
.hint:hover { opacity: 1; }

/* ---------- bean gallery ---------- */
.gallery-copy {
  position: fixed; z-index: 3; left: 50%; top: calc(var(--safe-top) + clamp(78px, 11vh, 120px));
  transform: translateX(-50%);
  width: min(calc(100vw - 2 * var(--gutter)), 760px);
  text-align: center; pointer-events: none;
  visibility: hidden; transition: visibility 0s .6s;
}
.gallery-copy .eyebrow { margin-bottom: clamp(8px, 1.4vh, 14px); }
#shopCopy, #storyCopy, #counterCopy { width: min(calc(100vw - 2 * var(--gutter)), 1000px); }
.gallery-title { font-size: clamp(34px, min(5vw, 8vh), 76px); }
.gallery-copy .lede { margin: clamp(8px, 1.6vh, 16px) auto 0; }

.bean-labels { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
.bean-label {
  position: absolute; left: 0; top: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 10px; border-radius: 14px;
  white-space: nowrap; pointer-events: auto;
  transition: background-color .3s;
}
.bean-name { font-family: var(--display); font-variation-settings: "SOFT" 100, "WONK" 0, "opsz" 48; font-weight: 800; font-size: clamp(16px, 1.45vw, 21px); color: var(--ink); }
.bean-notes { font-size: clamp(12px, 1vw, 14px); color: var(--accent); letter-spacing: .02em; }
.bean-label.is-selected .bean-name::after { content: ""; display: block; height: 2px; margin: 3px auto 0; width: 60%; border-radius: 2px; background: var(--accent); }
.bean-label:hover { background: color-mix(in srgb, var(--sun) 60%, transparent); }

.gallery-controls {
  position: fixed; z-index: 4; left: var(--gutter); right: var(--gutter);
  bottom: calc(var(--edge-bottom) + clamp(14px, 3.6vh, 36px));
  display: flex; justify-content: space-between; align-items: center;
  pointer-events: none; visibility: hidden; opacity: 0;
  transition: opacity .5s, visibility 0s .5s;
}
.gallery-controls > * { pointer-events: auto; }
.turn-buttons { display: none; gap: 12px; }

body[data-mode="gallery"] #galleryCopy,
body[data-mode="brew"] #brewCopy,
body[data-mode="shop"] #shopCopy,
body[data-mode="counter"] #counterCopy { visibility: visible; transition: none; }
body[data-mode="gallery"] .gallery-controls { visibility: visible; opacity: 1; transition: opacity .6s .9s; }
.bean-labels { visibility: hidden; opacity: 0; transition: opacity .4s, visibility 0s .4s; }
body[data-mode="gallery"] .bean-labels { visibility: visible; opacity: 1; transition: opacity .8s 1.2s; }

/* ---------- brew scene ---------- */
/* The brew hint is only a label: drags and taps go through to the scene. */
.brew-hint, .brew-hint.show { z-index: 4; margin: 0; pointer-events: none; }

.brew-controls, .story-controls {
  position: fixed; z-index: 4; left: var(--gutter); right: var(--gutter);
  bottom: calc(var(--edge-bottom) + clamp(14px, 3.6vh, 36px));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  visibility: hidden; opacity: 0;
  transition: opacity .5s, visibility 0s .5s;
}
body[data-mode="brew"] .brew-controls,
body[data-mode="story"] .story-controls { visibility: visible; opacity: 1; transition: opacity .6s .9s; }
.story-controls #storyBack { justify-self: start; }
.story-controls .story-turn { justify-self: end; }
.brew-controls #brewBack { justify-self: start; }
.brew-controls #brewAction { justify-self: end; touch-action: none; -webkit-user-select: none; user-select: none; }
.brew-controls #brewAction:disabled { opacity: .55; cursor: default; }

.steps {
  position: relative; margin: 0; padding: 0; list-style: none;
  display: flex; gap: clamp(18px, 3vw, 44px);
  font-size: 13px; letter-spacing: .02em;
}
.steps::before {
  content: ""; position: absolute; left: 22px; right: 22px; top: 6px; height: 1.5px;
  background: color-mix(in srgb, var(--ink) 35%, transparent);
}
.steps li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; width: 44px; opacity: .7; transition: opacity .4s; }
.step-dot {
  width: 13px; height: 13px; border-radius: 50%;
  border: 1.5px solid var(--ink); background: var(--bg);
  transition: background-color .4s, scale .5s cubic-bezier(.3,1.8,.5,1);
}
.steps li.done, .steps li.active { opacity: 1; }
.steps li.done .step-dot { background: var(--ink); }
.steps li.active .step-dot { background: var(--ink); scale: 1.3; }
/* In the story the steps are buttons you can jump with. */
.steps button { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0; white-space: nowrap; }
.story-controls .steps li { width: auto; min-width: 44px; }
.story-controls .steps li:hover { opacity: 1; }

/* ---------- story ---------- */
body[data-mode="story"] #storyCopy { visibility: visible; transition: none; }
.story-caption { margin-top: clamp(18px, 4.5vh, 48px); display: grid; justify-items: center; gap: 4px; }
.story-chapter, .story-line { margin: 0; pointer-events: auto; -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.story-chapter { font-family: var(--display); font-variation-settings: "SOFT" 100, "opsz" 48; font-weight: 800; font-size: clamp(18px, 1.6vw, 23px); }
.story-line { font-size: clamp(13.5px, 1.1vw, 15.5px); color: var(--accent); max-width: 36em; }
.story-cta { margin-top: 10px; min-height: 42px; padding: 0 22px; pointer-events: auto; }
.story-cta[aria-hidden="true"] { visibility: hidden; }
#storyFx path { fill: none; stroke: var(--steam); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shop ---------- */
[hidden] { display: none !important; }
.round { position: relative; }
.badge {
  position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--btn); color: var(--btn-ink);
  font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
  scale: 0; transition: scale .4s cubic-bezier(.3,1.8,.5,1);
}
.badge.show { scale: 1; }

.shop-prices { position: fixed; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; visibility: hidden; opacity: 0; transition: opacity .4s, visibility 0s .4s; }
body[data-mode="shop"] .shop-prices { visibility: visible; opacity: 1; transition: opacity .8s 1.2s; }
.shop-price {
  position: absolute; left: 0; top: 0; pointer-events: auto;
  padding: 4px 10px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; color: var(--ink); opacity: .75;
  transition: opacity .3s, background-color .3s;
}
.shop-price.is-selected { opacity: 1; font-weight: 600; background: color-mix(in srgb, var(--sun) 70%, transparent); }

.shop-card {
  position: fixed; z-index: 5; left: 0; top: 0;
  display: grid; gap: 12px; width: max-content; min-width: 190px; padding: 16px 18px 18px;
  border-radius: 18px; background: color-mix(in srgb, var(--bg) 55%, white);
  box-shadow: 0 18px 40px -22px rgba(40,20,10,.45);
  opacity: 0; visibility: hidden; scale: .96;
  transition: opacity .3s, scale .3s, visibility 0s .3s;
}
body.is-dark .shop-card { background: color-mix(in srgb, var(--sun) 75%, var(--bg)); box-shadow: 0 18px 40px -22px rgba(0,0,0,.6); }
.shop-card.show { opacity: 1; visibility: visible; scale: 1; transition: opacity .45s, scale .5s cubic-bezier(.3,1.5,.5,1); }
.shop-card p { margin: 0; }
.shop-card-name { font-family: var(--display); font-variation-settings: "SOFT" 100, "opsz" 48; font-weight: 800; font-size: 20px; letter-spacing: -.01em; white-space: nowrap; }
.shop-card-notes { margin-top: 3px !important; font-size: 13.5px; color: var(--accent); }
.shop-card-meta { margin-top: 6px !important; font-size: 14px; }
.shop-card-name, .shop-card-notes, .shop-card-meta { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.shop-card .btn { min-height: 46px; justify-self: start; padding: 0 24px; }

.shop-controls {
  position: fixed; z-index: 4; left: var(--gutter); right: var(--gutter);
  bottom: calc(var(--edge-bottom) + clamp(14px, 3.6vh, 36px));
  display: flex; justify-content: space-between; align-items: center;
  pointer-events: none; visibility: hidden; opacity: 0;
  transition: opacity .5s, visibility 0s .5s;
}
.shop-controls > * { pointer-events: auto; }
body[data-mode="shop"] .shop-controls { visibility: visible; opacity: 1; transition: opacity .6s .9s; }

.fly-dot { position: fixed; z-index: 9; left: 0; top: 0; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--btn); opacity: 0; pointer-events: none; }

/* ---------- counter (checkout) ---------- */
.to-counter {
  grid-column: 1 / -1; justify-self: start;
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px;
  text-decoration-color: color-mix(in srgb, var(--accent) 60%, transparent);
}
.counter-panel {
  position: fixed; z-index: 5; right: var(--gutter); top: 50%;
  width: min(340px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100% - 2 * var(--gutter));
  translate: 0 -40%;
  padding: 20px 20px 22px; border-radius: 20px;
  background: color-mix(in srgb, var(--bg) 55%, white);
  box-shadow: 0 22px 50px -26px rgba(40,20,10,.45);
  visibility: hidden; opacity: 0; scale: .97;
  transition: opacity .35s, scale .35s, visibility 0s .35s;
}
body.is-dark .counter-panel { background: color-mix(in srgb, var(--sun) 75%, var(--bg)); }
body[data-mode="counter"] .counter-panel.show { visibility: visible; opacity: 1; scale: 1; transition: opacity .5s, scale .5s cubic-bezier(.3,1.5,.5,1); }
.counter-panel p { margin: 0; }
.panel-title { font-family: var(--display); font-variation-settings: "SOFT" 100, "opsz" 48; font-weight: 800; font-size: 22px; letter-spacing: -.01em; }
.order { display: grid; gap: 14px; }
.order-lines { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; max-height: 38vh; overflow-y: auto; }
.order-line { display: grid; grid-template-columns: 12px 1fr auto auto; align-items: center; gap: 10px; min-width: 0; }
.order-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.order-name { min-width: 0; font-size: 14.5px; font-weight: 500; line-height: 1.25; -webkit-user-select: text; user-select: text; }
.order-name small { display: block; font-size: 12.5px; font-weight: 400; color: var(--accent); }
.stepper { display: inline-flex; align-items: center; gap: 2px; border-radius: 999px; background: color-mix(in srgb, var(--sun) 70%, transparent); }
.stepper button { width: 32px; height: 32px; border-radius: 50%; font-size: 17px; font-weight: 600; line-height: 1; color: var(--ink); }
.stepper button:hover { background: color-mix(in srgb, var(--sun) 100%, transparent); }
.stepper output { min-width: 18px; text-align: center; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.order-price { min-width: 40px; text-align: right; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.order-total { display: flex; justify-content: space-between; padding-top: 12px; border-top: 1.5px dashed color-mix(in srgb, var(--ink) 25%, transparent); font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; }
.panel-note { font-size: 12.5px; line-height: 1.45; color: var(--accent); -webkit-user-select: text; user-select: text; }
.order .btn.primary { justify-self: stretch; }
.order.busy .stepper, .order.busy #wrapIt { opacity: .5; pointer-events: none; }

/* The receipt prints out line by line, with a torn edge at the bottom. */
.receipt { display: grid; gap: 16px; }
.receipt-paper {
  position: relative; padding: 16px 16px 22px;
  background: #FFFDF8; color: #4A3328;
  font-size: 13.5px; line-height: 1.6; font-variant-numeric: tabular-nums;
  -webkit-user-select: text; user-select: text;
  box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 10px 24px -18px rgba(40,20,10,.5);
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat, conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 12px 8px repeat-x;
          mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat, conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 12px 8px repeat-x;
}
.receipt-paper p { display: flex; justify-content: space-between; gap: 12px; }
.receipt-paper .r-head { justify-content: center; font-family: var(--display); font-variation-settings: "SOFT" 100; font-weight: 800; font-size: 17px; }
.receipt-paper .r-meta { justify-content: center; font-size: 12px; color: #8A6E5C; }
.receipt-paper .r-rule { height: 0; margin: 6px 0; border-top: 1.5px dashed rgba(74,51,40,.3); }
.receipt-paper .r-total { font-weight: 700; }
.receipt-paper .r-note { justify-content: center; text-align: center; font-size: 12px; color: #8A6E5C; }
.receipt-paper > * { opacity: 0; translate: 0 -4px; transition: opacity .25s, translate .25s; }
.receipt-paper > .in { opacity: 1; translate: 0 0; }
.receipt-actions { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; opacity: 0; translate: 0 8px; transition: opacity .4s, translate .5s cubic-bezier(.3,1.5,.5,1); }
.receipt-actions.in { opacity: 1; translate: 0 0; }
.receipt-actions .btn.ghost { padding: 0 8px; }

.counter-controls {
  position: fixed; z-index: 4; left: var(--gutter);
  bottom: calc(var(--edge-bottom) + clamp(14px, 3.6vh, 36px));
  visibility: hidden; opacity: 0; transition: opacity .5s, visibility 0s .5s;
}
body[data-mode="counter"] .counter-controls { visibility: visible; opacity: 1; transition: opacity .6s .9s; }

/* ---------- close-up controls ---------- */
.closeup {
  position: fixed; z-index: 4; left: 0; right: 0;
  bottom: calc(var(--edge-bottom) + clamp(14px, 4.5vh, 44px));
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  opacity: 0; visibility: hidden; transform: translateY(20px);
  transition: opacity .5s, transform .6s cubic-bezier(.3,1.4,.5,1), visibility 0s .5s;
}
body[data-mode="closeup"] .closeup { opacity: 1; visibility: visible; transform: none; transition: opacity .6s .5s, transform .7s .5s cubic-bezier(.3,1.4,.5,1); }
.closeup-row { display: flex; gap: 18px; align-items: center; }
.stir-hint { margin: 0; font-size: 14.5px; letter-spacing: .03em; opacity: .8; transition: opacity .6s; }
.stir-hint.done { opacity: 0; }

body[data-mode="closeup"] .actions,
body[data-mode="closeup"] .hint,
body[data-mode="closeup"] .copy { pointer-events: none; }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 8; left: 50%; top: calc(var(--safe-top) + 92px);
  transform: translate(-50%, -10px);
  margin: 0; padding: 10px 18px; border-radius: 999px;
  background: var(--btn); color: var(--btn-ink);
  font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .35s, transform .5s cubic-bezier(.3,1.5,.5,1);
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.above { transform: translate(-50%, calc(-100% + 10px)); }
.toast.above.show { transform: translate(-50%, -100%); }

/* ---------- loader ---------- */
.loader {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-content: center; justify-items: center; gap: 18px;
  background: #F3EBDD; color: #4A3328;
  transition: opacity .7s ease .1s, visibility 0s .8s;
}
.loader.done { opacity: 0; visibility: hidden; }
.loader-ring { width: 84px; height: 84px; display: grid; place-items: center; position: relative; }
.loader-ring::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: repeating-conic-gradient(#C89F7A 0 7deg, transparent 7deg 30deg);
  -webkit-mask: radial-gradient(circle, transparent 36px, #000 37px 40px, transparent 41px);
          mask: radial-gradient(circle, transparent 36px, #000 37px 40px, transparent 41px);
  animation: spin 3s linear infinite;
}
.loader-bean { width: 26px; height: 34px; transform: rotate(28deg); animation: bob 1.6s ease-in-out infinite; }
.loader-word { margin: 0; font-family: var(--display); font-weight: 800; font-variation-settings: "SOFT" 100; font-size: 18px; letter-spacing: -.01em; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bob { 50% { transform: rotate(18deg) translateY(-4px); } }

/* ---------- tall screens (phones in portrait) ---------- */
@media (max-aspect-ratio: 1/1) {
  .nav { display: none; }
  .round.menu-button { display: grid; }
  .copy {
    top: calc(var(--safe-top) + clamp(70px, 11vh, 120px));
    right: var(--gutter); width: auto;
    transform: none;
  }
  .eyebrow { margin-bottom: 12px; letter-spacing: .18em; }
  .eyebrow { font-size: 11px; }
  .headline { font-size: clamp(34px, min(10.6vw, 6.4vh), 76px); }
  .lede { margin-top: 10px; font-size: clamp(14px, 3.8vw, 18px); line-height: 1.45; }
  .actions {
    position: fixed; z-index: 4; margin: 0;
    left: var(--gutter); right: var(--gutter);
    bottom: calc(var(--edge-bottom) + clamp(12px, 2.6vh, 32px));
    justify-content: space-between; gap: 12px;
  }
  .actions .btn.primary { flex: 1 1 auto; max-width: 300px; padding: 0 22px; }
  .actions .btn.ghost { flex: none; gap: 9px; }
  .hint { padding: 4px; }
  .turn-buttons { display: flex; }
  .counter-panel {
    top: auto; left: var(--gutter); right: var(--gutter); width: auto; translate: none;
    bottom: calc(var(--edge-bottom) + clamp(14px, 3.6vh, 36px) + 56px);
    max-height: 66vh; overflow-y: auto; padding: 14px 16px 16px;
  }
  .order { gap: 9px; }
  .order-lines { max-height: none; gap: 6px; }
  .order-total { padding-top: 8px; }
  .panel-title { font-size: 18px; }
  .panel-note { font-size: 12px; }
  .order .btn.primary { min-height: 46px; }
  #counterCopy .lede { display: none; }
  .receipt { gap: 12px; }
  .receipt-paper { padding: 12px 14px 18px; font-size: 12.5px; line-height: 1.5; }
  .shop-card {
    left: var(--gutter); right: var(--gutter); top: auto; width: auto;
    bottom: calc(var(--edge-bottom) + clamp(14px, 3.6vh, 36px) + 64px);
    grid-template-columns: 1fr auto; align-items: center;
    transform: none !important;
  }
  .shop-card .btn { justify-self: end; }
  .shop-card-name { white-space: normal; }
  .brew-controls, .story-controls { grid-template-columns: 1fr auto; row-gap: 18px; }
  .brew-controls .steps, .story-controls .steps { grid-column: 1 / -1; grid-row: 1; justify-self: center; }
  .story-controls .steps { gap: 10px; font-size: 12px; }
  .story-caption { margin-top: 14px; }
  .gallery-copy { top: calc(var(--safe-top) + clamp(70px, 11vh, 110px)); }
  .gallery-title { font-size: clamp(32px, min(10vw, 6vh), 64px); }
  .bean-name { font-size: 22px; }
  .bean-notes { font-size: 14px; }
}

/* narrow phones (iPhone mini / 11 Pro and smaller) */
@media (max-aspect-ratio: 1/1) and (max-width: 400px) {
  .top { gap: 12px; }
  .top-icons { gap: 8px; }
  .round { width: 40px; height: 40px; }
  .round svg { width: 19px; height: 19px; }
  .logo { font-size: 20px; }
  .btn { font-size: 15px; min-height: 48px; }
  .actions .btn.primary { padding: 0 18px; }
  .play { width: 30px; height: 30px; }
  .play::after { left: 11px; top: 9px; }
  .closeup-row { gap: 12px; }
}

/* short landscape phones */
@media (min-aspect-ratio: 1/1) and (max-height: 520px) {
  .steps { font-size: 12px; gap: 14px; }
  .turn-buttons { display: flex; }
  .counter-panel { top: calc(var(--safe-top) + 66px); translate: none; max-height: calc(100% - 80px - var(--safe-top)); overflow-y: auto; padding: 14px 16px; }
  .counter-panel .panel-note { display: none; }
  /* The panel takes the right side, so the title sits on the left. */
  #counterCopy { left: var(--gutter); transform: none; width: calc(100vw - min(340px, 100vw - 2 * var(--gutter)) - 3 * var(--gutter)); text-align: left; }
  #counterCopy .eyebrow, #counterCopy .headline, #counterCopy .lede { margin-left: 0; }
  .receipt-paper { padding: 10px 12px 16px; font-size: 12px; line-height: 1.45; }
  .receipt { gap: 10px; }
  .shop-card {
    left: auto; right: var(--gutter); top: auto; width: max-content; max-width: calc(100vw - 2 * var(--gutter));
    bottom: calc(var(--edge-bottom) + 12px + 52px);
    grid-template-columns: auto; gap: 8px; padding: 12px 14px;
    transform: none !important;
  }
  .gallery-copy { top: calc(var(--safe-top) + clamp(68px, 15vh, 80px)); }
  .gallery-copy .eyebrow { display: none; }
  .gallery-copy .lede { margin-top: 4px; }
  .gallery-title { font-size: clamp(26px, 7vh, 40px); }
  .nav { display: none; }
  .round.menu-button { display: grid; }
  .btn { min-height: 44px; }
  .lede { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .loader-ring::before, .loader-bean { animation: none; }
}

/* night world: grain lifts instead of darkening */
body.is-dark .grain { mix-blend-mode: screen; opacity: .1; }

.close-dot { background: var(--sun) !important; position: relative; }
.close-dot::before, .close-dot::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 2px; border-radius: 2px;
  background: var(--ink); transform: translate(-50%, -50%) rotate(45deg);
}
.close-dot::after { transform: translate(-50%, -50%) rotate(-45deg); }
