/* CamView ZDW — asfalt, oznakowanie poziome i tabliczki numerów dróg (E-15). */

@font-face {
    font-family: "Overpass";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/overpass-latin-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308,
        U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Overpass";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/overpass-latin-ext-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
        U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    --asphalt: #1d2125;
    --surface: #272c31;
    --surface-2: #31373d;
    --line: #3d444b;
    --text: #e8ebed;
    --muted: #9ba4ac;
    --sign: #f2c200;
    --sign-ink: #15171a;
    --dk: #c4122f;
    --works: #f07c1b;
    --ok: #57b97f;

    --radius-plate: 4px;
    --radius-frame: 6px;
    --gutter: clamp(16px, 4vw, 32px);
    --font: "Overpass", "Segoe UI", system-ui, sans-serif;

    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--asphalt);
    color: var(--text);
    font: 400 1rem/1.5 var(--font);
    font-variant-numeric: tabular-nums;
}

a { color: inherit; }
img { display: block; max-width: 100%; }
h1, h2 { line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem); font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; font-weight: 700; }
p { margin: 0; }

:focus-visible { outline: 3px solid var(--sign); outline-offset: 2px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}
.muted { color: var(--muted); }

/* ---- Tabliczki numerów dróg ---------------------------------------------- */

.plate {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3.2em;
    padding: 0.28em 0.55em 0.18em;
    border-radius: var(--radius-plate);
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.01em;
    outline: 2px solid currentColor;
    outline-offset: -5px;
    white-space: nowrap;
}
.plate--dw { background: var(--sign); color: var(--sign-ink); }
.plate--dk { background: var(--dk); color: #fff; }
.plate--dp { background: var(--text); color: var(--asphalt); }
.plate--none { background: transparent; color: var(--muted); outline-style: dashed; outline-offset: -2px; font-weight: 600; }
.plate--lg { font-size: 1.6rem; padding: 0.32em 0.6em 0.22em; outline-width: 3px; outline-offset: -6px; }

/* ---- Pasek górny ----------------------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.6rem var(--gutter);
    padding-top: max(0.6rem, env(safe-area-inset-top));
    background: var(--asphalt);
    border-bottom: 1px solid var(--line);
}
.topbar__brand { font-weight: 800; font-size: 1.1rem; text-decoration: none; }
.topbar__brand span { color: var(--sign); }
.topbar__nav { display: flex; gap: 1rem; margin-right: auto; }
.topbar__nav a { text-decoration: none; color: var(--muted); padding: 0.35rem 0; border-bottom: 2px solid transparent; }
.topbar__nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--sign); }

.menu { position: relative; }
.menu summary {
    list-style: none; cursor: pointer; color: var(--muted);
    max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.menu summary::-webkit-details-marker { display: none; }
.menu__panel {
    position: absolute; right: 0; top: calc(100% + 0.5rem); min-width: 12rem;
    display: grid; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-frame);
    padding: 0.35rem 0;
}
.menu__panel a, .menu__panel button {
    display: block; width: 100%; text-align: left; padding: 0.55rem 1rem;
    background: none; border: 0; color: var(--text); font: inherit; text-decoration: none; cursor: pointer;
}
.menu__panel a:hover, .menu__panel button:hover { background: var(--surface-2); }

.topbar__brand { white-space: nowrap; }
@media (max-width: 520px) {
    .topbar { gap: 0.7rem; }
    .topbar__brand { font-size: 1rem; }
    .topbar__nav { gap: 0.7rem; }
    .menu summary { max-width: 5.5rem; }
}

/* ---- Baner awarii PullPush --------------------------------------------- */

.banner {
    padding: 0.75rem var(--gutter);
    background: var(--works);
    color: var(--sign-ink);
    font-weight: 600;
}

/* ---- Aplikacja ------------------------------------------------------------- */

.app { padding: 1.25rem var(--gutter) 3rem; max-width: 1400px; margin: 0 auto; outline: none; }
.section { margin-top: 2.25rem; }
.section > h2 { margin-bottom: 0.9rem; }
.empty { color: var(--muted); max-width: 60ch; }
.loading { color: var(--muted); }
.error { color: var(--works); }

/* Lista dróg: siatka tabliczek */
.roads-intro { color: var(--muted); margin: 0.4rem 0 1.5rem; max-width: 60ch; }
.roads {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: 0.75rem;
    list-style: none;
    padding: 0;
    margin: 0;
}
.road {
    display: grid;
    gap: 0.6rem;
    justify-items: start;
    padding: 0.9rem 0.9rem 0.8rem;
    background: var(--surface);
    border-radius: var(--radius-frame);
    text-decoration: none;
    border: 1px solid transparent;
}
.road:hover { border-color: var(--line); background: var(--surface-2); }
.road .plate { font-size: 1.35rem; }
.road__stats { font-size: 0.9rem; color: var(--muted); line-height: 1.35; }
.road__stats strong { color: var(--text); font-weight: 600; }
.road__problems { color: var(--works); }
.road--fav .plate { background: transparent; color: var(--sign); outline-color: var(--sign); }
.road--fav svg { fill: currentColor; }

/* Nagłówek drogi / kamery */
.head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; }
.head__text { display: grid; gap: 0.2rem; }
.head__sub { color: var(--muted); }
.back { display: inline-flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--text); }
.back .plate { font-size: 0.85rem; }

