/* Hearthvale — app styles on top of the kit design system (core.css).
   Tokens only; map colours and cached building illustrations live in
   view.js/scene.js (canvas pixels), including the build-list thumbnails. */

:root { --mark-bg: var(--moss); }

/* ── play: layout ── */
.hv { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100%; min-height: 0; }
.hv-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 0; border-top: 1px solid var(--line); }
.hv-map { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--paper-2); container-type: size; }
@container (max-height: 300px) { .hv-mini, .hv-zoom { display: none; } }
.hv-found .segmented { justify-self: start; width: max-content; }
.hv-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; outline: none; }
.hv-mini { position: absolute; inset-inline-end: 12px; bottom: 12px; width: 150px; height: 150px; border-radius: 12px; border: 1px solid var(--line-2); box-shadow: var(--shadow-md); background: var(--surface); cursor: pointer; touch-action: none; }
.hv-zoom { position: absolute; inset-inline-end: 12px; bottom: 172px; display: grid; gap: 6px; }
.hv-zoom .icon-btn { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.hv-founding { position: absolute; inset: 0; overflow: auto; background: var(--paper); }

/* resource strip */
.hv-bar { display: flex; align-items: center; gap: 6px; padding: 8px 14px; overflow-x: auto; scrollbar-width: none; background: var(--paper); }
.hv-bar::-webkit-scrollbar { display: none; }
.hv-hudbox { display: flex; align-items: center; gap: 6px; }
.hv-speed { flex: none; margin-inline-end: 6px; }
.hv-speed button { height: 26px; }
.hv-date { display: inline-flex; align-items: center; gap: 8px; flex: none; padding-inline-end: 8px; font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.hv-date .season { width: 10px; height: 10px; border-radius: 50%; background: var(--moss); }
.hv-date .season.summer { background: var(--ochre); }
.hv-date .season.autumn { background: var(--rust); }
.hv-date .season.winter { background: var(--slate); }
.hv-hud { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 30px; padding: 0 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.hv-hud .icon { width: 15px; height: 15px; color: var(--ink-3); }
.hv-hud b { color: var(--ink); font-weight: 620; }
.hv-hud.bad { border-color: var(--rust-line); background: var(--rust-soft); }
.hv-hud.bad b, .hv-hud.bad .icon { color: var(--rust); }

/* overlays on the map */
.hv-warns { position: absolute; top: 12px; inset-inline-start: 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; max-width: 60%; pointer-events: none; }
.hv-warn { pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--ochre-line); color: var(--ochre-ink); font-size: 12.5px; font-weight: 560; box-shadow: var(--shadow-sm); }
.hv-warn .icon { width: 14px; height: 14px; }
.hv-hint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; max-width: min(560px, calc(100% - 24px)); padding: 8px 8px 8px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--moss-line); box-shadow: var(--shadow-md); }
.hv-hint.bad { border-color: var(--rust-line); }
.hv-hint-main { display: grid; gap: 1px; min-width: 0; }
.hv-hint-main b { font-size: 13.5px; }
.hv-hint-main span { font-size: 12px; color: var(--ink-3); }
.hv-hint.bad .hv-hint-main span { color: var(--rust); }

/* top-bar controls */
.hv-speed button { display: inline-grid; place-items: center; min-width: 38px; padding: 0 10px; font-variant-numeric: tabular-nums; }
.hv-speed .icon { width: 15px; height: 15px; }
.hv-save { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; color: var(--ink-3); }
.hv-save:hover { color: var(--ink); background: var(--paper-2); }
.hv-save .icon { width: 15px; height: 15px; }
.hv-save.saved .icon { color: var(--moss); }
.hv-save.saving .icon { animation: spin 1s linear infinite; }
.hv-save.error, .hv-save.offline { color: var(--rust); }

