/* css/style.css — Kolik na ruku. Mobile-first, no framework, no build step.
   Colors follow the dataviz skill's validated categorical palette (fixed hue
   order: blue/orange/aqua/yellow for čistá/daň/SP/ZP — adjacent-pair CVD-safe
   by construction) and its chart-chrome ink/surface roles, applied site-wide
   for one consistent, accessible palette rather than hand-picked colors. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  /* #898781 (the dataviz skill's muted/axis token) only clears 3.4-3.5:1 against
     this surface/page — below WCAG AA's 4.5:1 for the small (<18px) text it's
     used on here (badge, notes, disclaimer). Darkened to clear 4.5:1 with
     margin (M2.1 accessibility pass); dark mode's value is unchanged since it
     already clears 4.85:1 against the dark surface. */
  --text-muted: #6b6963;
  --gridline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  /* #2a78d6 cleared white-on-accent at only 4.42:1 and accent-as-text-on-surface
     at 4.30:1 — both below 4.5:1. Darkened to clear both at ~4.9-5.0:1 (M2.1). */
  --accent: #2470c2;
  --series-cista: #2a78d6;
  --series-dan: #eb6834;
  --series-sp: #1baf7a;
  --series-zp: #eda100;
  --status-warning: #fab219;
  --status-serious: #ec835a;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --series-cista: #3987e5;
    --series-dan: #d95926;
    --series-sp: #199e70;
    --series-zp: #c98500;
    --status-warning: #fab219;
    --status-serious: #ec835a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.4;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

/* --- article (content pages, M3) ---------------------------------------- */

main.article {
  max-width: 720px;
}

main.article h1 {
  font-size: 1.6rem;
  margin: 8px 0 16px;
}

main.article h2 {
  font-size: 1.2rem;
  margin: 28px 0 10px;
}

main.article h2:first-of-type {
  margin-top: 20px;
}

main.article p,
main.article li {
  font-size: 0.95rem;
  color: var(--text-primary);
  margin: 0 0 12px;
}

main.article ul,
main.article ol {
  margin: 0 0 16px;
  padding-left: 22px;
}

main.article a {
  color: var(--accent);
}

main.article a:hover,
main.article a:focus-visible {
  text-decoration: none;
}

.table-scroll {
  overflow-x: auto;
  margin: 0 0 16px;
}

main.article table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}

main.article th,
main.article td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}

main.article th {
  color: var(--text-secondary);
  font-weight: 600;
}

.article-note {
  margin: 16px 0;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.faq dt {
  font-weight: 600;
  margin: 16px 0 4px;
}

.faq dd {
  margin: 0 0 4px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Mechanical audit (2026-08-09, after the blue-on-blue bug report) found this
   was ALSO failing in dark mode independently of the specificity bug: white
   text on the dark-mode accent (#3987e5) only clears 3.64:1 (fails 4.5:1) —
   the same root cause already documented on .mode-btn[aria-pressed="true"]
   above (that value works as text-on-surface, not as a white-text
   background). Reusing that rule's proven pattern — plain surface + accent
   border/text — rather than a solid accent fill, so this is safe in both
   themes without a new color token. This is now the house pattern for any
   accent-styled button/CTA; don't reintroduce solid-accent-fill+white-text. */
.article-cta {
  display: inline-block;
  margin: 8px 0 24px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 2px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

main.article a.article-cta {
  color: var(--accent);
}

.article-links {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
}

.article-links li {
  margin: 0 0 6px;
}

.site-header {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 8px;
}

.site-header .site-name {
  display: inline-block;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  margin: 0 0 4px;
}

.site-header .site-name:hover,
.site-header .site-name:focus-visible {
  text-decoration: underline;
}

main h1 {
  font-size: 1.5rem;
  margin: 8px 0 4px;
}

.badge {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.badge a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--border);
}

.badge a:hover,
.badge a:focus-visible {
  color: var(--accent);
}

/* --- mode tabs --------------------------------------------------------- */

.modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.mode-btn {
  flex: 1 1 auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 0.95rem;
  cursor: pointer;
}

/* Plain surface + accent border/text, not solid-accent-fill + white text: white
   on the dark-mode accent only cleared 3.64:1 (fails 4.5:1), and darkening the
   dark-mode accent enough to fix that would have broken its own 4.79:1 as text
   on the dark surface (M2.1) — same accent value works as text-on-surface but
   not as a white-text background in dark mode. A *tinted* fill was tried first
   but measured 3.99-4.02:1 (mixing toward the accent pulls the background
   luminance toward the text color, which lowers contrast, not preserves it) —
   plain surface keeps the already-verified 4.79-4.90:1 accent-on-surface ratio,
   with a thicker border as the non-color cue for the pressed state. */
.mode-btn[aria-pressed="true"] {
  background: var(--surface);
  border-width: 2px;
  border-color: var(--accent);
  color: var(--accent);
}

.mode-btn:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- form ---------------------------------------------------------------- */

.field {
  margin: 14px 0;
}

.field label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.field-inline label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.field-inline input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

fieldset input[type="radio"] {
  width: 20px;
  height: 20px;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-primary);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

fieldset legend {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 0 4px;
}

fieldset label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 16px;
  font-size: 0.95rem;
  color: var(--text-primary);
}

details.advanced {
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

details.advanced summary {
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

details.advanced[open] summary {
  margin-bottom: 8px;
}

/* --- result card ---------------------------------------------------------- */

.result-card {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin: 20px 0;
  box-shadow: 0 2px 8px rgba(11, 11, 11, 0.06);
}

.cista-label {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.cista-amount {
  margin: 2px 0 12px;
  font-size: 2.2rem;
  font-weight: 700;
  font-variant-numeric: proportional-nums;
}

.reverse-note {
  margin: -8px 0 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.breakdown-bar {
  display: flex;
  gap: 2px;
  height: 28px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--gridline);
}

.segment {
  height: 100%;
}

.segment-cista { background: var(--series-cista); }
.segment-dan   { background: var(--series-dan); }
.segment-sp    { background: var(--series-sp); }
.segment-zp    { background: var(--series-zp); }

.breakdown-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 10px 0 0;
  font-size: 0.85rem;
}

.breakdown-legend > div {
  display: flex;
  align-items: center;
  gap: 6px;
}

.breakdown-legend .swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex: none;
}

.breakdown-legend dt,
.breakdown-legend dd {
  margin: 0;
  display: inline;
}

.breakdown-legend .label {
  color: var(--text-secondary);
}

.breakdown-legend .value {
  color: var(--text-primary);
  font-weight: 600;
}

.cliff-warning {
  margin: 12px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--status-warning) 20%, var(--surface));
  border: 1px solid var(--status-warning);
  font-size: 0.85rem;
}

.strop-note {
  margin: 12px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.employer-cost {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--gridline);
  font-size: 0.9rem;
}

.employer-cost dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
}