/* Siatka miniatur */
.cams {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
    gap: 1rem 0.9rem;
}
@media (max-width: 520px) {
    .cams { grid-template-columns: 1fr 1fr; gap: 0.9rem 0.6rem; }
}
.cam { position: relative; }
.cam__link { display: grid; gap: 0.45rem; text-decoration: none; }
.frame {
    position: relative;
    aspect-ratio: 16 / 9;
    background: var(--surface);
    border-radius: var(--radius-frame);
    overflow: hidden;
}
.frame img { width: 100%; height: 100%; object-fit: cover; }
.frame--none {
    display: grid;
    place-items: center;
    color: var(--muted);
    font-weight: 600;
    background: repeating-linear-gradient(-45deg, var(--surface) 0 14px, var(--surface-2) 14px 28px);
}
.cam__link:hover .frame { outline: 2px solid var(--line); }
.chip {
    position: absolute;
    left: 0.4rem;
    bottom: 0.4rem;
    padding: 0.15rem 0.45rem 0.05rem;
    border-radius: 3px;
    background: rgba(21, 23, 26, 0.82);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 700;
}
.chip--stale { background: var(--works); color: var(--sign-ink); }
.badge {
    position: absolute;
    left: 0.4rem;
    top: 0.4rem;
    padding: 0.15rem 0.45rem 0.05rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 700;
    background: var(--works);
    color: var(--sign-ink);
}
.cam__meta { display: grid; line-height: 1.3; padding-right: 2.2rem; }
.cam__place { font-weight: 600; }
.cam__slot { color: var(--muted); font-size: 0.875rem; }

/* Gwiazdka ulubionych */
.star {
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--muted);
    cursor: pointer;
}
.star svg { width: 1.3rem; height: 1.3rem; fill: none; stroke: currentColor; stroke-width: 1.8; }
.star[aria-pressed="true"] { color: var(--sign); }
.star[aria-pressed="true"] svg { fill: currentColor; }
.star:hover { background: var(--surface-2); }
.cam .star { position: absolute; right: -0.3rem; bottom: -0.15rem; }

/* Stacje meteo */
.meteo { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; max-width: 46rem; }
.meteo li {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.55rem 0.5rem 0.45rem 0.9rem;
    background: var(--surface); border-radius: var(--radius-frame);
}
.meteo__text { margin-right: auto; line-height: 1.35; }
.meteo__name { font-weight: 600; }
.meteo__info { color: var(--muted); font-size: 0.9rem; }
.meteo__icon { width: 1.25rem; height: 1.25rem; color: var(--sign); flex: none; }

