/* ==========================================================================
   PHILLO.ROCKS 2.0 – Motion-Layer
   Progressive Enhancement über dem 1:1-Design (style.css):
   - CSS Scroll-Driven Animations (animation-timeline: view()/scroll()) – laufen auf dem Compositor
   - Cross-Document View Transitions (@view-transition)
   - Ladeanimationen für Titelbereiche
   Ohne Browser-Unterstützung oder bei „Bewegung reduzieren“ bleibt die Seite im statischen 1.0-Zustand.
   Nur transform/translate/scale/opacity/clip-path werden animiert.
   ========================================================================== */

:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

/* Bilder, die beim Erscheinen von 115–130 % auf 100 % skalieren, dürfen nicht überstehen */
.post-content picture, .about__media > picture, .post__featured picture, .ctitle__photo picture { overflow: clip; }

/* ---------- Scroll-Fortschritt ---------- */
.scroll-progress { position: fixed; top: 0; left: 0; right: 0; z-index: 60; height: 3px; background: linear-gradient(90deg, var(--c-accent), var(--c-accent-2)); transform: scaleX(0); transform-origin: 0 50%; pointer-events: none; }

/* ---------- Hover-Details (nur echte Maus) ---------- */
.btn-outline { position: relative; isolation: isolate; overflow: hidden; }
.btn-outline::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--c-accent); transform: scaleX(0); transform-origin: 0 50%; transition: transform 300ms var(--ease-out); }
.gallery__item { position: relative; }
.gallery__item::after { content: ''; position: absolute; inset: 0; background: rgba(0, 223, 229, .28) no-repeat center / 44px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 44 44'%3E%3Cpath d='M22 6v32M6 22h32' stroke='%23fff' stroke-width='2.5'/%3E%3C/svg%3E"); opacity: 0; transition: opacity 250ms var(--ease-out); pointer-events: none; }
.insta__photo img { transition: opacity .3s, scale 600ms var(--ease-out); }
.insta__caption { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; padding: 40px 12px 10px; background: linear-gradient(transparent, rgba(0, 0, 0, .7)); color: #fff; font: 600 13px/18px var(--f-body); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; opacity: 0; translate: 0 8px; transition: opacity 250ms var(--ease-out), translate 250ms var(--ease-out); pointer-events: none; }
.insta__btn { transition: opacity .2s, translate 200ms var(--ease-out); }
.socials__item { transition: color .2s, translate 300ms var(--ease-out); }
.scroll-top { transition: opacity .3s, transform .3s, visibility .3s, background-color .2s, translate 300ms var(--ease-out); }
.bcard, .lcard__inner { position: relative; }
.bcard::after, .lcard__inner::after { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 300ms var(--ease-out); background: radial-gradient(circle at var(--mx, 50%) var(--my, 0%), rgba(255, 255, 255, .45), transparent 55%); }
.bcard::after { inset: 0 21px; }

@media (hover: hover) and (pointer: fine) {
  .btn-outline:hover { background: transparent; }
  .btn-outline:hover::before { transform: scaleX(1); }
  .gallery__item:hover::after { opacity: 1; }
  .insta__photo:hover img { opacity: 1; scale: 1.08; }
  .insta__photo:hover .insta__caption, .insta__photo:focus-visible .insta__caption { opacity: 1; translate: 0 0; }
  .insta__btn:hover { translate: 0 -2px; }
  .bcard.is-tilting::after, .lcard__inner.is-tilting::after { opacity: 1; }
}

/* Navigations-Unterstrich (Desktop) */
@media (min-width: 1212px) {
  .primary-menu a { position: relative; }
  .primary-menu a::after { content: ''; position: absolute; left: 20px; right: 20px; bottom: 29px; height: 2px; background: currentColor; transform: scaleX(0); transform-origin: 0 50%; transition: transform 250ms var(--ease-out); }
  .primary-menu .is-active a::after { transform: scaleX(1); }
}
@media (min-width: 1212px) and (hover: hover) and (pointer: fine) {
  .primary-menu a:hover::after { transform: scaleX(1); }
}

/* Blogkarten-Einblendung: translate/scale statt transform (transform bleibt frei für den 3D-Tilt) */
.js .reveal { transform: none; opacity: 0; translate: 0 60px; scale: .96; transition: opacity 700ms var(--ease-out), translate 900ms var(--ease-out), scale 900ms var(--ease-out); }
.js .reveal.is-in { opacity: 1; translate: 0 0; scale: 1; }

/* ==========================================================================
   Animationen – nur ohne „Bewegung reduzieren“
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {

  /* ---------- Seitenübergänge (View Transitions API) ---------- */
  @view-transition { navigation: auto; types: page-nav; }
  .site-logo { view-transition-name: site-logo; }
  .primary-nav { view-transition-name: site-nav; }
  .scroll-progress { view-transition-name: scroll-progress; }
  html:active-view-transition-type(page-nav)::view-transition-old(root) { animation: vt-out 220ms var(--ease-out) both; }
  html:active-view-transition-type(page-nav)::view-transition-new(root) { animation: vt-in 520ms var(--ease-out) 60ms both; }
  ::view-transition-group(root) { animation-duration: 280ms; }
  ::view-transition-group(post-title), ::view-transition-group(post-image), ::view-transition-group(lightbox-image) { animation-duration: 560ms; animation-timing-function: var(--ease-in-out); }
  ::view-transition-old(post-title), ::view-transition-new(post-title) { height: 100%; object-fit: none; object-position: left center; }
  @keyframes vt-out { to { opacity: 0; } }
  @keyframes vt-in { from { opacity: 0; transform: translateY(28px); } }

  /* ---------- Titelbereiche der Unterseiten: Ladeanimation ---------- */
  .ctitle__photo { animation: wipe-in 1.1s var(--ease-in-out) .1s both; }
  .ctitle__photo img { animation: settle 1.6s var(--ease-out) .1s both; }
  .ctitle__bg { animation: rise-in 900ms var(--ease-out) both; }
  .ctitle__heading > span { display: inline-block; white-space: pre; animation: rise-in 900ms var(--ease-out) both; }
  .ctitle__dark { animation-delay: .35s !important; }
  .ctitle__light { animation-delay: .5s !important; }
  .ctitle__label { animation: fade-in 900ms var(--ease-out) .7s both; }
  .ptitle__heading { animation: rise-in 800ms var(--ease-out) .1s both; }
  .breadcrumbs { animation: fade-in 800ms var(--ease-out) .35s both; }
  .post__featured picture { animation: wipe-up 1.1s var(--ease-in-out) .2s both; }
  .post__featured img { animation: settle 1.6s var(--ease-out) .2s both; }
  @keyframes wipe-in { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0); } }
  @keyframes wipe-up { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0); } }
  @keyframes wipe-down { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0); } }
  @keyframes settle { from { scale: 1.15; } to { scale: 1; } }
  @keyframes rise-in { from { opacity: 0; translate: 0 40px; } to { opacity: 1; translate: 0 0; } }
  @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

  /* ---------- Scroll-Driven Animations ---------- */
  @supports (animation-timeline: view()) {
    .scroll-progress { animation: progress linear both; animation-timeline: scroll(root block); }
    @keyframes progress { to { transform: scaleX(1); } }

    /* Hero: Bild zoomt/verschiebt sich langsamer (Parallax), Texte gleiten schneller heraus, Fläche dunkelt ab */
    .hero { view-timeline: --hero block; }
    .hero::after { content: ''; position: absolute; inset: 0; z-index: 0; background: #0b1013; opacity: 0; pointer-events: none; animation: hero-dim linear both; animation-timeline: --hero; animation-range: exit 0% exit 100%; }
    .hero__media { animation: hero-media linear both; animation-timeline: --hero; animation-range: exit 0% exit 100%; }
    .hero__brand { animation: hero-brand linear both; animation-timeline: --hero; animation-range: exit 0% exit 70%; }
    .hero__claim { animation: hero-claim linear both; animation-timeline: --hero; animation-range: exit 0% exit 70%; }
    .hero__dots { animation: hero-dots linear both; animation-timeline: --hero; animation-range: exit 0% exit 100%; }
    @keyframes hero-dim { to { opacity: .6; } }
    @keyframes hero-media { to { translate: 0 32%; scale: 1.08; } }
    @keyframes hero-brand { to { translate: 0 -140px; opacity: 0; } }
    @keyframes hero-claim { to { translate: 0 -70px; opacity: 0; } }
    @keyframes hero-dots { to { translate: 0 -260px; } }

    /* water | snow | motor | hockey – Wort für Wort */
    .intro__title .kw { display: inline-block; animation: word-in linear both; animation-timeline: view(); }
    .intro__title .kw:nth-child(1) { animation-range: entry 10% cover 30%; }
    .intro__title .kw:nth-child(2) { animation-range: entry 14% cover 32%; }
    .intro__title .kw:nth-child(3) { animation-range: entry 18% cover 34%; }
    .intro__title .kw:nth-child(4) { animation-range: entry 22% cover 36%; }
    .intro__title .kw:nth-child(5) { animation-range: entry 26% cover 38%; }
    .intro__title .kw:nth-child(6) { animation-range: entry 30% cover 40%; }
    .intro__title .kw:nth-child(7) { animation-range: entry 34% cover 42%; }
    .intro__title .kw--pipe { color: var(--c-accent); }
    @keyframes word-in { from { translate: 0 .7em; filter: blur(10px); } to { translate: 0 0; filter: blur(0); } }
    .intro .quote blockquote { animation: rise-in linear both; animation-timeline: view(); animation-range: entry 10% cover 35%; }
    .quote__mark { animation: mark-pop linear both; animation-timeline: view(); animation-range: entry 30% cover 45%; }
    @keyframes mark-pop { from { opacity: 0; scale: .5; rotate: -20deg; } to { opacity: 1; scale: 1; rotate: 0deg; } }

    /* Galerie: Bilder öffnen sich (Clip-Reveal) und „setzen sich“; Mittelspalte mit Gegen-Parallax */
    .gallery__item { animation: frame-in linear both; animation-timeline: view(); animation-range: entry 0% entry 85%; }
    .gallery__item img { animation: img-settle linear both; animation-timeline: view(); animation-range: entry 0% cover 55%; }
    @keyframes frame-in { from { clip-path: inset(20% 10% 20% 10%); opacity: .15; } to { clip-path: inset(0); opacity: 1; } }
    @keyframes img-settle { from { scale: 1.3; } to { scale: 1; } }
    .gallery.is-masonry { view-timeline: --gallery block; }
    .gallery.is-masonry .gallery__col:nth-child(2) { animation: col-drift linear both; animation-timeline: --gallery; animation-range: cover; }
    @keyframes col-drift { from { translate: 0 70px; } to { translate: 0 -70px; } }

    /* A PASSION FOR SPORT: Fenster öffnet sich, Zeilen gleiten gegenläufig, Hintergrund-Parallax */
    .passion { view-timeline: --passion block; animation: window-open linear both; animation-timeline: --passion; animation-range: entry 0% entry 100%; }
    .passion__bg { animation: bg-drift linear both; animation-timeline: --passion; animation-range: cover; }
    .passion__line { display: block; animation: line-left linear both; animation-timeline: --passion; animation-range: entry 40% cover 55%; }
    .passion__line + .passion__line { animation-name: line-right; }
    @keyframes window-open { from { clip-path: inset(10% 7% round 28px); } to { clip-path: inset(0 round 0); } }
    @keyframes bg-drift { from { translate: 0 -66px; } to { translate: 0 66px; } }
    @keyframes line-left { from { translate: -35% 0; opacity: 0; } to { translate: 0 0; opacity: 1; } }
    @keyframes line-right { from { translate: 35% 0; opacity: 0; } to { translate: 0 0; opacity: 1; } }

    /* Panels: graue Hälfte fährt ein, Überschrift wird aufgedeckt */
    .panel { position: relative; isolation: isolate; background: #fff; view-timeline: --panel block; }
    .panel::before { content: ''; position: absolute; z-index: -1; top: 0; bottom: 0; left: 50%; right: 0; background: var(--c-panel); transform-origin: 100% 50%; animation: panel-in linear both; animation-timeline: --panel; animation-range: entry 0% cover 35%; }
    .panel__title { animation: title-in linear both; animation-timeline: view(); animation-range: entry 10% entry 100%; }
    @keyframes panel-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }
    @keyframes title-in { from { clip-path: inset(0 0 100% 0); translate: 0 30px; } to { clip-path: inset(0 0 -20% 0); translate: 0 0; } }

    /* Instagram-Kacheln gestaffelt */
    .insta__item { animation: tile-in linear both; animation-timeline: view(); }
    .insta__item:nth-child(4n+1) { animation-range: entry 0% entry 70%; }
    .insta__item:nth-child(4n+2) { animation-range: entry 8% entry 78%; }
    .insta__item:nth-child(4n+3) { animation-range: entry 16% entry 86%; }
    .insta__item:nth-child(4n+4) { animation-range: entry 24% entry 94%; }
    @keyframes tile-in { from { opacity: 0; translate: 0 50px; scale: .92; } to { opacity: 1; translate: 0 0; scale: 1; } }

    /* Beitragsbilder, About-Porträt, Footer-Linien */
    .post-content picture, .about__media > picture { animation: wipe-down linear both; animation-timeline: view(); animation-range: entry 0% entry 60%; }
    .post-content picture img, .about__media > picture img { animation: img-settle linear both; animation-timeline: view(); animation-range: entry 0% cover 50%; }
    .footer-lines { transform-origin: 50% 0; animation: line-grow linear both; animation-timeline: view(); animation-range: entry 0% entry 100%; }
    .footer-brand, .socials--footer, .footer-copy { animation: rise-in linear both; animation-timeline: view(); animation-range: entry 0% entry 100%; }
    @keyframes line-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

    /* Unterseiten-Foto: sanfte Parallax beim Wegscrollen */
    .ctitle { view-timeline: --ctitle block; }
    .ctitle__photo picture { display: block; animation: photo-drift linear both; animation-timeline: --ctitle; animation-range: exit 0% exit 100%; }
    @keyframes photo-drift { to { translate: 0 18%; } }
  }
}
