/* BK Brandýs – kalendář zápasů
   Paleta: reference categorical slots 1–5, ověřeno validátorem na adjacent pairlist
   (light: worst CVD ΔE 9.1 / normal 19.6; dark: 8.4 / 19.3).
   Kontrastní WARN u slotů 3–5 ve světlém režimu je ošetřen relief pravidlem:
   barva nikdy nenese identitu sama, každý prvek má viditelný textový popisek. */

:root {
  color-scheme: light;

  --surface-1:   #fcfcfb;
  --surface-2:   #f9f9f7;
  --surface-3:   #f0efec;
  --text-1:      #0b0b0b;
  --text-2:      #52514e;
  --text-muted:  #898781;
  --grid:        #e1e0d9;
  --rule:        #c3c2b7;
  --border:      rgba(11, 11, 11, .10);

  --s1: #2a78d6;  /* U13G  */
  --s2: #eb6834;  /* U12G  */
  --s3: #1baf7a;  /* U11G  */
  --s4: #eda100;  /* U11MIX */
  --s5: #e87ba4;  /* U10MIX */

  --accent: #2a78d6;
  --shadow: 0 1px 2px rgba(11, 11, 11, .06), 0 6px 20px rgba(11, 11, 11, .05);

  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;

  --sidebar-w: 250px;
  --topbar-h: 48px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1:  #1a1a19;
    --surface-2:  #0d0d0d;
    --surface-3:  #2c2c2a;
    --text-1:     #ffffff;
    --text-2:     #c3c2b7;
    --text-muted: #898781;
    --grid:       #2c2c2a;
    --rule:       #383835;
    --border:     rgba(255, 255, 255, .10);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
    --accent: #3987e5;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:  #1a1a19;
  --surface-2:  #0d0d0d;
  --surface-3:  #2c2c2a;
  --text-1:     #ffffff;
  --text-2:     #c3c2b7;
  --text-muted: #898781;
  --grid:       #2c2c2a;
  --rule:       #383835;
  --border:     rgba(255, 255, 255, .10);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
  --accent: #3987e5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-1);
  background: var(--surface-2);
  -webkit-text-size-adjust: 100%;
}

/* ── topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  background: color-mix(in oklab, var(--surface-1) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-in {
  height: 100%; padding: 0 16px;
  display: flex; align-items: center; gap: 10px;
}
.brand { font-size: 15px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.brand-sub { font-weight: 400; font-size: 13px; color: var(--text-2); margin-left: 8px; }
.brand-mark {
  width: 20px; height: 20px; border-radius: 50%; background: var(--s2); flex: none;
  box-shadow: inset 0 0 0 1.2px color-mix(in oklab, var(--surface-1) 70%, transparent);
}
#theme-toggle { margin-left: auto; }

/* ── shell: filtry vlevo, obsah vpravo ────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 0;
  align-items: start;
}

.sidebar {
  position: sticky; top: var(--topbar-h);
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 16px 16px 24px;
  border-right: 1px solid var(--border);
  background: var(--surface-1);
  display: flex; flex-direction: column; gap: 16px;
}
.side-block { display: flex; flex-direction: column; gap: 8px; }
.side-title {
  margin: 0; font-size: 11px; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase; color: var(--text-muted);
}
.side-more { display: flex; flex-direction: column; gap: 16px; }
.side-summary { display: none; }
.side-actions { display: flex; flex-direction: column; gap: 6px; }
.side-actions .btn, .side-actions .btn-ghost { width: 100%; text-align: center; }
.side-note {
  margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--text-muted);
  border-top: 1px solid var(--grid); padding-top: 12px;
}
.side-note strong { color: var(--text-2); }

.content { padding: 12px 20px 48px; min-width: 0; }

/* ── controls ─────────────────────────────────────────────────────────────── */
.icon-btn, .btn, .btn-ghost {
  font: inherit; cursor: pointer; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-1);
  padding: 6px 12px; transition: background .12s, border-color .12s;
}
.icon-btn { padding: 5px 10px; line-height: 1; }
.icon-btn:hover, .btn-ghost:hover { background: var(--surface-3); }
.btn { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; font-size: 13.5px; }
.btn:hover { filter: brightness(1.06); }
.btn-ghost { color: var(--text-2); font-size: 13px; }
:is(button, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 13px; cursor: pointer;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-2);
  transition: background .12s, color .12s, border-color .12s;
}
.chip:hover { background: var(--surface-3); }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--text-muted)); flex: none; }
.chip[aria-pressed="true"], .chip[aria-checked="true"] {
  background: color-mix(in oklab, var(--c, var(--accent)) 14%, var(--surface-1));
  border-color: color-mix(in oklab, var(--c, var(--accent)) 45%, var(--border));
  color: var(--text-1); font-weight: 600;
}
.chip[aria-pressed="false"] .dot { opacity: .3; }

