/* OVERFORGED DOM UI: the art layer. Every rule here paints a "Forge-chunk" kit piece (art/production/ui-v3,
   copied to ui/ by src/ui/build/build_ui.py). Layout, type and motion live in src/ui/style.css.
   Frames are CSS nine-slices drawn on ::before (and the pressed frame on ::after), so they stretch to any size
   and the text on them stays live. border-image-slice numbers are px of the stored file (manifest "ui" block).
   Each frame's border width is tied to the element's height variable, so corners keep the kit's proportions. */

/* shared frame setup */
.btn::before, .btn::after, .sq::before, .see::before, .cur::before, .toast::before, .panel::before, .card::before,
.up::before, .stat::before, .meter::before, .hpbar i, .hpbar s, .trk i, .meter i {
  border-style: solid;
  border-color: transparent;
  border-image-repeat: stretch;
  border-image-width: 1;
}
.btn::before, .btn::after, .sq::before, .see::before, .cur::before, .toast::before, .panel::before, .card::before,
.up::before, .stat::before, .meter::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

/* ---------------------------------------------------------------- big buttons (--bh = height) */
.btn::before, .btn::after {
  border-width: calc(var(--bh) * 0.453) calc(var(--bh) * 0.49);
  border-image-slice: 83 90 fill;
  transition: opacity 90ms ease-out;
}
/* the pressed piece is shorter: it sits at the bottom, so the face drops and the lip compresses */
.btn::after { top: calc(var(--bh) * 0.067); opacity: 0; }
.btn.down::before, .btn:not([disabled]):active::before { opacity: 0; }
.btn.down::after, .btn:not([disabled]):active::after { opacity: 1; }
.btn.bone::before { border-image-source: url(ui/btn_bone.webp); }
.btn.bone::after { border-image-source: url(ui/btn_bone_pressed.webp); }
.btn.green::before { border-image-source: url(ui/btn_green.webp); }
.btn.green::after { border-image-source: url(ui/btn_green_pressed.webp); }
.btn.slate::before { border-image-source: url(ui/btn_slate.webp); }
.btn.slate::after { border-image-source: url(ui/btn_slate_pressed.webp); }
/* cannot afford: the slate button, dimmed so the red price clears 4.5:1 */
.btn.unaff::before { filter: brightness(0.6) saturate(0.75); }
.btn.unaff::after { display: none; }
/* maxed: the kit's disabled grey */
.btn.dis::before { border-image-source: url(ui/btn_slate_disabled.webp); }
.btn.dis::after { display: none; }

/* the smith's skill emblem in a main action's left inset (dark ink on bone, DECISIONS.md 3) */
.emb { background: url(ui/emblem_quench.webp) center / 82% no-repeat; }

/* ---------------------------------------------------------------- square icon buttons (--s = side) */
/* the kit has no pressed square: the frame squashes from the top instead (CSS) */
.sq::before {
  border-width: calc(var(--s) * 0.333);
  border-image-source: url(ui/btn_icon_square.webp);
  border-image-slice: 60 fill;
  transform-origin: 50% 100%;
  transition: transform 90ms ease-out, filter 90ms ease-out;
}
.sq.down::before, .sq:active::before { transform: scaleY(0.93); filter: brightness(0.9); }

/* ---------------------------------------------------------------- pills (--ph = height) */
.see::before, .cur::before, .toast::before {
  border-width: calc(var(--ph) * 0.449) calc(var(--ph) * 0.5);
  border-image-slice: 46 51 fill;
}
/* fight strip: see-through slate */
.see::before { border-image-source: url(ui/pill_long_see.webp); }
/* menus: the opaque version */
.cur::before, .toast::before { border-image-source: url(ui/health_bar_frame.webp); }

/* health fills (--fh = fill height); the value is a clip-path set by the game */
.hpbar i, .hpbar s, .trk i {
  border-width: calc(var(--fh) * 0.4375) calc(var(--fh) * 0.5);
  border-image-source: url(ui/health_bar_fill.webp);
  border-image-slice: 22 26 fill;
}

/* ---------------------------------------------------------------- panels, cards, tiles */
.panel::before {
  border-width: 22px;
  border-image-source: url(ui/panel_dark.webp);
  border-image-slice: 69 fill;
}
/* every part card uses the neutral frame: parts have no rarity */
.card::before {
  border-width: 18px 18px 16px 36px;
  border-image-source: url(ui/card_frame_common.webp);
  border-image-slice: 60 60 54 120 fill;
}
.up::before, .stat::before {
  border-width: 13px 13px 14px 13px;
  border-image-source: url(ui/count_badge.webp);
  border-image-slice: 40 40 44 40 fill;
}
.tile { background: url(ui/icon_tile.webp) center / 100% 100% no-repeat; }

/* ---------------------------------------------------------------- wind-up meter (--mw = width) */
.meter::before {
  border-width: calc(var(--mw) * 0.475) calc(var(--mw) * 0.459);
  border-image-source: url(ui/meter_frame.webp);
  border-image-slice: 29 28 fill;
}
.meter i {
  border-width: calc(var(--fw) * 0.477);
  border-image-source: url(ui/meter_fill.webp);
  border-image-slice: 21 fill;
}

/* ---------------------------------------------------------------- rings */
.ring { background: url(ui/portrait_ring.webp) center / contain no-repeat; }
.cd { background: url(ui/countdown_ring.webp) center / contain no-repeat; }
/* the amber band shows the time left, wiped clockwise from twelve */
.cd i {
  background: url(ui/countdown_fill.webp) center / contain no-repeat;
  -webkit-mask: conic-gradient(#000 calc((1 - var(--p, 0)) * 1turn), transparent 0);
  mask: conic-gradient(#000 calc((1 - var(--p, 0)) * 1turn), transparent 0);
}

/* ---------------------------------------------------------------- icons: one atlas, 4 x 3 cells of 128 px */
.ic {
  display: inline-block;
  flex: none;
  width: var(--is, 24px);
  height: var(--is, 24px);
  background: url(ui/icons.webp) no-repeat;
  background-size: 400% 300%;
}
.ic-ore { background-position: 0 0; }
.ic-pause { background-position: 33.333% 0; }
.ic-sound { background-position: 66.667% 0; }
.ic-music { background-position: 100% 0; }
.ic-smiths { background-position: 0 50%; }
.ic-cross { background-position: 33.333% 50%; }
.ic-x2 { background-position: 66.667% 50%; }
.ic-arrow { background-position: 100% 50%; }
.ic-run { background-position: 0 100%; }
.ic-forge { background-position: 33.333% 100%; }
.ic-check { background-position: 66.667% 100%; }
