/* Screen "town" structural styles. Use CSS variables from base.css (--bg, --ink, --accent, --line, ...) so all three themes apply; never hardcode colors here.
   All selectors are low-specificity classes prefixed with .town- so theme
   rules scoped under body[data-tier="..."] win when they need to. */

.town { display: flex; flex-direction: column; gap: 0; }
.town .btn, .town .input, .town .town-sky-building { min-height: 44px; }
.town .btn-small { min-height: 40px; padding: 6px 12px; }

/* ---------- header ---------- */
.town-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 14px; }
.town-title { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0 0 4px; }
.town-sub { margin: 0; }
.town-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- skyline strip ---------- */
.town-sky {
  position: relative; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 14px 0; margin-bottom: var(--gap);
  background: linear-gradient(to bottom, color-mix(in srgb, var(--accent-2) 22%, var(--bg-elev)) 0%, color-mix(in srgb, var(--accent-2) 6%, var(--bg-elev)) 60%, var(--bg-elev) 100%);
  box-shadow: var(--shadow);
}
.town-sky-sun {
  position: absolute; top: 16px; right: 9%; width: 52px; height: 52px; border-radius: 50%;
  background: var(--warn); opacity: 0.8;
  box-shadow: 0 0 38px 12px color-mix(in srgb, var(--warn) 45%, transparent);
}
.town-sky-hill {
  position: absolute; left: -12%; right: -12%; bottom: -70px; height: 130px;
  border-radius: 50% 50% 0 0;
  background: color-mix(in srgb, var(--good) 34%, var(--bg-sunken));
  border-top: 3px solid color-mix(in srgb, var(--good) 55%, var(--line));
}
.town-sky-row {
  position: relative; z-index: 1;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end;
  gap: 10px; padding-bottom: 18px;
}
.town-sky-building {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  flex: 1 1 110px; max-width: 170px;
  padding: 10px 8px 10px;
  border: 2px solid var(--line); border-bottom-width: 5px;
  border-radius: var(--radius-sm) var(--radius-sm) 4px 4px;
  background: var(--bg-elev); color: var(--ink);
  cursor: pointer; text-align: center; line-height: 1.2;
  transition: transform 0.12s, box-shadow 0.12s;
}
.town-sky-building::before {
  /* roof */
  content: ''; position: absolute; left: -2px; right: -2px; top: -16px; height: 16px;
  background: var(--accent);
  clip-path: polygon(0 100%, 50% 0, 100% 100%);
}
.town-sky-building:hover, .town-sky-building:focus-visible { transform: translateY(-3px); box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12); }
.town-sky-building.is-unbuilt { border-style: dashed; background: color-mix(in srgb, var(--bg-elev) 55%, transparent); opacity: 0.8; }
.town-sky-building.is-unbuilt::before { background: var(--line); clip-path: polygon(10% 100%, 50% 30%, 90% 100%); }
.town-sky-icon { font-size: 1.9rem; line-height: 1; }
.town-sky-name { font-family: var(--font-display); font-weight: 700; font-size: 0.92rem; }
.town-sky-sub { font-size: 0.74rem; color: var(--ink-soft); }
/* a gentle hill: middle buildings stand higher */
.town-sky-building:nth-child(3), .town-sky-building:nth-child(4) { margin-bottom: 30px; }
.town-sky-building:nth-child(2), .town-sky-building:nth-child(5) { margin-bottom: 14px; }

/* ---------- grid of panels ---------- */
.town-grid { display: grid; gap: var(--gap); grid-template-columns: 1fr; align-items: start; }
.town-grid > .panel { margin-bottom: 0; }
.town-panel { scroll-margin-top: calc(var(--topbar-h) + 12px); transition: outline-color 0.3s; outline: 3px solid transparent; outline-offset: 2px; }
.town-panel.is-highlight { outline-color: var(--accent); }
.town-panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.town-panel-icon { font-size: 2.1rem; line-height: 1; }
.town-panel-titles { flex: 1 1 160px; min-width: 0; }
.town-panel-title { margin: 0; font-size: 1.45rem; }
.town-panel-sub { font-size: 0.9rem; }
.town-desc { margin-bottom: 12px; }
.town-small { font-size: 0.9rem; }
.town-empty { padding: 8px 0; }
.town-callout {
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--bg-sunken); border-left: 4px solid var(--accent);
  font-weight: 600;
}
.town-cost { font-size: 0.88rem; color: var(--ink-soft); }
.town-cost.is-short { color: var(--bad); font-weight: 600; }

