/* =====================================================================
   La Palma Reiseplaner – Stylesheet
   ---------------------------------------------------------------------
   INHALT
   1. Design-Tokens   (Farben, Abstände, Schrift  → hier anpassen!)
   2. Basis           (Reset, Typografie)
   3. Layout          (Topbar, Seitenraster)
   4. Hero            (Tageskopf mit Titelbild)
   5. Boxen & Listen  (Programm, Sehenswert, Equipment …)
   6. Wetter
   7. Übersicht       (Startseite)
   8. Galerie & Lightbox
   9. Sonstiges       (Print, reduzierte Bewegung)
   Moderne Features: @layer, Nesting, light-dark(), oklch(), color-mix(),
   Container Queries, :has(), View Transitions, Scroll-driven Animations.
   ===================================================================== */

@layer tokens, basis, layout, hero, komponenten, wetter, uebersicht, galerie, sonstiges;
@view-transition { navigation: auto; }

/* ============================ 1. TOKENS ============================ */
@layer tokens {
  :root {
    color-scheme: light dark;

    /* Farben – automatisch hell/dunkel nach Geräteeinstellung */
    --bg:        light-dark(oklch(97% .012 85),  oklch(17% .02 265));
    --flaeche:   light-dark(oklch(100% 0 0),     oklch(23% .025 265));
    --flaeche-2: light-dark(oklch(94% .015 85),  oklch(28% .03 265));
    --text:      light-dark(oklch(24% .02 265),  oklch(93% .01 85));
    --text-leise:light-dark(oklch(46% .02 265),  oklch(73% .02 265));
    --linie:     light-dark(oklch(88% .015 85),  oklch(34% .03 265));
    --akzent:    oklch(68% .19 45);    /* Lava-Orange  */
    --akzent-2:  oklch(72% .11 200);   /* Atlantik-Türkis */
    --akzent-3:  oklch(80% .15 90);    /* Sternen-Gelb */
    --gefahr:    oklch(62% .22 27);

    /* Schrift */
    --schrift-text:  system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --schrift-titel: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;

    /* Maße */
    --rand: clamp(1rem, 4vw, 2rem);
    --abstand: clamp(1rem, 2.5vw, 1.75rem);
    --radius: 1.1rem;
    --breite: 78rem;
    --schatten: 0 .1rem .2rem oklch(0% 0 0 / .08), 0 .8rem 2rem -1rem oklch(0% 0 0 / .25);
  }
}

/* ============================== 2. BASIS =========================== */
@layer basis {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
  body {
    margin: 0; min-height: 100dvh;
    background: var(--bg); color: var(--text);
    font: 1rem/1.6 var(--schrift-text);
    text-wrap: pretty;
  }
  h1, h2, h3 { font-family: var(--schrift-titel); line-height: 1.15; text-wrap: balance; margin: 0 0 .6em; }
  h1 { font-size: clamp(2rem, 6vw + .5rem, 3.75rem); }
  h2 { font-size: clamp(1.35rem, 2vw + 1rem, 1.9rem); }
  h3 { font-size: 1.1rem; font-family: var(--schrift-text); font-weight: 650; }
  p { margin: 0 0 1em; }
  a { color: var(--akzent); text-underline-offset: .2em; }
  a:hover { color: color-mix(in oklch, var(--akzent), var(--text) 30%); }
  img { max-width: 100%; display: block; }
  :focus-visible { outline: .18rem solid var(--akzent-2); outline-offset: .15rem; border-radius: .3rem; }
  ul { padding-left: 1.2em; margin: 0 0 1em; }
  li { margin-block: .35em; }
}

/* ============================= 3. LAYOUT =========================== */
@layer layout {
  .topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: .75rem; justify-content: space-between;
    padding: .6rem var(--rand);
    background: color-mix(in oklch, var(--bg) 82%, transparent);
    backdrop-filter: blur(.8rem) saturate(1.4);
    border-bottom: 1px solid var(--linie);

    .marke { font-family: var(--schrift-titel); font-weight: 700; color: var(--text); text-decoration: none; }
    nav { display: flex; gap: .4rem; }
  }
  .knopf {
    display: inline-flex; align-items: center; gap: .4em;
    padding: .45rem .9rem; border-radius: 99rem;
    background: var(--flaeche); color: var(--text); text-decoration: none;
    border: 1px solid var(--linie); font-size: .9rem; cursor: pointer;
    &:hover { background: var(--flaeche-2); color: var(--text); }
    &[aria-disabled="true"] { opacity: .35; pointer-events: none; }
  }

  .seite { max-width: var(--breite); margin-inline: auto; padding: var(--abstand) var(--rand) 4rem;
           display: grid; gap: var(--abstand); }

  /* Zwei Spalten ab Tablet-Breite: Hauptinhalt + Seitenleiste */
  .spalten { display: grid; gap: var(--abstand); align-items: start; }
  .spalte  { display: grid; gap: var(--abstand); min-width: 0; }
  @media (min-width: 60rem) {
    .spalten { grid-template-columns: minmax(0, 1.7fr) minmax(18rem, 1fr); }
    .spalte.seite-leiste { position: sticky; top: 4.5rem; }
  }
}