/* side panel */
.hv-side { display: flex; flex-direction: column; min-height: 0; border-inline-start: 1px solid var(--line); background: var(--paper-2); }
.hv-side-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); }
.hv-side-head .tabs { flex: 1; border-bottom: 0; margin: 0; overflow-x: auto; scrollbar-width: none; }
.hv-sheet-btn { display: none; }
.hv-panel-body { flex: 1; overflow: auto; overscroll-behavior: contain; }
.hv-pane { padding: 14px 14px 28px; }
.hv-ihead { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.hv-ihead h3 { font-size: 19px; }
.hv-ihead p { margin-top: 3px; }
.hv-kv { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.hv-kv > span { color: var(--ink-2); }
.hv-kv b { font-weight: 600; text-align: end; }
.hv-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.hv-chips, .hv-cov, .hv-stock, .hv-names { display: flex; flex-wrap: wrap; gap: 6px; }
.hv-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); }
.hv-chip b { color: var(--ink); font-weight: 620; }
.hv-chip .icon { width: 13px; height: 13px; }
.hv-chip.ok { background: var(--moss-soft); border-color: var(--moss-line); color: var(--moss-ink); }
.hv-chip.warn { background: var(--ochre-soft); border-color: var(--ochre-line); color: var(--ochre-ink); }
.hv-name { padding: 3px 9px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; color: var(--ink); }
.hv-name:hover { border-color: var(--moss-line); color: var(--moss-ink); }
.hv-kv .hv-name { font-weight: 560; }

/* build list */
.hv-cats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.hv-cat { display: grid; justify-items: center; gap: 3px; padding: 8px 4px 7px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); font-size: 11.5px; color: var(--ink-2); }
.hv-cat span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hv-cat .icon { width: 18px; height: 18px; color: var(--ink-3); }
.hv-cat[aria-pressed="true"] { background: var(--moss-soft); border-color: var(--moss-line); color: var(--moss-ink); font-weight: 600; }
.hv-cat[aria-pressed="true"] .icon { color: var(--moss); }
.hv-blist { display: grid; gap: 8px; }
.hv-bcard { display: flex; gap: 11px; align-items: flex-start; width: 100%; padding: 10px 12px; border-radius: 13px; border: 1px solid var(--line); background: var(--surface); text-align: start; transition: border-color 0.15s, transform 0.15s; }
.hv-bcard:hover { border-color: var(--line-2); transform: translateY(-1px); }
.hv-bcard.on { border-color: var(--moss); box-shadow: 0 0 0 3px var(--moss-soft); }
.hv-bcard.short .hv-cost { color: var(--rust); }
.hv-bcard.short .hv-swatch { opacity: 0.45; }
.hv-swatch { flex: none; width: 40px; height: 40px; margin-top: 2px; border-radius: 7px; background: var(--moss-soft); }
.hv-bmain { display: grid; gap: 2px; min-width: 0; }
.hv-bmain b { font-size: 14px; font-weight: 600; }
.hv-bdesc { font-size: 12.5px; color: var(--ink-2); line-height: 1.4; }
.hv-bmeta { font-size: 11.5px; color: var(--ink-3); }
.hv-cost { font-size: 12px; color: var(--ink-2); font-weight: 520; font-variant-numeric: tabular-nums; }
.hv-tools { margin-top: 18px; display: grid; gap: 8px; }
.hv-tools .label { margin: 6px 0 0; }
.hv-tools .chip { display: inline-flex; align-items: center; gap: 6px; }
.hv-tools .chip .icon { width: 14px; height: 14px; }

/* info */
.hv-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.hv-stat { display: grid; gap: 1px; padding: 9px 10px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line); }
.hv-stat b { font-family: var(--font-serif); font-size: 22px; font-weight: 440; line-height: 1.1; }
.hv-stat span { font-size: 11.5px; color: var(--ink-3); }
.hv-stat.bad b { color: var(--rust); }
.hv-meter { display: grid; grid-template-columns: 5.5em minmax(0, 1fr) 2.2em; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
.hv-meter b { text-align: end; color: var(--ink); font-weight: 600; }
.hv-meter.low .progress i { background: var(--rust); }
.hv-meter.mood .progress i { background: var(--ochre); }
.hv-reshead, .hv-res { display: grid; grid-template-columns: minmax(0, 1fr) 5em 6em; align-items: center; gap: 8px; font-size: 13px; }
.hv-reshead { margin-top: 8px; font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }
.hv-reshead span:not(:first-child), .hv-res b { text-align: end; }
.hv-reslist { display: grid; gap: 4px; }
.hv-res span { color: var(--ink-2); }
.hv-lim { height: 30px; padding: 0 8px; font-size: 12.5px; text-align: end; }
.hv-spark { width: 100%; height: 70px; }
.hv-spark polyline { fill: none; stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.hv-spark .s-pop { stroke: var(--moss); }
.hv-spark .s-food { stroke: var(--ochre); }
.hv-legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-3); }
.hv-legend span::before { content: ""; display: inline-block; width: 10px; height: 3px; margin-inline-end: 6px; vertical-align: middle; border-radius: 2px; }
.hv-legend .s-pop::before { background: var(--moss); }
.hv-legend .s-food::before { background: var(--ochre); }

