/* Phone controls, onboarding, accessibility. Loaded after style.css; see src/ux.js. */

/* ===================== touch controls ===================== */
/* A wider steer zone that starts under the top HUD row and runs to the bottom. The buttons sit
   above it in the stack, so they always win a touch. */
#steer-zone { left: 0; right: auto; top: calc(60px + var(--safe-t)); bottom: 0; width: 55%; }
.t-brake { width: 76px; height: 76px; right: 22px; bottom: 118px; font-size: 12px; }
.t-gas { width: 76px; height: 76px; right: 118px; bottom: 108px; font-size: 13px; }
body.autogas.on-grid .t-gas { width: 88px; height: 88px; right: 134px; bottom: 104px; }
.t-item, .t-drift, .t-brake, .t-gas { touch-action: none; }
.t-drift.auto { box-shadow: 0 0 0 4px rgba(127, 216, 255, .35), 0 4px 14px rgba(0, 0, 0, .35); }
/* the item box in the HUD is a big second item button */
body.is-touch .hud-tr .item-slot { pointer-events: auto; touch-action: none; }

/* left-hand layout: the stick goes to the right, the buttons to the left */
body.lefty #steer-zone { left: auto; right: 0; top: calc(104px + var(--safe-t)); }
body.lefty #stick-base { left: calc(100% - 110px - var(--safe-r)); }
body.lefty .zone-hint { left: auto; right: calc(40px + var(--safe-r)); }
body.lefty #touch-buttons { right: auto; left: calc(12px + var(--safe-l)); }
body.lefty .t-drift { right: auto; left: 0; }
body.lefty .t-item { right: auto; left: 116px; }
body.lefty .t-brake { right: auto; left: 22px; }
body.lefty .t-gas { right: auto; left: 118px; }
body.lefty.autogas.on-grid .t-gas { right: auto; left: 134px; }
/* with the buttons on the left, the minimap and lap readout move clear of them */
body.lefty.is-touch #minimap { left: auto; right: calc(112px + var(--safe-r)); top: calc(8px + var(--safe-t)); }
body.lefty.is-touch .hud-br { right: auto; left: calc(112px + var(--safe-l)); align-items: flex-start; }