/* ---------- requirements / upgrade block ---------- */
.town-upgrade {
  margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bg-sunken); border: 1px dashed var(--line);
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px;
}
.town-upgrade-info { flex: 1 1 260px; min-width: 0; }
.town-upgrade-title { margin: 0 0 4px; font-size: 1.1rem; }
.town-upgrade-info p { margin-bottom: 6px; }
.town-upgrade-done { margin: 0; font-weight: 600; }
.town-reqs { list-style: none; margin: 0; padding: 0; font-size: 0.92rem; display: flex; flex-direction: column; gap: 3px; }
.town-reqs li::before { content: '•'; display: inline-block; width: 1.2em; color: var(--ink-soft); }
.town-reqs li.is-ok::before { content: '✓'; color: var(--good); font-weight: 700; }
.town-reqs li.is-missing::before { content: '✗'; color: var(--bad); font-weight: 700; }
.town-reqs li.is-missing { color: var(--bad); }

/* ---------- guild ---------- */
.town-guild-level { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.town-guild-level.is-locked { opacity: 0.72; }
.town-guild-level-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.town-guild-level-title { margin: 0; font-size: 1.1rem; }
.town-spells { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.town-spell { background: var(--bg); }
.town-spell.is-learned { border-color: color-mix(in srgb, var(--good) 55%, var(--line)); }
.town-spell.is-available { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.town-spell-top { display: flex; gap: 10px; align-items: center; }
.town-spell-top .card-title { font-size: 1.1rem; }
.town-spell-name { font-size: 0.85rem; }
.town-spell-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.town-spell-strength { display: flex; flex-direction: column; gap: 4px; }
.town-spell-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: auto; }

/* ---------- dwellings ---------- */
.town-creatures { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.town-creature { background: var(--bg); }
.town-creature-top { display: flex; gap: 10px; align-items: center; }
.town-creature-top .card-title { font-size: 1.1rem; }
.town-creature-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.town-stock { font-weight: 700; }
.town-stock.is-empty { font-weight: 400; color: var(--ink-soft); font-size: 0.9rem; }
.town-recruit { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.town-recruit .btn-primary { flex: 1 1 160px; }
.town-qty { width: 92px; flex: 0 0 auto; font-variant-numeric: tabular-nums; text-align: center; }
.town-locked-note { margin-top: auto; }

/* ---------- hall ---------- */
.town-income { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--line); }
.town-income-total { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; font-size: 1.05rem; }
.town-income-label { color: var(--ink-soft); }

/* ---------- market ---------- */
.town-trade-qty { margin: 6px 0 4px; }
.town-inline-label { display: flex; align-items: center; gap: 10px; margin: 0; }
.town-inline-label .input { width: 92px; margin: 0; }
.town-trade { display: flex; flex-direction: column; }
.town-trade-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px dashed var(--line); }
.town-trade-res { display: flex; align-items: center; gap: 6px; font-weight: 600; flex: 1 1 140px; }
.town-trade-icon { font-size: 1.4rem; line-height: 1; }
.town-trade-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- tavern ---------- */
.town-event { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--line); margin-bottom: 10px; }
.town-event-title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; margin-bottom: 4px; }
.town-event p { margin: 0; }
.town-tip { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg-sunken); margin-bottom: 12px; }
.town-tip-body { display: flex; gap: 8px; align-items: flex-start; flex: 1 1 220px; font-size: 0.95rem; }
.town-tip-icon { font-size: 1.3rem; line-height: 1.2; }
.town-log-title { margin: 0 0 6px; font-size: 1.1rem; }
.town-log { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow-y: auto; }
.town-log li { display: flex; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--line); font-size: 0.93rem; }
.town-log-day { color: var(--ink-soft); white-space: nowrap; min-width: 62px; font-variant-numeric: tabular-nums; }

/* ---------- army & end of day ---------- */
.town-stacks { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.town-stack { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--line); }
.town-stack-icon { font-size: 1.7rem; line-height: 1; }
.town-stack-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.town-stack-count { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.town-day { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.town-day-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.town-day-actions .btn { flex: 1 1 140px; }

/* ---------- responsive ---------- */
@media (min-width: 900px) {
  .town-grid { grid-template-columns: 1fr 1fr; }
  .town-panel-wide { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .town-sky { padding: 22px 8px 0; }
  .town-sky-row { gap: 8px; }
  .town-sky-building { flex: 1 1 28%; max-width: none; min-width: 0; padding: 8px 4px 8px; }
  .town-sky-name { font-size: 0.8rem; }
  .town-sky-sub { font-size: 0.68rem; }
  .town-sky-building:nth-child(3), .town-sky-building:nth-child(4) { margin-bottom: 0; }
  .town-sky-building:nth-child(2), .town-sky-building:nth-child(5) { margin-bottom: 10px; }
  .town-sky-building:nth-child(1), .town-sky-building:nth-child(3) { margin-bottom: 4px; }
  .town-sky-building:nth-child(6) { margin-bottom: 4px; }
  .town-spells, .town-creatures { grid-template-columns: 1fr; }
  .town-trade-actions { width: 100%; }
  .town-trade-actions .btn { flex: 1 1 45%; }
  .town-head-actions { width: 100%; }
  .town-head-actions .btn { flex: 1 1 45%; }
}
