/* Loopworm: game CSS. Tokens from /design/garden.css. The canvas draws the garden slice (a thin strip of surface on
   top of the bed, a square, the same on every screen); the DOM holds the HUD, the two held-side glows, the hint and the cards. ui.js places the HUD and hint for
   each layout (portrait: above and below the bed; landscape: beside it). Card and appbar patterns follow Boom Bloom. */
html, body { height: 100%; }
/* the page is a column: app bar, the playtest strip when there is one (platform/playtest.js; its placeholder holds
   the place from the first paint), then the stage takes whatever height is left, so the bed never runs under the
   bottom edge whether the strip is there, still loading, moved into the app bar (short landscape) or absent */
body { display: flex; flex-direction: column; height: 100svh; overflow: hidden; overscroll-behavior: none; background: var(--gg-cream); }
/* round 5: the dynamic height where the browser has it, so the garden grows into the space a phone's toolbar gives back */
@supports (height: 100dvh) { body { height: 100dvh; } }
.lw-appbar { position: relative; z-index: 5; flex: none; }
/* the home link is a 44 px target too (same look, a taller hit box) */
.lw-appbar .gg-wordmark { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }
.lw-namechip { min-height: 30px; }
@media (max-width: 560px) { .lw-namechip { display: none; } }
@media (max-width: 370px) { .lw-appbar .gg-wordmark span { display: none; } }
@media (orientation: landscape) and (max-height: 500px) {
  .lw-appbar .gg-appbar__in { min-height: 50px; }
  .lw-appbar .gg-wordmark { font-size: 19px; }
  .lw-appbar .gg-wordmark svg { width: 30px; height: 30px; }
}

.lw-main { position: relative; flex: 1 1 auto; min-height: 0; width: 100%; }

/* ---------- round 4 (Ariel 11-09): the bed as big as a phone allows ----------
   While a run is on (body.lw-playing: not on the title, pause or result) a phone or small tablet folds the app bar and
   the playtest strip away, so the stage is the whole screen; a compact pause (and full screen where the browser has the
   Fullscreen API) sits in the stage's corner instead. Pause brings the bar and the strip (vote, board, share) back.
   Desktop keeps its bar. The safe areas (notch, home bar) are read by ui.js from these variables for the HUD, the pads
   and the controls. Pinch zoom stays on (the viewport tag never says user-scalable=no). */
