@font-face {
    font-family: "Bricolage Grotesque";
    src: url("fonts/bricolage-grotesque-latin.woff2") format("woff2");
    font-weight: 200 800;
    font-display: swap;
}

:root {
    --bg: #0b0e11;
    --surface: #161b20;
    --ink: #f5f7f8;
    --muted: rgb(245 247 248 / .68);
    --surface-hover: #1e252c;
    --well: #07090b;
    --line: rgb(255 255 255 / .1);
    --accent: #ffcf5c;
    --radius: 20px;
    --pad: clamp(14px, 2.2vw, 36px);
    --display: "Bricolage Grotesque", system-ui, sans-serif;
    --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

html {
    background: var(--bg);
    color: var(--ink);
    font: 400 16px/1.4 var(--body);
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100dvh;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    color: inherit;
    border: 0;
    background: none;
    cursor: pointer;
}

img {
    display: block;
}

[hidden] {
    display: none !important;
}

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

.icon {
    width: 1.25em;
    height: 1.25em;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---------- Übersicht ---------- */

.bar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: var(--pad) var(--pad) calc(var(--pad) * .7);
}

.bar__brand {
    font: 700 clamp(1.6rem, 2.4vw, 2.2rem)/1 var(--display);
    letter-spacing: -.03em;
}

.clock {
    display: flex;
    gap: .7em;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.clock strong {
    color: var(--ink);
    font-weight: 600;
}

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(400px, 100%), 1fr));
    gap: 14px;
    padding: 0 var(--pad);
}

.tile {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--surface);
    transition: background .2s;
}

.tile:has(.tile__info:hover) {
    background: var(--surface-hover);
}

/* Alle Kacheln einheitlich 16:9, das Bild füllt die Fläche (wird beschnitten). */
.tile__cam {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    background: var(--well);
}

