/* ============================================================
   Shardkin · Medieval + Void UI System
   Base: Franuka RPG UI Pack (2x) — used via 9-slice border-image.
   Overlay: synthwave "void corruption" as accent only.
   ============================================================ */

/* -------- bitmap fonts (Franuka pack) -------- */
@font-face {
  font-family: "RPGtext";
  src: url("ui-pack/fonts/FantasyRPGtext.ttf") format("truetype");
  font-display: block;
}
@font-face {
  font-family: "RPGtitle";
  src: url("ui-pack/fonts/FantasyRPGtitle.ttf") format("truetype");
  font-display: block;
}
@font-face {
  font-family: "RPGtitleOutline";
  src: url("ui-pack/fonts/FantasyRPGtitleOutline.ttf") format("truetype");
  font-display: block;
}

/* ============================================================
   TOKENS
   ============================================================ */
:root {
  /* -------- Medieval base (sampled from pack 01B/02B/06A) -------- */
  --sk-parchment:    #e8d5b8;  /* banner cream interior */
  --sk-parchment-d:  #c9b395;
  --sk-stone-0:      #1e1f3a;  /* deep navy panel center */
  --sk-stone-1:      #2c2f55;
  --sk-stone-2:      #3a3f70;
  --sk-frame-d:      #0d0d1c;  /* outer-most pixel of frames */
  --sk-frame-m:      #2a2547;
  --sk-frame-l:      #4a4070;
  --sk-blood-0:      #5a1828;  /* red trim outer */
  --sk-blood-1:      #8c2333;
  --sk-blood-2:      #b9354a;  /* red trim highlight */
  --sk-gold-0:       #6b4a18;
  --sk-gold-1:       #c08a2a;
  --sk-gold-2:       #f0c64a;
  --sk-gold-3:       #ffe89a;
  --sk-moss:         #4a6a4f;  /* corruption growth tone */

  /* -------- Void corruption (synthwave overlay — use sparingly) -------- */
  --sk-void:         #0a0418;
  --sk-violet:       #6b2bd9;
  --sk-violet-l:     #9b5cff;
  --sk-magenta:      #ff3a8c;
  --sk-magenta-l:    #ff8ac0;
  --sk-cyan:         #41e0e0;
  --sk-cyan-l:       #8ef4f4;
  --sk-shock:        #fff14a;

  /* -------- Text -------- */
  --sk-ink-0:        #1a1426;  /* near-black on parchment */
  --sk-ink-1:        #3a2a45;
  --sk-ink-muted:    #6e5a78;
  --sk-paper-0:      #f6ecd6;  /* near-white on stone */
  --sk-paper-1:      #d4c9a8;
  --sk-paper-muted:  #9a8d75;

  /* -------- Sizing (CSS px = source 2x px, no upscale) -------- */
  --sk-px: 2px;            /* one "pixel" in our scale (the 2x pack is rendered 1:1) */
  --sk-gap-1: 4px;
  --sk-gap-2: 8px;
  --sk-gap-3: 12px;
  --sk-gap-4: 16px;
  --sk-gap-5: 24px;
  --sk-gap-6: 32px;
}

/* ============================================================
   GLOBAL PIXEL RENDERING
   ============================================================ */
img.sk-pixel,
.sk-pixel-img,
[data-pixel] {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* ============================================================
   TYPE
   ============================================================ */
.sk-font-text     { font-family: "RPGtext", "Courier New", monospace; letter-spacing: 0.5px; }
.sk-font-title    { font-family: "RPGtitle", "Courier New", monospace; letter-spacing: 1px; }
.sk-font-outline  { font-family: "RPGtitleOutline", "Courier New", monospace; letter-spacing: 1px; }

.sk-h1 {
  font-family: "RPGtitleOutline", monospace;
  font-size: 72px;
  line-height: 1;
  color: var(--sk-gold-3);
  text-shadow:
    0 0 12px rgba(155, 92, 255, 0.55),
    0 0 28px rgba(107, 43, 217, 0.45);
}
.sk-h2 {
  font-family: "RPGtitle", monospace;
  font-size: 36px;
  line-height: 1;
  color: var(--sk-paper-0);
}
.sk-h3 {
  font-family: "RPGtitle", monospace;
  font-size: 24px;
  color: var(--sk-paper-0);
}
.sk-body {
  font-family: "RPGtext", monospace;
  font-size: 16px;
  line-height: 1.5;
  color: var(--sk-paper-1);
}
.sk-eyebrow {
  font-family: "RPGtext", monospace;
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--sk-cyan);
  text-shadow: 0 0 6px rgba(65, 224, 224, 0.45);
}

