/* ============================================================
   KRAUTH+WERNET — global.css (Produktionsdatei)
   Fonts + shared styles across all pages: design tokens, reset, page frame,
   header, contact button, highlight button, lazy load animations,
   exit transitions, custom cursor, menu, footer, and mobile overrides.
   
   Spacing principle: all fixed desktop content containers use
   bottom: min(160px, 15vh) — scales proportionally on short
   viewports (e.g. 13" laptops). Mobile breakpoints untouched.
   ============================================================ */


/* ---------- FONTS ---------- */
@font-face {
  font-family: "PP Formula";
  font-style: normal;
  font-weight: 500;
  font-display: block;
  src: url("../fonts/pp-formula-500.woff") format("woff");
}
@font-face {
  font-family: "PP Formula Extended";
  font-style: normal;
  font-weight: 900;
  font-display: block;
  src: url("../fonts/pp-formula-extended-900.woff") format("woff");
}
@font-face {
  font-family: "TRJN DaVinci";
  font-style: normal;
  font-weight: 300;
  font-display: block;
  src: url("../fonts/trjn-davinci-300.woff") format("woff");
}

:root {
  --bg:     #DFE1E3;
  --ink:    #404040;
  --accent: #FF4E00;

  --font-body:    "PP Formula", system-ui, sans-serif;
  --font-display: "PP Formula Extended", system-ui, sans-serif;
  --font-head:    "TRJN DaVinci", Georgia, serif;

  /* Desktop grid */
  --margin-x: 16px;
  --gutter:   12px;
}

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background-color: var(--bg); }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
  font-synthesis: none;
  min-height: 100svh;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }

/* ---------- PAGE FRAME ---------- */
.page {
  /* Positionierter Vorfahre für absolute Kinder (Intro, Gallery, Hero).
     Kein Padding mehr: Header/Menu/Footer sind fixed am Viewport mit eigenem
     left/right; Seiten-Inhalt (z.B. Photo-Gallery) definiert seine
     horizontale Einrückung selbst. */
  position: relative;
  min-height: 100svh;
}

/* ---------- HEADER ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 18px;
  /* Fixed am Viewport: Logo + Contact-Button scrollen nie weg */
  position: fixed;
  top: 0;
  left: var(--margin-x);
  right: var(--margin-x);
  z-index: 10;
}
.logo {
  display: block;
  width: 50px;
  height: auto;
  color: var(--ink);
}
.logo svg { display: block; width: 100%; height: auto; fill: currentColor; }

.contact-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  height: 21px;
  padding-top: 2px;
  padding-right: 4px;
  padding-bottom: 0;
  padding-left: 4px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 12px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--accent);
  background: transparent;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: none;
  margin-left: 0;
  transition: background-color 1.6s cubic-bezier(0.16, 1, 0.3, 1),
              color 1.6s cubic-bezier(0.16, 1, 0.3, 1),
              padding-right .7s cubic-bezier(0.22, 1, 0.36, 1),
              margin-left .7s cubic-bezier(0.22, 1, 0.36, 1);
}
/* inner circle that represents the "swallowed" cursor */
.contact-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 4px;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: var(--bg);
  transform: translate(0, calc(-50% - 1px));
  transition: width .6s cubic-bezier(0.16, 1, 0.3, 1),
              height .6s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.contact-btn:hover {
  background: var(--accent);
  color: var(--bg);
  padding-right: 20px;
  margin-left: -16px;
  transition: background-color .6s cubic-bezier(0.22, 1, 0.36, 1),
              color .6s cubic-bezier(0.22, 1, 0.36, 1),
              padding-right .7s cubic-bezier(0.22, 1, 0.36, 1),
              margin-left .7s cubic-bezier(0.22, 1, 0.36, 1);
}
.contact-btn:hover::after {
  width: 13px;
  height: 13px;
  transition: width .7s cubic-bezier(0.22, 1, 0.36, 1),
              height .7s cubic-bezier(0.22, 1, 0.36, 1);
  animation: btn-circle-pulse .9s ease-in-out infinite;
  animation-delay: .7s;
}
@keyframes btn-circle-pulse {
  0%, 100% { transform: translate(0, calc(-50% - 1px)) scale(1); }
  50%      { transform: translate(0, calc(-50% - 1px)) scale(0.85); }
}