/* ============================== 4. HERO ============================ */
@layer hero {
  .tour-kopf {
    --bild: linear-gradient(transparent, transparent);
    position: relative; isolation: isolate; overflow: clip;
    min-height: clamp(18rem, 48vh, 30rem);
    display: grid; align-content: end; gap: .3rem;
    padding: clamp(1.25rem, 4vw, 3rem);
    border-radius: var(--radius);
    color: oklch(98% 0 0);
    background: var(--bild), linear-gradient(135deg, oklch(30% .06 265), oklch(22% .08 20)); background-size: cover; background-position: center;

    &::before { content: ""; position: absolute; inset: 0; z-index: -1;
      background: linear-gradient(to top, oklch(10% .02 265 / .88), oklch(10% .02 265 / .15) 70%); }
    h1 { margin: 0; text-shadow: 0 .1rem 1rem oklch(0% 0 0 / .5); }
    .tagzeile { font-size: .95rem; letter-spacing: .06em; text-transform: uppercase; opacity: .9; display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
    .fokus { margin: .25rem 0 0; font-size: 1.05rem; color: var(--akzent-3); font-weight: 600; }
    .teaser { max-width: 46rem; margin: .5rem 0 0; opacity: .95; font-size: 1.05rem; }
  }
  .chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0 0; padding: 0; list-style: none; }
  .chip { margin: 0; padding: .15rem .65rem; border-radius: 99rem; font-size: .8rem; font-weight: 600;
          background: oklch(100% 0 0 / .16); border: 1px solid oklch(100% 0 0 / .3); backdrop-filter: blur(.4rem); }
  .chip.tausch { background: color-mix(in oklch, var(--akzent) 55%, transparent); }
}

/* ========================= 5. BOXEN & LISTEN ======================= */
@layer komponenten {
  .box {
    background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius);
    padding: clamp(1rem, 3vw, 1.6rem); box-shadow: var(--schatten);
    container-type: inline-size;

    > :last-child { margin-bottom: 0; }
    h2 { display: flex; align-items: center; gap: .5em; padding-bottom: .4em; border-bottom: 2px solid var(--linie); }
    h2::before { content: var(--icon, "•"); }
    &.programm   { --icon: "🧭"; }
    &.sehenswert { --icon: "⭐"; border-color: color-mix(in oklch, var(--akzent-3) 60%, var(--linie)); }
    &.logistik   { --icon: "🚗"; }
    &.equipment  { --icon: "🎒"; }
    &.fototipp   { --icon: "📷"; background: color-mix(in oklch, var(--akzent-2) 12%, var(--flaeche)); }
    &.tagesinfo  { --icon: "🏨"; background: color-mix(in oklch, var(--akzent) 10%, var(--flaeche)); }
    &.mond       { --icon: "🌙"; }
  }

  /* Sehenswert: nummerierte Spot-Liste */
  .spots { list-style: none; padding: 0; counter-reset: spot; display: grid; gap: .8rem; }
  .spots li { counter-increment: spot; display: grid; grid-template-columns: 2rem 1fr; gap: .75rem; margin: 0; }
  .spots li::before { content: counter(spot); display: grid; place-items: center; width: 2rem; height: 2rem;
                      border-radius: 50%; background: var(--akzent); color: white; font-weight: 700; font-size: .9rem; }
  .spots strong { display: block; }

  /* Equipment: abhakbare Checkliste */
  .checkliste { list-style: none; padding: 0; display: grid; gap: .1rem; }
  .checkliste label { display: flex; gap: .6rem; align-items: start; padding: .3rem .2rem; cursor: pointer; border-radius: .5rem; }
  .checkliste label:hover { background: var(--flaeche-2); }
  .checkliste input { accent-color: var(--akzent); width: 1.1rem; height: 1.1rem; margin-top: .25rem; flex: none; }
  .checkliste label:has(input:checked) { opacity: .5; text-decoration: line-through; }

  /* Kennzahlen (km, Höhenmeter …) */
  .metriken { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: .6rem; margin: 0 0 1rem; }
  .metriken div { background: var(--flaeche-2); border-radius: .8rem; padding: .6rem .8rem; }
  .metriken dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-leise); }
  .metriken dd { margin: 0; font-size: 1.3rem; font-weight: 700; font-family: var(--schrift-titel); }

  /* Flugstatus-Karte (Tag 1 und Tag 11) */
  .flug { padding: .8rem 1rem; margin-bottom: 1rem; border-radius: .9rem; background: color-mix(in oklch, var(--akzent-2) 14%, var(--flaeche)); border: 1px solid var(--linie); }
  .flug p { margin-bottom: .5rem; }
  .flug-links { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; }

  .warnung { border-left: .3rem solid var(--gefahr); padding: .6rem 1rem; background: color-mix(in oklch, var(--gefahr) 12%, transparent); border-radius: 0 .6rem .6rem 0; }
  .zeitblock { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--akzent); margin: 1rem 0 .2rem; }
  .klein { font-size: .85rem; color: var(--text-leise); }
  .laden { padding: 2rem; text-align: center; color: var(--text-leise); }
}

