/* =========================================================
   Atmosy – domovská stránka
   Jeden výrazný prvok: živá teplota ako veľké číslo a pod ňou
   „termograf“ – priebeh posledných 24 h ako záznam meracieho prístroja.
   Ostatné je tiché a podriadené. Farby berie z premenných webu (svetlý/tmavý režim).
   ========================================================= */

.home {
    --display: 'Archivo', 'Inter', sans-serif;
    --ink: var(--text);
    --paper-line: color-mix(in srgb, var(--accent) 14%, transparent);
    --cold: #2563eb;
    --warm: #dc2626;
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 20px 20px;
    box-sizing: border-box;
}
[data-theme="dark"] .home { --cold: #60a5fa; --warm: #f87171; }

.home h2 {
    font-family: var(--display);
    font-variation-settings: 'wdth' 88;
    font-weight: 600;
    font-size: clamp(1.4rem, 2.4vw, 1.75rem);
    letter-spacing: -0.01em;
    line-height: 1.2;
    margin: 0;
    color: var(--text);
}
.home p { line-height: 1.6; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 1. TERAZ ---------- */
.now {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "top top"
        "temp readings";
    align-items: end;
    column-gap: 48px;
    padding: 8px 0 28px;
}
.now-top {
    grid-area: top;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.home-picker { min-width: 0; flex: 0 1 auto; }
.home-picker .sp-trigger { background: var(--card); }
.now-status {
    margin: 0;
    font-size: 0.88rem;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.now-status .dot { margin: 0; }

.now-title {
    grid-area: temp;
    margin: 0;
    display: flex;
    align-items: flex-start;
    font-family: var(--display);
    font-variant-numeric: tabular-nums lining-nums;
    color: var(--ink);
    line-height: 0.82;
}
.now-temp {
    font-size: clamp(7rem, 23vw, 15.5rem);
    font-weight: 250;
    font-variation-settings: 'wdth' 72;
    letter-spacing: -0.045em;
}
.now-unit {
    font-size: clamp(1.8rem, 5vw, 3.4rem);
    font-weight: 400;
    font-variation-settings: 'wdth' 80;
    margin: 0.35em 0 0 0.08em;
    color: var(--text-muted);
}

.now-readings {
    grid-area: readings;
    margin: 0 0 0.6rem;
    display: grid;
    gap: 18px;
    padding-left: 28px;
    border-left: 1px solid var(--border);
}
.now-readings div { margin: 0; }
.now-readings dt { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 2px; }
.now-readings dd {
    margin: 0;
    font-family: var(--display);
    font-variation-settings: 'wdth' 85;
    font-size: 1.9rem;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    color: var(--text);
}
.now-readings dd small { font-size: 0.55em; color: var(--text-muted); font-weight: 400; }
.now-readings dd.trend {
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ---------- 2. TERMOGRAF ---------- */
.trace { margin: 20px 0 72px; }
.trace-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.trace-head h2 { font-size: 1.05rem; font-family: 'Inter', sans-serif; font-weight: 600; font-variation-settings: normal; color: var(--text-muted); }
.trace-tabs { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.trace-tabs button {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 8px;
    cursor: pointer;
}
.trace-tabs button:hover { color: var(--text); }
.trace-tabs button.is-active { background: var(--accent); color: #fff; }
[data-theme="dark"] .trace-tabs button.is-active { color: #0f172a; }
.trace-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.trace-paper {
    position: relative;
    margin: 0;
    padding: 34px 0 30px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    touch-action: pan-y;
    cursor: crosshair;
}
.trace-paper svg { display: block; width: 100%; height: clamp(180px, 26vw, 260px); overflow: visible; }
.trace-paper .grid line { stroke: var(--paper-line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.trace-paper .grid line.v { stroke-dasharray: 2 4; }
.trace-paper .ink { fill: none; stroke: var(--ink); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.trace-paper .cursor { stroke: var(--accent); stroke-width: 1; }
.trace-paper [hidden] { display: none; }

.trace-paper .axis { position: relative; height: 0; }
.trace-paper .axis span {
    position: absolute;
    top: 8px;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.marks { position: absolute; inset: 34px 0 30px; pointer-events: none; }
.mark {
    position: absolute;
    transform: translate(-50%, 0);
    display: flex;
    flex-direction: column;
    align-items: center;
    white-space: nowrap;
    font-size: 0.78rem;
    line-height: 1.25;
    transition: opacity .15s;
}
.mark::before { content: ''; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--card); box-sizing: content-box; order: 0; }
.mark b { font-weight: 700; font-variant-numeric: tabular-nums; }
.mark small { color: var(--text-muted); font-size: 0.72rem; }
.mark-max { transform: translate(-50%, calc(-100% + 6px)); flex-direction: column-reverse; }
.mark-max::before { background: var(--warm); margin-top: 4px; }
.mark-max b { color: var(--warm); }
.mark-min { transform: translate(-50%, -6px); }
.mark-min::before { background: var(--cold); margin-bottom: 4px; }
.mark-min b { color: var(--cold); }
.trace-paper.is-reading .mark { opacity: 0.25; }
.mark.at-start { align-items: flex-start; margin-left: -6px; }
.mark.at-start.mark-max, .mark.at-start.mark-min { transform: translate(0, 0); }
.mark.at-start.mark-max { transform: translate(0, calc(-100% + 6px)); }
.mark.at-start.mark-min { transform: translate(0, -6px); }
.mark.at-end { align-items: flex-end; }
.mark.at-end.mark-max { transform: translate(-100%, calc(-100% + 6px)); margin-left: 6px; }
.mark.at-end.mark-min { transform: translate(-100%, -6px); margin-left: 6px; }

.readout {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 8px;
    white-space: nowrap;
    pointer-events: none;
}
.readout b { font-weight: 700; }
.trace-empty { color: var(--text-muted); padding: 28px 0; border-top: 1px solid var(--border); }

/* ---------- 3. SIEŤ ---------- */
.network {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr);
    gap: 40px;
    align-items: stretch;
    margin-bottom: 72px;
}
.network-text p { color: var(--text-muted); margin: 10px 0 18px; max-width: 34ch; }
.network-list { list-style: none; margin: 0 0 18px; padding: 0; border-top: 1px solid var(--border); max-height: 330px; overflow-y: auto; }
.network-list a {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 11px 4px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
}
.network-list a:hover .nl-name { color: var(--accent); }
.network-list a.is-current .nl-name { font-weight: 700; color: var(--accent); }
.network-list .dot { margin: 0; }
.nl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nl-temp { font-family: var(--display); font-variation-settings: 'wdth' 85; font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.network-map { min-height: 440px; height: 100%; border-radius: 20px; border: 1px solid var(--border); margin: 0; z-index: 0; }

.map-pin { background: none; border: 0; }
.map-pin span {
    display: inline-block;
    transform: translate(-50%, -50%);
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font: 700 13px/1 'Inter', sans-serif;
    box-shadow: 0 0 0 2px #fff, 0 2px 8px rgba(15, 23, 42, .25);
    white-space: nowrap;
}
.map-pin.is-off span { background: #94a3b8; }
.map-pin.is-current span { box-shadow: 0 0 0 2px #fff, 0 0 0 5px var(--accent), 0 2px 10px rgba(15, 23, 42, .3); }

.text-link { color: var(--accent); font-weight: 600; text-decoration: none; font-size: 0.95rem; }
.text-link:hover { text-decoration: underline; }

/* ---------- 4. AKO VZNIKAJÚ DÁTA ---------- */
.how { margin-bottom: 72px; }
.how-steps {
    list-style: none;
    counter-reset: step;
    margin: 24px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 32px;
}
.how-steps li { counter-increment: step; padding-top: 16px; border-top: 2px solid var(--text); }
.how-steps li::before {
    content: counter(step);
    display: block;
    font-family: var(--display);
    font-variation-settings: 'wdth' 70;
    font-weight: 300;
    font-size: 2.4rem;
    line-height: 1;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.how-steps h3 { margin: 0 0 6px; font-size: 1.02rem; font-weight: 600; color: var(--text); }
.how-steps p { margin: 0; color: var(--text-muted); font-size: 0.95rem; max-width: 36ch; }
.how-steps a { color: var(--accent); }

/* ---------- 5. MIESTO PRE STANICU ---------- */
.host {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    flex-wrap: wrap;
    padding: 32px 36px;
    border-radius: 24px;
    background: color-mix(in srgb, var(--accent) 9%, var(--card));
    border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.host > div:first-child { flex: 1 1 380px; }
.host p { margin: 8px 0 0; color: var(--text-muted); max-width: 58ch; }
.host-actions { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.btn-primary {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    padding: 13px 22px;
    border-radius: 12px;
    transition: filter .15s;
}
[data-theme="dark"] .btn-primary { color: #0f172a; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:focus-visible, .text-link:focus-visible, .network-list a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ---------- RESPONZÍVNE ---------- */
@media (max-width: 860px) {
    .now { grid-template-columns: 1fr; grid-template-areas: "top" "temp" "readings"; }
    .now-readings {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        border-left: 0;
        padding-left: 0;
        border-top: 1px solid var(--border);
        padding-top: 16px;
        margin: 18px 0 0;
        gap: 12px;
    }
    .now-readings dd { font-size: 1.5rem; }
    .network { grid-template-columns: 1fr; gap: 20px; }
    .network-list { max-height: none; }
    .network-map { min-height: 320px; height: 320px; }
    .how-steps { grid-template-columns: 1fr; gap: 24px; }
}
@media (max-width: 520px) {
    .home { padding: 0 16px 16px; }
    .now-top { flex-direction: column; align-items: stretch; }
    .now-status { align-self: flex-start; }
    .trace-tabs { width: 100%; }
    .trace-tabs button { flex: 1; }
    .mark small { display: none; }
    .trace-paper .axis span.minor { display: none; }
    .host { padding: 24px 20px; }
}
@media (prefers-reduced-motion: reduce) {
    .mark, .btn-primary { transition: none; }
}
