/* Civ & Spire UI kit (HA 5631) — the ONE source for every component skin. Screens (style.css, v3.css, loadscreen.js,
   lobby.html) only lay things out; how a panel / button / tab / row / meter / chip / tooltip / modal / sheet / top bar
   LOOKS lives here.
   CIV 6 (transcribed, Base/Assets/UI): structure + frames + textures + meters + tooltip format + type hierarchy.
     textures  art/civ6ui/* (tools/civ6-ui-assets.py from UI_Controls/UI_HUD .blp); 9-slice insets from Civ6_Styles.xml
     type      body = Myriad Pro Semibold 14-16 (FontNormal*), numbers Myriad Bold; text 208,212,217 (TabFont Color0)
     tooltip   Controls_Tooltip light box, ink 5,29,51 (TTText), title / stats / cost / description blocks
     buttons   Controls_Button (Grid9MainButton), Controls_Confirm (Grid9ConfirmButton) for the one primary action
     rows      ProductionPanel_ChooserButton, icon left, name, turns-left big on the right, cost under it
     meters    CityPanel_MeterBacking + CityPanel_ProductionMeter / CitizenMeter (+ the Small variants in rows)
     panels    CityPanel_StatPanel navy gradient, bronze rim; modal = Controls_WindowFrame ornate frame
     top bar   TopBar_Back strip, yield chips = TopBar_YieldBacking colours (TopPanel.xml), Civ font icons
   SPIRE (accents only): gold-ink headings in Kreon small caps (StS2's UI face), the gold rim tone, the StS2 click/hover
   sfx (sfx.js 'ui_click'), card/relic/character art inside the chrome. */
@font-face { font-family: Kreon; src: url(fonts/kreon_bold.ttf); font-weight: 700; font-display: swap; }   /* StS2's UI face (headings) */
@font-face { font-family: 'Civ Myriad'; src: url(fonts/civ6/myriad-semibold.otf); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Civ Myriad'; src: url(fonts/civ6/myriad-regular.otf); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Civ Myriad'; src: url(fonts/civ6/myriad-bold.otf); font-weight: 700; font-display: swap; }

:root {
  --k-font: 'Civ Myriad', 'Myriad Pro', 'Segoe UI', system-ui, sans-serif;
  --k-head: Kreon, Spectral, serif;
  --k-text: rgb(208, 212, 217);           /* Civ TabFont / ButtonFont Color0 */
  --k-dim: rgb(143, 160, 176);
  --k-ink: rgb(5, 29, 51);                /* Civ TTText / TabSelectedFont */
  --k-gold: #efc851;                      /* Spire gold ink (headings, rims) */
  --k-rim: #a8865a;                       /* bronze rim, Civ panel edge + Spire gold mixed */
  --k-navy0: #07111c; --k-navy1: #0d2236; --k-navy2: #14385a;
  --k-food: #8ec94a; --k-prod: #e3893b; --k-gold-y: rgb(185, 176, 70); --k-sci: rgb(24, 156, 216); --k-red: #e0533f;
  --k-row-h: 44px;
}

/* ---- type hierarchy (Civ: FontFlair headers in small caps, FontNormal body) ---- */
body { font-family: var(--k-font); color: var(--k-text); }
.k-h1, .k-h2, .k-h3, .panel h3, .panel h4, .modal h2, .modal h3 { font-family: var(--k-head); font-weight: 700; font-variant: small-caps; letter-spacing: 0.04em; color: var(--k-gold); margin: 0; }
.k-h1 { font-size: 30px; } .k-h2, .modal h2 { font-size: 22px; } .k-h3, .panel h3 { font-size: 19px; } .panel h4 { font-size: 15px; letter-spacing: 0.1em; }
.k-dim { color: var(--k-dim); }
kbd { font-family: var(--k-font); font-size: 11px; color: var(--k-dim); border: 1px solid rgba(208, 212, 217, 0.25); border-radius: 3px; padding: 0 4px; margin-left: 4px; }

