/* Xoundly app. Same identity as getxoundly.com: calm and friendly.
   Setup (you are parked): light grey ground, one white panel, soft rounded headings,
   yellow as the single accent, black for the thing to press.
   Ride: asphalt ground. Dark keeps an OLED phone cool on a long ride and does not
   glare at night; the few colours each mean one thing:
     yellow = the thing to press, and music
     teal   = your partner's voice and the link
     red    = YOUR mic is open
   Type: Fredoka for headings and the lines read at a glance, Instrument Sans for
   reading, DM Mono for the ride code and small technical labels. Served from this site. */
@font-face { font-family: "Fredoka"; font-weight: 500 700; font-style: normal; font-display: swap; src: url("../fonts/fredoka-var.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 400 700; font-style: normal; font-display: swap; src: url("../fonts/instrument-sans-var.woff2") format("woff2"); }
@font-face { font-family: "DM Mono"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/dm-mono-500.woff2") format("woff2"); }

:root {
  --ground: #F4F4F2;
  --card: #FFFFFF;
  --hairline: #E6E6E2;
  --edge: #84888F;          /* input and button outlines: 3.5:1 on white */
  --ink: #17191C;
  --muted: #5C6066;         /* 5.7:1 on the ground, 6.3:1 on white */
  --yellow: #FFC933;
  --yellow-deep: #F2B705;
  --yellow-edge: #B98A00;
  --asphalt: #17191C;
  --asphalt-2: #23262B;
  --asphalt-3: #34383E;
  --asphalt-4: #4A4F56;
  --paper: #F6F6F3;
  --fog: #C9CBC7;
  --ash: #A9ADB3;
  --teal: #0B7A75;
  --teal-bright: #38C6BC;
  --red: #E5383B;
  --red-deep: #C42B2E;      /* behind small white text: 5.4:1 */
  --red-edge: #9E1F22;
  --display: "Fredoka", "Nunito", "Arial Rounded MT Bold", system-ui, sans-serif;
  --body: "Instrument Sans", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: "DM Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* The ground colour lives on <html>: the ride screen scrolls past one screenful,
   and only the root element paints the whole scrolled page. */
html, body {
  margin: 0; height: 100%;
  color: var(--ink);
  font: 17px/1.45 var(--body);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
html { background: var(--ground); }
html[data-screen="ride"] { background: var(--asphalt); }
html[data-screen="ride"] body { color: var(--paper); }

[hidden] { display: none !important; }

.screen {
  min-height: 100%;
  max-width: 560px; margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}

.label { margin: 0; font: 500 12px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ---------- shared controls ---------- */
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend, .field > span { display: block; padding: 0; margin-bottom: 7px; font-weight: 600; font-size: 15px; }
.field em { font-style: normal; font-weight: 500; color: var(--muted); }

input {
  width: 100%; padding: 14px 16px; font: 500 17px/1.3 var(--body); color: inherit;
  border: 1.5px solid var(--edge); border-radius: 16px; background: var(--card);
  outline: none;
}

.btn {
  position: relative; overflow: hidden;
  width: 100%; min-height: 56px; padding: 12px 20px;
  font: 600 17px/1.15 var(--body); color: var(--ink);
  background: var(--card); border: 1.5px solid var(--edge); border-radius: 999px;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--asphalt); border-color: var(--asphalt); color: #FFFFFF; box-shadow: 0 8px 20px -10px rgba(23, 25, 28, .55); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.small { min-height: 50px; font-size: 15px; padding: 8px 10px; border-radius: 16px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segbtn {
  min-height: 56px; font: 600 17px/1.15 var(--body); color: var(--ink);
  background: var(--card); border: 1.5px solid var(--edge); border-radius: 16px;
  touch-action: manipulation; cursor: pointer;
}
.segbtn[aria-pressed="true"] { background: var(--yellow); border-color: var(--yellow-edge); font-weight: 700; }

.error { margin: 0; font-weight: 600; color: #B3261E; min-height: 1.45em; }
.error:empty { display: none; }

.btn:focus-visible, .segbtn:focus-visible, .talk:focus-visible, .code:focus-visible, .about:focus-visible, .ver a:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }
input:focus-visible { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(11, 122, 117, .22); }

/* ---------- setup screen: light ground ---------- */
.brandbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 8px; margin: 0; font: 700 27px/1 var(--display); letter-spacing: -.01em; }
.brand img { width: 38px; height: 38px; flex: none; }
.about { font-weight: 600; font-size: 15px; color: var(--muted); text-underline-offset: 4px; padding: 10px 0; }

.sign { margin: 14px 0 0; font: 700 clamp(30px, 8.6vw, 44px)/1.04 var(--display); letter-spacing: -.015em; }
.lede { margin: 0 0 4px; font-size: 18px; color: var(--muted); }

.panel {
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px 18px 22px; background: var(--card);
  border: 1px solid var(--hairline); border-radius: 28px;
  box-shadow: 0 1px 0 rgba(23, 25, 28, .03), 0 18px 40px -22px rgba(23, 25, 28, .28);
}
.or { margin-top: 6px; padding-top: 18px; border-top: 1px solid var(--hairline); text-align: center; font-weight: 500; font-size: 15px; color: var(--muted); }
#code { font: 500 24px/1.2 var(--mono); text-transform: uppercase; letter-spacing: .3em; text-align: center; padding-left: calc(16px + .3em); }
#code::placeholder { font: 500 17px/1.3 var(--body); letter-spacing: normal; text-transform: none; color: var(--muted); }

.before { margin-top: 8px; }
.notes { margin: 10px 0 0; padding-left: 20px; font-size: 15px; color: var(--muted); }
.notes li + li { margin-top: 6px; }
.ver { margin: auto 0 0; padding-top: 8px; display: flex; justify-content: space-between; gap: 12px; font: 500 12px/1.4 var(--mono); color: var(--muted); }
.ver a { color: inherit; text-underline-offset: 3px; }

/* ---------- ride screen: asphalt ground ---------- */
#ride .btn, #ride .segbtn { color: var(--paper); border-color: var(--asphalt-4); background: var(--asphalt-2); box-shadow: none; }
#ride .btn:active { background: var(--asphalt-3); }
#ride .btn.primary { color: var(--asphalt); background: var(--yellow); border-color: var(--yellow); font-weight: 700; }
#ride .btn.primary:active { background: var(--yellow-deep); }
#ride .segbtn { color: var(--fog); }
#ride .segbtn[aria-pressed="true"] { color: var(--asphalt); background: var(--paper); border-color: var(--paper); }
#ride input { color: var(--paper); background: var(--asphalt); border: 1.5px solid #6E737A; }
#ride input::placeholder { color: #9BA0A6; }
#ride input:focus-visible { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(255, 201, 51, .22); }
#ride legend, #ride .field > span { color: var(--fog); }
#ride .error { color: #FF9C9E; }
#ride .btn:focus-visible, #ride .segbtn:focus-visible, #ride .talk:focus-visible, #ride .code:focus-visible { outline-color: #FFFFFF; }
#ride .label { color: var(--ash); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.code {
  font: 500 13px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase;
  color: var(--ash); background: none; border: 0; padding: 12px 0; touch-action: manipulation; cursor: pointer;
}
.code b { margin-left: 6px; font-size: 17px; font-weight: 500; letter-spacing: .22em; color: var(--yellow); border-bottom: 2px dashed var(--asphalt-4); padding-bottom: 2px; }
.pill {
  padding: 8px 13px; border-radius: 999px; font: 600 13px/1 var(--body);
  color: var(--fog); border: 1.5px solid var(--asphalt-4); white-space: nowrap;
}
.pill.linked { color: #04302D; background: var(--teal-bright); border-color: var(--teal-bright); }
.pill.warn { color: var(--asphalt); background: var(--yellow); border-color: var(--yellow); }
.pill.bad { color: #FFFFFF; background: var(--red-deep); border-color: var(--red-deep); }

/* Two helmets, one line. */
.duo { max-width: 400px; margin: 2px 0 10px; }
.duo svg { display: block; width: 100%; height: auto; overflow: visible; }
.duo .helmet.pillion .shell { fill: var(--yellow); }
.duo .helmet.rider .shell { fill: #ECEDE9; }
.duo .visor { fill: var(--teal-bright); }
.duo .vent { fill: none; stroke: var(--asphalt); stroke-width: 7; stroke-linecap: round; opacity: .35; }
.duo .mic { fill: var(--asphalt-4); }
.duo .helmet { transition: opacity .3s ease; }
/* Your partner's helmet is a ghost until the two of you are linked. */
.duo[data-me="rider"]:not([data-link="linked"]) .helmet.pillion,
.duo[data-me="pillion"]:not([data-link="linked"]) .helmet.rider { opacity: .22; }
.duo[data-me="rider"][data-mic="live"] .helmet.rider .mic,
.duo[data-me="pillion"][data-mic="live"] .helmet.pillion .mic { fill: var(--red); }
.duo .wire { stroke: var(--asphalt-4); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 3 11; }
.duo[data-link="linked"] .wire { stroke: #6E737A; stroke-dasharray: none; }
.duo .wave { display: none; fill: none; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.duo[data-who="partner"] .wave, .duo[data-who="me"] .wave { display: block; }
.duo[data-who="partner"] .wire, .duo[data-who="me"] .wire { display: none; }
.duo[data-who="partner"] .wave { stroke: var(--teal-bright); }
.duo[data-who="me"] .wave { stroke: var(--red); }
.duo[data-from="left"] .wave { animation: flowRight .55s linear infinite; }
.duo[data-from="right"] .wave { animation: flowLeft .55s linear infinite; }
@keyframes flowRight { to { transform: translateX(32px); } }
@keyframes flowLeft { to { transform: translateX(-32px); } }
.duo-tags { display: flex; justify-content: space-between; margin-top: 6px; font: 600 13px/1.2 var(--body); color: var(--ash); }
.duo-tags span { max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duo[data-me="pillion"] #duoL, .duo[data-me="rider"] #duoR { color: var(--paper); }

.status { padding: 0; }
.big { font: 700 clamp(30px, 8.8vw, 44px)/1.05 var(--display); letter-spacing: -.015em; overflow-wrap: anywhere; }
.status.speaking .big { color: var(--teal-bright); }
.sub { margin-top: 10px; display: flex; align-items: center; gap: 9px; color: var(--fog); font-size: 18px; font-weight: 500; }
.sub::before { content: ""; width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--asphalt-4); }
.sub:empty::before { display: none; }
.sub.live { color: #FFFFFF; }
.sub.live::before { background: var(--red); }

/* The one big button. A physical key: it sits on an edge and sinks when pressed. */
.talk {
  flex: 1 1 auto; min-height: 24vh; width: 100%; margin-bottom: 7px;
  color: var(--asphalt); background: var(--yellow);
  border: 0; border-radius: 32px; box-shadow: 0 7px 0 var(--yellow-edge);
  touch-action: manipulation; user-select: none; -webkit-user-select: none; cursor: pointer;
}
.talk:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--yellow-edge); }
.talk .t1, .talk .t2 { display: block; }
.talk .t1 { font: 700 clamp(44px, 13.5vw, 72px)/1 var(--display); letter-spacing: -.02em; }
.talk .t2 { margin-top: 10px; font: 700 19px/1.2 var(--body); opacity: .82; }
.talk .t2:empty { display: none; }
.talk[data-state="muted"] { color: var(--fog); background: var(--asphalt-2); box-shadow: inset 0 0 0 2px var(--asphalt-4), 0 7px 0 #0B0C0E; }
.talk[data-state="muted"]:active { box-shadow: inset 0 0 0 2px var(--asphalt-4), 0 2px 0 #0B0C0E; }
.talk.live { color: #FFFFFF; background: var(--red); box-shadow: 0 7px 0 var(--red-edge); }
.talk.live:active { box-shadow: 0 2px 0 var(--red-edge); }
.talk.live .t2 { opacity: 1; }
.talk[disabled] { opacity: .5; cursor: default; }

.help { margin: -4px 0 0; color: var(--ash); font-size: 15px; min-height: 2.9em; }

/* Music card and sound settings */
.card { background: var(--asphalt-2); border: 1px solid var(--asphalt-3); border-radius: 26px; padding: 16px 14px; display: flex; flex-direction: column; gap: 12px; }
#ride .card .btn:not(.primary) { background: var(--asphalt); }
#ride .card .btn:not(.primary):active { background: var(--asphalt-3); }
.card .help { margin: 0; min-height: 0; }
.mhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.mtext { min-width: 0; }
.mtitle { margin-top: 6px; font: 600 22px/1.15 var(--display); overflow-wrap: anywhere; }
.msub { margin-top: 4px; color: var(--ash); font-size: 15px; display: flex; flex-wrap: wrap; gap: 0 14px; }
.msub span { white-space: nowrap; }
.chip { flex: none; padding: 6px 11px; border-radius: 999px; font: 600 13px/1 var(--body); color: var(--yellow); border: 1.5px solid var(--yellow); }
.ytwrap { position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 200px; border-radius: 16px; overflow: hidden; background: #000; }
.ytwrap iframe, .ytwrap > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.kbox { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 18px; border: 2px dashed var(--yellow); }
.kline { margin: 0; font-size: 17px; font-weight: 700; color: #FFFFFF; }
.ytstatus { margin: 0; color: var(--ash); font: 500 12px/1.4 var(--mono); font-variant-numeric: tabular-nums; }
.taphint { margin: 0; padding: 13px 15px; border-radius: 16px; font-size: 18px; font-weight: 700; line-height: 1.3; color: var(--asphalt); background: var(--yellow); }
.ytwrap.needtap { outline: 3px solid var(--yellow); outline-offset: 3px; animation: needtap 1.4s ease-in-out infinite; }
@keyframes needtap { 50% { outline-color: transparent; } }
.ytfield > span { margin-bottom: 5px; }
.ytfield input { padding: 12px 14px; font-size: 16px; }
.mctl { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; }
.mrow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filebtn { display: flex; align-items: center; justify-content: center; text-align: center; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; padding: 0; }
.vh:focus-visible + .btn, .filebtn:focus-within { outline: 3px solid #FFFFFF; outline-offset: 3px; }

.slider { display: block; }
.slider > span { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; color: var(--fog); font-size: 15px; }
.slider output { color: var(--yellow); font: 500 14px/1.5 var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
#ride input[type="range"] { width: 100%; height: 36px; padding: 0; margin: 0; background: none; border: 0; box-shadow: none; accent-color: var(--yellow); }
.check { display: flex; align-items: center; gap: 10px; font-size: 16px; }
#ride .check input { width: 24px; height: 24px; padding: 0; accent-color: var(--yellow); flex: none; box-shadow: none; }

.foot { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
/* Ending the ride is held, not tapped: the sweep shows how long is left. */
.btn.danger .fill { position: absolute; inset: 0; width: 0; background: rgba(255, 255, 255, .2); }
.btn.danger.holding .fill { width: 100%; transition: width 1.2s linear; }
.btn.danger .lbl { position: relative; }
.meta {
  margin: 0; color: #9BA0A6; font: 500 12px/1.5 var(--mono); font-variant-numeric: tabular-nums;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 16px;
}
.meta .warnText { color: var(--yellow); }

.unblock {
  position: fixed; inset: 0; z-index: 10; padding: 24px;
  font: 700 clamp(36px, 10vw, 56px)/1.05 var(--display); letter-spacing: -.02em; color: var(--asphalt);
  background: var(--yellow); border: 0; cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .btn.danger.holding .fill { transition: none; }
  .ytwrap.needtap { animation: none; }
  .duo .wave { animation: none !important; }
  .duo .helmet { transition: none; }
  .btn:active, .talk:active { transform: none; }
}
