/* ==========================================================================
   Domácnosť – living on the farm (docs/SPEC_HOUSEHOLD.md §3)
   Editor section „Domácnosť“ (views/editor/household.js) and the household parts of the
   editor shell (strip tile), Kategórie, Nákup a investície and Situácie.
   All classes are prefixed .hh-. Colours only through app.css tokens.
   ========================================================================== */

/* ---------- Editor shell: 8 strip tiles while „Rodine mesačne zostane“ is shown ----------
   The strip is at most ~984 px wide next to the desktop navigation, so 8 tiles get slightly
   tighter padding and type. Below ~920 px the tiles scroll sideways (like the phone layout)
   instead of cutting numbers. */
.ed-strip.hh-strip--family { container: hhstrip / inline-size; }
.ed-strip.hh-strip--family .ed-strip-tiles { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.ed-strip.hh-strip--family .ed-kpi { padding: 9px 8px 8px; }
.ed-strip.hh-strip--family .kpi-value { font-size: 14.5px; }
.ed-strip.hh-strip--family .kpi-label { font-size: 11px; }
@container hhstrip (max-width: 919px) {
  .ed-strip-tiles {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }
  .ed-kpi { flex: 0 0 auto; min-width: 138px; scroll-snap-align: start; }
}

/* ---------- Section root ---------- */
.hh { container: hh / inline-size; }
.hh-on { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.hh-on[hidden], .hh-switch[hidden], .hh-off[hidden] { display: none; }

/* On/off switch */
.hh-switch-body {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  min-width: 0;
}
.hh-switch-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.hh-switch .toggle { flex: 1 1 auto; min-width: 0; }
.hh-switch .toggle-label { font-weight: 600; }
.hh-switch .toggle-hint { display: block; margin-top: 2px; font-size: 12.5px; color: var(--text-2); }

/* Off state: explanation + big „Zapnúť“ */
.hh-off {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
}
.hh-off-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.hh-off-title { margin: 0; font-size: 19px; font-weight: 650; line-height: 1.3; }
.hh-off-text, .hh-off-note { max-width: 620px; margin: 0; color: var(--text-2); line-height: 1.5; }
.hh-off-note { font-size: 13px; }
.hh-off-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 560px;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
}
.hh-off-list li { display: flex; align-items: flex-start; gap: 10px; line-height: 1.45; }
.hh-off-list strong { font-weight: 650; }
.hh-off-li-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
}
.hh-off-btn { margin-top: 4px; }
.hh-off-readonly { margin: 0; font-weight: 600; color: var(--text-2); }
.hh-off-stored { max-width: 560px; margin: 0; font-size: 12.5px; color: var(--muted); }
.hh-off-stored[hidden] { display: none; }

/* ---------- Kto bude na farme bývať ---------- */
.hh-members-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  min-width: 0;
}
@container hh (min-width: 860px) {
  .hh-members-body { grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.4fr); align-items: start; gap: 28px; }
}
.hh-members-people { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.hh-steppers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.hh-members-total {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13.5px;
  color: var(--text-2);
}
.hh-members-total > .icon { flex: none; color: var(--muted); }
.hh-members-total strong { color: var(--text); font-weight: 650; }

.hh-stepper { display: flex; align-items: center; gap: 6px; min-width: 0; }
.hh-stepper > .input-affix { flex: 0 1 72px; min-width: 52px; }
.hh-stepper .input { height: 36px; text-align: center; font-weight: 600; }
.hh-stepper .hh-stepper-btn { flex: none; width: 36px; height: 36px; padding: 0; }
@media (pointer: coarse), (max-width: 720px) {
  /* Touch: 40 px tap targets, the number in between keeps the same height. */
  .hh-stepper .input { height: 40px; }
  .hh-stepper .hh-stepper-btn { width: 40px; height: 40px; }
}

.hh-wallet { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.hh-wallet-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.hh-wallet-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--brand-strong);
}
.hh-wallet-title { font-size: 14px; font-weight: 650; line-height: 1.35; }
.hh-wallet-text { margin: 2px 0 0; font-size: 13px; line-height: 1.5; color: var(--text-2); }