/* ---- panel (CityPanel_StatPanel navy + bronze rim) ---- */
.panel, .k-panel { background: url(art/civ6ui/CityPanel_StatPanel.png) center / 100% 100%, var(--k-navy1); border: 1px solid var(--k-rim);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.55), 0 6px 18px rgba(0, 0, 0, 0.55); border-radius: 4px; padding: 10px 12px; color: var(--k-text); font-size: 15px; line-height: 1.35; }
.panel h4, .k-section { display: block; padding-bottom: 6px; margin-bottom: 6px; background: url(art/civ6ui/Controls_DivHeader.png) center bottom / 100% 12px no-repeat; }

/* ---- buttons (Grid9MainButton: Controls_Button, corners 41,20 of 80x41; Grid9ConfirmButton for the primary) ---- */
.btn, .k-btn { font-family: var(--k-font); font-weight: 600; font-size: 15px; color: var(--k-text); text-shadow: 0 1px 2px rgba(16, 43, 67, 0.9);
  border-style: solid; border-width: 10px 18px; border-image: url(art/civ6ui/Controls_Button_normal.png) 20 38 20 41 fill / 10px 18px stretch;
  background: none; padding: 2px 4px; margin: 3px; min-height: 36px; cursor: pointer; border-radius: 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover:not([disabled]), .k-btn:hover:not([disabled]) { border-image-source: url(art/civ6ui/Controls_Button_over.png); }
.btn:active:not([disabled]), .k-btn:active:not([disabled]) { border-image-source: url(art/civ6ui/Controls_Button_down.png); }
.btn[disabled], .k-btn[disabled] { border-image-source: url(art/civ6ui/Controls_Button_disabled.png); color: rgba(208, 212, 217, 0.45); cursor: not-allowed; }
.btn.primary, .k-btn.primary { border-image-source: url(art/civ6ui/Controls_Confirm_normal.png); border-image-slice: 20 45 20 34 fill; color: #fff; }
.btn.primary:hover:not([disabled]), .k-btn.primary:hover:not([disabled]) { border-image-source: url(art/civ6ui/Controls_Confirm_over.png); }
.btn.primary[disabled], .k-btn.primary[disabled] { border-image-source: url(art/civ6ui/Controls_Confirm_disabled.png); }
.btn.small { font-size: 13px; min-height: 30px; border-width: 8px 14px; border-image-width: 8px 14px; }
.btn.warn { color: var(--k-gold); }

/* ---- tabs (TabButtonGrid; selected = SliceStart 0,136 with dark ink text — ONE highlight, nothing else) ---- */
.k-tabs { display: flex; gap: 2px; }
.k-tab { flex: 1; font-family: var(--k-font); font-weight: 600; font-size: 15px; color: var(--k-text); background: none; cursor: pointer; min-height: 40px;
  border-style: solid; border-width: 8px 10px; border-image: url(art/civ6ui/Controls_Tab_normal.png) 16 20 17 21 fill / 8px 10px stretch; }
.k-tab:hover { border-image-source: url(art/civ6ui/Controls_Tab_over.png); }
.k-tab[aria-selected="true"] { border-image-source: url(art/civ6ui/Controls_Tab_sel.png); color: var(--k-ink); }

/* ---- list rows (ProductionPanel_ChooserButton): icon | name / sub | turns-left (big) + cost ---- */
.bopts, .k-rows { display: flex; flex-direction: column; gap: 3px; }
.bopt, .k-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 2px 8px; width: 100%; min-height: var(--k-row-h); text-align: left;
  font-family: var(--k-font); font-weight: 600; font-size: 15px; color: var(--k-text); background: none; cursor: pointer; padding: 0 4px;
  border-style: solid; border-width: 6px; border-image: url(art/civ6ui/ProductionPanel_ChooserButton_normal.png) 12 fill / 6px stretch; }
.bopt:hover:not([disabled]), .k-row:hover:not([disabled]) { border-image-source: url(art/civ6ui/ProductionPanel_ChooserButton_over.png); }
.bopt.active, .k-row.active { border-image-source: url(art/civ6ui/ProductionPanel_ChooserButton_down.png); color: #fff; }
.bopt[disabled], .k-row[disabled] { border-image-source: url(art/civ6ui/ProductionPanel_ChooserButton_disabled.png); color: rgba(208, 212, 217, 0.4); cursor: not-allowed; }
.k-row .ri { grid-column: 1; grid-row: 1 / 3; width: 34px; height: 34px; display: grid; place-items: center; }
.k-row .ri img, .k-row .ri .uicon, .k-row .ri .bic { width: 32px; height: 32px; }
.k-row .rn { grid-column: 2; grid-row: 1; align-self: end; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.k-row .rs { grid-column: 2; grid-row: 2; align-self: start; font-size: 12px; font-weight: 400; color: var(--k-dim); line-height: 1.2; }
.k-row .rt { grid-column: 3; grid-row: 1 / 3; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; min-width: 52px; }
.k-row .rt b { font-weight: 700; font-size: 20px; line-height: 1; color: #fff; display: inline-flex; align-items: center; gap: 2px; }   /* Civ CostText "7 [ICON_Turn]" */
.k-row .rt b img { width: 18px; height: 18px; vertical-align: 0; }
.k-row .rt small { font-size: 11px; font-weight: 400; color: var(--k-dim); }
.k-row[disabled] .rt b { color: inherit; }

/* ---- meters (CityPanel_MeterBacking + *Meter fill; Small variants for rows) ---- */
.k-meter { position: relative; height: 21px; border-style: solid; border-width: 0 10px; border-image: url(art/civ6ui/CityPanel_MeterBacking.png) 0 10 fill / 0 10px stretch; }
.k-meter > i { position: absolute; left: -8px; top: 2px; bottom: 2px; max-width: calc(100% + 16px); background: url(art/civ6ui/CityPanel_ProductionMeter.png) left center / 178px 100%; border-radius: 8px; }
.k-meter.food > i { background-image: url(art/civ6ui/CityPanel_CitizenMeter.png); }
.k-meter > span { position: absolute; inset: 0 -6px; display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 13px; line-height: 21px; text-shadow: 0 1px 2px #000; white-space: nowrap; }
.k-meter > span b { font-weight: 700; color: #fff; }

/* ---- yield chips (TopBar_YieldBacking colours from TopPanel.xml) + Civ font icons ---- */
.k-chip, .stat { display: inline-flex; align-items: center; gap: 3px; font-family: var(--k-font); font-weight: 700; font-size: 16px; color: var(--k-text); white-space: nowrap; }
.k-chip { padding: 1px 8px; border-radius: 11px; background: rgba(255, 255, 255, 0.08); }
.k-chip.food { background: rgba(142, 201, 74, 0.28); } .k-chip.prod { background: rgba(227, 137, 59, 0.3); }
.k-chip.gold { background: rgba(185, 176, 70, 0.59); } .k-chip.sci { background: rgba(24, 156, 216, 0.59); }
.fi { width: 20px; height: 20px; vertical-align: -4px; }
.fi.s { width: 16px; height: 16px; vertical-align: -3px; }

/* ---- top bar (TopBar_Back strip) ---- */
.topbar.v3 { background: url(art/civ6ui/TopBar_Back.png) center / 100% 100%, var(--k-navy0); border-bottom: 1px solid var(--k-rim); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6); }
.topbar.v3 button.stat { border-style: solid; border-width: 3px 6px; border-image: url(art/civ6ui/Controls_Button_normal.png) 20 38 20 41 fill / 3px 6px stretch; background: none; cursor: pointer; padding: 0 1px; min-height: 30px; }
.topbar.v3 button.stat:hover { border-image-source: url(art/civ6ui/Controls_Button_over.png); }
.topbar.v3 .stat small { font-size: 12px; font-weight: 600; color: var(--k-dim); }

/* ---- tooltip (Controls_Tooltip, SliceCorner 10 of 33x32; TTText ink) — Civ format: title / stats / cost / text ---- */
.tip, .k-tip { position: fixed; z-index: 50; max-width: 340px; pointer-events: none; font-family: var(--k-font); font-weight: 400; font-size: 14px; line-height: 1.35; color: var(--k-ink);
  border-style: solid; border-width: 10px; border-image: url(art/civ6ui/Controls_Tooltip.png) 10 fill / 10px stretch; background: none; border-radius: 0; padding: 2px 4px;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.55)); }
.tip b, .tip strong { font-weight: 700; }
.tip .tt-t { display: block; font-weight: 700; font-size: 16px; text-transform: uppercase; letter-spacing: 0.02em; }
.tip .tt-s { display: block; color: rgba(5, 29, 51, 0.75); }
.tip .tt-c { display: block; font-weight: 600; }
.tip .tt-d { display: block; margin-top: 4px; padding-top: 4px; border-top: 1px solid rgba(5, 29, 51, 0.25); }
.tip .red, .tip .warn { color: #a3271a; }

/* ---- modal (navy fill + Controls_WindowFrame ornate frame, corners 55 of 118) ---- */
.modal-back { position: fixed; inset: 0; background: rgba(2, 8, 14, 0.66); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal { position: relative; background: linear-gradient(180deg, #102a42, #0a1a2b); color: var(--k-text); max-width: min(1200px, 94vw); max-height: 92vh; overflow-y: auto; text-align: center; font-size: 16px;
  border-style: solid; border-width: 24px; border-image: url(art/civ6ui/Controls_WindowFrame.png) 55 / 24px stretch; padding: 4px 10px; border-radius: 0; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7); }
.modal p { margin: 6px 0 12px; }

/* ---- bottom sheet (phone): one grab handle is the only collapse/close control (HA 5619) ---- */
.k-sheet-grab { display: block; width: 100%; height: 22px; padding: 0; border: 0; background: none; cursor: grab; touch-action: none; }
.k-sheet-grab span { display: block; width: 44px; height: 5px; margin: 8px auto 0; border-radius: 3px; background: var(--k-rim); }

/* ---- choice cards (hero picks etc.): Civ chooser button, selected = the pressed state — one highlight ---- */
.k-card { background: none; color: var(--k-text); cursor: pointer; font-family: var(--k-font); font-weight: 600;
  border-style: solid; border-width: 6px; border-image: url(art/civ6ui/ProductionPanel_ChooserButton_normal.png) 12 fill / 6px stretch; }
.k-card:hover { border-image-source: url(art/civ6ui/ProductionPanel_ChooserButton_over.png); }
.k-card[aria-pressed="true"] { border-image-source: url(art/civ6ui/ProductionPanel_ChooserButton_down.png); color: #fff; }

/* ---- text input ---- */
.k-input { width: 100%; min-height: 44px; padding: 8px 12px; font: 600 16px var(--k-font); color: var(--k-text); background: var(--k-navy0); border: 1px solid var(--k-rim); border-radius: 3px; box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.7); }
.k-input:focus { outline: none; border-color: var(--k-gold); }

/* ---- touch: every control is a 44px target (mobile-a11y) — the kit owns it so no screen rule can undercut it ---- */
body.touch .btn, body.touch .k-tab, body.touch .k-row, body.touch .topbar.v3 button.stat { min-height: 44px; }
body.touch .topbar.v3 button.stat { min-width: 44px; }
html, body, button, [data-act] { touch-action: manipulation; }   /* HA 5778: no double-tap zoom eating taps (lobby too) */