/* ============================================================
   PANELS — 9-slice border-image from pack PNGs
   All BGbox sprites are 96×96. Slice values measured from the
   actual corner-ornament extents (alpha-contour scan).
   border-width is set to match the slice so corners render
   1:1 pixel-perfect with no scaling — combined with
   image-rendering: pixelated the edges stay crisp.
   `stretch` (default) is used instead of `repeat` so the
   solid-color center never visibly tiles or duplicates.
   ============================================================ */
/* ============================================================
   PANELS — 9-slice border-image from pack PNGs

   All BGbox sprites are 96×96. Slice values measured by finding
   where each corner's UNIQUE artwork stops (the first row/column
   that becomes identical to the middle of the sprite). Using
   smaller slices left fragments of the corner ornament inside
   the edge bands — which `stretch` then smeared across the
   entire top/bot/left/right, producing the "duplicated ornament"
   look. Borders are SET TO MATCH THE SLICE so each corner draws
   1:1 at native pixel size (no scaling = no fuzz, no doubling).

   Per-variant slice/width:
     navy (02B):       v32  h26   — curl + top-shine band
     parchment (06A):  v30  h28   — full metal-bracket extent
     azure (01B):      v32  h32   — curl + red-gem inset
     stone (04B):      not 9-sliceable (organic textured pillow,
                       non-uniform edges) → rendered as a single
                       100%×100% background-image.
   ============================================================ */
.sk-panel {
  --sk-panel-bw-v: 32px;
  --sk-panel-bw-h: 26px;
  position: relative;
  padding: 4px 12px;
  color: var(--sk-paper-1);
  font-family: "RPGtext", monospace;
  border-style: solid;
  border-width: var(--sk-panel-bw-v) var(--sk-panel-bw-h);
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  box-sizing: border-box;
}

/* deep navy panel — primary HUD surface */
.sk-panel-navy {
  --sk-panel-bw-v: 32px;
  --sk-panel-bw-h: 26px;
  border-image: url("ui-pack/2x/bgbox/BGbox_02B.png") 32 26 fill;
}

/* cream / dusty rose — for dialog & parchment surfaces */
.sk-panel-parchment {
  --sk-panel-bw-v: 30px;
  --sk-panel-bw-h: 28px;
  border-image: url("ui-pack/2x/bgbox/BGbox_06A.png") 30 28 fill;
  color: var(--sk-ink-0);
}

/* warm blue — secondary HUD card */
.sk-panel-azure {
  --sk-panel-bw-v: 32px;
  --sk-panel-bw-h: 32px;
  border-image: url("ui-pack/2x/bgbox/BGbox_01B.png") 32 fill;
  color: var(--sk-paper-0);
}

/* dark stone — settings / system panels.
   This sprite is an organic pillow with non-uniform edges — it
   can't be 9-sliced cleanly. Render it as a single stretched
   background instead. The chunky corner blobs stay visible at
   any size; mid-edges look continuous because the speckled
   texture is supposed to look irregular. */
.sk-panel-stone {
  --sk-panel-bw-v: 0px;
  --sk-panel-bw-h: 0px;
  border: none;
  padding: 28px 28px;
  background: url("ui-pack/2x/bgbox/BGbox_04B.png") no-repeat center / 100% 100%;
  color: var(--sk-paper-0);
}

/* ============================================================
   BANNERS — 3-slice HORIZONTAL (left cap · middle stretch · right cap)

   Source banners include a baked-in drop shadow below the body,
   so a vertical cut would smear that shadow into the top edge.
   We slice only along x (top/bot slice = 0), and render the
   banner at the source's native height so the caps draw 1:1.

   Slices measured from column-uniformity scan:
     BannerMedium_*:  cap = 26px wide   (96×64 source)
     BannerSmall_*:   cap = 18px wide   (96×32 source)
   ============================================================ */