.employer-cost dt { color: var(--text-secondary); }
.employer-cost dd { margin: 0; text-align: right; font-weight: 600; }

/* --- srovnání ------------------------------------------------------------- */

.srovnani-view {
  margin: 20px 0;
}

.srovnani-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 640px) {
  .srovnani-columns {
    grid-template-columns: repeat(3, 1fr);
  }
}

.srovnani-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.srovnani-col h2 {
  font-size: 1rem;
  margin: 0 0 6px;
}

.srovnani-col .cista {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 8px;
}

.srovnani-col dl {
  margin: 8px 0 0;
  font-size: 0.82rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 8px;
}

.srovnani-col dt { color: var(--text-secondary); }
.srovnani-col dd { margin: 0; text-align: right; }

.srovnani-col .note {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.srovnani-caveat {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 12px 4px 0;
}

/* --- actions / footer ------------------------------------------------------ */

.actions {
  margin: 20px 0;
}

#share-btn {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
}

.share-feedback {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  min-height: 1.2em;
}

.jak-to-funguje {
  margin: 20px 0 0;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.jak-to-funguje h2 {
  font-size: 1rem;
  margin: 0 0 4px;
}

.jak-to-funguje p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 8px;
}

.jak-to-funguje ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.jak-to-funguje li {
  margin: 0 0 4px;
}

.jak-to-funguje a {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.jak-to-funguje a:hover,
.jak-to-funguje a:focus-visible {
  text-decoration: underline;
}

.mode-info {
  margin: 28px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--gridline);
}

.mode-info h2 {
  font-size: 1rem;
  margin: 16px 0 4px;
}

.mode-info h2:first-child {
  margin-top: 0;
}

.mode-info p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0;
}

.pripravovane-zmeny {
  margin: 20px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.pripravovane-zmeny h2 {
  font-size: 0.9rem;
  margin: 0 0 8px;
}

.pripravovane-zmeny ul {
  margin: 0 0 8px;
  padding-left: 18px;
  font-size: 0.85rem;
}

.pripravovane-zmeny li {
  margin: 0 0 6px;
}

.pripravovane-zmeny .article-note {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
}

.cross-promo {
  max-width: 640px;
  margin: 20px auto 0;
  padding: 0 16px;
}

.cross-promo ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.cross-promo a {
  color: var(--accent);
  font-size: 0.85rem;
  text-decoration: none;
}

.cross-promo a:hover,
.cross-promo a:focus-visible {
  text-decoration: underline;
}

.site-footer {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

.disclaimer {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.sources {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

.sources a {
  color: var(--text-muted);
  text-decoration: underline;
}

.sources a:hover,
.sources a:focus-visible {
  color: var(--accent);
}

.provozovatel {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 8px 0 0;
}
