/* ==========================================================================
   DÖVR — mobil-öncəlikli oyun interfeysi
   docs/ide-prompts.md P10 (bünövrə) · P11 (Dünya) · P12 (Dövlətlər) · P13/P14

   PRİNSİPLƏR
   · Qədim dünya: yandırılmış torpaq fonu, gil-kərpic səthlər, qızıl aksent.
     Status rəngləri (yaşıl/narıncı/qırmızı) KİMLİK rəngi deyil — yalnız vəziyyət.
   · Rəqəmlər həmişə monospace + tabular-nums (sütunlar titrəməsin).
   · Toxunma hədəfi ≥44px, alt naviqasiya baş barmaq zonasında, safe-area var.
   · Kartda kölgə yox — 1px xətt. Kölgə yalnız ÜZƏN elementdə (sheet).
   ========================================================================== */

:root {
  /* Torpaq */
  --bg: #14100d;
  --bg2: #1c1712;
  --bg3: #241d17;
  --bg4: #2e2519;
  --line: #33281f;
  --line2: #4a3b2b;
  /* Mətn */
  --ink: #f0e6d8;
  --ink2: #a89684;
  --ink3: #7a6a58;
  /* Aksent və status */
  --gold: #d9a441;
  --gold2: #f0c467;
  --gold-dim: rgba(217, 164, 65, 0.14);
  --ok: #7ba05b;
  --warn: #cf7a3a;
  --bad: #c04a38;
  --info: #5f96ad;
  /* Zonalar — YALNIZ fon kimi (α .12–.22), mətn rəngi kimi YOX */
  --z-admin: #8b7bd8;
  --z-craft: #c98a44;
  --z-home: #7aa860;
  --z-mil: #c05a44;
  --z-lab: #5f96ad;
  --z-market: #d4b04a;

  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  --serif: ui-serif, Georgia, "Times New Roman", serif;

  --hud: 54px;
  --tabs: 62px;
  --r: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}