/* Mapa */
.map { height: min(60vh, 520px); border-radius: var(--radius-frame); background: var(--surface); }
.map .leaflet-control-layers, .map .leaflet-bar a { background: var(--surface); color: var(--text); border-color: var(--line); }
.map .leaflet-control-attribution { background: rgba(29, 33, 37, 0.85); color: var(--muted); }
.map .leaflet-control-attribution a { color: var(--text); }
.map .leaflet-popup-content-wrapper, .map .leaflet-popup-tip { background: var(--surface); color: var(--text); }
.map .leaflet-popup-content { margin: 0.75rem 0.9rem; font: 400 0.95rem/1.4 var(--font); }
.marker {
    display: grid; place-items: center;
    width: 30px; height: 30px;
    border: 2px solid var(--asphalt);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.marker svg { width: 16px; height: 16px; }
.marker--cam { background: var(--sign); color: var(--sign-ink); border-radius: 5px; }
.marker--cam.is-problem { background: var(--works); }
.marker--cam.is-off { background: var(--muted); }
.marker--meteo { background: #4aa3df; color: #0d2333; border-radius: 50%; }
.popup { display: grid; gap: 0.6rem; min-width: 12rem; }
.popup__title { font-weight: 700; }
.popup__cams { display: grid; grid-template-columns: repeat(2, 7rem); gap: 0.5rem; }
.popup__cams a { text-decoration: none; font-size: 0.85rem; color: var(--text); display: grid; gap: 0.25rem; }
.popup__cams .frame { width: 7rem; }

/* Widok kamery */
.viewer { display: grid; gap: 1rem; margin-top: 1.25rem; }
@media (min-width: 1000px) {
    .viewer { grid-template-columns: minmax(0, 1fr) 19rem; align-items: start; }
}
.viewer .frame { aspect-ratio: auto; min-height: 12rem; }
.viewer .frame img { height: auto; object-fit: contain; }
.facts { display: grid; gap: 0.9rem; align-content: start; }
.facts dl { margin: 0; display: grid; gap: 0.6rem; }
.facts dt { color: var(--muted); font-size: 0.875rem; }
.facts dd { margin: 0; font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.5rem; }
@media (max-width: 520px) {
    .timeline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.timeline button {
    display: grid; gap: 0.3rem; width: 100%; padding: 0; border: 0; background: none;
    color: var(--muted); font: inherit; font-size: 0.875rem; text-align: left; cursor: pointer;
}
.timeline button[aria-pressed="true"] { color: var(--text); font-weight: 700; }
.timeline button[aria-pressed="true"] .frame { outline: 3px solid var(--sign); outline-offset: 1px; }

/* ---- Przyciski i formularze ---------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    min-height: 2.75rem; padding: 0.55rem 1.1rem 0.45rem;
    border: 1px solid var(--line); border-radius: var(--radius-frame);
    background: var(--surface-2); color: var(--text);
    font: 600 1rem var(--font); text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn--primary { background: var(--sign); color: var(--sign-ink); border-color: var(--sign); }
.btn--primary:hover { background: #ffd21f; border-color: #ffd21f; }
.btn--danger { border-color: var(--works); color: var(--works); background: none; }
.btn--quiet { background: none; border-color: transparent; color: var(--muted); }
.btn svg { width: 1.1rem; height: 1.1rem; }
.btn--star svg { fill: none; stroke: currentColor; stroke-width: 1.8; }
.btn--star[aria-pressed="true"] svg { fill: var(--sign); stroke: var(--sign); }

.form { display: grid; gap: 1rem; width: 100%; max-width: 24rem; }
.form--wide { max-width: 34rem; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.form h2 { margin-bottom: 0.25rem; }
.form__hint { color: var(--muted); font-size: 0.9rem; }
.field { display: grid; gap: 0.35rem; }
.field > span { font-weight: 600; }
.field small { color: var(--muted); }
.field input, .field select {
    width: 100%; min-height: 2.75rem; padding: 0.5rem 0.75rem 0.4rem;
    border: 1px solid var(--line); border-radius: var(--radius-frame);
    background: var(--asphalt); color: var(--text); font: 1rem var(--font);
}
.field input:focus, .field select:focus { border-color: var(--sign); outline: none; }

.notice { padding: 0.65rem 0.9rem 0.55rem; border-radius: var(--radius-frame); border-left: 4px solid; background: var(--surface); }
.notice--error { border-color: var(--works); }
.notice--ok { border-color: var(--ok); }

/* Logowanie i zmiana hasła */
.page-auth { min-height: 100vh; display: grid; place-items: center; padding: var(--gutter); }
.auth { display: grid; gap: 2rem; width: 100%; max-width: 24rem; }
.auth__brand { display: grid; gap: 0.6rem; justify-items: start; }
.auth__brand h1 { font-size: 2.6rem; }
.auth__brand p { color: var(--muted); }

/* Panel admina (desktop) */
.admin { padding: 1.5rem var(--gutter) 4rem; max-width: 1100px; margin: 0 auto; display: grid; gap: 1rem; justify-items: start; }
.admin h2 { margin-top: 1rem; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 0.6rem 0.75rem 0.5rem; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 600; font-size: 0.9rem; }
.table tr.is-off td { color: var(--muted); }
.admin .form--wide { margin-top: 0.5rem; }

@media (prefers-reduced-motion: no-preference) {
    .frame img { transition: opacity 0.25s; }
    .frame img.is-loading { opacity: 0.35; }
}