.sk-banner {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 64px;
  padding: 0 38px 12px;  /* extra bottom for the baked-in shadow */
  border-style: solid;
  border-width: 0 26px;
  font-family: "RPGtitle", monospace;
  font-size: 22px;
  line-height: 1;
  color: var(--sk-paper-0);
  text-shadow: 0 2px 0 rgba(0,0,0,0.45);
  white-space: nowrap;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  box-sizing: border-box;
}
.sk-banner-navy     { border-image: url("ui-pack/2x/banner/BannerMedium_01B.png") 0 26 fill; }
.sk-banner-azure    { border-image: url("ui-pack/2x/banner/BannerMedium_02B.png") 0 26 fill; color: var(--sk-ink-0); text-shadow: none; }
.sk-banner-blood    { border-image: url("ui-pack/2x/banner/BannerMedium_01A.png") 0 26 fill; color: var(--sk-paper-0); }
.sk-banner-moss     { border-image: url("ui-pack/2x/banner/BannerMedium_06A.png") 0 26 fill; color: var(--sk-paper-0); }

.sk-banner-small {
  height: 32px;
  padding: 0 22px 6px;
  border-width: 0 18px;
  font-size: 14px;
}
.sk-banner-small.sk-banner-navy   { border-image: url("ui-pack/2x/banner/BannerSmall_01B.png") 0 18 fill; }
.sk-banner-small.sk-banner-azure  { border-image: url("ui-pack/2x/banner/BannerSmall_02B.png") 0 18 fill; color: var(--sk-ink-0); text-shadow: none; }
.sk-banner-small.sk-banner-blood  { border-image: url("ui-pack/2x/banner/BannerSmall_01A.png") 0 18 fill; }
.sk-banner-small.sk-banner-moss   { border-image: url("ui-pack/2x/banner/BannerSmall_06A.png") 0 18 fill; }

/* Banner pinned to top of panel (overlapping). Absolute children are
   positioned relative to the parent's PADDING box, so `top: 0` would
   land at the inside of the top border. We offset by -1 × border-width
   to reach the panel's outer top edge, then translate(-50%) horizontally
   and -50% vertically so the banner's midline straddles that edge. */
.sk-panel-title {
  position: absolute;
  top: calc(-1 * var(--sk-panel-bw-v, 16px));
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

/* ============================================================
   BUTTONS — 3-slice HORIZONTAL (cleaned sprites)

   Source buttons are 64×32 with a 4-row baked-in salmon drop
   shadow at the bottom. Cropped versions live in button-clean/
   (64×28, shadow removed). Render at 28px height with caps of
   16px so the bevel reads 1:1 with no white halo.
   ============================================================ */
.sk-btn {
  --btn-img-normal: url("ui-pack/2x/button-clean/Button_01B_Normal.png");
  --btn-img-pressed: url("ui-pack/2x/button-clean/Button_01B_Pressed.png");
  --btn-img-selected: url("ui-pack/2x/button-clean/Button_01B_Selected.png");
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 28px;
  padding: 0 22px;
  border-style: solid;
  border-width: 0 16px;
  border-image: var(--btn-img-normal) 0 16 fill;
  font-family: "RPGtitle", monospace;
  font-size: 18px;
  line-height: 1;
  color: var(--sk-paper-0);
  text-shadow: 0 2px 0 rgba(0,0,0,0.55);
  cursor: pointer;
  user-select: none;
  transition: filter 80ms steps(2,end);
  position: relative;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  box-sizing: border-box;
  background: transparent;
}
.sk-btn:hover        { border-image: var(--btn-img-selected) 0 16 fill; filter: brightness(1.05); }
.sk-btn:active,
.sk-btn.is-pressed   { border-image: var(--btn-img-pressed) 0 16 fill; transform: translateY(2px); }
.sk-btn.is-selected  { border-image: var(--btn-img-selected) 0 16 fill; }
.sk-btn[disabled]    { filter: grayscale(0.7) brightness(0.7); cursor: not-allowed; }

/* button variants — only two: blue (primary action) and slate (secondary).
   .sk-btn-blood and .sk-btn-gold are aliases of these so existing markup
   keeps rendering, but visually they reduce to the same two-button system. */
.sk-btn-navy,
.sk-btn-blood,
.sk-btn-gold {
  --btn-img-normal:   url("ui-pack/2x/button-clean/Button_01B_Normal.png");
  --btn-img-pressed:  url("ui-pack/2x/button-clean/Button_01B_Pressed.png");
  --btn-img-selected: url("ui-pack/2x/button-clean/Button_01B_Selected.png");
}
.sk-btn-stone {
  --btn-img-normal:   url("ui-pack/2x/button-clean/Button_03B_Normal.png");
  --btn-img-pressed:  url("ui-pack/2x/button-clean/Button_03B_Pressed.png");
  --btn-img-selected: url("ui-pack/2x/button-clean/Button_03B_Selected.png");
}

/* ============================================================
   ORBS — pack PNGs displayed at native pixel size
   ============================================================ */
.sk-orb-wrap {
  position: relative;
  display: inline-block;
  width: 96px;
  height: 96px;
}
.sk-orb-wrap > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}
.sk-orb-wrap > .sk-orb-frame { z-index: 2; }
.sk-orb-wrap > .sk-orb-fill  { z-index: 1; }
.sk-orb-label {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-family: "RPGtext", monospace;
  font-size: 12px;
  color: var(--sk-paper-1);
  letter-spacing: 1px;
  white-space: nowrap;
}

