@import url("https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600&family=Permanent+Marker&family=Caveat:wght@500;700&display=swap");

/* Wet Paint: one WebGL canvas (#gl) lights the wall from a height field; #scene (2D, transparent over the wall)
   holds the trim, drop cloth, ladder, tray, signs and the painter; #finger is a DOM cursor. */
:root {
  --font: "Geist", system-ui, -apple-system, sans-serif;
  --ink: #f2f0ea;
  --panel: rgba(18, 20, 24, 0.72);
  --line: rgba(255, 255, 255, 0.2);
}

*,*::before,*::after { box-sizing: border-box; }
html, body {
  -webkit-tap-highlight-color: transparent; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body { font-family: var(--font); color: var(--ink); touch-action: none; background: #0b4a52; }

canvas {
  display: block; position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
#gl { z-index: 1; cursor: none; }
#scene { z-index: 2; pointer-events: none; }

/* the fingertip cursor (mouse and pen only; a real finger is its own cursor) */
#finger { position: fixed; left: 0; top: 0; z-index: 7; pointer-events: none; display: none; will-change: transform; }
#finger.is-on { display: block; }
#fingerCv { position: absolute; left: -34px; top: -26px; width: 100px; height: 168px; inset: auto; pointer-events: none;
  transform-origin: 34px 26px; transform: scale(0.92); transition: transform 0.09s ease-out; }
#finger.is-down #fingerCv { transform: scale(0.84) translate(0, 1px); }
.finger__shadow { position: absolute; left: -14px; top: -10px; width: 36px; height: 36px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0,0,0,0.42), rgba(0,0,0,0)); transform: translate(16px, 14px) scale(1.25);
  opacity: 0.8; transition: transform 0.09s ease-out, opacity 0.09s; }
#finger.is-down .finger__shadow { transform: translate(3px, 3px) scale(0.9); opacity: 0.55; }
body.is-dry #finger.is-on .finger__shadow { opacity: 0.5; }

.sound-btn {
  appearance: none; position: fixed; z-index: 12; cursor: pointer; padding: 0;
  top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: transform 0.12s ease, opacity 0.15s ease;
}
.sound-btn:active { transform: scale(0.94); }
.sound-btn[aria-pressed="false"] { opacity: 0.6; }
.sound-btn[aria-pressed="false"] .sound-btn__wave { opacity: 0; }
.sound-btn:focus-visible, .play-btn:focus-visible, .opt-share:focus-visible { outline: 2px dashed rgba(255, 255, 255, 0.9); outline-offset: 2px; }

.frame { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.frame__corner {
  position: absolute; font-size: clamp(0.58rem, 1.2vw, 0.7rem); font-weight: 600;
  letter-spacing: 0.22em; text-transform: uppercase; color: rgba(255, 255, 255, 0.78);
  white-space: nowrap; font-family: var(--font); text-shadow: 0 1px 7px rgba(0, 0, 0, 0.85), 0 0 2px rgba(0, 0, 0, 0.6);
}
.frame__corner--tl { top: calc(max(12px, env(safe-area-inset-top)) + 13px); left: max(18px, env(safe-area-inset-left)); }
.frame__corner--tr { top: calc(max(12px, env(safe-area-inset-top)) + 13px); right: calc(max(12px, env(safe-area-inset-right)) + 54px); }
.frame__corner--bl { bottom: max(18px, env(safe-area-inset-bottom)); left: max(18px, env(safe-area-inset-left)); }
.frame__corner a { color: inherit; text-decoration: none; pointer-events: auto; border-bottom: 1px solid transparent; transition: color .14s, border-color .14s; }
.frame__corner a:hover { color: #fff; border-bottom-color: rgba(255, 255, 255, 0.6); }

.hint {
  position: fixed; top: calc(max(12px, env(safe-area-inset-top)) + 48px); left: 50%; transform: translateX(-50%);
  width: min(88vw, 560px); margin: 0; text-align: center; z-index: 9; pointer-events: none;
  font-size: 0.66rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; line-height: 1.6;
  color: rgba(255, 255, 255, 0.86); text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.5); transition: opacity .8s;
}
.hint.is-hidden { opacity: 0; }

/* what the painter says, as a caption */
.sub {
  position: fixed; left: 50%; bottom: calc(max(86px, env(safe-area-inset-bottom) + 70px)); transform: translateX(-50%) translateY(6px);
  z-index: 9; margin: 0; max-width: min(88vw, 520px); padding: 8px 16px; border-radius: 10px; text-align: center;
  font-size: clamp(0.82rem, 2.6vw, 1rem); font-weight: 500; line-height: 1.35; color: #fff; letter-spacing: 0.01em;
  background: rgba(10, 12, 14, 0.74); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease;
}
.sub.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }
.sub:empty { display: none; }

