/* Motion and drawings for the Wrong House home page.
   Idea: everything here is drawn in ink on paper, so marks draw themselves
   in as they scroll into view. Content is always visible by default; the
   hidden "before" states only apply once the page adds the .mo class, which
   it skips for people who prefer reduced motion. */

:root{--out:cubic-bezier(.16,1,.3,1)}

/* Hero: the lime highlighter swipes in behind "Right Vibe" */
.swipe{background-repeat:no-repeat;background-size:100% 100%;animation:swipe .7s var(--out) .3s both}
@keyframes swipe{from{background-size:0% 100%}to{background-size:100% 100%}}

/* Shared drawing style */
.doodle{display:block;overflow:visible}
.doodle .s{fill:none;stroke:var(--ink);stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round}
.doodle .lf{fill:var(--lime)}
.doodle .pf{fill:var(--card)}
.doodle .kf{fill:var(--ink)}

/* Lines that draw themselves. Each path has pathLength="1". */
.draw{stroke-dasharray:1;stroke-dashoffset:0;transition:stroke-dashoffset .9s var(--out)}
.fillin{transition:opacity .5s ease .35s}
.mo [data-in]:not(.in) .draw{stroke-dashoffset:1}
.mo [data-in]:not(.in) .fillin{opacity:0}
/* stagger the strokes inside one drawing */
.draw.d1{transition-delay:.12s}.draw.d2{transition-delay:.24s}.draw.d3{transition-delay:.36s}

/* Marker squiggle under section headings */
.squig{width:clamp(120px,32vw,210px);height:auto;margin-top:12px}
.squig path{fill:none;stroke:var(--lime);stroke-width:6;stroke-linecap:round}
.squig .draw{transition-duration:1.1s}

/* Facts strip: a small drawing beside each fact */
.facts div{display:grid;grid-template-columns:auto 1fr;column-gap:16px;align-items:center}
.facts .fi{grid-row:span 2;width:52px;height:52px}
.facts div:nth-child(2) .draw{transition-delay:.1s}.facts div:nth-child(2) .draw.d1{transition-delay:.22s}.facts div:nth-child(2) .draw.d2{transition-delay:.34s}
.facts div:nth-child(3) .draw{transition-delay:.2s}.facts div:nth-child(3) .draw.d1{transition-delay:.32s}.facts div:nth-child(3) .draw.d2{transition-delay:.44s}

/* Book a court: the pickleball flies in, bounces twice and rolls to a stop.
   Tap it to give it another hit. Choreography lives in motion.js. */