/* Webcams nebeneinander, Wischen rastet pro Bild ein */
.tile__track {
    display: flex;
    cursor: zoom-in;
    height: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

.tile__track::-webkit-scrollbar {
    display: none;
}

.tile__slide {
    flex: 0 0 100%;
    height: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

.tile__slide :is(img, video) {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tile__arrow {
    position: absolute;
    top: 50%;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    border-radius: 50%;
    background: rgb(11 14 17 / .62);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity .2s, background .2s;
}

.tile__arrow--prev {
    left: 10px;
}

.tile__arrow--next {
    right: 10px;
}

.tile__arrow:hover {
    background: rgb(11 14 17 / .85);
}

.tile__cam:hover .tile__arrow,
.tile__arrow:focus-visible {
    opacity: 1;
}

/* Touch-Geräte wischen, dort braucht es keine Pfeile */
@media (hover: none) {
    .tile__arrow {
        display: none;
    }
}

.tile__dots {
    position: absolute;
    bottom: 10px;
    left: 50%;
    display: flex;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 999px;
    background: rgb(11 14 17 / .45);
    transform: translateX(-50%);
    pointer-events: none;
}

.tile__dots i {
    width: 6px;
    height: 6px;
    border-radius: 3px;
    background: rgb(255 255 255 / .5);
    transition: width .3s, background .3s;
}

.tile__dots i.is-active {
    width: 16px;
    background: #fff;
}

.tile__info {
    display: flex;
    transition: background .2s;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px 16px;
}

.tile__text {
    min-width: 0;
}

.tile__name {
    display: block;
    font: 700 clamp(1.4rem, 1.9vw, 1.8rem)/1.1 var(--display);
    letter-spacing: -.03em;
}

.tile__sub {
    display: block;
    margin-top: 4px;
    min-height: 1.4em;
    color: var(--muted);
    font-size: .92rem;
}

.tile__sub span:empty {
    display: none;
}

.tile__sub span:not(:empty)~span:not(:empty)::before {
    content: "· ";
}

.tile__ski {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: .92rem;
    font-variant-numeric: tabular-nums;
}

.tile__ski:empty {
    display: none;
}

.tile__weather {
    display: flex;
    align-items: center;
    gap: 8px;
    font: 600 clamp(1.6rem, 2vw, 2rem)/1 var(--display);
    letter-spacing: -.03em;
    font-variant-numeric: tabular-nums;
}

.tile__weather .icon {
    width: .9em;
    height: .9em;
}

.credits {
    padding: calc(var(--pad) * .8) var(--pad) var(--pad);
    color: var(--muted);
    font-size: .8rem;
}

.credits a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.empty {
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 1.2rem;
    min-height: 100dvh;
    padding: var(--pad);
    text-align: center;
    color: var(--muted);
}

.empty h1 {
    color: var(--ink);
    font: 700 2.4rem/1 var(--display);
}

/* Großansicht: Das Bild wächst aus der Kachel (app.js, setupPreview) */
.peek {
    position: fixed;
    inset: 0;
    z-index: 50;
}

.peek__backdrop {
    position: absolute;
    inset: 0;
    background: rgb(5 7 9 / .78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    cursor: zoom-out;
    transition: opacity .35s;
}

.peek__box {
    position: absolute;
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--well);
    box-shadow: 0 30px 90px rgb(0 0 0 / .65), 0 0 0 1px var(--line);
    transform-origin: 0 0;
    transition: transform .42s cubic-bezier(.2, .85, .15, 1);
}

.peek.is-open .peek__backdrop {
    opacity: 1;
}

.peek__box > :is(img, video) {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.peek__button {
    position: absolute;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgb(11 14 17 / .62);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity .25s .15s, background .2s;
}

.peek.is-open .peek__button {
    opacity: 1;
}

.peek__button:hover {
    background: rgb(11 14 17 / .85);
}

.peek__button--close {
    top: 12px;
    right: 12px;
}

.peek__button--prev,
.peek__button--next {
    top: 50%;
    margin-top: -22px;
}

.peek__button--prev {
    left: 12px;
}

.peek__button--next {
    right: 12px;
}

/* Großes Bild lädt: kleines Bild unscharf, Schimmer läuft drüber, rechts unten
   ein Ring. Ist das große da, wird es weich scharf. */
:is(.cam__frame, .peek__box) > img {
    transition: filter .7s ease, transform .7s ease;
}

:is(.cam__frame, .peek__box).is-loading > img {
    filter: blur(14px) saturate(1.15);
    transform: scale(1.05);
}

:is(.cam__frame, .peek__box).is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 35%, rgb(255 255 255 / .13) 50%, transparent 65%) 0 0 / 250% 100%;
    animation: gm-shimmer 1.5s linear infinite;
    pointer-events: none;
}

:is(.cam__frame, .peek__box).is-loading::before {
    content: "";
    position: absolute;
    z-index: 1;
    right: 16px;
    bottom: 16px;
    width: 22px;
    height: 22px;
    border: 2.5px solid rgb(255 255 255 / .25);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: gm-spin .8s linear infinite;
    pointer-events: none;
}

@keyframes gm-shimmer {
    from { background-position: 150% 0; }
    to { background-position: -100% 0; }
}

@keyframes gm-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .peek__box,
    :is(.cam__frame, .peek__box) > img {
        transition: none;
    }

    :is(.cam__frame, .peek__box).is-loading::after,
    :is(.cam__frame, .peek__box).is-loading::before {
        animation: none;
    }
}

/* ---------- Ort ---------- */

.place {
    --side: clamp(300px, 24vw, 360px);
    display: grid;
    grid-template: "top top" auto "cam side" auto "news news" auto / minmax(0, 1fr) var(--side);
    gap: 16px 24px;
    padding: var(--pad);
    padding-bottom: max(var(--pad), env(safe-area-inset-bottom));
}

.top {
    grid-area: top;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.top__nav {
    display: flex;
    gap: 8px;
}

.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    height: 44px;
    padding: 0 18px 0 14px;
    border-radius: 999px;
    background: var(--surface);
    font-size: .95rem;
    font-weight: 600;
    transition: background .2s;
}

.chip:hover {
    background: var(--surface-hover);
}

.chip--icon {
    width: 44px;
    padding: 0;
}

/* Das Bild wird so groß wie möglich gezeigt, aber immer ganz: Die Breite
   richtet sich nach der Spalte oder, wenn das Bild sonst zu hoch würde,
   nach der Fensterhöhe abzüglich Kopfzeile und Nachrichten (--chrome).
   --ratio setzt app.js, sobald die Bildmaße bekannt sind. */
.cam {
    --chrome: 300px;
    grid-area: cam;
    min-width: 0;
}

.cam__frame {
    position: relative;
    display: block;
    width: min(100%, (100dvh - var(--chrome)) * var(--ratio, 1.7778));
    min-width: min(100%, 520px);
    margin-inline: auto;
    aspect-ratio: var(--ratio, 1.7778);
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--surface) center / cover no-repeat;
}

.cam__frame :is(img, video) {
    display: block;
    width: 100%;
    height: 100%;
}

