@import url('./frame-bars.css');
:root { --hq-frame-size: 32px; }
/* Standard frames always use the same source slice AND displayed corner size. */
.hq-frame {
  --frame-edge: var(--hq-frame-size);
  box-sizing: border-box; position: relative; isolation: isolate; min-width: 0;
  border: var(--frame-edge) solid transparent;
  border-image: url('/textures/frame-iron-v2.png') 25% / var(--frame-edge) stretch;
  padding: 12px; color: #f1e8d1;
}
.hq-frame::before {
  content: ''; position: absolute; inset: calc(var(--frame-edge) * -.32); z-index: -1;
  background: #23292e url('/textures/forged-steel-v2.jpg'); pointer-events: none;
}
.hq-frame--gold { border-image-source: url('/textures/frame-gold-v2.png'); }
.hq-frame--paper { color: #2c2117; }
.hq-frame--paper::before { background: #ead8aa url('/textures/parchment-v1.jpg'); }
.hq-frame--slot { padding: 6px; }
.hq-frame--compact { --frame-edge: 24px; }
/* Explicit plain-edge option, useful for numbers and narrow gold counters. */
.hq-frame--plain {
  --frame-edge: 6px; border-image: none; border-color: #737b81 #252c33 #11161b #92999c;
  box-shadow: inset 0 0 0 2px #090c10, 0 2px 1px #000a;
}
.hq-frame--plain.hq-frame--gold { border-color: #e8c879 #82602d #493319 #cfab5c; }
.hq-number-window, .wheel .readout {
  box-sizing: border-box; display: flex; align-items: center; justify-content: center;
  width: 100%; max-width: 172px; min-width: 0; min-height: 62px;
  padding: 0 3px; gap: 3px;
  border: solid transparent; border-width: 10px 12px;
  border-image: url('/textures/number-bezel-v3.png') 30% 12% fill / 10px 12px stretch;
  background: #000; background-clip: padding-box; box-shadow: none;
  filter: drop-shadow(0 -1px 0 #b9c3c099) drop-shadow(0 2px 1px #030507ee);
  color: #fff0cb; font: bold 32px/1.1 var(--font-display, Georgia, serif);
  font-variant-numeric: tabular-nums; text-align: center;
}
.hq-number-window--gold { border-color: #e8c879 #82602d #493319 #cfab5c; }
.hq-thumbwheel {
  position: relative; isolation: isolate; display: block;
  width: 172px; max-width: 100%; height: 48px;
  min-height: 48px; border: 0; padding: 0; background: transparent;
  cursor: grab; touch-action: pan-y;
}
.hq-thumbwheel::before {
  content: ''; position: absolute; inset: 7% 8% 12%; border-radius: 40%;
  background: #080b0e; box-shadow: inset 0 3px 5px #000, 0 1px 0 #697078;
  pointer-events: none;
}
/* No side bars: the toothed rim is exposed and its axle stays hidden. */
.hq-thumbwheel::after { content: none; }
.hq-roller {
  position: absolute; inset: 0 2%; display: block; overflow: visible;
  clip-path: inset(3px -12px -20px);
  container-type: inline-size; pointer-events: none;
}
.hq-roller__view { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateX(-8deg); }
.hq-roller__cylinder, .hq-roller__segment { position: absolute; inset: 0; transform-style: preserve-3d; }
.hq-roller__core {
  position: absolute; left: 50%; top: 23%; width: 14.4cqw; height: 53%;
  transform: translateX(-50%) translateZ(40cqw); backface-visibility: hidden;
  background: #282d34; border-top: 1px solid #646971; border-bottom: 1px solid #0b0e12;
}
.hq-roller__tooth {
  position: absolute; left: 50%; top: 12%; width: 11.8cqw; height: 73%;
  transform: translateX(-50%) translateZ(46cqw); transform-style: preserve-3d;
  backface-visibility: hidden;
  background: url('/textures/roller-teeth-v1.png') 0 center / 800% 100% no-repeat;
  box-shadow: inset 1px 0 #c5c3b888, inset -2px 0 #080c12aa;
}
.hq-roller__tooth::before, .hq-roller__tooth::after {
  content: ''; position: absolute; left: 0; width: 100%; height: 7cqw;
  background: #68717a url('/textures/forged-steel-v2.jpg') center / 80px;
  border: 1px solid #b5b8b5; box-sizing: border-box;
}
.hq-roller__tooth::before { top: 0; transform-origin: top; transform: rotateX(-90deg); filter: brightness(1.8); }
.hq-roller__tooth::after { bottom: 0; transform-origin: bottom; transform: rotateX(90deg); filter: brightness(.7); }
.hq-roller::after {
  content: ''; position: absolute; inset: 9% -1% 0; border-radius: 20%;
  background: linear-gradient(90deg,#030508ed, #080b0f77 12%,transparent 35%,#fff3d51a 48%,transparent 60%,#080b0f88 88%,#030508ed);
}
.hq-roller__cylinder::before {
  content: ''; position: absolute; left: 10%; top: 23%; width: 80%; height: 80cqw;
  border-radius: 50%; transform: translateY(-50%) rotateX(90deg);
  background: radial-gradient(circle,#2b3035 0 55%,#565e65 56% 58%,#252b31 59% 92%,#878d91 93% 96%,#151a20 98%);
}
/* The number, its suffix and the wheel share one width. */
.hq-stat-base, .wheel .housing, .wheel.wheel--row .housing {
  --control-width: 172px;
  box-sizing: border-box; position: relative; isolation: isolate;
  width: 100%; max-width: 212px;
  display: flex; flex-direction: column; align-items: center;
  gap: 5px; padding: 24px 20px 0; border: 0; background: none; filter: none;
}
/* Painted chassis under a painted notched faceplate. Source corners and
   the notch shoulders stay fixed; only straight rails and flat metal stretch. */
.hq-stat-base::before, .wheel .housing::before {
  content: ''; position: absolute; inset: 2px 2px 0; z-index: -2;
  border: 18px solid transparent;
  border-image: url('/textures/stat-chassis-v1.png') 20% fill / 18px stretch;
  pointer-events: none;
}
.hq-stat-base::after, .wheel .housing::after {
  content: ''; position: absolute; inset: 0 0 -16px; z-index: -1;
  border: 28px solid transparent;
  border-image: url('/textures/stat-face-v1.png') 30% fill / 28px stretch;
  mask: linear-gradient(#000 0 0) top / 100% calc(100% - 46px) no-repeat;
  pointer-events: none;
}
.wheel .readout { width: min(100%, var(--control-width)); }
.wheel .readout .drum {
  flex: 1 1 0; width: 0; min-width: 32px; max-width: 90px; height: 44px;
  border: 0; background: none; box-shadow: none; border-radius: 0;
}
.wheel .readout .drum::after { background: none; }
.wheel .readout .drum__number { font-size: clamp(16px,calc(38px - var(--number-digits,1) * 6px),32px); }
.wheel .readout .drum--input { color: #fff0cb; font-size: 30px; }
.wheel .readout .readout__suffix { flex: 0 0 auto; padding-right: 3px; font-size: 1.1rem; }
.wheel .readout .readout__icon .icon { width: 24px; height: 24px; }
.wheel .drum:focus-visible { outline: 2px solid #ffe39a; outline-offset: -2px; }
.wheel .wheel__wheel, .wheel.wheel--row .wheel__wheel {
  width: min(100%, var(--control-width)); max-width: 172px; height: 48px; min-height: 48px;
  aspect-ratio: auto; border: 0; padding: 0; border-radius: 4px; background: none;
  transform: translateY(7px); margin: 0 0 -7px; z-index: 1;
  filter: drop-shadow(0 4px 2px #08090baa);
}
.wheel.wheel--stack { padding-bottom: 22px; }
.wheel.wheel--row .housing { --control-width: 132px; width: min(55%,132px); flex: none; }
.wheel .wheel__wheel:focus-visible, .hq-thumbwheel:focus-visible { outline: 2px solid #ffe39a; outline-offset: 2px; }
/* Glass lenses seated in a dark machine rail: red/blue, off/on. */
.bulbs.bulbs {
  display: flex; flex-wrap: nowrap; justify-content: center; align-items: center; gap: 3px;
  width: min(100%,172px); max-width: 172px; min-height: 24px;
  padding: 4px 5px; border: 1px solid #0b0e13; border-radius: 4px;
  background: linear-gradient(#12161c,#313840); box-shadow: inset 0 1px 1px #000,0 1px 0 #646a6c;
}
.hq-lamp, .bulb.bulb {
  --lamp-bright: #ff5c43; --lamp-dark: #411713; --lamp-glow: #fa422b80;
  display: inline-block; box-sizing: border-box; width: 17px; max-width: 17px; height: auto;
  flex: 0 1 17px; min-width: 0;
  aspect-ratio: 1; border: 2px solid #868c8b; border-radius: 50%;
  background: radial-gradient(ellipse at 32% 23%, #ffffff3b,transparent 36%),radial-gradient(circle at 45% 40%,var(--lamp-dark),#080b10 88%);
  box-shadow: 0 1px 0 #05070a,inset 0 0 0 1px #05070a,inset 0 -2px 2px #0008;
  transition: background-color 100ms,box-shadow 100ms;
}
.hq-lamp--mind, .tone-mind .bulb.bulb { --lamp-bright: #65c9ff; --lamp-dark: #112b48; --lamp-glow: #2a9cff80; }
.hq-lamp.is-lit, .bulb.bulb.is-lit {
  background: radial-gradient(ellipse at 32% 23%,#fff 0 9%,#ffffff80 15%,transparent 30%),radial-gradient(circle at 45% 40%,var(--lamp-bright) 25%,var(--lamp-dark) 85%);
  box-shadow: 0 1px 0 #05070a,inset 0 0 0 1px #05070a,0 0 6px 1px var(--lamp-glow);
}
@media (prefers-reduced-motion: reduce) { .hq-roller__cylinder { transform: none !important; } .hq-lamp,.bulb.bulb { transition: none; } }
[data-reduce-motion='true'] .hq-roller__cylinder { transform: none !important; }
/* App frames use the SAME 32px corner size irrespective of their container. */
.panel.panel {
  --frame-edge: var(--hq-frame-size); isolation: isolate;
  border: var(--frame-edge) solid transparent;
  border-image: url('/textures/frame-iron-v2.png') 25% / var(--frame-edge) stretch; background: none;
}
.panel.panel::before {
  content: ''; position: absolute; inset: calc(var(--frame-edge) * -.32); z-index: -1;
  background: #23292e url('/textures/forged-steel-v2.jpg'); pointer-events: none;
}
.panel.gold { border-image-source: url('/textures/frame-gold-v2.png'); }
.sheet.sheet { border: 0; background: #ead8aa url('/textures/parchment-v1.jpg'); }
.sheet.sheet::after {
  content: ''; position: absolute; inset: 0; z-index: 4;
  border: var(--hq-frame-size) solid transparent;
  border-image: url('/textures/frame-iron-v2.png') 25% / var(--hq-frame-size) stretch; pointer-events: none;
}
.sheet .sheet__rail { background: #23292e url('/textures/forged-steel-v2.jpg'); padding-inline: 22px; }
.sheet .sheet__footer { padding-inline: 22px; padding-bottom: max(20px,env(safe-area-inset-bottom)); }
.sheet .sheet__body { padding-inline: 20px; }
/* Original gold coin art, with HTML amounts over the blank center. */
.coin.coin {
  width: 54px; height: 54px; flex: 0 0 54px; padding: 0; border: 0;
  background: url('/textures/gold-coin-v1.png') center / contain no-repeat;
  box-shadow: none; filter: drop-shadow(0 3px 0 #3f2915); border-radius: 50%;
}
.coin.coin:active { transform: translateY(2px); box-shadow: none; filter: drop-shadow(0 1px 0 #3f2915); }
.coin .coin__face { color: #26190c; text-shadow: 0 1px #f5d889; font-weight: 900; }
@media(max-width:360px) { .coin.coin { width:46px; height:46px; flex-basis:46px; } }

/* Painted lower assembly ends at the chassis baseline, including both feet. */
.hq-stat-foot {
  position: absolute; left: 0; bottom: -10px; width: 100%; height: 52px; z-index: 2;
  border: solid transparent; border-width: 14px 28px 28px;
  border-image: url('/textures/stat-foot-v1.png') 30% 17% 30% fill / 14px 28px 28px stretch;
  pointer-events: none;
}
/* Readouts stay uniformly black, including while typing or turning. */
.wheel .readout .drum__strip { background: none; }
.wheel .readout .drum--input { background: #000; }
/* Raised painted title plate overlaps behind the front housing. */
.wheel.wheel { position: relative; isolation: isolate; container-type: inline-size; gap: 0; }
.wheel .control-title {
  position: relative; z-index: 0; width: min(100%,212px); align-self: center;
  min-height: 66px; margin-bottom: -10px; padding: 2px 0 6px;
  border: 12px solid transparent;
  border-image: url('/textures/stat-title-v1.png') 35% 16% fill / 12px stretch;
  gap: 5px; letter-spacing: .025em;
}
.wheel .housing { z-index: 1; }
.wheel .control-title__text { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.1; }
.wheel .control-title__button { justify-content: center; width: 100%; padding: 0; min-height: 34px; gap: 5px; }
.wheel .stat-emblem { object-fit: contain; flex: 0 0 28px; filter: drop-shadow(0 1px 1px #000); }
.wheel.wheel--row .control-title { width: auto; align-self: flex-start; margin-bottom: 0; }
@container(max-width:140px) {
  .wheel .control-title, .wheel .control-title__button { flex-direction: column; }
  .wheel .control-title { min-height: 80px; font-size: .75rem; }
  .wheel .control-title__more { display: none; }
  .wheel .stat-emblem { width: 25px; height: 25px; flex-basis: 25px; }
}

/* The saved sheet and creation share full-width stat pairs and side emblems. */
:is(.hero-board,.stat-board) .wheel--stack { align-items: center; }
:is(.hero-board,.stat-board) .wheel .control-title {
  flex-direction: row; width: min(85%,180px); margin-top: 8px; min-height: 62px;
  padding: 4px 0; color: var(--gold); font-size: clamp(11px,8cqw,16px);
}
:is(.hero-board,.stat-board) .wheel .control-title__button {
  position: static; flex-direction: row; min-height: 30px;
}
:is(.hero-board,.stat-board) .wheel .stat-emblem {
  position: absolute; left: -31px; top: calc(50% - 8px); transform: translateY(-50%);
  width: clamp(50px,22cqw,62px); height: clamp(50px,22cqw,62px);
}
:is(.hero-board .vitals,.stat-board .tone-body,.stat-board .tone-mind) .stat-emblem {
  width: clamp(62px,28cqw,76px); height: clamp(62px,28cqw,76px);
  filter: grayscale(1) drop-shadow(0 2px 1px #000);
}
:is(.hero-board,.stat-board) .wheel .control-title__text { width: 100%; padding-left: 22px; text-align: center; }
:is(.hero-board .vitals,.stat-board .tone-body,.stat-board .tone-mind) .control-title { font-size: clamp(14px,10cqw,18px); }

:is(.hero-board,.stat-board) .control-title:not(:has(.stat-emblem,.icon)) .control-title__text { padding-left: 0; }