/* ============================= 6. WETTER =========================== */
@layer wetter {
  .wetter {
    container-type: inline-size;
    background: linear-gradient(135deg, color-mix(in oklch, var(--akzent-2) 22%, var(--flaeche)), var(--flaeche));
    border: 1px solid var(--linie); border-radius: var(--radius); padding: clamp(1rem, 3vw, 1.6rem); box-shadow: var(--schatten);

    h2 { margin-bottom: .8rem; }
    .w-haupt { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: center; }
    .w-icon { font-size: clamp(3rem, 12vw, 4.5rem); line-height: 1; }
    .w-temp { font-family: var(--schrift-titel); font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 700; }
    .w-temp .min { color: var(--akzent-2); } .w-temp .max { color: var(--akzent); }
    .w-werte { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: .6rem; margin: 1rem 0 0; }
    .w-werte div { background: color-mix(in oklch, var(--flaeche-2) 70%, transparent); border-radius: .8rem; padding: .5rem .75rem; }
    .w-werte dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-leise); }
    .w-werte dd { margin: 0; font-weight: 650; }
    .w-tipp { margin: 1rem 0 0; padding: .6rem .9rem; border-radius: .8rem; background: color-mix(in oklch, var(--akzent-3) 25%, transparent); }
    details { margin-top: 1rem; }
    summary { cursor: pointer; font-weight: 600; }
    iframe { width: 100%; height: min(70vh, 30rem); border: 0; border-radius: .8rem; margin-top: .6rem; }
  }
  /* Stundenbalken für Regenwahrscheinlichkeit */
  .stunden { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; align-items: end; height: 3.5rem; margin-top: 1rem; }
  .stunden i { height: max(4%, calc(var(--p) * 1%)); background: var(--akzent-2); border-radius: 2px 2px 0 0;
               opacity: calc(.35 + var(--p) / 160); }
  .stunden i.nacht { background: color-mix(in oklch, var(--akzent-2), black 40%); }
  .stunden-skala { display: flex; justify-content: space-between; font-size: .7rem; color: var(--text-leise); }
}

