/* Base: font, colors, the size unit --u, the art pieces (9 pieces baked in canvas by src/ui/nine.js) and buttons.
   One centering mechanism: the text box is the face of the piece (its padding box), the text centers in it,
   --cap corrects the font and each art declares the offset of its face (--dy). */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url(../assets/ui/fonts/fredoka-latin-ext.woff2) format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url(../assets/ui/fonts/fredoka-latin.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;
}
:root {
  /* one unit: 1px on a 390-wide phone, grows with the height on wide screens, capped on large displays */
  --u: min(100vw / 390, 100dvh / 480, var(--ui-cap, 2px));
  --bg: #152029;
  --text: #f2f8f5;
  --muted: #a9bec2;
  --em: #2fbf7f;
  --gold: #ffd36a;
  --mana: #4fd2ff;
  --cap: 0.06em; /* Fredoka sits a little high in its box: push the text down by this */
  --shadow: 0 calc(var(--u) * 2) 0 rgba(6, 16, 20, 0.55);
  --touch: max(44px, calc(var(--u) * 48));
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font:
    600 calc(var(--u) * 16) / 1.2 'Fredoka',
    system-ui,
    sans-serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
}
button:focus {
  outline: none;
}
button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
img {
  -webkit-user-drag: none;
  user-select: none;
}
b,
small,
h2,
h3 {
  text-shadow: var(--shadow);
}

#field {
  position: fixed;
  left: 0;
  top: 0;
  display: block;
  touch-action: none;
  z-index: 0;
}
#app {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
/* the stage: everything is laid out in it. Landscape: a centered 16:9 box, so an ultrawide shows the same
   composition as a laptop, with open ground on both sides */
#stage {
  position: relative;
  height: 100%;
  width: 100%;
  margin: 0 auto;
}
@media (min-aspect-ratio: 16/9) and (min-height: 501px) {
  #stage {
    width: calc(100dvh * 16 / 9);
    max-width: 100%;
  }
}
#stage > * {
  pointer-events: auto;
}

/* less motion: entries still happen, in 1 ms (never animation: none); only infinite loops stop */
.calm *,
.calm *::before,
.calm *::after {
  animation-duration: 1ms !important;
  transition-duration: 1ms !important;
}
.calm .loop {
  animation-name: none !important;
}

/* ---------------------------------------------------------------- art pieces (9 pieces) */
.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;
}
.art {
  border-style: solid;
  border-color: transparent;
  border-image-repeat: stretch;
}
.ic {
  display: block;
  width: 1.25em;
  height: 1.25em;
  flex: none;
  object-fit: contain;
}

/* a button: art + live text. The face is the padding box; text never wraps (fit.js shrinks it) */
.btn {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  justify-content: center;
  min-height: var(--touch);
  border-style: solid;
  border-color: transparent;
  white-space: nowrap;
  transition:
    transform 280ms cubic-bezier(0.3, 1.7, 0.5, 1),
    filter 120ms;
}
.btn > span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35em;
  width: 100%;
  min-width: 0;
  padding-top: var(--cap);
  transform: translateY(var(--dy, 0));
}
.btn > span > b {
  font-weight: 600;
  overflow: visible;
}
/* press: sinks 3 px fast, comes back with a spring on release (the transition above) */
.btn:active {
  transform: translateY(3px) scale(0.98);
  filter: brightness(0.9);
  transition-duration: 60ms, 60ms;
}
.btn[disabled] {
  cursor: default;
}
.btn[disabled]:active {
  transform: none;
  filter: none;
}

/* wide buttons: 600x127 art, face 6..99, lip below */
.btn.go,
.btn.green,
.btn.slate,
.btn.warn,
.btn.info,
.btn.off {
  --bt: calc(var(--u) * 12);
  --bb: calc(var(--u) * 15);
  border-width: var(--bt) calc(var(--u) * 14) var(--bb);
  border-image-slice: 30 30 34 30 fill;
  padding: 0 calc(var(--u) * 8);
  /* ONE rule for every lipped art: the text centers on the art's FACE, never on the face + the dark lip under it.
     Face center - padding-box center, from the art's slices (top St, bottom Sb, image IH) and its face rows Ft..Fb:
     dy = (bt * (Ft/St - 1) + bb * (Fb - IH + Sb) / Sb) / 2. These arts (01/12, the colors pass, 600x140): Ft 11, Fb 110,
     St 30, Sb 34, IH 140 -> dy = -0.317 bt + 0.059 bb (checked by the ruler, tools/regua-config.py). Any size: set --bt/--bb */
  --dy: calc(var(--bt) * -0.317 + var(--bb) * 0.059);
  font-size: calc(var(--u) * 19);
  height: calc(var(--u) * 54);
}
/* one color per role, the whole game (01/12, "the colors are dead"): go = the main action (warm yellow, dark text);
   slate = a common action (vivid blue); green = confirm / buy / repair (green); warn = restart camp (burnt orange, WHITE text: 5.2:1 on the face, the owner 01/12);
   off = disabled (gray-blue). Text contrast >= 4.5:1 on the face and on its light band (output/fotos-jornada-telas/cores/) */