/* Webcams nebeneinander, Wischen rastet pro Webcam ein */
.cam__track {
    display: flex;
    align-items: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

.cam__track::-webkit-scrollbar {
    display: none;
}

.cam__slide {
    flex: 0 0 100%;
    min-width: 0;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

/* Die Höhe richtet sich nach der gezeigten Webcam (Panoramen sind flach),
   Nachbarn ragen beim Wischen nur hinein */
.cam__slide.is-off {
    height: 0;
}

/* Mehrere Webcams: Leiste zum Blättern unter dem Bild, nichts liegt darüber */
.cam--slides {
    --chrome: 360px;
}

.cam__nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
}

.cam__label {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
    padding: 0 6px;
    text-align: center;
}

.cam__label strong {
    overflow: hidden;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cam__label span {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cam__empty {
    padding: 20vh 0;
    text-align: center;
    color: var(--muted);
}

.side {
    grid-area: side;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.hero {
    padding: 4px 4px 6px;
}

.hero__name {
    margin-top: .12em;
    font: 700 clamp(2.4rem, 3.5vw, 3.6rem)/.98 var(--display);
    letter-spacing: -.04em;
    text-wrap: balance;
}

.hero__name small {
    display: block;
    margin-top: .35em;
    font-size: .42em;
    font-weight: 500;
    letter-spacing: -.01em;
    color: var(--muted);
}

.now {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 3.2rem;
    margin-top: 16px;
}

.now .icon {
    width: 2.6rem;
    height: 2.6rem;
    stroke-width: 1.4;
}

.now__temp {
    font: 600 3.2rem/1 var(--display);
    letter-spacing: -.04em;
    font-variant-numeric: tabular-nums;
}

.now__text {
    display: grid;
    gap: 2px;
    padding-left: 12px;
    border-left: 1px solid var(--line);
}

.now__label {
    font-size: 1.05rem;
    font-weight: 600;
}

.now__meta {
    color: var(--muted);
    font-size: .88rem;
}

.card {
    padding: 8px 18px;
    border-radius: var(--radius);
    background: var(--surface);
}

.day {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 1.6rem 4.3rem;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    font-variant-numeric: tabular-nums;
}

.day+.day {
    border-top: 1px solid var(--line);
}

.day__name {
    font-weight: 600;
}

.day__name abbr {
    text-decoration: none;
}

.day__rain {
    display: flex;
    align-items: center;
    gap: 3px;
    color: var(--muted);
    font-size: .8rem;
}

.day__rain .icon {
    width: 1em;
    height: 1em;
}

.day>.icon {
    width: 1.6rem;
    height: 1.6rem;
}

.day__temp {
    text-align: right;
    font-weight: 600;
}

.day__temp span {
    margin-left: .45em;
    color: var(--muted);
    font-weight: 400;
}

.sun {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .85rem;
    font-variant-numeric: tabular-nums;
}

.sun span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ski {
    display: grid;
    gap: 12px;
    padding-block: 16px;
}

.ski__row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 7px 10px;
    font-variant-numeric: tabular-nums;
}

.ski__row strong {
    font-weight: 600;
}

.ski__row span {
    color: var(--muted);
}

.ski__bar {
    grid-column: 1 / -1;
    height: 4px;
    border-radius: 2px;
    background: var(--line);
    overflow: hidden;
}

.ski__bar i {
    display: block;
    height: 100%;
    border-radius: 2px;
    background: var(--accent);
}

.side__credit {
    padding: 0 4px;
    color: var(--muted);
    font-size: .75rem;
}

/* Vier Meldungen nebeneinander, alle vollständig lesbar. */
.news {
    grid-area: news;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.news__item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius);
    background: var(--surface);
    transition: background .2s;
}

.news__item:hover {
    background: var(--surface-hover);
}

.news__item img {
    flex: none;
    width: 76px;
    height: 76px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--well);
}

.news__text {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.news__meta {
    color: var(--muted);
    font-size: .78rem;
}

.news__title {
    font-size: .98rem;
    font-weight: 600;
    line-height: 1.28;
    text-wrap: pretty;
}

@media (min-width: 901px) {

    /* Panorama: Bild über die ganze Breite, Meldungen und Wetter darunter */
    .place.is-wide {
        grid-template-areas: "top top" "cam cam" "news side";
    }

    .place.is-wide .news {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-content: start;
    }

    .place.is-wide .news__item:nth-child(n+4) {
        display: flex;
    }

    /* Kurzform („Do“) steht im Element, die Langform kommt aus dem title */
    .day__name abbr {
        font-size: 0;
    }

    .day__name abbr::after {
        content: attr(title);
        font-size: 1rem;
    }
}

@media (max-width: 1300px) {
    .news {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .news__item:nth-child(n+4) {
        display: none;
    }
}

@media (max-width: 900px) {
    .place {
        grid-template: "top" auto "cam" auto "side" auto "news" auto / minmax(0, 1fr);
    }

    .cam__frame {
        width: 100%;
        min-width: 0;
    }

    .chip--fullscreen {
        display: none;
    }

    .forecast__days {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
    }

    .day {
        grid-template-columns: 1fr;
        justify-items: center;
        gap: 6px;
        padding: 10px 4px;
        text-align: center;
    }

    .day+.day {
        border-top: 0;
        border-left: 1px solid var(--line);
    }

    .day__name {
        order: -2;
    }

    .day>.icon {
        order: -1;
    }

    .day__temp {
        text-align: center;
    }

    .day__rain:empty {
        display: block;
        min-height: 1.1em;
    }

    .news {
        grid-template-columns: 1fr;
    }

    .news__item:nth-child(n+4) {
        display: flex;
    }
}

@view-transition {
    navigation: auto;
}

::view-transition-group(*) {
    animation-duration: .45s;
    animation-timing-function: cubic-bezier(.3, .7, .2, 1);
}

@media (prefers-reduced-motion: reduce) {
    @view-transition {
        navigation: none;
    }
}