/* ---------- LAZY LOAD ---------- */
/* Overlay elements: fade-in only */
.logo,
.site-footer {
  opacity: 1;
  transition: opacity 1.1s ease-out .15s;
}
.contact-btn {
  opacity: 1;
  transition: background-color 1.2s cubic-bezier(0.16, 1, 0.3, 1),
              color 1.2s cubic-bezier(0.16, 1, 0.3, 1),
              padding-right .55s cubic-bezier(0.22, 1, 0.36, 1),
              margin-left .55s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 1.1s ease-out .15s;
}
.is-loading .logo,
.is-loading .contact-btn,
.is-loading .site-footer {
  opacity: 0;
  transition: none;
}

/* Menu items: each li fades in (opacity), the inner a slides in (transform).
   Stagger via per-item delay, only applied during fade-in. */
.menu li {
  opacity: 1;
  transition: opacity .55s cubic-bezier(0.22, 1, 0.36, 1);
}
.is-loading .menu li {
  opacity: 0;
  transition: none;
}
/* Stagger delays only during initial load */
body:not(.is-loaded) .menu li:nth-child(1),
body:not(.is-loaded) .menu li:nth-child(1) .item { transition-delay: .75s; }
body:not(.is-loaded) .menu li:nth-child(2),
body:not(.is-loaded) .menu li:nth-child(2) .item { transition-delay: .83s; }
body:not(.is-loaded) .menu li:nth-child(3),
body:not(.is-loaded) .menu li:nth-child(3) .item { transition-delay: .91s; }
body:not(.is-loaded) .menu li:nth-child(4),
body:not(.is-loaded) .menu li:nth-child(4) .item { transition-delay: .99s; }

