/* Truco Showdown - base: fonts, colour tokens, the stage, buttons and the fixed corner.
   The stage has the proportion of the art (992 x 1586 portrait, 1672 x 941 landscape) and scales to FIT the
   window (the smaller of width and height), centred; on the TABLE it stands on the window's bottom edge (the spare height
   is sky above, the spare width is scenery at the sides). Every piece is placed in % of the stage.
   --pw / --ph = 1% of the stage width / height; --u = 1/720 of the stage's short side (kept for the panels). */
/* static 600 / 700 instances of Fredoka (cut from the variable font): WebKit drew the variable one at its thinnest weight */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../assets/fonts/fredoka-latin-600.woff2) format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC,
    U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../assets/fonts/fredoka-latin-ext-600.woff2) format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
    U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(../assets/fonts/fredoka-latin-700.woff2) format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC,
    U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(../assets/fonts/fredoka-latin-ext-700.woff2) format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
    U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --vw: calc(100vw - var(--safe-l) - var(--safe-r));
  --vh: calc(100dvh - var(--safe-t) - var(--safe-b));
  --sw: min(var(--vw), calc(var(--vh) * 992 / 1586));
  --sh: calc(var(--sw) * 1586 / 992);
  --pw: calc(var(--sw) / 100);
  --ph: calc(var(--sh) / 100);
  --u: calc(var(--sw) / 720);
  --navy: #14205a;
  --navy2: #1f2f7c;
  --navy3: #2a3d96;
  --ink: #14205a;
  --teal: #17b3a3;
  --teal-d: #0d7f74;
  --orange: #f47a1c;
  --orange-d: #b9530a;
  --yellow: #ffd21f;
  --yellow-d: #d19d00;
  --magenta: #d81b7a;
  --magenta-d: #9c0f55;
  --red: #e0283a;
  --black: #1b2142;
  --font:
    'Fredoka', 'Hiragino Maru Gothic ProN', 'Yu Gothic UI', 'Meiryo', 'Apple SD Gothic Neo', 'Malgun Gothic',
    'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', system-ui, sans-serif;
}
@media (orientation: landscape) {
  :root {
    --sh: min(var(--vh), calc(var(--vw) * 941 / 1672));
    --sw: calc(var(--sh) * 1672 / 941);
    --u: calc(var(--sh) / 720);
  }
}
/* the table: the scene (mesa4) is 941 x 1672 in portrait, 1672 x 941 in landscape, and its bottom is the window's bottom,
   so the safe area below is not taken from the stage (the dock and the hand rise above it: --below in table.css) */
#app:is([data-screen='table'], [data-screen='quick']) {
  --vh: calc(100dvh - var(--safe-t));
  --sw: min(var(--vw), calc(var(--vh) * 941 / 1672));
  --sh: calc(var(--sw) * 1672 / 941);
  --pw: calc(var(--sw) / 100);
  --ph: calc(var(--sh) / 100);
  --u: calc(var(--sw) / 720);
}
@media (orientation: landscape) {
  #app:is([data-screen='table'], [data-screen='quick']) {
    --sw: min(var(--vw), calc(var(--vh) * 1672 / 941));
    --sh: calc(var(--sw) * 941 / 1672);
    --u: calc(var(--sh) / 720);
  }
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overflow: clip;
  background: #14205a;
}
body {
  font-family: var(--font);
  font-weight: 600;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}
button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}
button:focus {
  outline: none;
}
button:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.8);
  outline-offset: 3px;
  border-radius: 14px;
}
svg {
  display: block;
}
[hidden] {
  display: none !important;
}