/* ---------- Vyžijeme z toho? ---------- */
.hh-summary { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.hh-summary[hidden] { display: none; }
.hh-summary-title { font-size: 17px; }
.hh-verdict .alert { padding: 14px 16px; }
.hh-verdict .alert-title { font-size: 15.5px; }
.hh-verdict .alert-text { font-variant-numeric: tabular-nums; }
.hh-tiles .kpi-value { font-size: 20px; font-variant-numeric: tabular-nums; }
@media (max-width: 480px) { .hh-tiles .kpi-value { font-size: 17px; } }

.hh-summary-row { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; }
@container hh (min-width: 860px) {
  .hh-summary-row { grid-template-columns: minmax(0, 560px); }
}
.hh-budget .card-body { padding-top: 10px; }
.hh-budget-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.hh-budget-table th, .hh-budget-table td { padding: 7px 0; border-bottom: 1px solid var(--grid); vertical-align: top; }
.hh-budget-table th { text-align: left; font-weight: 500; }
.hh-budget-table tbody tr:last-child > * { border-bottom: 0; }
.hh-budget-label { display: block; color: var(--text); }
.hh-budget-note { display: block; font-size: 12px; color: var(--text-2); }
.hh-budget-amount { padding-left: 16px !important; text-align: right; white-space: nowrap; font-weight: 600; }
.hh-budget-amount.is-negative { color: var(--critical-text); }
.hh-budget-amount.is-positive { color: var(--good-text); }
.hh-budget-table tfoot th, .hh-budget-table tfoot td {
  padding-top: 10px;
  border-top: 2px solid var(--border-strong);
  border-bottom: 0;
  font-size: 15px;
  font-weight: 650;
}

/* ---------- Tables (living costs, other income, self-use) ---------- */
.hh-block { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.hh-block[hidden] { display: none; }
.hh-block-head { min-width: 0; }
.hh-block-head > p { max-width: 860px; line-height: 1.5; }

.hh-starter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--brand-soft);
}
.hh-starter[hidden] { display: none; }
/* Filter chips „Všetky / ↔ Prepojené / Doplňte sumu“ above a household table (styles: editor2.css .ed2-chips) */
.hh-chips { min-width: 0; }
.hh-starter-icon { display: flex; flex: none; color: var(--brand-strong); }
.hh-starter-text { flex: 1 1 280px; min-width: 0; font-size: 13.5px; line-height: 1.45; }
.hh-starter-text strong { font-weight: 650; }

.hh-selfuse-hint {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 10px;
}
.hh-selfuse-case {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.hh-selfuse-case strong { font-size: 13.5px; font-weight: 650; }
.hh-selfuse-case p { margin: 2px 0 0; font-size: 13px; line-height: 1.45; color: var(--text-2); }
.hh-selfuse-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.hh-warnings { display: flex; flex-direction: column; gap: 8px; }
.hh-warnings:empty { display: none; }
.hh-link-info:empty { display: none; }
.hh-link-alert { font-size: 13px; }

/* ---------- Súkromný majetok ---------- */
.hh-private .card-body { min-width: 0; }
.hh-private .table-wrap { border-left: 0; border-right: 0; border-bottom: 0; border-radius: 0; }
.hh-private-off { color: var(--muted); font-size: 12px; }
.hh-private-link { position: relative; font-weight: 550; }
@media (pointer: coarse), (max-width: 720px) {
  .hh-private-link::after { content: ""; position: absolute; inset: -10px -6px; } /* 40 px tap target */
}
.hh-private-linked {
  display: inline-flex;
  align-items: center;
  height: 18px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--link);
  font-size: 11.5px;
  font-weight: 600;
  vertical-align: middle;
  white-space: nowrap;
}
.hh-private-note { margin: 0; padding: 10px 20px 14px; font-size: 12.5px; line-height: 1.45; color: var(--text-2); }
.hh-private-empty {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 4px 20px 18px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-2);
}
.hh-private-empty > .icon { flex: none; margin-top: 2px; color: var(--muted); }

/* ---------- Charts ---------- */
.hh-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: 16px;
  min-width: 0;
}
.hh-chart-budget { grid-column: 1 / -1; }
.hh-chart-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-2);
}
.hh-chart-note > .icon { flex: none; color: var(--muted); }
.hh-chart-note > span { flex: 1 1 260px; min-width: 0; }

/* ---------- Kategórie: household group ---------- */
.hh-cat-group { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; min-width: 0; }
.hh-cat-group-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hh-cat-group-head > .icon { flex: none; color: var(--brand-strong); }
.hh-cat-group-title { margin: 0; font-size: 16px; font-weight: 650; line-height: 1.3; }
.hh-cat-group-note { margin: 0; font-size: 13px; color: var(--text-2); }
.hh-cat-group-note:empty { display: none; }