/* the end card */
.card {
  position: fixed; z-index: 20; left: 50%; top: 46%; transform: translate(-50%, -50%);
  width: min(88vw, 360px); padding: 18px 20px 16px; border-radius: 16px; text-align: center;
  color: #f4f2ec; background: rgba(15, 17, 20, 0.86); border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.08) inset;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: card-in 0.45s cubic-bezier(.2,.8,.2,1) both;
}
.card[hidden] { display: none; }
@keyframes card-in { from { opacity: 0; transform: translate(-50%, -46%) scale(0.97); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.card__eyebrow { margin: 0 0 6px; font-size: 0.62rem; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; color: var(--wall, #5fc4cf); }
.card__title { margin: 0 0 14px; font-size: clamp(1.3rem, 5.4vw, 1.6rem); font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; }
.stats { margin: 0 0 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { padding: 9px 4px 8px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.08); }
.stats dt { font-size: 0.56rem; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(255, 255, 255, 0.55); margin: 0 0 3px; }
.stats dd { margin: 0; font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.card__note { margin: 0 0 14px; min-height: 1.2em; font-size: 0.82rem; line-height: 1.4; color: rgba(255, 255, 255, 0.72); }
.card__note:empty { display: none; }
.card__row { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.share-host { display: inline-flex; }
.share-host:empty { display: none; }
.play-btn, .card .opt-share.opt-share {
  appearance: none; cursor: pointer; font-family: var(--font); display: inline-flex; align-items: center; justify-content: center; height: 40px; margin: 0; padding: 0 16px;
  border-radius: 999px; font-size: 0.82rem; font-weight: 600; letter-spacing: 0.01em; opacity: 1; text-decoration: none;
  color: #f4f2ec; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.2); touch-action: manipulation;
  transition: transform 0.12s ease, background 0.15s ease;
}
.play-btn { color: #101214; background: #f4f2ec; border-color: transparent; }
.play-btn:hover { background: #fff; }
.card .opt-share.opt-share:hover { background: rgba(255, 255, 255, 0.16); }
.play-btn:active, .card .opt-share.opt-share:active { transform: scale(0.96); }

/* tip-jar and fullscreen badges sit bottom-right, off the play area (doubled classes out-specify the injected styles) */
.opt-tipjar.opt-tipjar { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); transform: none; }
.opt-fs.opt-fs { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); right: calc(max(14px, env(safe-area-inset-right)) + 54px); transform: none; }
.opt-tipjar.opt-tipjar.tj-nudge { animation: none; }

@media (max-width: 520px) { .hint { width: 96vw; letter-spacing: 0.1em; font-size: 0.62rem; } }
/* a phone on its side is short: the card goes two columns and the hint tucks up */
@media (orientation: landscape) and (max-height: 500px) {
  .hint { top: calc(max(10px, env(safe-area-inset-top)) + 40px); }
  .card { width: min(92vw, 560px); padding: 12px 16px 12px; display: grid; grid-template-columns: 1.05fr 1fr; column-gap: 18px; text-align: left; align-items: center; top: 50%; }
  .card__eyebrow, .card__title, .card__note { grid-column: 1; }
  .card__title { margin-bottom: 6px; font-size: 1.25rem; }
  .stats { grid-column: 2; grid-row: 1 / span 3; margin: 0 0 8px; }
  .card__row { grid-column: 1 / span 2; justify-content: flex-start; }
  .card__note { margin-bottom: 8px; }
  .sub { bottom: 62px; }
}
@media (prefers-reduced-motion: reduce) { .hint, .sub, .sound-btn, .play-btn { transition: none; } .card { animation: none; } #fingerCv, .finger__shadow { transition: none; } }