/* jobs */
.hv-jobs { display: grid; gap: 6px; }
.hv-job { display: grid; grid-template-columns: minmax(0, 1fr) auto 4.5em; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line); }
.hv-job-name { display: grid; min-width: 0; }
.hv-job-name b { font-size: 13.5px; font-weight: 600; }
.hv-step { display: inline-flex; align-items: center; gap: 4px; }
.hv-step span { min-width: 2ch; text-align: center; font-weight: 620; }
.hv-auto { font-size: 11.5px; color: var(--ink-3); text-align: end; }
.hv-job .btn-xs { justify-self: end; }

/* log */
.hv-log { list-style: none; padding: 0; display: grid; gap: 0; }
.hv-log li { display: grid; gap: 2px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.hv-log li:first-child { border-top: 0; }
.hv-log li.ev-died span:last-child, .hv-log li.ev-left span:last-child, .hv-log li.ev-cropsLost span:last-child { color: var(--rust); }
.hv-log li.ev-born span:last-child, .hv-log li.ev-built span:last-child { color: var(--moss-ink); }

/* founding a village */
.hv-found { min-height: 100%; display: grid; place-items: center; padding: 28px 16px; }
.hv-found-card { width: min(640px, 100%); padding: 28px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-md); }
.hv-found-card h2 { font-size: clamp(26px, 4vw, 34px); }
.hv-found-mark { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--moss-soft); color: var(--moss); }
.hv-found-mark .icon { width: 26px; height: 26px; }
.hv-presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.hv-preset { display: grid; gap: 3px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); text-align: start; }
.hv-preset b { font-size: 13.5px; }
.hv-preset span { font-size: 12px; color: var(--ink-3); line-height: 1.35; }
.hv-preset.on { border-color: var(--moss); background: var(--moss-soft); }
.hv-preset.on b { color: var(--moss-ink); }

/* steward */
.hv-steward .md { font-size: 14.5px; }
.hv-act { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper-2); }
.hv-act b { font-size: 14px; }

/* market */
.hv-inbox { align-items: center; }
.hv-inbox > div { flex: 1; }
.hv-book { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.hv-levels { list-style: none; padding: 0; display: grid; gap: 2px; font-size: 13px; }
.hv-levels li { display: flex; justify-content: space-between; gap: 8px; }
.hv-levels b { font-weight: 600; }

/* saves */
.hv-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.hv-slot.active { border-color: var(--moss-line); }
.hv-slot h3 { font-size: 20px; }
.hv-slot-head { display: flex; align-items: center; justify-content: space-between; }
.hv-save-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; color: var(--ink-2); }

/* guide */
.hv-guide .md { font-size: 15px; }
.public-main .hv-guide { margin-top: 18px; }

/* ── narrow screens: the panel becomes a bottom sheet ── */
@media (max-width: 860px) { /* frontend-ok: the HUD strip and bottom sheet are tuned to the game layout */
  .hv-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .hv-side { border-inline-start: 0; border-top: 1px solid var(--line); max-height: 52px; transition: max-height 0.25s var(--ease); }
  .page.sheet-open .hv-side { max-height: clamp(180px, calc(100dvh - var(--top-h, 70px) - 240px), 60dvh); }
  .hv-sheet-btn { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 10px; color: var(--ink-2); }
  .hv-sheet-btn .icon { transform: rotate(180deg); transition: transform 0.2s; }
  .page.sheet-open .hv-sheet-btn .icon { transform: none; }
  .hv-mini { width: 110px; height: 110px; }
  .hv-zoom { bottom: 132px; }
  .hv-warns { max-width: calc(100% - 140px); }
  .hv-presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hv-book { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hv-found-card { padding: 20px; }
}
@media (max-width: 520px) { /* frontend-ok: chip labels fold away on phones */
  .hv-save span, .hv-steward-btn span { display: none; }
  .hv-steward-btn { padding: 0 9px; }
  .hv-cats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hv-cat span { font-size: 10.5px; }
  .hv-hint { top: 8px; }
  .hv-hint-main span { display: none; }
}