.rally{width:clamp(170px,24vw,250px);margin-top:8px;cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;user-select:none}
.rally svg{display:block;width:100%;height:auto;overflow:visible}
.rl-x,.rl-y,.rl-squash{transform-box:fill-box}
.rl-squash{transform-origin:50% 100%}
/* holes spin around the ball's centre; the shading and shine stay put, like light on a real ball */
.rl-spin{transform-box:view-box;transform-origin:70px 90px;fill:#24280c}
.rl-shade{fill:#a3ae35}.rl-face{fill:var(--lime)}.rl-shine{fill:#eef2c2;opacity:.75}
.rl-rim{fill:none;stroke:var(--ink);stroke-width:7;stroke-linejoin:round}
.rl-line{fill:none;stroke:var(--ink);stroke-width:7;stroke-linecap:round;stroke-dasharray:1 2;stroke-dashoffset:0}
.mo .rally:not(.in) .rl-x{opacity:0}
.mo .rally:not(.in) .rl-line{stroke-dashoffset:1.02}

/* The place: courts settle in one after another, then each net is drawn across */
.mo #place .map[data-in]:not(.in) .ct{opacity:0}
.mo #place .map.in:not(.done) .ct{animation:ctIn .6s var(--out) both}
.mo #place .map.in:not(.done) .ct .net{animation:netIn .5s var(--out) both;transform-origin:left center}
#place .ct:nth-child(2){animation-delay:.06s}#place .ct:nth-child(3){animation-delay:.12s}#place .ct:nth-child(4){animation-delay:.18s}#place .ct:nth-child(5){animation-delay:.24s}#place .ct:nth-child(6){animation-delay:.3s}
#place .ct .net{animation-delay:.35s}#place .ct:nth-child(2) .net{animation-delay:.41s}#place .ct:nth-child(3) .net{animation-delay:.47s}#place .ct:nth-child(4) .net{animation-delay:.53s}#place .ct:nth-child(5) .net{animation-delay:.59s}#place .ct:nth-child(6) .net{animation-delay:.65s}
@keyframes ctIn{from{opacity:0;transform:translateY(18px)}to{opacity:1;transform:none}}
@keyframes netIn{from{transform:scaleX(0)}to{transform:scaleX(1)}}

/* Rain and rebooking: a sticker drawing on each card */
.rules{margin-top:48px;row-gap:42px}
.rule{position:relative}
.stk{position:absolute;top:-36px;right:16px;width:58px;height:58px;transform:rotate(7deg);pointer-events:none}
.rule.alt .stk{transform:rotate(-6deg)}
.stk .drop{animation:drop 1.6s linear infinite;animation-play-state:paused}
.stk .drop:nth-child(2){animation-delay:-.55s}.stk .drop:nth-child(3){animation-delay:-1.1s}
.stk.live .drop{animation-play-state:running}
@keyframes drop{0%{transform:translateY(-3px);opacity:0}25%{opacity:1}80%{opacity:1}100%{transform:translateY(7px);opacity:0}}
.stk .rays{transform-origin:29px 29px;animation:spin 30s linear infinite;animation-play-state:paused}
.stk.live .rays{animation-play-state:running}
@keyframes spin{to{transform:rotate(360deg)}}

/* Find us: a pin drops onto the map */
.mapwrap{position:relative}
.pin{position:absolute;z-index:2;top:-30px;left:26px;width:42px;height:54px;filter:drop-shadow(2px 3px 0 rgba(17,17,17,.18))}
.mo .mapwrap[data-in]:not(.in) .pin{opacity:0;transform:translateY(-36px)}
.pin{transition:opacity .25s ease,transform .7s var(--out)}

/* No movement for people who ask for less of it */
@media(prefers-reduced-motion:reduce){
  .swipe{animation:none}
  .draw,.fillin,.pin{transition:none}
}
@media(max-width:560px){
  .facts .fi{width:46px;height:46px}
  .stk{width:52px;height:52px;top:-33px;right:12px}
  .pin{left:18px}
}

/* Hero scene: Wrong House at dusk. The rally is driven by motion.js; the rest are slow CSS loops
   that pause when the scene is off screen. */
.hx-vid{background:var(--card)}
.scene{position:absolute;inset:0;width:100%;height:100%;display:block}
.scene *{transform-box:view-box}
.scene:not(.live) *{animation-play-state:paused!important}
/* The moving parts get their own layer, so each frame only redraws them and the
   backdrop underneath is drawn once and reused. */
.sc-fg{pointer-events:none;will-change:transform}
/* set by motion.js during a game, or for the whole visit on a slow phone */
.sc-still .scene *{animation-play-state:paused!important}
.sc-fronds{animation:sway 6s ease-in-out infinite alternate}
.sc-palm:nth-of-type(2n) .sc-fronds{animation-duration:7.5s;animation-direction:alternate-reverse}
@keyframes sway{from{transform:rotate(-2.5deg)}to{transform:rotate(2.5deg)}}
.sc-cloud{animation:drift 26s ease-in-out infinite alternate}
.sc-cloud2{animation-duration:34s;animation-direction:alternate-reverse}
.sc-cloud3{animation-duration:30s}
@keyframes drift{from{transform:translateX(-30px)}to{transform:translateX(40px)}}
.sc-steam path{animation:steam 3.2s ease-out infinite}
.sc-steam path:nth-child(2){animation-delay:-1.6s}
@keyframes steam{0%{transform:translateY(8px);opacity:0}30%{opacity:.8}100%{transform:translateY(-18px);opacity:0}}

/* The rally game: the whole scene is one big button, with a score chip on top */
.sc-play{position:absolute;inset:0;z-index:1;width:100%;height:100%;padding:0;border:0;background:none;cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;border-radius:inherit}
.sc-play:focus-visible{outline:3px solid var(--ink);outline-offset:-8px}
.sc-hud{position:absolute;z-index:2;top:14px;left:14px;right:14px;display:flex;flex-wrap:wrap;align-items:flex-start;gap:8px;pointer-events:none}
.sc-msg{font:700 15px/1.25 var(--hand);background:var(--lime);border:2.5px solid var(--ink);border-radius:var(--sk);padding:7px 14px;box-shadow:3px 3px 0 var(--ink);max-width:100%}
.sc-msg:empty{display:none}
.sc-score{order:-1;display:flex;align-items:baseline;gap:10px;background:var(--card);border:2.5px solid var(--ink);border-radius:var(--box);padding:5px 12px;font:600 14px var(--hand)}
.sc-score[hidden]{display:none}
.sc-score b{font:800 21px var(--hand)}
@media(max-width:560px){.sc-hud{top:8px;left:8px;right:8px;gap:6px}.sc-msg{font-size:13px;padding:4px 10px;border-width:2px;box-shadow:2px 2px 0 var(--ink)}.sc-score{padding:3px 9px;gap:8px;font-size:12px;border-width:2px}.sc-score b{font-size:17px}}

/* Personal best: a small button by the game chips, and a scorecard over the scene */
.sc-bestbtn{pointer-events:auto;font:700 14px/1.2 var(--hand);color:var(--ink);background:var(--card);border:2.5px solid var(--ink);border-radius:var(--sk2);padding:6px 12px;box-shadow:3px 3px 0 var(--ink);cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:transform .14s var(--out),box-shadow .14s var(--out)}
.sc-bestbtn:hover{background:#fff}
.sc-bestbtn:active{transform:translate(3px,3px);box-shadow:0 0 0 var(--ink)}
.sc-bestbtn[hidden]{display:none}
.sc-board{position:absolute;z-index:3;left:50%;top:50%;transform:translate(-50%,-50%);width:min(calc(100% - 24px),360px);max-height:calc(100% - 24px);overflow:auto;background:var(--card);border:2.5px solid var(--ink);border-radius:var(--card-r);box-shadow:6px 6px 0 var(--ink);padding:20px 22px 18px;display:flex;flex-direction:column;gap:14px;text-align:left;animation:boardIn .3s var(--out) both}
.sc-board [data-board-body]{display:flex;flex-direction:column;gap:14px;min-width:0}
@keyframes boardIn{from{opacity:0;transform:translate(-50%,-46%)}to{opacity:1;transform:translate(-50%,-50%)}}
.sc-board[hidden]{display:none}
.sc-board h3{font-size:22px}
.sc-board h3{margin:0;line-height:1.1}
.sc-board h4{margin:4px 0 -8px;font:700 13px var(--hand);text-transform:uppercase;letter-spacing:.06em;color:var(--mute)}
.sc-big{margin:0;display:flex;flex-direction:column;gap:6px}
.sc-big b{font:800 36px/1 var(--hand)}
.sc-big span{font-size:14px;color:var(--mute)}
.sc-recent{margin:0;padding:0;list-style:none;display:flex;flex-direction:column}
.sc-recent li{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:9px 0;border-top:1.5px dashed rgba(17,17,17,.25);font-size:15px}
.sc-recent li:last-child,.sc-rank li:last-child{border-bottom:1.5px dashed rgba(17,17,17,.25)}
.sc-recent li b{font:700 15px var(--hand);font-variant-numeric:tabular-nums}
.sc-recent li.top b{background:var(--lime);border-radius:6px;padding:0 6px}
.sc-meta{margin:0;font-size:13px;color:var(--mute)}
.sc-close{align-self:flex-start;margin-top:2px;font:700 15px var(--hand);background:var(--lime);color:var(--ink);border:2.5px solid var(--ink);border-radius:var(--sk);padding:7px 16px;box-shadow:3px 3px 0 var(--ink);cursor:pointer}
.sc-close:active{transform:translate(3px,3px);box-shadow:0 0 0 var(--ink)}
@media(max-width:560px){
  .sc-bestbtn{font-size:13px;padding:4px 10px;border-width:2px;box-shadow:2px 2px 0 var(--ink)}
  .sc-board{padding:16px 18px 16px;gap:12px}
  .sc-board [data-board-body]{gap:12px}
  .sc-board h3{font-size:19px}
  .sc-big b{font-size:30px}
  .sc-recent li{padding:7px 0;font-size:14px}
}

/* Shared leaderboard inside the scorecard */
.sc-board:focus{outline:none}
.sc-tabs{display:flex;gap:6px;flex-wrap:wrap}
.sc-tabs button{font:700 14px var(--hand);color:var(--ink);background:var(--card);border:2px solid var(--ink);border-radius:999px;padding:4px 12px;cursor:pointer}
.sc-tabs button[aria-pressed="true"]{background:var(--lime)}
.sc-rank{margin:0;padding:0;list-style:none;display:flex;flex-direction:column}
.sc-rank li{display:grid;grid-template-columns:1.25em 1fr auto;align-items:center;gap:12px;padding:9px 0;border-top:1.5px dashed rgba(17,17,17,.25);font-size:15px}
.sc-rank li i{font:700 15px var(--hand);font-style:normal;color:var(--mute);text-align:left;font-variant-numeric:tabular-nums}
.sc-rank li span{min-width:0;display:flex;flex-direction:column;gap:2px;overflow-wrap:anywhere;font-weight:600;line-height:1.25}
.sc-rank li small{font-size:12px;font-weight:400;color:var(--mute)}
.sc-rank li b{font:700 15px var(--hand);font-variant-numeric:tabular-nums}
.sc-rank li.me b{background:var(--lime);border-radius:6px;padding:0 6px}
.sc-lead{margin:0;font-size:16px}
.sc-form{display:flex;flex-direction:column;gap:8px}
.sc-form label{gap:6px;font:700 14px var(--hand)}
.sc-form input{font-size:17px;padding:10px 12px}
.sc-hint{font-size:13px;color:var(--mute)}
.sc-err{margin:0;font-size:14px;color:#8a1c0f;min-height:0}
.sc-err:empty{display:none}
.sc-form input[aria-invalid="true"]{border-color:#8a1c0f;box-shadow:3px 3px 0 #8a1c0f}
.sc-err.shake{animation:errShake .4s var(--out)}
@keyframes errShake{20%{transform:translateX(-5px)}45%{transform:translateX(4px)}70%{transform:translateX(-2px)}100%{transform:none}}
@media(prefers-reduced-motion:reduce){.sc-err.shake{animation:none}}
.sc-acts{display:flex;align-items:center;gap:14px;flex-wrap:wrap}
.sc-skip{background:none;border:none;padding:8px 0;font:700 15px var(--hand);text-decoration:underline;text-decoration-color:var(--lime);text-decoration-thickness:3px;text-underline-offset:3px;cursor:pointer;color:var(--ink)}
.sc-close:disabled{opacity:.6;cursor:wait}
@media(max-width:560px){.sc-rank li{padding:7px 0;gap:10px;font-size:14px}.sc-rank li small{display:none}.sc-tabs button{font-size:13px;padding:3px 10px}}