#app {
  --cw: calc(var(--u) * 96);
  position: fixed;
  inset: 0;
  overflow: hidden;
  overflow: clip;
}
/* the scene: placed by main.js so its middle part lines up exactly with the stage; its extension fills the rest */
#scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  overflow: clip;
}
.scene {
  position: absolute;
}
.scene .bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
}
.stage {
  position: absolute;
  z-index: 2;
  width: var(--sw);
  height: var(--sh);
  left: calc(var(--safe-l) + (var(--vw) - var(--sw)) / 2);
  top: calc(var(--safe-t) + (var(--vh) - var(--sh)) / 2);
}
#app:is([data-screen='table'], [data-screen='quick']) .stage {
  top: calc(var(--safe-t) + var(--vh) - var(--sh));
}
/* a control drawn smaller than 44 px (small phones) still takes a 44 px touch */
.hit::after {
  content: '';
  position: absolute;
  inset: min(0px, calc((100% - 44px) / 2));
}
.fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 60;
}
.screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
}
#app[data-screen='title'] #s-title,
#app[data-screen='menu'] #s-menu,
#app[data-screen='quick'] #s-quick,
#app[data-screen='circuit'] #s-circuit,
#app[data-screen='table'] #s-table {
  display: block;
}

/* Pill button: the art (assets/img/ui/btn-<colour>.webp, 420 x ~97, face down to 88%, then the darker lip) in 3
   pieces glued by src/lib/nine.js; only the flat middle stretches. Live text centred on the FACE: the lip is the bottom
   padding. --h is the one size of the piece: every place that sizes a pill sets --h, never height. */
.nine {
  border-image: none !important;
  background-size: 100% 100% !important;
  background-origin: border-box !important;
  background-clip: border-box !important;
  background-repeat: no-repeat !important;
}
.pill {
  --h: calc(var(--u) * 96);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--h) * 0.14);
  height: var(--h);
  min-width: calc(var(--h) * 2);
  padding: 0 0 calc(var(--h) * 0.11);
  border: solid transparent;
  border-width: 0 calc(var(--h) * 0.42);
  border-image: var(--art) 0 40 fill;
  font-size: calc(var(--h) * 0.4);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
  text-transform: uppercase;
  color: #fff;
  filter: drop-shadow(0 calc(var(--u) * 4) calc(var(--u) * 5) rgba(5, 10, 40, 0.35));
}
.pill > span {
  display: block;
  margin: 0 calc(var(--h) * -0.22);
  white-space: nowrap;
}
.pill.teal {
  --art: url(../assets/img/ui/btn-teal.webp);
}
.pill.orange {
  --art: url(../assets/img/ui/btn-orange.webp);
}
.pill.yellow {
  --art: url(../assets/img/ui/btn-yellow.webp);
  color: var(--navy);
}
.pill.magenta {
  --art: url(../assets/img/ui/btn-magenta.webp);
}
.pill.navy {
  --art: url(../assets/img/ui/btn-navy.webp);
}
.pill.slate {
  --art: url(../assets/img/ui/btn-slate.webp);
}
.pill:disabled {
  filter: grayscale(0.6) brightness(0.85);
  pointer-events: none;
}
.pill.big {
  --h: calc(var(--u) * 112);
}

/* Round icon button: navy disc, white glyph. Never smaller than 44 px (touch) */
/* Round button: the whole button is a picture (assets/img/ui/b-*.webp); pressed = sinks a little and darkens */
.icon-btn {
  --s: max(44px, calc(var(--u) * 84));
  position: relative;
  width: var(--s);
  height: var(--s);
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
}
.icon-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 calc(var(--s) * 0.04) calc(var(--s) * 0.06) rgba(5, 10, 40, 0.4));
}
.icon-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}
#b-sound img {
  grid-area: 1 / 1;
}
#b-sound .mute,
#b-sound.muted .on {
  visibility: hidden;
}
#b-sound.muted .mute {
  visibility: visible;
}
/* sound + gear: anchored to the WINDOW's top-right corner on every screen, fixed comfortable size (they don't scale) */
/* on very wide windows they come in toward the stage: at most 200 px beyond its right edge */
.corner {
  position: fixed;
  z-index: 40;
  top: calc(var(--safe-t) + 14px);
  right: calc(var(--safe-r) + max(14px, (var(--vw) - var(--sw)) / 2 - 200px));
  display: flex;
  gap: 10px;
}
.corner .icon-btn {
  --s: clamp(52px, calc(var(--sh) * 0.07), 64px);
}