:root { --lw-sat: env(safe-area-inset-top, 0px); --lw-sar: env(safe-area-inset-right, 0px); --lw-sab: env(safe-area-inset-bottom, 0px); --lw-sal: env(safe-area-inset-left, 0px); }
.lw-ctl { position: absolute; z-index: 5; display: none; gap: 6px; top: 6px; right: 6px; }
.lw-ctl .gg-btn { box-shadow: var(--gg-shadow-sm); }
.lw-fsbtn[hidden] { display: none; }
@media (max-width: 560px) { .lw-appbar #fsbtn { display: none; } }
/* on the pause card the bar and the strip sit above the dimmed backdrop, so vote, board, share, sound and help work
   from there (the board sheet opens above them) */
body.lw-paused .lw-appbar, body.lw-paused .ggpt-strip { z-index: 61; }
/* the HUD row next to the corner pause on a phone: a little tighter so it stays one row */
.lw-hud.is-folded:not(.is-col) { gap: 4px; justify-content: flex-start; }
.lw-hud.is-folded:not(.is-col) .gg-pill { padding-inline: 9px; }
.lw-hud.is-folded:not(.is-col) .lw-hearts { padding-inline: 6px; }
.lw-hud.is-folded:not(.is-col) .lw-hearts svg { width: 18px; height: 18px; }
.lw-hud.is-folded:not(.is-col) .lw-score { min-width: 46px; }
@media (max-width: 1000px), (max-height: 560px) {
  body.lw-playing .lw-appbar, body.lw-playing .ggpt-strip { display: none; }
  body.lw-playing .lw-ctl { display: flex; }
}
.lw-stage {
  position: absolute; inset: 0; overflow: hidden; background: var(--gg-cream);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
/* nothing under the thumbs can be selected, called out or dragged (iOS long press; the stage's touchstart is
   cancelled in input.js as well, that is what really stops it on iOS) */
.lw-stage *, .lw-appbar, .lw-appbar *, .ggpt-strip, .ggpt-strip * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-user-drag: none; }
.lw-side, .lw-hud, .lw-hint, .lw-canvas { touch-action: none; }
.lw-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.lw-stage.is-idle .lw-hud, .lw-stage.is-idle .lw-hint, .lw-stage.is-idle .lw-side { visibility: hidden; }

/* ---------- the two halves: a glow on the side you hold, and a thumb pad in each bottom corner on touch screens ---------- */
.lw-side { position: absolute; top: 0; bottom: 0; width: 50%; z-index: 1; pointer-events: none; }
.lw-side::before { content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity .08s linear; }
.lw-side--l { left: 0; }
.lw-side--r { right: 0; }
.lw-side--l::before { background: linear-gradient(90deg, rgba(156, 255, 30, .55), rgba(156, 255, 30, 0) 42%); }
.lw-side--r::before { background: linear-gradient(270deg, rgba(156, 255, 30, .55), rgba(156, 255, 30, 0) 42%); }
.lw-side svg {
  position: absolute; bottom: 16px; width: 60px; height: 60px; padding: 8px; border-radius: 50%; opacity: 0;
  background: var(--gg-paper); border: 3px solid var(--gg-ink); box-shadow: 0 4px 0 var(--gg-ink);
  transition: transform .06s, box-shadow .06s, background-color .06s;
}
.lw-side--l svg { left: calc(14px + var(--lw-sal)); }
.lw-side--r svg { right: calc(14px + var(--lw-sar)); }
.lw-side svg { bottom: calc(16px + var(--lw-sab)); }
/* a short portrait stage: the pads shrink a little so a two-line hint under the bed never sits on them */
.lw-stage.is-short .lw-side svg { width: 52px; height: 52px; padding: 7px; bottom: calc(12px + var(--lw-sab)); }
.lw-stage.is-short .lw-side--l svg { left: calc(10px + var(--lw-sal)); }
.lw-stage.is-short .lw-side--r svg { right: calc(10px + var(--lw-sar)); }
.lw-stage.is-touch .lw-side svg { opacity: .6; }
.lw-side.is-on::before { opacity: 1; }
.lw-side.is-on svg { opacity: 1; background: var(--gg-lime); transform: translateY(3px); box-shadow: 0 1px 0 var(--gg-ink); }
/* the first time: the side to press breathes so a thumb knows where to go */
.lw-side.is-hint::before { animation: lw-breathe 1.6s ease-in-out infinite; }
.lw-side.is-hint svg { opacity: 1; }
.lw-side.is-on.is-hint::before { animation: none; opacity: 1; }
@keyframes lw-breathe { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }

/* ---------- HUD ---------- */
.lw-hud {
  position: absolute; z-index: 3; pointer-events: none;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center;
}
.lw-hud .gg-pill { min-height: 30px; box-shadow: var(--gg-shadow-sm); }
.lw-level { background: var(--gg-butter); font-family: var(--gg-font-display); font-weight: 800; }
.lw-hearts { display: inline-flex; align-items: center; gap: 2px; padding: 2px 8px; min-height: 30px; border: 2px solid var(--gg-ink); border-radius: 999px; background: var(--gg-paper); box-shadow: var(--gg-shadow-sm); }
.lw-hearts svg { width: 20px; height: 20px; display: block; }
.lw-hearts .is-gone { opacity: .22; }
.lw-hearts.is-hit { animation: lw-shake .4s; }
.lw-buds { background: var(--gg-paper); gap: 5px; font-family: var(--gg-font-display); font-weight: 800; font-variant-numeric: tabular-nums; }
.lw-buds svg { width: 18px; height: 18px; display: block; }
.lw-buds.is-up { animation: lw-pop .5s var(--gg-ease-spring); }
.lw-score { background: var(--gg-paper); font-family: var(--gg-font-display); font-weight: 800; font-variant-numeric: tabular-nums; min-width: 64px; justify-content: center; }
.lw-score.is-up { animation: lw-pop .35s var(--gg-ease-spring); }
.lw-hud.is-col { flex-direction: column; align-items: stretch; }
.lw-hud.is-col .gg-pill, .lw-hud.is-col .lw-hearts { justify-content: center; }
@media (min-width: 1000px) and (min-height: 600px) {
  .lw-hud.is-col { gap: 10px; }
  .lw-hud.is-col .gg-pill, .lw-hud.is-col .lw-hearts { min-height: 44px; font-size: 18px; }
  .lw-hud.is-col .lw-hearts svg, .lw-hud.is-col .lw-buds svg { width: 24px; height: 24px; }
  .lw-stage[data-mode="land"] .lw-hint { font-size: var(--gg-text-md); padding: 12px 16px; }
}
@keyframes lw-shake { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes lw-pop { from { transform: scale(1.35); } to { transform: none; } }

/* ---------- hint ---------- */
.lw-hint {
  position: absolute; z-index: 4; transform: translateX(-50%);
  width: max-content; max-width: min(94%, 420px); margin: 0; padding: 8px 14px; text-align: center;
  background: var(--gg-paper); border: var(--gg-border); border-radius: var(--gg-r-md); box-shadow: var(--gg-shadow);
  font-weight: 700; font-size: var(--gg-text-sm); line-height: 1.3; pointer-events: none;
  animation: lw-in .3s var(--gg-ease-spring);
}
.lw-hint[hidden] { display: none; }
.lw-hint b { background: var(--gg-butter); padding: 0 5px; border-radius: 6px; border: 2px solid var(--gg-ink); white-space: nowrap; }
.lw-hint.is-good { background: var(--gg-lime-100); }
.lw-stage[data-mode="land"] .lw-hint { transform: none; text-align: left; font-size: var(--gg-text-xs); animation: none; }
@keyframes lw-in { from { opacity: 0; transform: translate(-50%, -6px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

.lw-flash { position: absolute; inset: 0; z-index: 2; pointer-events: none; background: #FF1E73; opacity: 0; }
.lw-flash.is-on { animation: lw-flash .45s ease-out; }
@keyframes lw-flash { 0% { opacity: .3; } 100% { opacity: 0; } }

/* ---------- cards ---------- */
.lw-modal { z-index: 60; }
#how { z-index: 81; }
.lw-card { text-align: center; }
.lw-title { font-family: var(--gg-font-display); font-weight: 800; font-size: clamp(38px, 11vw, 56px); line-height: 1; margin: 6px 0 4px; }
.lw-titleart { display: block; width: 100%; max-width: 360px; height: auto; aspect-ratio: 560 / 200; margin: 0 auto 6px; }
.lw-lede { color: var(--gg-ink-2); margin: 0 0 16px; }
.lw-btns { display: grid; gap: 10px; margin-top: 4px; }
.lw-best { margin: 12px 0 0; font-size: var(--gg-text-sm); color: var(--gg-ink-2); }
.lw-best:empty { display: none; }
.lw-best b { color: var(--gg-ink); font-family: var(--gg-font-display); }
.lw-h2 { font-family: var(--gg-font-display); font-weight: 800; font-size: var(--gg-text-2xl); margin: 4px 0 10px; }
.lw-howlist { text-align: left; margin: 0 0 18px; padding-left: 20px; display: grid; gap: 8px; font-size: var(--gg-text-sm); }
.lw-rows { display: grid; gap: 6px; margin: 0 0 8px; }
.lw-resultart { display: block; width: 100%; max-width: 360px; height: auto; aspect-ratio: 1120 / 220; margin: 0 auto 10px; }
.lw-resultart[hidden] { display: none; }
.lw-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 7px 12px; border: 2px solid var(--gg-ink); border-radius: var(--gg-r-md); background: var(--gg-cream); font-size: var(--gg-text-sm); text-align: left; }
.lw-row b { font-family: var(--gg-font-display); font-size: 18px; font-variant-numeric: tabular-nums; }
.lw-row.is-good { background: var(--gg-lime-100); }
/* the playtest board line (platform/playtest.js renders it: "Saved to the Loopworm board: #3 this week" + Board) */
.lw-ptline { margin: 0 0 12px; }
.lw-ptline[hidden] { display: none; }
/* round 5 (Ariel 11-11): every card has a way home, to the garden's home page like the app bar's wordmark */
.lw-home { min-height: 44px; }
/* the pause sheet's confirm step for "End run here" */
.lw-confirm[hidden], .lw-btns[hidden] { display: none; }
.lw-confirm .lw-lede b { color: var(--gg-ink); font-family: var(--gg-font-display); }
@media (orientation: landscape) and (max-height: 500px) {
  .lw-modal .gg-modal__card { --gg-card-px: 20px; --gg-card-pb: 12px; width: min(640px, 100%); padding: 14px 20px 12px; max-height: calc(100svh - 16px); overflow: auto; }
  .lw-title { font-size: 36px; margin: 0 0 2px; }
  .lw-titleart { max-width: 240px; margin-bottom: 2px; }
  .lw-lede { margin: 0 0 10px; font-size: var(--gg-text-sm); }
  .lw-btns { grid-template-columns: 1fr 1fr; gap: 8px; }
  .lw-btns .gg-btn--lg { min-height: 48px; }
  .lw-btns > :only-child, .lw-btns > :first-child:has(+ [hidden]:last-child) { grid-column: 1 / -1; }
  /* with Home in the row: every visible button in one row (a third row would push the card past a short screen) */
  .lw-btns:has(> .lw-home) { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 1fr; }
  .lw-howlist { gap: 4px; margin-bottom: 10px; }
  .lw-resultcard { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; align-items: start; }
  .lw-resultcard > .gg-eyebrow, .lw-resultcard > .lw-h2, .lw-resultcard > .lw-best, .lw-resultcard > .lw-resultart { grid-column: 1; }
  .lw-resultcard > .lw-resultart { margin-bottom: 4px; }
  .lw-resultcard > .lw-rows { grid-column: 2; grid-row: 1 / span 4; margin-top: 4px; }
  .lw-resultcard > .lw-btns { grid-column: 1 / -1; }
  .lw-resultcard > .lw-ptline:not([hidden]) { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px 12px; margin: 4px 0 6px; padding: 6px 12px; text-align: left; }
  .lw-ptline .ggp-moment__line { flex: 1 1 auto; font-size: var(--gg-text-xs); margin: 0; }
  .lw-ptline .ggp-moment__row { flex: none; flex-wrap: nowrap; }
}
@media (max-width: 360px) { .lw-hint { font-size: 12.5px; padding: 6px 10px; } .lw-hud { gap: 4px; } .lw-hearts svg { width: 17px; height: 17px; } }
@media (prefers-reduced-motion: reduce) {
  .lw-hint, .lw-buds.is-up, .lw-score.is-up, .lw-hearts.is-hit { animation: none; }
  .lw-flash.is-on { animation: none; }
  .lw-side.is-hint::before { animation: none; opacity: .7; }
  .lw-side::before, .lw-side svg { transition: none; }
}
