/* ------------------------------------------------------------------
   timeline.css – vzhled stránky tématu (topic.php) a homepage (index.php)

   Barevná témata drží stejné CSS proměnné jako poll.php:
   tmavé výchozí, html.light = světlé.
   ------------------------------------------------------------------ */

:root {
    --bg: #12151c; --panel: #1a1f2b; --panel2: #161a24; --field: #12151c;
    --text: #e2e8f0; --faint: #64748b; --line: rgba(100,116,139,.28);
    --accent: #6366f1;
}
html.light {
    --bg: #eef2f7; --panel: #ffffff; --panel2: #f8fafc; --field: #ffffff;
    --text: #1e293b; --faint: #64748b; --line: rgba(100,116,139,.32);
    --accent: #4f46e5;
}

.app-bg    { background: var(--bg); color: var(--text); }
.panel-bg  { background: var(--panel); }
.panel2-bg { background: var(--panel2); }

html.light .text-slate-200 { color: #0f172a !important; }
html.light .text-slate-300 { color: #1e293b !important; }
html.light .text-slate-400 { color: #334155 !important; }
html.light .text-slate-500 { color: #55657a !important; }

body { margin: 0; }

/* --- rozvržení: postranní strom + hlavní sloupec --- */
.tl-shell   { display: flex; min-height: 100vh; align-items: stretch; }
.tl-sidebar {
    width: 264px; flex-shrink: 0; border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
}
.tl-shell.sidebar-hidden .tl-tree,
.tl-shell.sidebar-hidden .tl-sidebar-foot { display: none; }
.tl-shell.sidebar-hidden .tl-sidebar { width: 48px; }
/* ve schovaném panelu zůstává jen tlačítko ☰ (jinak by panel nešel vrátit) */
.tl-shell.sidebar-hidden .tl-sidebar-head > span:first-child,
.tl-shell.sidebar-hidden .tl-sidebar-head #newTopicBtn { display: none; }
.tl-shell.sidebar-hidden .tl-sidebar-head {
    justify-content: center; padding: .85rem .25rem;
}

.tl-sidebar-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: .5rem; padding: .85rem .9rem; border-bottom: 1px solid var(--line);
}
.tl-sidebar-foot {
    margin-top: auto; padding: .75rem .9rem; border-top: 1px solid var(--line);
    font-size: 12px;
    display: flex; flex-direction: column; gap: .3rem;
}
.tl-link { color: var(--faint); text-decoration: none; }
.tl-link:hover { color: var(--text); text-decoration: underline; }

.tl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tl-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line);
}
.tl-crumbs { font-size: 11px; color: var(--faint); margin-bottom: .15rem; }
.tl-crumbs a { color: inherit; text-decoration: none; }
.tl-crumbs a:hover { text-decoration: underline; }
.tl-crumb-sep { margin: 0 .35rem; opacity: .6; }

/* --- strom témat --- */
.tl-tree { padding: .5rem .35rem; overflow-y: auto; }
.tt-list { list-style: none; margin: 0; padding-left: .75rem; }
.tl-tree > .tt-list { padding-left: 0; }
.tt-node > .tt-list { display: none; }
.tt-node.open > .tt-list { display: block; }

.tt-row {
    display: flex; align-items: center; gap: .1rem;
    border-radius: 7px; padding: .2rem .35rem;
}
.tt-row:hover  { background: rgba(100,116,139,.14); }
.tt-row.active { background: rgba(99,102,241,.16); }
.tt-row.active .tt-link { color: var(--accent); font-weight: 600; }

.tt-toggle {
    width: 18px; height: 18px; flex-shrink: 0;
    background: none; border: 0; cursor: pointer; padding: 0;
    color: var(--faint); font-size: 11px; line-height: 18px; text-align: center;
}
.tt-toggle::before { content: '▸'; display: inline-block; transition: transform .15s; }
.tt-node.open > .tt-row .tt-toggle::before { transform: rotate(90deg); }
.tt-toggle-empty { cursor: default; }
.tt-toggle-empty::before { content: ''; }

.tt-link {
    flex: 1; min-width: 0; font-size: 13px; color: var(--text);
    text-decoration: none; padding: .1rem 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tt-count {
    font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums;
    flex-shrink: 0; padding-left: .3rem;
}

/* --- tlačítka, štítky --- */
.tl-btn {
    font-size: 13px; padding: .3rem .65rem; border-radius: 8px;
    border: 1px solid var(--line); color: var(--text); background: none;
    cursor: pointer; text-decoration: none; line-height: 1.5;
}
.tl-btn:hover { background: rgba(100,116,139,.16); }
.tl-icon-btn {
    background: none; border: 0; color: var(--faint); cursor: pointer;
    font-size: 15px; padding: .1rem .25rem;
}
.tl-icon-btn:hover { color: var(--text); }

.tl-warn {
    margin: 1.25rem; padding: .75rem 1rem; border-radius: 12px;
    border: 1px solid rgba(245,158,11,.6); background: rgba(245,158,11,.1);
    font-size: 13px; color: #fcd34d;
}
html.light .tl-warn { color: #92400e; }
.tl-warn code { font-size: 12px; opacity: .9; }

/* --- řádek volných hodnocení --- */
.tl-freepolls {
    display: flex; align-items: center; flex-wrap: wrap; gap: .5rem;
    padding: .7rem 1.25rem; border-bottom: 1px solid var(--line);
}
.tl-section-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--faint); margin-right: .35rem;
}
.tl-poll-chip {
    display: inline-flex; align-items: center; gap: .4rem;
    font-size: 12px; padding: .3rem .7rem; border-radius: 999px;
    border: 1px solid var(--line); color: var(--text); text-decoration: none;
    max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tl-poll-chip:hover { background: rgba(99,102,241,.14); border-color: rgba(99,102,241,.5); }
.tl-poll-icon { font-size: 14px; }

/* --- legenda kvalit + zoom --- */
.tl-controls {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap; padding: .6rem 1.25rem;
}
.tl-legend { display: flex; flex-wrap: wrap; gap: .35rem; }
.tl-legend-group {
    display: flex; align-items: center; gap: .3rem; padding: .15rem .3rem;
    border: 1px dashed var(--line); border-radius: 9px;
}
.tl-legend-group-name { font-size: 10px; color: var(--faint); padding: 0 .2rem; }
.tl-chip-q {
    display: inline-flex; align-items: center; gap: .35rem;
    font-size: 12px; padding: .22rem .6rem; border-radius: 999px;
    border: 1px solid var(--line); cursor: pointer; user-select: none;
    background: none; color: var(--text);
}
.tl-chip-q .tl-swatch {
    width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0;
}
.tl-chip-q[aria-pressed="false"] { opacity: .4; }
.tl-chip-q[aria-pressed="false"] .tl-swatch { background: var(--faint) !important; }

/* druhý řádek filtrů (kategorie událostí) navazuje těsně pod legendu kvalit */
.tl-controls-sub { padding-top: 0; padding-bottom: .5rem; }
.tl-chip-q .tl-cat-glyph { font-size: 12px; line-height: 1; flex-shrink: 0; }
.tl-chip-q .tl-cat-count {
    font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums;
}

.tl-zoom { display: flex; align-items: center; gap: .35rem; }
.tl-range {
    font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums;
    margin-left: .35rem; min-width: 9rem;
}

/* --- plátno --- */
.tl-canvas-wrap { position: relative; padding: 0 1.25rem 1.25rem; }
#tlCanvas {
    width: 100%; height: 460px; display: block; touch-action: none;
    cursor: grab; user-select: none;
}
#tlCanvas.panning { cursor: grabbing; }

.tl-axis-line, .tl-tick   { stroke: var(--line); }
.tl-tick-label            { fill: var(--faint); font-size: 10px; font-family: ui-monospace, monospace; }
.tl-grid                  { stroke: var(--line); stroke-dasharray: 2 4; opacity: .5; }
.tl-band-label            { fill: var(--faint); font-size: 10px; }

.tl-event-mark            { stroke: var(--faint); stroke-width: 1.5; }
.tl-event-mark.high       { stroke: var(--text); }
.tl-event-bar             { fill: rgba(99,102,241,.22); stroke: rgba(99,102,241,.5); }
.tl-event-hit             { cursor: pointer; }
.tl-event-icon-bg         { fill: var(--panel); stroke: var(--line); }
.tl-event-hit:hover .tl-event-icon-bg,
.tl-event-hit.selected .tl-event-icon-bg { stroke: var(--accent); stroke-width: 2; }
.tl-event-icon-glyph      { font-size: 13px; text-anchor: middle; dominant-baseline: central; }
.tl-event-badge           { fill: var(--accent); }
.tl-event-badge-text      { fill: #fff; font-size: 8px; text-anchor: middle; dominant-baseline: central; }

.tl-curve                 { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
/* schodovité křivky: ostré rohy, ať je skok u události čitelný */
.tl-curve-step            { stroke-linejoin: miter; stroke-linecap: butt; stroke-miterlimit: 4; }
.tl-curve-point           { stroke: var(--panel); stroke-width: 1.5; }
.tl-impact-arrow          { font-size: 9px; text-anchor: middle; dominant-baseline: central; }

/* --- tooltip a detail --- */
.tl-tooltip {
    position: absolute; z-index: 20; max-width: 320px; pointer-events: none;
    background: var(--panel); color: var(--text);
    border: 1px solid var(--line); border-radius: 10px;
    padding: .5rem .65rem; font-size: 12px; line-height: 1.4;
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.tl-tooltip-title { font-weight: 700; margin-bottom: .15rem; }
.tl-tooltip-date  { font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; }
.tl-tooltip-row   { display: flex; align-items: center; gap: .35rem; margin-top: .2rem; }

.tl-detail {
    position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 92vw;
    z-index: 30; overflow-y: auto; padding: 1.25rem 1.25rem 2rem;
    background: var(--panel); border-left: 1px solid var(--line);
    box-shadow: -12px 0 28px rgba(0,0,0,.28);
}
.tl-detail-close {
    position: absolute; top: .75rem; right: .9rem;
    background: none; border: 0; color: var(--faint); font-size: 15px; cursor: pointer;
}
.tl-detail-close:hover { color: var(--text); }
.tl-detail-date  { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.tl-detail-title { font-size: 17px; font-weight: 700; margin: .2rem 0 .35rem; line-height: 1.3; }
.tl-detail-meta  { font-size: 11px; color: var(--faint); margin-bottom: .6rem; }
.tl-detail-descr { font-size: 13px; line-height: 1.55; margin: 0 0 1rem; }
.tl-detail-block { margin-top: 1rem; font-size: 12px; }
.tl-detail-block h3 {
    font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--faint); margin: 0 0 .4rem;
}
.tl-impact-row {
    display: flex; align-items: center; gap: .45rem; padding: .2rem 0;
    font-variant-numeric: tabular-nums;
}
.tl-impact-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.tl-impact-up   { color: #ef4444; }
.tl-impact-down { color: #22c55e; }
.tl-tag {
    display: inline-block; font-size: 10px; padding: .1rem .45rem; margin: 0 .25rem .25rem 0;
    border-radius: 999px; border: 1px solid var(--line); color: var(--faint);
}

/* --- modální překryv (dialogy topic-edit.js) --- */
.tl-overlay {
    position: fixed; inset: 0; z-index: 40;
    background: rgba(0,0,0,.6); backdrop-filter: blur(2px);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 2.5vh 1rem;
}
.tl-overlay[hidden] { display: none; }
.tl-overlay-panel {
    width: 100%; max-width: 1200px; max-height: 95vh;
    display: flex; flex-direction: column;
    background: var(--bg); color: var(--text);
    border: 1px solid var(--line); border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0,0,0,.45); overflow: hidden;
}
.tl-overlay-head {
    display: flex; align-items: center; gap: .5rem;
    padding: .7rem 1rem; border-bottom: 1px solid var(--line);
    background: var(--panel2);
}
.tl-overlay-title { flex: 1; margin: 0; font-size: 15px; font-weight: 700; }
.tl-overlay-body { overflow-y: auto; padding: 1rem; }

/* akce v detailu události */
.tl-detail-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.tl-btn-accent {
    border-color: rgba(16,185,129,.5); color: #6ee7b7;
}
html.light .tl-btn-accent { color: #047857; }
.tl-btn-accent:hover { background: rgba(16,185,129,.12); }
.tl-btn[disabled] { opacity: .5; cursor: wait; }
.tl-hint { font-size: 11px; color: var(--faint); margin-top: .4rem; line-height: 1.45; }

.tl-input {
    width: 100%; font-size: 13px; padding: .45rem .65rem; border-radius: 8px;
    background: var(--field); color: var(--text); border: 1px solid var(--line);
    resize: vertical; font-family: inherit;
}
.tl-input:focus { outline: none; border-color: var(--accent); }
.tl-input::placeholder { color: var(--faint); }
input.tl-input[type="color"] { padding: .1rem; height: 2.1rem; }

.tl-field { display: block; margin-top: .6rem; }
.tl-field:first-child { margin-top: 0; }
.tl-field-label {
    display: block; font-size: 11px; color: var(--faint);
    margin-bottom: .2rem; letter-spacing: .02em;
}
.tl-field .tl-hint { margin-top: .2rem; }

/* editace hodnot křivek v detailu události */
.tl-edit-row { display: flex; align-items: center; gap: .35rem; margin-top: .35rem; }
.tl-edit-name {
    flex: 1; min-width: 0; font-size: 12px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tl-edit-input { width: 5.5rem; flex-shrink: 0; padding: .25rem .4rem; font-size: 12px; }
.tl-edit-btn { padding: .25rem .5rem; line-height: 1.2; flex-shrink: 0; }
.tl-input-suggested { border-color: rgba(168,85,247,.7); background: rgba(168,85,247,.08); }

/* seznam AI návrhů událostí */
.tl-suggest-row {
    display: flex; align-items: flex-start; gap: .6rem;
    padding: .55rem .2rem; border-bottom: 1px solid var(--line); cursor: pointer;
}
.tl-suggest-row:last-of-type { border-bottom: none; }
.tl-suggest-texts { flex: 1; min-width: 0; }
.tl-suggest-title { font-size: 13px; font-weight: 600; line-height: 1.35; }
.tl-suggest-meta  { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; margin-top: .1rem; }
.tl-suggest-descr { font-size: 12px; line-height: 1.45; margin-top: .25rem; }

@media (max-width: 860px) {
    .tl-sidebar { display: none; }
    #tlCanvas   { height: 380px; }
}