/* Straight title band (never curved), art band-<colour>.webp (384 x ~75, lip from 87%); text on the face */
.band {
  --bh: calc(var(--u) * 70);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 0 calc(var(--bh) * 0.12);
  height: var(--bh);
  border: solid transparent;
  border-width: 0 calc(var(--bh) * 0.4);
  border-image: var(--art) 0 30 fill;
  font-size: calc(var(--bh) * 0.54);
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  color: #fff;
}
.band > span {
  display: block;
  white-space: nowrap;
}
.band.teal {
  --art: url(../assets/img/ui/band-teal.webp);
}
.band.yellow {
  --art: url(../assets/img/ui/band-yellow.webp);
  color: var(--navy);
}
.band.slate {
  --art: url(../assets/img/ui/band-slate.webp);
}
.band.magenta {
  --art: url(../assets/img/ui/band-magenta.webp);
}
/* navy panel: art panel.webp (315 x 362) in 9 pieces, the lighter rim stays at the edges */
.navy-box {
  border: calc(var(--u) * 22) solid transparent;
  border-image: url(../assets/img/ui/panel.webp) 40 40 46 40 fill;
  filter: drop-shadow(0 calc(var(--u) * 10) calc(var(--u) * 14) rgba(5, 10, 40, 0.45));
}

/* Toggle: the switch art in three pieces (both tracks and the knob), all loaded from the start: the knob slides */
.switch {
  --w: max(64px, calc(var(--u) * 100));
  position: relative;
  width: var(--w);
  height: calc(var(--w) * 0.53);
  flex: none;
  background: url(../assets/img/vida/sw-off-t.webp) center / 100% 100% no-repeat;
}
.switch::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url(../assets/img/vida/sw-on-t.webp) center / 100% 100% no-repeat;
  opacity: 0;
  transition: opacity var(--f-switch);
}
.switch::after {
  content: '';
  position: absolute;
  left: 5%;
  top: calc(var(--w) * 0.045);
  width: 41%;
  aspect-ratio: 1;
  background: url(../assets/img/vida/sw-knob.webp) center / contain no-repeat;
  transition:
    translate var(--f-switch) cubic-bezier(0.3, 1.5, 0.5, 1),
    scale var(--f-switch);
}
.switch[aria-checked='true']::before {
  opacity: 1;
}
.switch[aria-checked='true']::after {
  translate: 118% 0;
}
/* Slider: track, yellow fill and knob are pictures; the native range sits on top, transparent, for drag and a11y */
.slider {
  --k: max(36px, calc(var(--u) * 50));
  position: relative;
  flex: 1.3;
  height: max(44px, var(--k));
  min-width: 0;
}
.slider > i {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  height: max(14px, calc(var(--u) * 24));
  border: solid transparent;
  border-width: 0 max(7px, calc(var(--u) * 12));
  pointer-events: none;
}
.slider .trk {
  left: 0;
  right: 0;
  border-image: url(../assets/img/ui/track.webp) 0 24 fill;
}
.slider .fil {
  left: 0;
  width: calc(var(--k) / 2 + (100% - var(--k)) * var(--p, 0.5));
  min-width: max(14px, calc(var(--u) * 24));
  border-image: url(../assets/img/ui/fill.webp) 0 24 fill;
}
.slider .kn {
  left: calc((100% - var(--k)) * var(--p, 0.5));
  width: var(--k);
  height: var(--k);
  border: 0;
  background: url(../assets/img/ui/knob.webp) center / contain no-repeat;
}
.range {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
/* End of css/base.css (complete file). */
