/* Slope 26: riding with two thumbs (touch-controls.js).
   Left: a stick that comes to wherever the thumb lands. Right: POP in the corner with every trick round it. The
   line and the rider stay clear in the middle. */
/* The sizes live on the body, so the rest of the ride screen can stand clear of the controls by the same numbers.
   --touch-u is the layout unit (TOUCH_UNIT in touch-controls.js): it grows with the height of the screen up to a
   cap, an upright phone is held by its width, and the size setting multiplies it. Every place and size below is a
   number of units. */
body{--ride-touch-scale:1;
  --touch-u:calc(min(1.15px,100vh / 420,100vw / 480) * var(--ride-touch-scale));
  --touch-pop:calc(var(--touch-u) * 100);--touch-pad:calc(var(--touch-u) * 124);
  --touch-edge-x:max(14px,env(safe-area-inset-right));--touch-edge-left:max(14px,env(safe-area-inset-left));--touch-edge-y:max(12px,env(safe-area-inset-bottom));
  /* How far the tricks reach in from the side of the screen they are on, and up from its foot. */
  --touch-span:calc(var(--touch-u) * 314);--touch-rise:calc(var(--touch-u) * 278)}
@supports(height:100dvh){body{--touch-u:calc(min(1.15px,100dvh / 420,100vw / 480) * var(--ride-touch-scale))}}
.ride-touch{--ride-touch-opacity:.8;--side:1;position:fixed;inset:0;z-index:19;pointer-events:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;color:#f6f8f9;font-family:var(--body,Arial,sans-serif)}
.ride-touch[hidden],.ride-touch [hidden]{display:none!important}
.ride-touch-safe{position:absolute;inset:0 var(--touch-edge-x) var(--touch-edge-y) var(--touch-edge-left);pointer-events:none}
.ride-touch button{box-sizing:border-box;appearance:none;-webkit-appearance:none;pointer-events:auto;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent;color:inherit;cursor:pointer;outline-offset:4px;margin:0}
.ride-touch button:focus-visible{outline:3px solid #d7ecff;box-shadow:0 0 0 5px #191d24}
.ride-touch button:disabled{pointer-events:none}

/* ---------- The stick: anywhere on this side ---------- */
.ride-touch-zone{position:absolute;left:0;bottom:0;width:44%;top:32%;pointer-events:auto;touch-action:none}
.ride-touch.is-swapped .ride-touch-zone{left:auto;right:0}
.ride-touch-stick{position:absolute;left:calc(var(--touch-edge-left) + var(--touch-u) * 30);bottom:calc(var(--touch-edge-y) + var(--touch-u) * 22);width:var(--touch-pad);height:var(--touch-pad);pointer-events:none;opacity:calc(var(--ride-touch-opacity) * .7);transform:translate(var(--float-x,0px),var(--float-y,0px));transition:transform .2s cubic-bezier(.2,.8,.2,1),opacity .2s}
.ride-touch.is-swapped .ride-touch-stick{left:auto;right:calc(var(--touch-edge-x) + var(--touch-u) * 30)}
/* Under a thumb it is there at once; it only glides on the way home. */
.ride-touch-stick.is-held{opacity:var(--ride-touch-opacity);transition:none}
.ride-touch-ring{position:absolute;inset:0;border-radius:50%;border:1.5px solid var(--brand-blue-hi);background:var(--brand-hud);box-shadow:0 0 0 1px var(--brand-navy)}
.ride-touch-stick.is-held .ride-touch-ring{border-color:var(--brand-snow);box-shadow:0 0 0 2px var(--brand-blue)}
.ride-touch .ride-touch-arrow{position:absolute;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:1px;width:44px;height:44px;padding:0;border:0;background:none;border-radius:50%;pointer-events:none;color:#f6f8f9c7;text-shadow:0 1px 4px #000a}
.ride-touch-arrow b{font:700 10px/1 Arial,sans-serif}
.ride-touch-arrow span{font-size:9px;font-weight:850;letter-spacing:.06em;line-height:1}
.ride-touch-up{left:calc(50% - 22px);top:-3px}.ride-touch-down{left:calc(50% - 22px);bottom:-3px;flex-direction:column-reverse}.ride-touch-left{left:-5px;top:calc(50% - 22px)}.ride-touch-right{right:-5px;top:calc(50% - 22px)}
.ride-touch-arrow.is-held{color:#85c9ff}
.ride-touch-thumb{display:grid;place-items:center;position:absolute;left:50%;top:50%;width:calc(var(--touch-u) * 58);height:calc(var(--touch-u) * 58);box-sizing:border-box;border:1.5px solid var(--brand-blue-hi);border-radius:50%;background:var(--brand-raised);transform:translate(calc(-50% + var(--stick-x,0px)),calc(-50% + var(--stick-y,0px)));pointer-events:none;z-index:3}
.ride-touch-thumb i{display:block;width:23%;height:23%;border-radius:50%;background:var(--brand-snow)}
.ride-touch-stick.is-held .ride-touch-thumb{background:var(--brand-blue);border-color:var(--brand-focus)}.ride-touch-stick.is-held .ride-touch-thumb i{background:var(--brand-navy)}
.ride-touch-hint{position:absolute;left:50%;bottom:calc(100% + 7px);transform:translateX(-50%);font-size:9px;font-weight:850;letter-spacing:.12em;line-height:1;white-space:nowrap;color:#f6f8f9;text-shadow:0 1px 6px #000,0 0 2px #000;transition:opacity .4s}
.ride-touch.has-steered .ride-touch-hint,.ride-touch.is-fixed .ride-touch-hint{opacity:0}
/* Fullscreen waits at the foot of the screen under the rider, out of both thumbs' way. */
.ride-touch-fullscreen{position:absolute;left:calc(50% - 22px);bottom:var(--touch-edge-y);width:44px;height:44px;border:1px solid #e3f2ff44;border-radius:50%;background:#171b23b8;box-shadow:0 4px 15px #0002;font:700 22px/1 Arial,sans-serif;opacity:calc(var(--ride-touch-opacity) * .75)}

/* In the air the foot of the screen belongs to the air clock. */
.ride-touch.is-airborne .ride-touch-fullscreen{opacity:0;pointer-events:none}
/* ---------- The tricks: round POP in the corner ---------- */
.ride-touch-actions{position:absolute;right:calc(var(--touch-edge-x) + var(--touch-u) * 18);bottom:calc(var(--touch-edge-y) + var(--touch-u) * 12);width:var(--touch-pop);height:var(--touch-pop);opacity:var(--ride-touch-opacity)}
.ride-touch.is-swapped{--side:-1}
.ride-touch.is-swapped .ride-touch-actions{right:auto;left:calc(var(--touch-edge-left) + var(--touch-u) * 18)}
/* A near miss still counts (touch-controls.js): this box round the whole cluster is where a thumb is listened for. */
.ride-touch-reach{position:absolute;left:calc(50% - var(--touch-u) * 98 * var(--side) - var(--touch-u) * 148 - 16px);top:calc(50% - var(--touch-u) * 216 - 16px);width:calc(var(--touch-u) * 296 + 32px);height:calc(var(--touch-u) * 275 + 32px);border-radius:28px;pointer-events:auto;touch-action:none}
.ride-touch-button{position:absolute;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:2px;border:1.5px solid var(--brand-edge);border-radius:50%;background:var(--brand-navy);box-shadow:0 0 0 1px #09162470;padding:0;overflow:hidden;transition:transform 80ms ease-out,opacity 140ms}
/* Each trick stands where its numbers say, measured from the centre of POP (TOUCH_LAYOUT). */
.ride-touch-trick{--size:calc(var(--touch-u) * var(--bs));width:var(--size);height:var(--size);left:calc(50% + var(--touch-u) * var(--bx) * var(--side) - var(--size) / 2);top:calc(50% + var(--touch-u) * var(--by) - var(--size) / 2)}
.ride-touch-trick.tier-minor{opacity:.85}
.ride-touch-button>b{display:grid;place-items:center;color:var(--brand-snow)}
.ride-touch-button>b svg{display:block;width:calc(var(--size,56px) * .38);height:calc(var(--size,56px) * .38)}
.ride-touch-button>span{font-size:max(9px,calc(var(--size,56px) * .17));line-height:1;font-weight:850;letter-spacing:.02em;max-width:calc(100% - 6px);overflow:hidden;white-space:nowrap}
.ride-touch-button.is-held{background:var(--brand-blue);border-color:var(--brand-focus);color:var(--brand-navy);box-shadow:0 0 0 2px var(--brand-navy);transform:scale(.93);opacity:1;transition:none}
.ride-touch-button.is-held>b{color:var(--brand-navy)}
/* What cannot be used right now steps back, but stays where it is: thumbs learn places. */
.ride-touch:not(.is-airborne) .ride-touch-trick[data-touch-when=air]:not(.is-held),.ride-touch.is-airborne .ride-touch-trick[data-touch-when=snow]:not(.is-held){opacity:.62}
.ride-touch-pop{inset:0;width:100%;height:100%;--size:var(--touch-pop);overflow:visible;gap:0;background:var(--brand-blue);border:2px solid var(--brand-navy);color:var(--brand-navy);box-shadow:0 0 0 1px var(--brand-focus)}
.ride-touch-pop>b{color:var(--brand-navy)}.ride-touch-pop>b svg{width:calc(var(--touch-pop) * .3);height:calc(var(--touch-pop) * .3);stroke-width:2.6}
.ride-touch-pop>span{font-size:calc(var(--touch-pop) * .18);font-weight:950;letter-spacing:.05em;overflow:visible}
.ride-touch-pop>small{font-size:max(9px,calc(var(--touch-pop) * .1));line-height:1;font-weight:850;letter-spacing:.08em;color:var(--brand-navy);margin-top:2px}
.ride-touch-pop.is-held{background:var(--brand-blue-hi);border-color:var(--brand-navy);transform:scale(.93);box-shadow:0 0 0 2px var(--brand-blue)}
.ride-touch-pop.is-held>b{color:var(--brand-navy)}
/* The load is a ring that closes round POP. */
.ride-touch-charge{position:absolute;inset:-9px;border-radius:50%;background:conic-gradient(var(--brand-blue-hi) var(--pop-charge,0%),var(--brand-hud) 0);-webkit-mask:radial-gradient(farthest-side,#0000 calc(100% - 6px),#000 calc(100% - 5px));mask:radial-gradient(farthest-side,#0000 calc(100% - 6px),#000 calc(100% - 5px));pointer-events:none;opacity:0}
.ride-touch-pop.is-loading .ride-touch-charge{opacity:1}
.ride-touch-pop.is-full .ride-touch-charge{background:var(--brand-snow)}
.ride-touch .ride-touch-stick.is-fitted,.ride-touch .ride-touch-button.is-fitted{left:var(--fit-left);top:var(--fit-top);right:auto;bottom:auto;width:var(--fit-size);height:var(--fit-size);--size:var(--fit-size)}
.ride-touch .ride-touch-stick.is-fitted .ride-touch-thumb{width:calc(var(--size) * .4677);height:calc(var(--size) * .4677)}
.ride-touch .ride-touch-stick.is-fitted{opacity:calc(var(--ride-touch-opacity) * var(--fit-alpha) * .7)}
.ride-touch .ride-touch-stick.is-fitted.is-held{opacity:calc(var(--ride-touch-opacity) * var(--fit-alpha))}
.ride-touch .ride-touch-button.is-fitted:not(.is-held){opacity:var(--fit-alpha)}
.ride-touch:not(.is-airborne) .ride-touch-trick.is-fitted[data-touch-when=air]:not(.is-held){opacity:calc(var(--fit-alpha) * .62)}
.ride-touch .ride-touch-pop.is-fitted>b svg{width:calc(var(--size) * .3);height:calc(var(--size) * .3)}
.ride-touch .ride-touch-pop.is-fitted>span{font-size:max(10px,calc(var(--size) * .18))}
.ride-touch .ride-touch-pop.is-fitted>small{font-size:max(9px,calc(var(--size) * .1))}

.ride-touch-rotate{position:absolute;left:50%;top:calc(max(10px,env(safe-area-inset-top)) + 82px);transform:translateX(-50%);box-sizing:border-box;width:min(340px,calc(100vw - 28px));display:flex;align-items:center;gap:10px;padding:8px 6px 8px 13px;border:1px solid #d4ebff55;border-radius:14px;background:#1b232df2;box-shadow:0 6px 24px #0004;pointer-events:auto}
.ride-touch-rotate>span{font-size:30px;color:#73c1ff}.ride-touch-rotate p{display:grid;gap:5px;margin:0;flex:1}.ride-touch-rotate strong{font-size:10px;letter-spacing:.04em}.ride-touch-rotate small{font-size:11px;line-height:1.35;color:#d1dae2}.ride-touch-rotate button{flex:none;width:44px;height:44px;min-width:44px;min-height:44px;border:0;border-radius:10px;background:#ffffff0e;font:400 26px/1 Arial,sans-serif}
@media(hover:hover) and (pointer:fine){.ride-touch-button:hover{border-color:#afddfe}}
/* A phone held upright: the stick's side starts lower, and fullscreen moves out from under the tricks. */
@media(orientation:portrait) and (max-width:600px){.ride-touch-zone{top:56%;width:50%}.ride-touch-fullscreen{left:var(--touch-edge-left);bottom:auto;top:calc(56% - 52px)}.ride-touch.is-swapped .ride-touch-fullscreen{left:auto;right:var(--touch-edge-x)}}
body.reduced-motion .ride-touch *{animation:none!important;transition:none!important}
@media(prefers-reduced-motion:reduce){.ride-touch *{animation:none!important;transition:none!important}}
/* Reserve actual HUD columns and thumb-zone clearance, including tall tablets. */
@media(orientation:landscape){
  body.playing.ride-touch-active:is([data-sport=ski],[data-sport=snowboard]) .hud-top-right{grid-template-columns:minmax(64px,1fr) 94px;column-gap:16px;width:clamp(200px,27vw,260px);max-width:none;right:max(18px,env(safe-area-inset-right))}
  body.playing.ride-touch-active:is([data-sport=ski],[data-sport=snowboard]) .score-panel{min-width:0;padding-right:4px}
  body.playing.ride-touch-active:is([data-sport=ski],[data-sport=snowboard]) .game-actions{gap:6px;justify-self:end}
  body.playing.ride-touch-active:is([data-sport=ski],[data-sport=snowboard]) .game-actions button{width:44px;min-width:44px;padding:0}
  body.playing.ride-touch-active .game-actions kbd{display:none}
  body.playing.ride-touch-active:is([data-sport=ski],[data-sport=snowboard]) :is(.ride-meter,.minimap-wrap){bottom:calc(max(24px,env(safe-area-inset-bottom)) + 276px)}
}
@media(orientation:landscape) and (max-height:500px){
  body.playing.ride-touch-active:is([data-sport=ski],[data-sport=snowboard]) .hud-top-right{top:10px;width:clamp(190px,27vw,230px)}
  body.playing.ride-touch-active:is([data-sport=ski],[data-sport=snowboard]) .score-panel strong{font-size:32px}
  body.playing.ride-touch-active:is([data-sport=ski],[data-sport=snowboard]) .ride-meter{bottom:calc(max(8px,env(safe-area-inset-bottom)) + 192px)}
  /* The trail map hangs from the top here, a size smaller, so it ends above the grab that stands over POP. */
  body.playing.ride-touch-active:is([data-sport=ski],[data-sport=snowboard]) .minimap-wrap{bottom:auto;top:calc(max(10px,env(safe-area-inset-top)) + 76px)}
  body.playing.ride-touch-active:is([data-sport=ski],[data-sport=snowboard]) .minimap-wrap.trail #minimap{width:50px!important;height:clamp(60px,calc(100vh - 104px - var(--touch-u) * 202),104px)!important}
}
/* An upright phone: the hint line and the trail map stand clear above the tricks. */
@media(orientation:portrait){
  body.playing.ride-touch-active:is([data-sport=ski],[data-sport=snowboard]) .status{top:auto;bottom:calc(max(10px,env(safe-area-inset-bottom)) + 258px)}
  body.playing.ride-touch-active:is([data-sport=ski],[data-sport=snowboard]) .minimap-wrap{bottom:var(--touch-actions-clearance,calc(max(10px,env(safe-area-inset-bottom)) + 236px))}
  /* The air clock goes above the stick's corner. */
  body.playing.ride-touch-active:is([data-sport=ski],[data-sport=snowboard]) .air-hud .air-clock{right:auto;left:var(--touch-edge-left);text-align:left;bottom:calc(var(--touch-edge-y) + var(--touch-pad) + 64px)}
  body.playing.ride-touch-active.ride-touch-swapped:is([data-sport=ski],[data-sport=snowboard]) .air-hud .air-clock{left:auto;right:var(--touch-edge-x);text-align:right}
}
/* Held sideways, the air clock used to hide behind the tricks. It stands at the foot of the screen beside them. */
@media(orientation:landscape){
  body.playing.ride-touch-active:is([data-sport=ski],[data-sport=snowboard]) .air-hud .air-clock{right:calc(var(--touch-edge-x) + var(--touch-span) + 16px);bottom:var(--touch-edge-y)}
  body.playing.ride-touch-active.ride-touch-swapped:is([data-sport=ski],[data-sport=snowboard]) .air-hud .air-clock{right:auto;left:calc(var(--touch-edge-left) + var(--touch-span) + 16px);text-align:left}
}
/* Portrait phones: lift the speed readout clear of the touch tools above the steering pad. */
@media(orientation:portrait) and (max-width:600px){
  body.playing.ride-touch-active:is([data-sport=ski],[data-sport=snowboard]) .ride-meter{bottom:calc(max(12px,env(safe-area-inset-bottom)) + 214px)}
}
@media(orientation:portrait) and (max-width:600px){
  body.playing.touch-enabled:is([data-sport=ski],[data-sport=snowboard]) .status{top:calc(var(--callout-top,20%) + 150px);bottom:auto;max-width:86vw}
}
/* Short landscape phones: callouts stay above the rider, routine status drops between the thumb zones. */
@media(orientation:landscape) and (max-height:500px){
  :root{--callout-top:19%}
  body.playing .land-grade{top:calc(var(--callout-top) + 82px)}
  body.playing .land-grade b{font-size:18px;padding:4px 10px}
  body.playing .land-grade span{font-size:15px}
  body.playing.touch-enabled:is([data-sport=ski],[data-sport=snowboard]) .status{top:auto;bottom:max(10px,env(safe-area-inset-bottom));max-width:40vw;font-size:12px}
}