.summary { margin: 0; font-size: 12.5px; color: var(--text-2); }
.summary b { color: var(--text-1); }

/* ── view tabs ────────────────────────────────────────────────────────────── */
.viewtabs { display: flex; gap: 2px; margin: 0 0 12px; border-bottom: 1px solid var(--grid); }
.tab {
  font: inherit; font-size: 14px; cursor: pointer; padding: 7px 13px;
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-2); margin-bottom: -1px;
}
.tab:hover { color: var(--text-1); }
.tab[aria-selected="true"] { color: var(--text-1); font-weight: 600; border-bottom-color: var(--accent); }

.view-note { font-size: 12.5px; color: var(--text-2); margin: 0 0 10px; }

/* ── month calendar ───────────────────────────────────────────────────────── */
.month-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.month-nav h2 { font-size: 16px; margin: 0; min-width: 155px; letter-spacing: -.01em; }
.month-nav .btn-ghost { margin-left: auto; }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; background: var(--grid); border: 1px solid var(--grid); border-radius: var(--radius); overflow: hidden; }
.cal-head { background: var(--surface-3); padding: 5px 8px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); text-align: center; }
.cal-cell { background: var(--surface-1); min-height: 92px; padding: 5px; display: flex; flex-direction: column; gap: 3px; }
.cal-cell.is-out { background: var(--surface-2); }
.cal-cell.is-weekend { background: color-mix(in oklab, var(--surface-3) 45%, var(--surface-1)); }
.cal-cell.is-out.is-weekend { background: var(--surface-2); }
.cal-day { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cal-cell.is-out .cal-day { opacity: .45; }

.ev {
  display: block; width: 100%; text-align: left; font: inherit; font-size: 11.5px;
  cursor: default; padding: 2px 5px 2px 6px; border: 0; border-left: 3px solid var(--c);
  border-radius: 3px; background: color-mix(in oklab, var(--c) 14%, var(--surface-1));
  color: var(--text-1); line-height: 1.3;
}
.ev:hover { background: color-mix(in oklab, var(--c) 24%, var(--surface-1)); }
.ev .ev-cat { font-weight: 600; }
.ev .ev-opp { color: var(--text-2); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.is-noncomp { border-left-style: dotted; background: none; box-shadow: inset 0 0 0 1px var(--grid); }
.ev.is-cancelled { text-decoration: line-through; opacity: .55; }

/* ── agenda ───────────────────────────────────────────────────────────────── */
.agenda-list { list-style: none; margin: 0; padding: 0; }
.agenda-month {
  margin: 20px 0 6px; font-size: 11.5px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-muted);
  border-bottom: 1px solid var(--grid); padding-bottom: 5px;
}
.agenda-month:first-child { margin-top: 0; }
.agenda-row {
  display: grid; grid-template-columns: 54px 1fr auto; gap: 12px; align-items: center;
  padding: 8px 10px; border-bottom: 1px solid var(--grid); background: var(--surface-1);
}
.agenda-row:hover { background: var(--surface-3); }
.agenda-date { text-align: center; line-height: 1.15; }
.agenda-date .d { display: block; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.agenda-date .w { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.agenda-main { min-width: 0; }
.agenda-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 7px; }
.agenda-title .opp { font-weight: 600; }
.agenda-meta { font-size: 12px; color: var(--text-2); margin-top: 1px; }
.agenda-side { text-align: right; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.agenda-row.is-cancelled .opp { text-decoration: line-through; }

.tag {
  display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 600;
  padding: 1px 8px 1px 6px; border-radius: 999px;
  border-left: 3px solid var(--c); background: color-mix(in oklab, var(--c) 14%, var(--surface-1));
  color: var(--text-1);
}
.pill { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-2); }
.pill.home { border-color: color-mix(in oklab, var(--accent) 40%, var(--border)); color: var(--text-1); }
.pill.noncomp { border-style: dashed; }
.tbd { color: var(--text-muted); font-style: italic; }

.upcoming { background: color-mix(in oklab, var(--accent) 7%, var(--surface-1)); border-radius: var(--radius); padding: 4px 0; }

/* ── season timeline: sloupec = jeden den, dvojice = víkend ───────────────── */
.timeline-scroll { overflow-x: auto; border: 1px solid var(--grid); border-radius: var(--radius); background: var(--surface-1); padding: 12px; }
.timeline { display: grid; grid-template-columns: max-content max-content; gap: 3px 12px; }
.tl-rowlabel {
  font-size: 12px; color: var(--text-1); white-space: nowrap;
  display: flex; align-items: center; gap: 7px;
  position: sticky; left: 0; background: var(--surface-1); z-index: 2; padding-right: 8px;
}
.tl-rowlabel .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }

.tl-track { display: flex; gap: 7px; }          /* mezera mezi víkendy */
/* Pevná šířka víkendu (13 + 2 + 13) drží hlavičku i datové řádky v zákrytu –
   popisek měsíce je širší než sloupec a musí přetéct, ne roztáhnout mřížku. */
.tl-week  { display: flex; gap: 2px; flex: 0 0 28px; width: 28px; }
.tl-cell  { width: 13px; height: 20px; border-radius: 3px; background: var(--surface-3); flex: none; }
.tl-cell.has { background: var(--c); position: relative; }
/* Tmavý inkoust drží >=4.4:1 na všech pěti slotech v obou režimech; bílá by na
   žluté a magentě spadla pod 2:1. */
.tl-count { position: absolute; inset: 0; display: grid; place-items: center; font-size: 9.5px; font-weight: 700; color: #0b0b0b; }
.tl-monthlabel { font-size: 10.5px; color: var(--text-muted); letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; height: 14px; width: 0; overflow: visible; }
.tl-daylabel { font-size: 9px; color: var(--text-muted); width: 13px; flex: none; text-align: center; line-height: 1; }

/* ── footer ───────────────────────────────────────────────────────────────── */
.foot { margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--grid); font-size: 11.5px; color: var(--text-muted); }
.foot p { margin: 3px 0; }

/* ── tooltip ──────────────────────────────────────────────────────────────── */
.tooltip {
  position: fixed; z-index: 60; pointer-events: none; max-width: 280px;
  background: var(--surface-1); color: var(--text-1);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  padding: 8px 10px; font-size: 12.5px; line-height: 1.4;
}
.tooltip b { display: block; margin-bottom: 2px; }
.tooltip .t-line { color: var(--text-2); }

.empty { padding: 36px 16px; text-align: center; color: var(--text-muted); }

/* ── responsive ───────────────────────────────────────────────────────────── */
#calendar-list { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; max-height: none; overflow: visible;
    border-right: 0; border-bottom: 1px solid var(--border);
    flex-direction: column; gap: 12px; padding: 12px 16px 16px;
  }
  /* Kategorie zůstávají vidět (jsou zároveň legendou), zbytek se skládá. */
  .side-summary {
    display: block; cursor: pointer; list-style: none;
    font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
    color: var(--text-1); padding: 2px 0;
  }
  .side-summary::-webkit-details-marker { display: none; }
  .side-summary::after { content: '▾'; margin-left: 6px; display: inline-block; transition: transform .15s; }
  details[open] > .side-summary::after { transform: rotate(180deg); }
  .side-summary #more-mini { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text-2); }
  details[open] > .side-summary #more-mini { display: none; }
  .side-more { gap: 12px; }
  .side-actions { flex-direction: row; }
  .side-actions .btn, .side-actions .btn-ghost { width: auto; flex: 1; }
  .side-note { display: none; }
  .content { padding: 12px 16px 48px; }
}

@media (max-width: 700px) {
  .calendar { display: none; }              /* měsíční mřížka se na mobilu degraduje na seznam */
  #calendar-list { display: block; }
  .agenda-row { grid-template-columns: 46px 1fr; }
  .agenda-side { grid-column: 2; text-align: left; }
  .month-nav h2 { min-width: 0; font-size: 15px; }
  .brand-sub { display: none; }
}

@media print {
  .sidebar, .viewtabs, .topbar, .month-nav .icon-btn, .month-nav .btn-ghost { display: none; }
  .shell { grid-template-columns: 1fr; }
  body { background: #fff; }
}