.btn.go {
  border-image-source: url(../assets/ui/btn-yellow.webp);
}
.btn.slate {
  border-image-source: url(../assets/ui/btn-blue.webp);
}
.btn.green {
  border-image-source: url(../assets/ui/btn-vivid.webp);
}
.btn.warn {
  border-image-source: url(../assets/ui/btn-orange.webp);
}
.btn.go {
  color: #14232e;
}
.btn.warn {
  color: #ffffff;
}
/* info: a dark plate that can be tapped (the menu's camp and wave line): it informs, it never calls like the yellow.
   The older dark art: face rows 7.5..93 of 127, slices 28 / 34 -> dy = -0.366 bt */
.btn.info {
  border-image-source: url(../assets/ui/btn-slate.webp);
  border-image-slice: 28 30 34 30 fill;
  --dy: calc(var(--bt) * -0.366);
}
.btn.go b {
  text-shadow: 0 1px 0 rgba(255, 244, 214, 0.45);
}
.btn.off,
.btn.go[disabled],
.btn.green[disabled],
.btn.slate[disabled],
.btn.warn[disabled] {
  border-image-source: url(../assets/ui/btn-gray.webp);
  color: #f2f6f8;
}
.btn.off b,
.btn[disabled] b {
  text-shadow: var(--shadow);
}
.btn.big {
  height: calc(var(--u) * 70);
  font-size: calc(var(--u) * 30);
  --bt: calc(var(--u) * 15);
  --bb: calc(var(--u) * 19);
  border-width: var(--bt) calc(var(--u) * 17) var(--bb);
}
/* square buttons: 197x199 art, face 1..164 */
.btn.sq {
  width: var(--touch);
  height: var(--touch);
  padding: 0;
  font-size: calc(var(--u) * 17);
  --bt: calc(var(--u) * 8);
  --bb: calc(var(--u) * 11);
  border-width: var(--bt) calc(var(--u) * 8) var(--bb);
  border-image-slice: 30 30 40 30 fill;
  --dy: calc(
    var(--bt) * -0.342 + var(--bb) * 0.05
  ); /* face rows 9.5..163 of 199, slices 30 / 40 (same rule as above) */
}
.btn.sq.slate {
  border-image-source: url(../assets/ui/sq-slate.webp);
}
.btn.sq.green {
  border-image-source: url(../assets/ui/sq-green.webp);
}
.btn.sq .ic {
  width: 62%;
  height: 62%;
}

/* plates and pills (HUD, coins, labels) */
.plate {
  border-style: solid;
  border-color: transparent;
  border-image: url(../assets/ui/plate.webp) 40 fill / calc(var(--u) * 10);
  border-width: calc(var(--u) * 10);
}
.art-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-style: solid;
  border-color: transparent;
  border-image-source: url(../assets/ui/pill.webp);
  border-image-slice: 70 80 fill;
  border-width: calc(var(--u) * 13) calc(var(--u) * 13);
  min-height: calc(var(--u) * 42);
  white-space: nowrap;
}
.art-pill > span {
  display: flex;
  align-items: center;
  gap: 0.35em;
  padding: var(--cap) calc(var(--u) * 2) 0;
}

/* bars: frame + fill clipped (never the art stretched by the value) */
.bar {
  position: relative;
  display: block;
  border-style: solid;
  border-color: transparent;
  border-image: url(../assets/ui/bar-frame.webp) 24 30 fill;
  border-width: calc(var(--u) * 6) calc(var(--u) * 7);
}
.bar > .fill {
  position: absolute;
  inset: calc(var(--u) * -2) calc(var(--u) * -3);
  border-style: solid;
  border-color: transparent;
  border-image: url(../assets/ui/bar-green.webp) 22 30 fill;
  border-width: calc(var(--u) * 5) calc(var(--u) * 7);
  clip-path: inset(0 calc(100% - var(--f, 1) * 100%) 0 0);
  transition: clip-path 0.18s;
}

.grow {
  flex: 1 1 auto;
  min-height: 0;
}
/* Font stacks by script: Fredoka has Latin only (no Cyrillic, Japanese, Korean or Chinese), so those languages fall to
   the system fonts of Windows, Android, iPhone and Mac (rounded where the system has one). Nothing is downloaded.
   html:lang() follows document.documentElement.lang (src/i18n.js). */
html:lang(ru),
html:lang(ru) body {
  font-family: 'Fredoka', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, system-ui, sans-serif;
}
html:lang(ja),
html:lang(ja) body {
  font-family:
    'Fredoka', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', 'Yu Gothic UI', 'Meiryo UI', 'Noto Sans JP',
    'Noto Sans CJK JP', system-ui, sans-serif;
}
html:lang(ko),
html:lang(ko) body {
  font-family:
    'Fredoka', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', 'Noto Sans CJK KR', system-ui, sans-serif;
}
html:lang(zh),
html:lang(zh) body {
  font-family:
    'Fredoka', 'PingFang SC', 'Microsoft YaHei UI', 'Microsoft YaHei', 'Noto Sans SC', 'Noto Sans CJK SC', system-ui,
    sans-serif;
}

@media (max-aspect-ratio: 4/3) {
  :root {
    --ui-cap: 1.35px;
  }
}
/* End of css/base.css (complete file). */