/* =========================== 7. ÜBERSICHT ========================== */
@layer uebersicht {
  .start-hero { padding: clamp(2rem, 8vw, 5rem) var(--rand) 2rem; max-width: var(--breite); margin-inline: auto; }
  .start-hero p { max-width: 44rem; color: var(--text-leise); font-size: 1.1rem; }
  .zaehler { display: inline-block; padding: .3rem .9rem; border-radius: 99rem; background: var(--akzent); color: white; font-weight: 700; margin-bottom: 1rem; }
  .abschnitt h2 { display: flex; flex-wrap: wrap; gap: .3rem 1rem; align-items: baseline; }
  .abschnitt .hinweis { font: .9rem var(--schrift-text); color: var(--text-leise); }
  .karten { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: var(--abstand); margin-bottom: 2rem; }
  .tag-karte {
    --bild: linear-gradient(transparent, transparent); position: relative; isolation: isolate; overflow: clip; display: grid; align-content: end; gap: .2rem;
    min-height: 15rem; padding: 1rem; border-radius: var(--radius); color: white; text-decoration: none;
    background: var(--bild), linear-gradient(135deg, oklch(35% .06 265), oklch(25% .08 20)); background-size: cover; background-position: center;
    box-shadow: var(--schatten); transition: transform .25s, box-shadow .25s;
    &::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(to top, oklch(10% .02 265 / .9), oklch(10% .02 265 / .1) 75%); }
    &:hover { transform: translateY(-.25rem); color: white; }
    .datum { position: absolute; top: .8rem; left: .8rem; padding: .25rem .7rem; border-radius: .7rem; background: oklch(0% 0 0 / .55); backdrop-filter: blur(.4rem); font-weight: 700; font-size: .85rem; }
    h3 { margin: 0; font-family: var(--schrift-titel); font-size: 1.3rem; }
    p { margin: 0; font-size: .9rem; opacity: .9; }
    &.heute { outline: .2rem solid var(--akzent-3); outline-offset: .15rem; }
  }
  .anleitung { font-size: .95rem; }
  .anleitung code { background: var(--flaeche-2); padding: .1em .4em; border-radius: .3em; }
}

/* ======================= 8. GALERIE & LIGHTBOX ===================== */
@layer galerie {
  .galerie-sektion h2 { display: flex; justify-content: space-between; align-items: baseline; }
  .galerie {
    display: grid; gap: .6rem;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
    grid-auto-flow: dense; grid-auto-rows: 11rem;

    figure { margin: 0; position: relative; overflow: clip; border-radius: .9rem; background: var(--flaeche-2); }
    button { all: unset; display: block; width: 100%; height: 100%; cursor: zoom-in; }
    img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease, filter .3s; }
    figure:hover img { transform: scale(1.06); }
    figcaption { position: absolute; inset: auto 0 0; padding: 1.5rem .7rem .5rem; font-size: .8rem; color: white;
                 background: linear-gradient(to top, oklch(0% 0 0 / .75), transparent); translate: 0 100%; transition: translate .25s; pointer-events: none; }
    figure:hover figcaption, figure:focus-within figcaption { translate: 0 0; }

    /* Mosaik: jedes 5. Bild groß, jedes 7. hoch */
    @media (min-width: 40rem) {
      figure:nth-child(5n+1) { grid-column: span 2; grid-row: span 2; }
      figure:nth-child(7n+4) { grid-row: span 2; }
    }
    /* Einblend-Animation beim Scrollen (nur wo unterstützt) */
    @supports (animation-timeline: view()) {
      figure { animation: einblenden linear both; animation-timeline: view(); animation-range: entry 0% entry 40%; }
    }
  }
  @keyframes einblenden { from { opacity: 0; scale: .94; translate: 0 1.5rem; } }
  .galerie-leer { padding: 1.5rem; border: 2px dashed var(--linie); border-radius: var(--radius); color: var(--text-leise); }

  dialog.lightbox {
    border: 0; padding: 0; background: transparent; color: white; width: 100vw; height: 100dvh; max-width: none; max-height: none;
    &::backdrop { background: oklch(8% .02 265 / .94); backdrop-filter: blur(.5rem); }
    &[open] { display: grid; grid-template-rows: 1fr auto; }
    .bildflaeche { display: grid; place-items: center; min-height: 0; padding: 1rem 3.5rem; touch-action: pan-y; }
    img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: .5rem; }
    .unterschrift { padding: .5rem 1rem 1.2rem; text-align: center; font-size: .9rem; }
    .unterschrift a { color: var(--akzent-3); }
    .unterschrift .klein { color: oklch(85% .01 265); }
    .lb-knopf { position: absolute; background: oklch(100% 0 0 / .14); color: white; border: 0; border-radius: 50%;
                width: 2.8rem; height: 2.8rem; font-size: 1.4rem; cursor: pointer; }
    .lb-knopf:hover { background: oklch(100% 0 0 / .3); }
    .lb-zu { top: .8rem; right: .8rem; } .lb-zurueck { left: .5rem; top: 50%; } .lb-vor { right: .5rem; top: 50%; }
  }
}

/* ============================ 9. SONSTIGES ========================= */
@layer sonstiges {
  @media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  }
  @media print {
    .topbar, .galerie-sektion, details, .lb-knopf { display: none !important; }
    body { background: white; color: black; }
    .box, .wetter { box-shadow: none; break-inside: avoid; }
    .spalten { display: block; }
  }
}