/* The slide-in uses an inner wrapper so it doesn't conflict with hover transform */
.menu .item {
  display: inline-block;
  transform: translateX(0);
  transition: transform 1.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.is-loading .menu .item {
  transform: translateX(8px);
  transition: none;
}

/* ---------- EXIT TRANSITION ---------- */
/* Reverse of entry at ~60% speed.
   Order: 1) Content, 2) Menu (reverse stagger), 3) Overlay.
   JS adds .is-exiting to body, waits EXIT_DURATION, then navigates. */

/* Block all interaction during exit */
body.is-exiting { pointer-events: none; }

/* Phase 1: Page content — fades immediately.
   Targets every direct child of .page that isn't chrome (header/menu/footer).
   Works generically across all pages. */
body.is-exiting .page > *:not(.site-header):not(.menu):not(.site-footer) {
  opacity: 0;
  transition: opacity .4s cubic-bezier(0.4, 0, 0.6, 1);
  pointer-events: none;
}

/* Phase 2: Menu — reverse stagger (last item first) */
body.is-exiting .menu li {
  opacity: 0;
  transition: opacity .33s cubic-bezier(0.4, 0, 0.6, 1);
}
body.is-exiting .menu li:nth-child(4) { transition-delay: .25s; }
body.is-exiting .menu li:nth-child(3) { transition-delay: .30s; }
body.is-exiting .menu li:nth-child(2) { transition-delay: .35s; }
body.is-exiting .menu li:nth-child(1) { transition-delay: .40s; }

body.is-exiting .menu .item {
  transform: translateX(8px);
  transition: transform .5s cubic-bezier(0.4, 0, 0.6, 1);
}
body.is-exiting .menu li:nth-child(4) .item { transition-delay: .25s; }
body.is-exiting .menu li:nth-child(3) .item { transition-delay: .30s; }
body.is-exiting .menu li:nth-child(2) .item { transition-delay: .35s; }
body.is-exiting .menu li:nth-child(1) .item { transition-delay: .40s; }

/* Current-marker dot: hide immediately */
body.is-exiting .menu li.is-current .item::after {
  opacity: 0;
  transition: opacity .15s ease;
}

/* Phase 3: Overlay — logo, contact button, footer exit last */
body.is-exiting .logo {
  opacity: 0;
  transition: opacity .4s cubic-bezier(0.4, 0, 0.6, 1) .5s;
}
body.is-exiting .contact-btn {
  opacity: 0;
  transition: opacity .4s cubic-bezier(0.4, 0, 0.6, 1) .5s;
}
body.is-exiting .site-footer {
  opacity: 0;
  transition: opacity .4s cubic-bezier(0.4, 0, 0.6, 1) .5s;
}

/* Cursor: fade instantly */
body.is-exiting .cursor {
  opacity: 0 !important;
  transition: opacity .15s ease !important;
}

/* ---------- CUSTOM CURSOR ---------- */
@media (hover: hover) and (pointer: fine) {
  html, body { cursor: none; }
  a, button, .contact-btn, [role="button"] { cursor: none; }

  .cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    transform: translate3d(-50%, -50%, 0);
    transition: width .3s cubic-bezier(0.22, 1, 0.36, 1),
                height .3s cubic-bezier(0.22, 1, 0.36, 1),
                opacity .9s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
  }
  .cursor.is-ready { opacity: 1; }
  .cursor.is-inside-btn {
    opacity: 0;
    transition: width .3s cubic-bezier(0.22, 1, 0.36, 1),
                height .3s cubic-bezier(0.22, 1, 0.36, 1),
                opacity .2s ease;
  }
  .cursor.is-hover {
    /* Intro: Cursor wächst von 8 (default) auf 22 (Atem-Maximum).
       Danach setzt die Puls-Loop nahtlos auf 22 ein und atmet 22 → 17 → 22.
       Kein Stop, kein Tempowechsel — die Loop beginnt an ihrem natürlichen
       Umkehrpunkt. */
    animation:
      cursor-hover-intro .3s ease-in-out forwards,
      cursor-pulse 1.2s ease-in-out .3s infinite;
  }
  @keyframes cursor-hover-intro {
    from { width: 8px;  height: 8px;  }
    to   { width: 22px; height: 22px; }
  }
  @keyframes cursor-pulse {
    0%, 100% { width: 22px; height: 22px; }
    50%      { width: 17px; height: 17px; }
  }

  /* Title-Pill: cursor morphs from circle, expanding symmetrically from center.
     translate(-50%, -50%) on .cursor ensures growth radiates outward from center. */
  .cursor.is-title {
    width: auto;
    height: 21px;
    border-radius: 999px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 4px 0 5px;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 12px;
    line-height: 21px;
    letter-spacing: -0.02em;
    color: var(--bg);
    white-space: nowrap;
    overflow: hidden;
    max-width: 8px;
    animation: cursor-pill-expand .7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }
  @keyframes cursor-pill-expand {
    0% {
      max-width: 8px;
      height: 8px;
      padding: 0;
    }
    35% {
      height: 21px;
      padding: 0 4px 0 5px;
      max-width: 21px;
    }
    100% {
      max-width: 400px;
      height: 21px;
      padding: 0 4px 0 5px;
    }
  }
  .cursor-label {
    white-space: nowrap;
    margin-right: 3px;
    opacity: 0;
    animation: pill-content-in .3s ease .4s forwards;
  }
  .cursor-dot {
    flex-shrink: 0;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--bg);
    margin-top: -1px;
    opacity: 0;
    animation: pill-content-in .3s ease .45s forwards,
               cursor-dot-pulse .9s ease-in-out 1s infinite;
  }
  @keyframes pill-content-in {
    0%   { opacity: 0; }
    100% { opacity: 1; }
  }
  @keyframes cursor-dot-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(0.85); }
  }

  /* Title-Pill EXIT: reversed collapse back to circle */
  .cursor.is-title-out {
    width: auto;
    height: 21px;
    border-radius: 999px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 4px 0 5px;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 12px;
    line-height: 21px;
    letter-spacing: -0.02em;
    color: var(--bg);
    white-space: nowrap;
    overflow: hidden;
    animation: cursor-pill-collapse .45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }
  .cursor.is-title-out .cursor-label,
  .cursor.is-title-out .cursor-dot {
    animation: none;
    opacity: 0;
    transition: opacity .1s ease;
  }
  @keyframes cursor-pill-collapse {
    0% {
      max-width: 400px;
      height: 21px;
      padding: 0 4px 0 5px;
    }
    65% {
      max-width: 21px;
      height: 21px;
      padding: 0 4px 0 5px;
    }
    100% {
      max-width: 8px;
      height: 8px;
      padding: 0;
    }
  }
}