body { display: flex; flex-direction: column; overflow: hidden; }
.hidden { display: none !important; }
.muted { color: var(--ink3); font-size: 12px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* --- HUD ---------------------------------------------------------------- */
.hud {
  height: calc(var(--hud) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, #251d17, #1a1410);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.hud-title { min-width: 0; display: flex; flex-direction: column; line-height: 1.16; }
.hud-title strong {
  font-family: var(--serif); font-size: 18px; font-weight: 600;
  color: var(--gold2); letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hud-title span {
  font-size: 11.5px; color: var(--ink3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hud-clock {
  margin-left: auto; text-align: right; line-height: 1.16;
  cursor: pointer; padding: 4px 2px; border-radius: 6px;
}
.hud-clock:active { background: var(--bg3); }
.hud-clock strong { font-size: 13px; font-weight: 600; display: block; }
.hud-clock span { display: block; font-size: 10.5px; color: var(--ink3); }

/* Stend rejimi xəbərdarlığı (P3.3) */
.mode-banner {
  flex: none; padding: 6px 12px; text-align: center;
  font: 600 11px/1.3 var(--mono); letter-spacing: 0.1em; text-transform: uppercase;
  background: rgba(207, 122, 58, 0.16); color: #e8bb8c;
  border-bottom: 1px solid rgba(207, 122, 58, 0.35);
}

.icon-btn {
  min-width: 44px; min-height: 40px;
  display: grid; place-items: center;
  background: var(--bg3); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r);
  font-size: 19px; cursor: pointer; flex: none;
}
.icon-btn:active { background: var(--bg4); }
.icon-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* --- EKRANLAR ----------------------------------------------------------- */
.screen { position: relative; flex: 1; min-height: 0; }
.screen.scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* P10.5: alt tab-bar son sətri kəsməsin */
  padding-bottom: calc(var(--tabs) + env(safe-area-inset-bottom) + 16px);
}
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.pad { padding: 14px 14px 0; display: flex; flex-direction: column; gap: 12px; }

/* --- XƏRİTƏ ALƏTLƏRİ ---------------------------------------------------- */
.map-tools { position: absolute; top: 10px; left: 10px; right: 10px; pointer-events: none; }
.chips { display: flex; gap: 7px; overflow-x: auto; pointer-events: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: none; min-height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line2);
  background: rgba(26, 20, 16, 0.86); backdrop-filter: blur(6px);
  color: var(--ink2); font: 600 12.5px var(--sans); cursor: pointer;
}
.chips button.active {
  background: var(--gold); border-color: var(--gold); color: #17120f;
}
.zoom-tools {
  position: absolute; right: 10px; bottom: 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.zoom-tools .icon-btn { background: rgba(26, 20, 16, 0.86); backdrop-filter: blur(6px); }

/* --- ALT VƏRƏQ (bottom sheet) ------------------------------------------- */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, #221b15, var(--bg2));
  border-top: 1px solid var(--line2);
  border-radius: 16px 16px 0 0;
  padding: 8px 14px calc(12px + env(safe-area-inset-bottom));
  /* P13: panel açıq olanda xəritənin ≥40%-i görünür */
  max-height: 56%;
  overflow-y: auto;
  box-shadow: 0 -12px 34px rgba(0, 0, 0, 0.5);
}
.sheet-grip {
  width: 42px; height: 4px; border-radius: 2px;
  background: var(--line2); margin: 2px auto 10px;
}
.sheet-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.sheet-head strong { display: block; font-size: 17px; font-family: var(--serif); font-weight: 600; }
.city-sheet { max-height: 46%; transition: max-height 0.22s ease; }
.city-sheet.peek { max-height: 116px; overflow: hidden; }

.primary {
  min-height: 44px; padding: 0 16px; border: 0; border-radius: var(--r);
  background: var(--gold); color: #17120f;
  font: 700 14px var(--sans); cursor: pointer; white-space: nowrap;
}
.primary:active { filter: brightness(0.9); }
.primary:focus-visible { outline: 2px solid var(--gold2); outline-offset: 2px; }

/* --- STAT ŞƏBƏKƏSİ ------------------------------------------------------ */
.sheet-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 8px; margin-top: 12px;
}
.stat {
  background: var(--bg3); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 10px;
}
.stat b { display: block; font: 700 15px var(--mono); font-variant-numeric: tabular-nums; }
.stat span { display: block; font-size: 10.5px; color: var(--ink3); margin-top: 3px; }
.stat.bad b { color: #e08a78; }
.stat.warn b { color: var(--warn); }
.stat.ok b { color: #a9c78d; }

/* --- VACİB METRİKA KARTI (P11.1) ---------------------------------------- */
.metric {
  border: 1px solid var(--line); background: var(--bg2);
  border-radius: var(--r); padding: 14px 16px;
}
.metric .label {
  font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink3);
}
.metric .value {
  font: 700 34px/1 var(--mono); font-variant-numeric: tabular-nums; margin-top: 7px;
}
.metric .hint { font-size: 13px; color: var(--ink2); margin-top: 7px; line-height: 1.4; }
.metric .target { font: 600 11px var(--mono); color: var(--ink3); margin-top: 5px; }
.metric.bad { border-color: rgba(192, 74, 56, 0.45); background: rgba(192, 74, 56, 0.09); }
.metric.bad .value { color: #e8968a; }
.metric.ok { border-color: rgba(123, 160, 91, 0.4); }
.metric.ok .value { color: #a9c78d; }
.metric-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric-row .metric .value { font-size: 22px; }

/* --- NİSBƏT BARI (1,00 həddi işarəli — P12.3) --------------------------- */
.ratiobar {
  position: relative; height: 8px; border-radius: 5px;
  background: var(--bg4); overflow: hidden; margin: 9px 0 4px;
}
.ratiobar i {
  display: block; height: 100%; border-radius: 5px;
  background: linear-gradient(90deg, #7ba05b 0%, #7ba05b 38%, #cf7a3a 52%, #c04a38 70%);
}
.ratiobar b {
  position: absolute; left: 50%; top: -2px; width: 2px; height: 12px;
  background: var(--ink2); opacity: 0.85;
}
.rbscale {
  display: flex; justify-content: space-between;
  font: 600 10px var(--mono); color: var(--ink3);
}

/* --- DÖVLƏT KARTI (P12) ------------------------------------------------- */
.realm {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px 13px;
}
.realm.mine { border-color: rgba(217, 164, 65, 0.55); background: var(--gold-dim); }
.realm-top { display: flex; align-items: center; gap: 8px; }
.realm-top .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.realm-top .nm {
  font-weight: 700; font-size: 15px; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--ink); /* P12.1: ad NEYTRAL — rəng yalnız status nişanında */
}
.realm-top .rv { font: 700 15px var(--mono); font-variant-numeric: tabular-nums; }
.realm-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 9px; }
.realm-stats div { background: var(--bg3); border-radius: 8px; padding: 6px 8px; }
.realm-stats b { display: block; font: 700 13px var(--mono); font-variant-numeric: tabular-nums; }
.realm-stats span { font-size: 10px; color: var(--ink3); }

.pill {
  font: 600 10px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase;
  padding: 5px 7px; border-radius: 5px; white-space: nowrap;
}
.pill.ok { background: rgba(123, 160, 91, 0.18); color: #a9c78d; }
.pill.warn { background: rgba(207, 122, 58, 0.18); color: #e8bb8c; }
.pill.bad { background: rgba(192, 74, 56, 0.2); color: #e08a78; }

/* Sıralama / filtr sətri (P12.5) */
.toolbar { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; }
.toolbar::-webkit-scrollbar { display: none; }
.toolbar button {
  flex: none; min-height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line2); background: var(--bg3);
  color: var(--ink2); font: 600 12px var(--sans); cursor: pointer;
}
.toolbar button.active { background: var(--gold-dim); border-color: rgba(217, 164, 65, 0.5); color: var(--gold2); }

.group-row {
  border: 1px dashed var(--line2); border-radius: var(--r);
  padding: 12px 13px; display: flex; justify-content: space-between;
  align-items: center; font-size: 13.5px; color: var(--ink2);
}

/* --- KART / SİYAHI ------------------------------------------------------ */
.card {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 13px 14px;
}
.card h2 {
  margin: 0 0 10px; font: 600 13px/1 var(--mono);
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink3);
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.card h2 .note { font: 400 11px var(--sans); letter-spacing: 0; text-transform: none; }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; margin: 0; font-size: 13.5px; }
.kv dt, .kv > span:nth-child(odd) { color: var(--ink2); }
.kv dd, .kv > span:nth-child(even) {
  margin: 0; text-align: right; font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* İqlim barları (P11.3) */
.climate-row { display: grid; gap: 4px; margin-bottom: 10px; }
.climate-row .top { display: flex; justify-content: space-between; font-size: 12.5px; }
.climate-row .top b { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.climate-bar { position: relative; height: 5px; border-radius: 3px; background: var(--bg4); overflow: hidden; }
.climate-bar i { display: block; height: 100%; }
.climate-bar b { position: absolute; left: 50%; top: -2px; width: 2px; height: 9px; background: var(--ink3); }

/* Bina sətri */
.building-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.building {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg3); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 10px; font-size: 13px;
}
.building .dot { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.building b { flex: 1; min-width: 0; font-weight: 600; }
.building .lvl { font: 600 11px var(--mono); color: var(--ink3); }

/* Kənd resurs zolağı — MASTER §8.4: dəyər + illik sürət + anbar barı */
.res-strip {
  position: absolute; top: 10px; left: 10px; right: 10px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 6px; pointer-events: none;
}
.res-card {
  background: rgba(26, 20, 16, 0.86); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px;
}
.res-card .t { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink2); }
.res-card .v { font: 700 14px var(--mono); font-variant-numeric: tabular-nums; margin-top: 2px; }
.res-card .r { font: 600 10px var(--mono); margin-top: 1px; }
.res-card .r.up { color: var(--ok); } .res-card .r.dn { color: #e08a78; } .res-card .r.zero { color: var(--ink3); }

.city-legend {
  position: absolute; top: 62px; left: 10px; right: 10px;
  display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none;
}
.legend-item {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(26, 20, 16, 0.86); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 9px; font-size: 10.5px; color: var(--ink2);
}
.legend-item .dot { width: 7px; height: 7px; border-radius: 2px; }

/* Xronika */
.chronicle { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.chronicle li {
  padding: 8px 0; border-bottom: 1px solid var(--line);
  color: var(--ink2); line-height: 1.45;
}
.chronicle li:last-child { border-bottom: 0; }
.chronicle time {
  display: block; font: 600 10.5px var(--mono);
  color: var(--gold); letter-spacing: 0.06em; margin-bottom: 3px;
}

/* --- ALT NAVİQASİYA ----------------------------------------------------- */
.tabs {
  height: calc(var(--tabs) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: linear-gradient(180deg, #1a1410, #241d17);
  border-top: 1px solid var(--line); flex: none;
}
.tabs button {
  background: none; border: 0; color: var(--ink3);
  font: 600 10.5px var(--sans); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.tabs button span { font-size: 19px; line-height: 1; filter: grayscale(1) opacity(0.65); }
.tabs button.active { color: var(--gold2); }
.tabs button.active span { filter: none; }

/* --- MASAÜSTÜ: eyni layout mərkəzləşir ---------------------------------- */
@media (min-width: 780px) {
  body { max-width: 1180px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .sheet { max-height: 46%; }
  .pad { padding: 18px 18px 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