/* ===================== options: tabs ===================== */
#options .menu-panel.ux-options { width: min(780px, 100%); display: block; }
.ux-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.ux-head h2 { margin: 0; flex: 0 0 auto; }
.ux-tabs { display: flex; gap: 6px; flex: 1; }
.ux-tab { flex: 1; padding: 8px 6px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.05); font-weight: 800; font-size: 14px; }
.ux-tab.on { background: var(--gold); color: #2a1a00; border-color: var(--gold); }
.ux-back { width: auto; padding: 8px 18px; }
.ux-tabpanel { display: none; }
.ux-tabpanel.on { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 26px; align-content: start; }
.ux-tabpanel > h3, .ux-tabpanel > .seg, .ux-tabpanel > .opt-note { grid-column: 1 / -1; }
.ux-tabpanel > .opt-note { margin: -6px 0 6px; }
.ux-tabpanel > .btn { align-self: center; }
.ux-tabpanel .slider { gap: 10px; }
.ux-tabpanel .slider > span:first-child { flex: 0 0 auto; }
.ux-tabpanel .slider input { max-width: none; min-width: 0; }
.ux-val { min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.ux-hidden { display: none !important; }
#options.ux-over { z-index: 30; }
.ux-from-pause .ux-gfx { display: none; }
@media (max-width: 640px) {
  .ux-tabpanel.on { grid-template-columns: 1fr; }
  .ux-head { flex-wrap: wrap; }
  .ux-tabs { order: 3; flex: 1 1 100%; }
}

/* ===================== pause screen ===================== */
@media (max-height: 520px) {
  #pause .menu-panel.narrow { width: min(560px, 100%); display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; align-items: center; }
  #pause .menu-panel h2, #pause .big-btn { grid-column: 1 / -1; }
  #pause .menu-panel h2 { margin: 0; }
}

.ux-toast { position: fixed; left: 50%; bottom: calc(20px + var(--safe-b)); transform: translate(-50%, 10px); z-index: 65; max-width: min(520px, 86vw);
  padding: 9px 16px; border-radius: 14px; background: rgba(10,14,30,.88); border: 1px solid var(--line); font-weight: 700; font-size: 14px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.ux-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===================== first launch prompt ===================== */
.ux-setup { z-index: 40; background: radial-gradient(ellipse at 50% 30%, rgb(29,42,92), rgb(5,8,20) 75%); }
.uxs-panel { display: grid; grid-template-columns: 1fr 1.1fr; gap: 22px; width: min(900px, 100%); align-items: center; }
.uxs-panel h2 { margin: 0 0 8px; font-size: 26px; }
.uxs-preview { margin-bottom: 6px; }
.uxs-preview svg { width: 100%; height: auto; display: block; }
.uxs-right { display: flex; flex-direction: column; gap: 6px; }
.uxs-group h3 { margin: 0 0 6px; }
.uxs-group .seg { margin-bottom: 8px; }
.uxs-group .seg button { padding: 7px 8px; }
.uxs-group .seg b { display: block; font-size: 15px; }
.uxs-group .seg small { display: block; font-size: 12px; font-weight: 600; opacity: .8; }
.uxs-right .big-btn { margin-top: 4px; }
@media (max-width: 700px) { .uxs-panel { grid-template-columns: 1fr; gap: 10px; } }

/* ===================== how to play cards ===================== */
#controls .menu-panel { width: min(920px, 100%); }
.ux-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.ux-card { background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px 10px; }
.ux-card-art { height: 58px; border-radius: 10px; background: rgba(5,8,20,.5); display: flex; justify-content: center; margin-bottom: 6px; }
.ux-card-art svg { height: 100%; width: auto; }
.ux-card b { display: block; font-size: 15px; font-style: italic; }
.ux-card p { margin: 2px 0 0; font-size: 12px; line-height: 1.35; color: #dfe4f7; }
.ux-more { margin-bottom: 8px; }
.ux-more summary { cursor: pointer; font-weight: 800; padding: 6px 0; color: var(--gold); }
@media (max-width: 720px) { .ux-cards { grid-template-columns: repeat(2, 1fr); } }

/* ===================== guided first run ===================== */
.ux-guide { position: fixed; left: 50%; bottom: calc(10px + var(--safe-b)); transform: translate(-50%, 12px); z-index: 12; display: flex; gap: 10px; align-items: center;
  width: max-content; max-width: min(460px, 52vw); padding: 8px 12px; border-radius: 14px; background: rgba(10,14,30,.84); border: 1px solid rgba(255,197,61,.65);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.ux-guide.show { opacity: 1; transform: translate(-50%, 0); }
.ux-guide.ok { border-color: #8fffb0; }
.ug-icon { width: 64px; height: 38px; flex: none; }
.ug-icon svg { width: 100%; height: 100%; }
.ug-body small { display: block; font-size: 12px; color: var(--gold); letter-spacing: .5px; font-weight: 800; }
.ug-body b { display: block; font-size: 15px; line-height: 1.25; }
.ug-body span { display: block; font-size: 12px; color: #cfd6f2; }
.ug-skip { pointer-events: none; flex: none; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.08); font-size: 12px; font-weight: 800; }
.ux-guide.show .ug-skip { pointer-events: auto; }
.ux-guide.ok .ug-skip { display: none; }

/* ===================== scroll cue and setup spacing ===================== */
.menu-panel.more-below::after, .ux-scroll.more-below::after { content: "More below \25BE"; display: block; position: sticky; bottom: -14px; height: 34px; margin: -34px -20px -18px; padding-top: 16px;
  text-align: center; font-size: 12px; font-weight: 800; letter-spacing: 1px; color: var(--muted); pointer-events: none;
  background: linear-gradient(180deg, rgba(12,18,38,0), rgba(12,18,38,.97) 42%); border-radius: 0 0 18px 18px; }
.ux-scroll.more-below::after { bottom: 0; margin: -34px 0 0; }
/* setup: the scrolling area sits above a fixed Back and Start bar */
.setup-panel.ux-setup-panel { display: flex; flex-direction: column; overflow: hidden; }
.setup-panel.ux-setup-panel .ux-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
.setup-panel.ux-setup-panel .row-btns { position: static; flex: none; margin: 8px 0 0; padding: 0; background: none; }

/* ===================== text size floor: 12px ===================== */
.driver { font-size: 12px; }
.track-card small, .vehicle-card small, .cup-card small, .adv-world small, .adv-event .ae-type, .ar-type, .ad-head small, .mm-btn small, .fps { font-size: 12px; }
.tbtn { font-size: 13px; }
.t-brake, .t-gas { font-size: 12px; }
@media (max-height: 480px) { .driver { font-size: 12px; } .coach { font-size: 14px; } }

/* ===================== reduce motion ===================== */
body.reduce-motion #speedlines, body.reduce-motion #flash { display: none !important; }
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
body.reduce-motion .banner { transition: opacity .01s; transform: none; }

/* ===================== colour-blind friendly ===================== */
body.cb .delta-good { color: #5ad1ff; }
body.cb .delta-bad { color: #ffb13d; }
body.cb .banner.warn { background: linear-gradient(180deg, #fff 20%, #ffb13d 60%, #c25a00); -webkit-background-clip: text; background-clip: text; }
body.cb .t-gas { border-color: #5ad1ff; }
body.cb .t-brake { border-color: #ffb13d; }
body.cb .ux-guide.ok { border-color: #5ad1ff; }