/* ---------- MENU ---------- */
.menu {
  /* Fixed am Viewport: scrollt nie weg */
  position: fixed;
  top: 127px;
  left: var(--margin-x);
  z-index: 10;
  font-family: "PP Formula Extended", system-ui, sans-serif;
  font-weight: 900;
  font-style: normal;
  font-size: 22px;
  line-height: 21px;
  letter-spacing: -0.04em;
  font-feature-settings: normal;
  font-variant-ligatures: none;
}
.menu li { margin: 0; }
.menu a {
  display: inline-block;
  padding-right: 20px;
  margin-right: -20px;
}
.menu .item {
  position: relative;
}
.menu .item::after {
  content: "";
  position: absolute;
  top: calc(50% - 2px);
  left: calc(100% + 4px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transform: translateY(-50%) scale(0.6);
  transition: opacity .35s cubic-bezier(0.22, 1, 0.36, 1),
              transform .35s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  /* Subpixel-Rundung vermeiden: ans GPU-Layer delegieren */
  will-change: transform;
  backface-visibility: hidden;
}
.menu a:hover .item::after,
.menu li.is-current .item::after {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}
/* Current-marker only appears after the full menu has finished loading */
body:not(.is-loaded) .menu li.is-current .item::after {
  transition: opacity .45s cubic-bezier(0.22, 1, 0.36, 1) 1.9s,
              transform .45s cubic-bezier(0.22, 1, 0.36, 1) 1.9s;
}
.is-loading .menu li.is-current .item::after {
  opacity: 0;
  transform: translateY(-50%) scale(0.6);
}
/* While hovering anywhere in the menu, hide the current-marker to avoid duplicates */
.menu:hover li.is-current .item::after {
  opacity: 0;
  transform: translateY(-50%) scale(0.6);
}
/* But re-show it if the current item itself is being hovered */
.menu li.is-current a:hover .item::after {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}
.menu a:hover .item {
  transform: translateX(8px);
  transition: transform .6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- FOOTER ---------- */
.site-footer {
  /* Fixed am Viewport: scrollt nie weg */
  position: fixed;
  left: var(--margin-x);
  right: var(--margin-x);
  bottom: 16px;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr var(--gutter) 1fr var(--gutter) 1fr;
  align-items: end;
  font-size: 12px;
  line-height: 15px;
  font-weight: 500;
  pointer-events: none;
}
.site-footer a,
.site-footer .copy { pointer-events: auto; }
.footer-cluster { grid-row: 1; }
.footer-cluster--1 { grid-column: 1; }
.footer-cluster--2 { grid-column: 3; }
.footer-cluster--3 {
  grid-column: 5;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}
.footer-cluster a { display: block; }
.footer-line { display: block; }
.footer-line {
  font-size: 12px;
  line-height: 15px;
}
.footer-cluster--3 .copy { white-space: nowrap; }

/* Highlight button — same architecture as contact-btn,
   but filled with accent color by default */
.btn--highlight {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  height: 21px;
  padding-top: 3px;
  padding-right: 4px;
  padding-bottom: 0;
  padding-left: 4px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 12px;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: var(--bg);
  background: var(--accent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: none;
  transition: padding-left .7s cubic-bezier(0.22, 1, 0.36, 1),
              background-color 1.6s cubic-bezier(0.16, 1, 0.3, 1),
              color 1.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Circle: hidden by default, appears on hover at LEFT (mirrored from contact-btn) */
.btn--highlight::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 4px;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: var(--bg);
  transform: translate(0, -50%);
  transition: width .6s cubic-bezier(0.16, 1, 0.3, 1),
              height .6s cubic-bezier(0.16, 1, 0.3, 1),
              background-color .6s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.btn--highlight:hover {
  padding-left: 20px;
  background: transparent;
  color: var(--accent);
  transition: padding-left .7s cubic-bezier(0.22, 1, 0.36, 1),
              background-color .6s cubic-bezier(0.22, 1, 0.36, 1),
              color .6s cubic-bezier(0.22, 1, 0.36, 1);
}

.btn--highlight:hover::after {
  background: var(--accent);
  width: 13px;
  height: 13px;
  transition: width .7s cubic-bezier(0.22, 1, 0.36, 1),
              height .7s cubic-bezier(0.22, 1, 0.36, 1);
  animation: btn-highlight-pulse .9s ease-in-out infinite;
  animation-delay: .7s;
}
@keyframes btn-highlight-pulse {
  0%, 100% { transform: translate(0, -50%) scale(1); }
  50%      { transform: translate(0, -50%) scale(0.85); }
}

/* ---------- MOBILE — shared layout overrides ---------- */
@media (max-width: 768px) {
  :root {
    --margin-x: 12px;
    --gutter:   12px;
  }
  .menu {
    top: auto;
    bottom: 14px;
    left: var(--margin-x);
    z-index: 100;
  }
  .site-footer {
    grid-template-columns: 1fr;
    bottom: 14px;
    z-index: 99;  /* Unter dem Menü */
  }
  .footer-cluster--1,
  .footer-cluster--2 { display: none; }
  .footer-cluster--3 {
    grid-column: 1;
    display: block;
    text-align: right;
    margin-left: 50%;
  }
  .footer-cluster--3 .copy {
    display: block;
    text-align: right;
    white-space: nowrap;
  }
}