/* ---------- Nákup a investície: private items ---------- */
.hh-items-alert[hidden] { display: none; }

/* ---------- Situácie: household groups ---------- */
.hh-sit-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 2px;
  padding: 0 12px;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-2);
}
.hh-sit-group-title > .icon { color: var(--brand-strong); }
.hh-sit-group-title[hidden] { display: none; }
.hh-sit-presets-title { margin: 14px 0 8px; padding: 0; }
.hh-sit-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 12px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-2);
}
.hh-sit-note[hidden] { display: none; }
.hh-sit-note > span { flex: 1 1 240px; min-width: 0; }
.hh-sit-cats { margin-top: 20px; }
.hh-sit-cats[hidden] { display: none; }
.hh-sit-cats > .ed2-h4 { display: flex; align-items: center; gap: 6px; }
.hh-sit-cats > .ed2-h4 > .icon { color: var(--brand-strong); }

/* ---------- Small screens ---------- */
@container hh (max-width: 520px) {
  .hh-off { padding: 24px 16px; }
  .hh-switch-body { padding: 12px 14px; }
  .hh-wallet-item { padding: 10px 12px; }
}
@media (max-width: 420px) {
  .hh-steppers { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Print ---------- */
@media print {
  .hh-off-btn, .hh-starter, .hh-chart-note button, .hh-stepper-btn, .hh-sit-presets-title, .hh-sit-note { display: none !important; }
  .hh-wallet-item, .hh-budget, .hh-selfuse-case { break-inside: avoid; }
}

/* ---------- Wallet mode (views/wallet-ui.js, prefix .wl-; Komunita + Cashflow) ----------
   The checkbox „Spojiť financie farmy a komunity“ keeps its size in both states; the inputs of the
   separate mode appear below it, so nothing above them moves when it is tapped. */
.wl { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.wl-check { align-items: flex-start; max-width: 720px; }
.wl-check .checkbox-label { font-weight: 650; }
.wl-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; min-width: 0; }
.wl-fields[hidden] { display: none; }
.wl-field { min-width: 0; }
.wl-field .input-affix { max-width: 280px; }
.wl-note { margin: 0; font-size: 13px; color: var(--warning-text); }
.wl-note[hidden] { display: none; }
@media (pointer: coarse) {
  .checkbox.wl-check { align-items: flex-start; }
  .wl-check .checkbox-input { margin-top: 2px; }
  .wl-field .input { font-size: 16px; }
}
@media (max-width: 480px) {
  .wl-fields { grid-template-columns: minmax(0, 1fr); }
  .wl-field .input-affix { max-width: none; }
}
/* Plán (views/plan.js): the community's cash under the farm's in a month row (separate finances only). */
.pl-m-cash .pl-m-comm { grid-column: 1 / -1; text-align: right; font-size: 11.5px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pl-m-cash .pl-m-comm.is-negative { color: var(--critical-text); font-weight: 650; }
.pl-m-comm[hidden] { display: none; }

/* „Na začiatku chýba …“ (one-off gap of the first year's investments): the two actions are phone targets. */
.hh-verdict-alert .alert-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (pointer: coarse) {
  .hh-verdict-alert .alert-actions .btn { min-height: 44px; }
}

/* Členovia komunity (SPEC_V2 §2.3): one block per member, the fields wrap on a phone. */
.hh-mcard[hidden] { display: none; }
.hh-mcard-body { display: flex; flex-direction: column; gap: 12px; }
.hh-mlist { display: flex; flex-direction: column; gap: 10px; }
.hh-member { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.hh-mhead { font-weight: 600; overflow-wrap: anywhere; }
.hh-mfields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px 12px; }
.hh-mfields > .field[hidden] { display: none; }
.hh-mnote { display: flex; gap: 8px; align-items: flex-start; margin: 0; color: var(--text-2); font-size: 13px; line-height: 1.45; }
.hh-mnote > .icon { flex: none; margin-top: 2px; color: var(--muted); }
@media (max-width: 480px) {
  .hh-mfields { grid-template-columns: minmax(0, 1fr); }
}
@media (pointer: coarse) {
  .hh-mcard .input, .hh-mcard .select { min-height: 44px; }
}