/* Orb fill drain mask — clipping for current value */
.sk-orb-fill {
  --orb-pct: 100%;
  clip-path: inset(calc(100% - var(--orb-pct)) 0 0 0);
}

/* ============================================================
/* ============================================================
   STAT BARS — 3-slice horizontal track + solid-color fill

   Slider01_Box source is 96×32:
     · pill body sits at y=8..23
     · inner "well" (where the fill lives) is y=14..17 (4px tall)
     · cap is 10px wide (column-uniformity scan)
   The track is rendered at native source height (32px) for
   pixel-perfect caps. The fill is a single coloured div sized
   to the well: solid pixels read as crisply as the sprite-fill
   PNG would, but stay flat at any track length.
   ============================================================ */
.sk-bar {
  position: relative;
  display: block;
  width: 240px;
  height: 24px;
  border-style: solid;
  border-width: 0 10px;
  border-image: url("ui-pack/2x/slider-clean/Slider01_Box.png") 0 10 fill;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  box-sizing: border-box;
  background: transparent;
}
.sk-bar-fill {
  position: absolute;
  top: 14px;
  left: 0;
  height: 4px;
  width: var(--bar-pct, 50%);
  background-color: currentColor;
}
.sk-bar-fill-red    { color: rgb(230, 69, 57);   }
.sk-bar-fill-orange { color: rgb(255, 137, 51);  }
.sk-bar-fill-yellow { color: rgb(255, 200, 70);  }
.sk-bar-fill-green  { color: rgb(200, 212, 93);  }
.sk-bar-fill-blue   { color: rgb(146, 232, 192); }

/* labelled bar layout */
.sk-stat {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 10px;
  font-family: "RPGtext", monospace;
  color: var(--sk-paper-1);
  font-size: 12px;
}
.sk-stat-label { text-transform: uppercase; letter-spacing: 1.5px; font-size: 11px; }
.sk-stat-val { font-family: "RPGtitle", monospace; font-size: 14px; color: var(--sk-paper-0); }

/* ============================================================
   SLIDERS — interactive (cleaned sprites)
   Track = cropped Slider01_Box (96×24), rendered at native 24px
   height with 10px caps so it pixel-matches the stat bar.
   Fill = thin colored bar in the same well row.
   Knob = circular slider button sprite, native size.
   ============================================================ */
.sk-slider {
  position: relative;
  width: 240px;
  height: 24px;
  border-style: solid;
  border-width: 0 10px;
  border-image: url("ui-pack/2x/slider-clean/Slider01_Box.png") 0 10 fill;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  box-sizing: border-box;
  background: transparent;
}
.sk-slider-track {
  position: absolute;
  top: 14px;
  left: 0;
  height: 4px;
  width: var(--val, 50%);
  background-color: rgb(146, 232, 192);
}
.sk-slider-knob {
  position: absolute;
  top: 50%;
  left: var(--val, 50%);
  width: 24px;
  height: 24px;
  margin-left: -12px;
  margin-top: -12px;
  background: url("ui-pack/2x/slider/Slider01_Button.png") no-repeat center / contain;
  image-rendering: pixelated;
  cursor: ew-resize;
}

/* ============================================================
   SLOTS — inventory cells
   ============================================================ */
.sk-slot {
  position: relative;
  width: 64px;
  height: 64px;
  background: url("ui-pack/2x/slot/Slot_02_Empty.png") no-repeat center / 100% 100%;
  image-rendering: pixelated;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sk-slot > img {
  width: 64%;
  height: 64%;
  image-rendering: pixelated;
}
.sk-slot-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 6), 64px);
  gap: 4px;
}

/* ============================================================
   DIVIDERS — purely decorative
   ============================================================ */
.sk-divider {
  display: block;
  height: 16px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: auto 100%;
  image-rendering: pixelated;
  margin: 12px 0;
}
.sk-divider-ornate { background-image: url("ui-pack/2x/divider/Divider_07.png"); }
.sk-divider-rope   { background-image: url("ui-pack/2x/divider/Divider_03.png"); }
.sk-divider-thin   { background-image: url("ui-pack/2x/divider/Divider_01.png"); }

/* ============================================================
   ICONS — 32x32 mini icons (pack)
   ============================================================ */
.sk-icon {
  width: 32px;
  height: 32px;
  display: inline-block;
  image-rendering: pixelated;
  vertical-align: middle;
}
.sk-icon-lg { width: 48px; height: 48px; }
.sk-icon-sm { width: 24px; height: 24px; }

/* ============================================================
   CHECKBOXES
   ============================================================ */
.sk-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "RPGtext", monospace;
  color: var(--sk-paper-1);
  cursor: pointer;
}
.sk-check-box {
  width: 24px;
  height: 24px;
  background: url("ui-pack/2x/checkbox/Checkbox_01A_Off.png") no-repeat center / contain;
  image-rendering: pixelated;
  flex: 0 0 24px;
}
.sk-check.is-on .sk-check-box {
  background-image: url("ui-pack/2x/checkbox/Checkbox_01A_On.png");
}

/* ============================================================
   VOID CORRUPTION OVERLAY — synthwave accents
   Applied selectively: .is-corrupted on any element layers
   a subtle scanline + animated chromatic shimmer.
   Used to mark void-touched UI: low HP, cursed item, etc.
   ============================================================ */
@keyframes sk-shimmer {
  0%, 100% { opacity: 0.0; transform: translateX(-12%); }
  45%      { opacity: 0.5; }
  60%      { opacity: 0.0; }
}
@keyframes sk-pulse {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(155, 92, 255, 0.55)); }
  50%      { filter: drop-shadow(0 0 14px rgba(255, 58, 140, 0.7)); }
}
@keyframes sk-scan {
  0%   { background-position: 0 0; }
  100% { background-position: 0 8px; }
}

.is-corrupted {
  position: relative;
  isolation: isolate;
}
.is-corrupted::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(
      180deg,
      rgba(155, 92, 255, 0.0) 0px,
      rgba(155, 92, 255, 0.10) 2px,
      rgba(155, 92, 255, 0.0) 4px
    );
  mix-blend-mode: screen;
  animation: sk-scan 0.5s linear infinite;
  z-index: 5;
}
.is-corrupted::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 58, 140, 0.18) 45%,
    rgba(65, 224, 224, 0.18) 55%,
    transparent 100%
  );
  mix-blend-mode: screen;
  animation: sk-shimmer 2.4s ease-in-out infinite;
  z-index: 4;
}

/* Void glow — for important interactive accents */
.sk-glow-void  { box-shadow: 0 0 0 2px var(--sk-violet), 0 0 16px rgba(155, 92, 255, 0.6); }
.sk-glow-cyan  { filter: drop-shadow(0 0 6px rgba(65, 224, 224, 0.6)); }
.sk-glow-blood { filter: drop-shadow(0 0 8px rgba(255, 58, 140, 0.5)); }

/* Void-pulse for headings (low intensity by default) */
.sk-pulse { animation: sk-pulse 3.2s ease-in-out infinite; }

/* ============================================================
   PAGE / BACKDROP
   ============================================================ */
.sk-page-bg {
  background:
    /* faint scanlines */
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 2px,
      rgba(155, 92, 255, 0.025) 3px,
      transparent 4px
    ),
    /* vignette */
    radial-gradient(ellipse at top, #1a0e2a 0%, var(--sk-void) 55%, #050210 100%);
  min-height: 100vh;
  color: var(--sk-paper-1);
  font-family: "RPGtext", monospace;
}

/* ============================================================
   UTIL
   ============================================================ */
.sk-row    { display: flex; align-items: center; gap: var(--sk-gap-3); flex-wrap: wrap; }
.sk-col    { display: flex; flex-direction: column; gap: var(--sk-gap-3); }
.sk-stack  { display: flex; flex-direction: column; gap: var(--sk-gap-2); }
.sk-center { display: flex; align-items: center; justify-content: center; }
.sk-grow   { flex: 1 1 auto; }
