/* ===========================================
   CRITICAL PERFORMANCE OPTIMIZATIONS
   =========================================== */

/* CSS Custom Properties für bessere Performance */
:root {
  /* Häufig verwendete Werte zwischenspeichern */
  --transition-fast: 0.15s;
  --transition-medium: 0.3s;
  --transition-slow: 0.6s;
  --easing-smooth: cubic-bezier(0.25, 1, 0.5, 1);
  --easing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  
  /* Z-Index Management */
  --z-header: 100;
  --z-overlay: 200;
  --z-modal: 300;
  
  /* Performance Colors (vermeidet Repaint) */
  --color-primary: #333;
  --color-secondary: #7c7c7c;
  --color-white: #ffffff;
  --color-transparent: transparent;
}

/* Critical rendering optimization */
* {
  box-sizing: border-box;
}

*,
*::before,
*::after {
  /* GPU-Beschleunigung für alle Animationen */
  will-change: auto;
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Font loading optimization */
html {
  font-display: swap; /* Verhindert FOIT (Flash of Invisible Text) */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Critical layout styles */
html,
body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  /* Prevent layout shifts */
  min-height: 100vh;
  position: relative;
}

/* Mobile: Verhindere vertikales Scrolling */
@media screen and (max-width: 768px) {
  html,
  body {
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
  }
}

/* Header-Nav - Performance optimiert */
header {
  position: fixed;
  top: 0;
  left: 0;
  height: var(--full-h);
  width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  background-color: rgba(255, 255, 255, 0.8);
  transition: background-color var(--transition-medium) ease;
  /* GPU-Beschleunigung */
  will-change: background-color;
  transform: translateZ(0);
  z-index: var(--z-header);
}

header li {
  position: relative;
  text-decoration: none;
  color: var(--color-secondary);
  font-weight: bold;
  margin: 25px 15px;
  width: 50px;
  height: 50px;
  /* Optimierte Transitions */
  transition: 
    color var(--transition-medium) ease,
    transform var(--transition-medium) ease,
    width 0.4s var(--easing-smooth),
    height 0.4s var(--easing-smooth),
    margin 0.4s var(--easing-smooth);
  /* Performance */
  will-change: transform, width, height, margin;
  contain: layout style;
}
  
  .header-center {
    margin-top: var(--quarter-h);
    justify-content: flex-start;
    width: 100%;
    display: block;
}


header nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin: 0;
  padding: 0;
}


header li img {
  object-fit: cover;
  cursor: pointer;
  width: 100%;
  height: 100%;
  transition: opacity var(--transition-medium) ease, transform var(--transition-medium) ease;
  /* Performance optimiert */
  will-change: opacity, transform;
  transform: translateZ(0);
}

/* Hover-Optimierung - nur für Desktop */
@media (hover: hover) and (pointer: fine) {
  header li:hover {
    margin: 15px 5px;
    width: 70px;
    height: 70px;
  }
}

/* Active state optimiert */
header li.active {
  margin: 15px 5px;
  width: 70px;
  height: 70px;
}

header li.active img {
  opacity: 1;
  transform: scale(1.05) translateZ(0);
}

/* Entferne veraltete Performance-Styles */

/* Body - Performance optimiert */
body {
  font-family: 'Noto Sans JP', sans-serif;
  margin: 0;
  padding: 0;
  color: var(--color-primary);
  max-width: 100vw;
  min-height: 100vh;
  position: relative;
  /* Critical performance optimizations */
  will-change: scroll-position;
  transform: translateZ(0);
  contain: layout style paint;
}

  /* Main-Container */
  main {
    margin-left: 100px;
    /* Entspricht der Header-Breite */
    padding: 20px;
    width: calc(100% - 100px);
    min-height: 100vh;
    position: relative;
    /* Über dem Hintergrund */
  }

  main h2 {
    border-bottom: 2px solid #333;
    padding-bottom: 10px;
    margin-bottom: 20px;
  }

  /* Karte */
  section.map iframe {
    width: 100%;
    height: 400px;
    border: 0;
    border-radius: 4px;
  }

  /* Öffnungszeiten & Kontakt */
  section.hours,
  section.contact {
    margin-top: 30px;
  }

  section.hours h3,
  section.contact h3 {
    font-size: 18px;
    margin-bottom: 10px;
  }

  section.hours ul,
  section.contact ul {
    list-style: none;
    padding: 0;
  }

  section.hours li,
  section.contact li {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
  }

  /* Footer */
  footer {
    text-align: center;
    padding: 20px;
    color: #777;
    border-top: 1px solid #ddd;
    background: #fff;
    margin-top: 40px;
  }

  /* Responsive Design für mobile Geräte */
  @media screen and (max-width: 768px) {
    main {
      margin-left: 0;
      width: 100%;
      height: auto;
      background-color: #333;
    }
    header{
      display: none;
    }
    @keyframes fadeInUp {
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }
  }

  .bg-container {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--full-w);
    height: 100%;
    display: flex;
    overflow: hidden;
  }

  /* Mobile bg-container - verhindert Scrolling */
  @media screen and (max-width: 768px) {
    .bg-container {
      height: 100vh;
      max-height: 100vh;
      overflow: hidden;
    }
  }

  .bg-image.desktop {
    position: relative;
    max-width: var(--half-w);
    height: var(--full-h);
    background-size: cover;
    background-position: center;
    opacity: 0.8;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    transition: opacity var(--transition-medium) ease, flex 0.5s var(--easing-smooth);
    flex: 1;
    overflow: hidden;
    /* Kritische Performance-Optimierungen */
    will-change: opacity, flex;
    backface-visibility: hidden;
    transform: translateZ(0);
    contain: layout style paint;
    /* Image rendering optimization */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }

  /* Lazy loading optimization - NUR für nicht geladene Bilder */
  .bg-image.desktop:not(.loaded) {
    background-color: #f0f0f0;
    /* Skeleton loading effect */
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
  }

  @keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }

  /* Erstes Bild - immer sofort sichtbar */
  .bg-image.desktop:nth-child(1) {
    background-image: url('/static/media/IwasashoutenAboutUs.png');
    background-position: left center;
  }

  /* Zweites und drittes Bild - werden per JS geladen */
  .bg-image.desktop:nth-child(2) {
    background-position: center center;
  }

  .bg-image.desktop:nth-child(3) {
    background-position: right center;
  }

  /* Überschreibt das Skeleton für bereits geladene Bilder */
  .bg-image.desktop.loaded {
    animation: none;
    /* Skeleton-Gradient entfernen, aber background-image beibehalten */
    background-color: transparent;
  }

  /* Content-Bereich Container außerhalb der Bilder */
  .content-container {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--full-w);
    height: var(--full-h);
    box-sizing: border-box;
    overflow: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  /* Individuelle Content-Bereiche - standardmäßig versteckt */
  .content-overlay {
    height: var(--full-h);
    display: none;
    transition: opacity 0.3s ease;
    padding: var(--space-xxl);
    padding-top: var(--space-viewport-quarter);
    overflow: hidden;
  }

  /* Spezielles padding-top für die ersten beiden Content-Overlays */
  .content-overlay:nth-child(2),
  .content-overlay:nth-child(3) {
    padding-top: var(--space-xl);
  }

  .content-overlay h2 {
    position: relative;
    text-align: center;
    transition: opacity 0.3s ease;
    padding-bottom: var(--space-xs);
    /* Platz für die Unterstreichung */
    display: inline-block;
    margin-bottom: var(--space-md);
  }


  .content-overlay:nth-child(1) {
    position: absolute;
    width: var(--half-w);
    left:   var(--half-w);
  }

  .content-overlay:nth-child(2) {
    position: absolute;
    width: var(--quarter-w);
    left: 0;
  }

  .content-overlay:nth-child(3) {
    position: absolute;
    width: var(--quarter-w);
    left: calc(var(--three-quarter-w) - 100px);
  }

  .content-overlay:nth-child(4) {
    position: absolute;
    width: var(--half-w);
    left: 0;
  }

  /* Hover-Effekt für den Kontaktformular-Button */
  .contact a {
    text-decoration: none;
    color: black;
    background-color: white;
    padding: var(--space-sm) var(--space-lg);
    border-radius: 4px;
    display: inline-block;
    border: 2px solid black;
    transition: all 0.3s ease;
  }

  .contact a:hover {
    color: white;
    background-color: black;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
  }



  /* ===========================================
     MOBILE OPTIMIZATIONS
     =========================================== */
  @media screen and (max-width: 768px) {
    
    /* Mobile container - optimiert für --full-h ohne Scrolling */
    .bg-image.mobile {
      width: var(--full-w);
      max-width: var(--full-w);
      height: var(--full-h);
      max-height: var(--full-h);
      overflow: hidden; /* Verhindert Scrolling */
      background-color: var(--color-white);
      position: relative;
      display: flex;
      justify-content: center;
      align-items: flex-start;
      flex-direction: column;
      padding: var(--space-xs) var(--space-md);
      box-sizing: border-box;
      /* Mobile performance */
      will-change: auto;
      contain: layout style paint;
      transform: translateZ(0);
    }

    /* Mobile Content Container - exakte Höhe ohne Scroll */
    .bg-image.mobile .mobile-content {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: flex-start;
      width: 100%;
      max-width: 600px;
      height: calc(var(--full-h) - var(--space-xs) * 2);
      max-height: calc(var(--full-h) - var(--space-xs) * 2);
      gap: clamp(var(--space-xs), 2vh, var(--space-sm)); /* Kleinere Gaps */
      position: relative;
      overflow: hidden; /* Verhindert Scrolling */
    }

    /* Logo Container */
    .bg-image.mobile .logo-container {
      flex: 0 0 auto;
      width: clamp(200px, 50vw, 400px);
      height: clamp(200px, 50vw, 400px);
      background-image: url('/static/media/iwasashoutenLogo3D.webp');
      background-size: contain;
      background-repeat: no-repeat;
      background-position: center;
      /* Fade-in Animation */
      opacity: 0;
      animation: fadeInUp 0.8s ease-out forwards;
      animation-delay: 0.2s;
    }

    /* Introduction Text Container */
    .storename, .introduction-text {
      font-size: clamp(var(--font-size-md), 4vw, var(--font-size-lg));
      font-weight: bold;
      color: rgb(0, 0, 0);
      text-align: center;
      margin: 0;
      flex: 0 0 auto;
      width: 100%;
      max-width: 100%;
      padding: 0 var(--space-sm);
      line-height: 1.4;
      order: 2; /* Nach dem Logo */
      /* Fade-in Animation */
      opacity: 0;
      animation: fadeInUp 0.8s ease-out forwards;
      animation-delay: 0.6s;
    }

    .bg-image.mobile p{
      font-weight: bold;
    }

    /* Contact Info Container */
    .bg-image.mobile .contact-info {
      flex: 0 0 auto;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: clamp(var(--space-xs), 2vh, var(--space-sm));
      order: 3; /* Nach dem Typing Text */
      width: 100%;
      margin-top: var(--space-xs);
      margin-bottom: var(--space-xs);
      /* Fade-in Animation */
      opacity: 0;
      animation: fadeInUp 0.8s ease-out forwards;
      animation-delay: 1.4s;
    }

    /* Contact Info Styling */
    .bg-image.mobile .phone,
    .bg-image.mobile .email {
      position: relative;
      text-align: center;
      font-size: clamp(var(--font-size-sm), 3.5vw, var(--font-size-md));
      font-weight: bold;
      color: #333;
      text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
      width: 100%;
      max-width: 100%;
      margin: var(--space-sm) 0; /* Entferne alle margins */
    }

    .bg-image.mobile .phone {
      /* font-family: 'Courier New', monospace; */
      letter-spacing: 1px;
    }

    .bg-image.mobile .email {
      /* font-family: 'Courier New', monospace; */
      letter-spacing: 0px; /* Kein letter-spacing für den initialen Text */
      white-space: nowrap; /* Verhindert Zeilenumbruch */
      overflow: hidden; /* Verhindert Überlauf */
      text-overflow: ellipsis; /* Zeigt ... bei Überlauf */
      min-width: 0; /* Erlaubt Schrumpfung */
    }
    
    /* Spezifisches Styling für die finale E-Mail */
    .bg-image.mobile .email.final {
      letter-spacing: 0.5px; /* Letter-spacing nur für die finale E-Mail */
      white-space: nowrap; /* Verhindert Zeilenumbruch auch bei der finalen E-Mail */
    }

    /* Social Icons Container */
    .bg-image.mobile .social-icons {
      flex: 0 0 auto;
      display: flex;
      gap: clamp(var(--space-sm), 3vw, var(--space-md));
      align-items: center;
      justify-content: center;
      order: 4; /* Nach den Kontaktinfos */
      /* margin-top: clamp(var(--space-xs), 2vh, var(--space-sm)); */
      width: 100%;
      text-align: center;
      /* Fade-in Animation */
      opacity: 0;
      animation: fadeInUp 0.8s ease-out forwards;
      animation-delay: 1.8s;
    }

    .bg-image.mobile .icon-link {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 8px;
      text-decoration: none;
    }

    .bg-image.mobile .social-icon {
      width: 32px;
      height: 32px;
      object-fit: contain;
    }

    /* Links in Contact Info behalten Stil */
    .bg-image.mobile .phone a,
    .bg-image.mobile .email a {
      text-decoration: none;
      color: inherit;
      display: block;
      width: 100%;
      height: 100%;
    }

    .content-container{
      display: none;
    }

  }

  /* Responsive Breakpoints für verschiedene mobile Größen */
  
  /* Sehr kleine Bildschirme (< 400px) */
  @media screen and (max-width: 400px) {
    .bg-image.mobile .mobile-content {
      gap: clamp(var(--space-xs), 2vh, var(--space-sm));
      padding: var(--space-xs);
    }
    
    .bg-image.mobile .logo-container {
      width: clamp(150px, 60vw, 250px);
      height: clamp(100px, 45vw, 200px);
    }
    
    .storename, .introduction-text {
      font-size: clamp(14px, 4.5vw, 18px);
      padding: 0 var(--space-xs);
    }
    
    .bg-image.mobile .phone,
    .bg-image.mobile .email {
      font-size: clamp(12px, 4vw, 16px);
    }
    
    .bg-image.mobile .social-icons {
      gap: var(--space-sm);
    }
    
    .bg-image.mobile .social-icon {
      width: 28px;
      height: 28px;
    }
  }

  /* Große mobile Bildschirme und Tablets (> 600px aber < 768px) */
  @media screen and (min-width: 600px) and (max-width: 768px) {
    .bg-image.mobile .mobile-content {
      max-width: 700px;
      gap: clamp(var(--space-md), 5vh, var(--space-xl));
    }
    
    .bg-image.mobile .logo-container {
      width: clamp(300px, 45vw, 500px);
      height: clamp(200px, 35vw, 400px);
    }
    
    .storename, .introduction-text {
      font-size: clamp(var(--font-size-md), 3vw, var(--font-size-xl));
      max-width: 90%;
    }
    
    .bg-image.mobile .social-icons {
      gap: var(--space-lg);
    }
    
    .bg-image.mobile .social-icon {
      width: 40px;
      height: 40px;
    }
  }

  /* Landscape Orientierung bei mobilen Geräten */
  @media screen and (max-width: 768px) and (orientation: landscape) and (max-height: 500px) {
    .bg-image.mobile {
      min-height: 100vh;
      padding: var(--space-xs) var(--space-md);
    }
    
    .bg-image.mobile .mobile-content {
      flex-direction: row;
      flex-wrap: wrap;
      justify-content: space-around;
      align-items: center;
      gap: var(--space-md);
      min-height: calc(100vh - var(--space-xs) * 2);
    }
    
    .bg-image.mobile .logo-container {
      flex: 0 0 auto;
      width: clamp(150px, 30vw, 250px);
      height: clamp(100px, 25vh, 200px);
      order: 1;
    }
    
    .storename, .introduction-text {
      flex: 1 1 auto;
      order: 2;
      min-width: 200px;
      font-size: clamp(14px, 3vw, 18px);
    }
    
    .bg-image.mobile .contact-info {
      flex: 0 0 auto;
      order: 3;
      min-width: 150px;
    }
    
    .bg-image.mobile .social-icons {
      flex: 0 0 100%;
      order: 4;
    }
  }
  
  /* Business Hours Mobile Styling - Kompakt für no-scroll */
  .businesshours.mobile {
    margin-top: var(--space-xs);
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    order: 3;
    width: 100%;
    height: clamp(100px, 30vh, 250px);
    overflow: hidden;
    opacity: 0;
    animation: fadeInUp 0.8s ease-out forwards;
    animation-delay: 1.0s;
  }

  .businesshours.mobile h5,
  .businesshours.mobile p {
    margin: 0;
    font-size: var(--font-xs);
    font-weight: normal;
  }

  .businesshours.mobile h1 {
    margin: 0;
    font-size: clamp(var(--font-size-md), 4vw, var(--font-size-lg));
    font-weight: normal;
    text-align: center;
    color: #333;
  }

  /* Kompakte Table für business hours - verstärkter Shadow */
  .hours-table {
    width: 100%;
    max-width: 280px;
    border-collapse: collapse;
    font-size: var(--font-xs);
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 
      0 4px 12px rgba(0, 0, 0, 0.15),
      0 2px 6px rgba(0, 0, 0, 0.1),
      0 1px 3px rgba(0, 0, 0, 0.08);
  }

  .hours-table tr {
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
  }

  .hours-table tr:last-child {
    border-bottom: none;
  }

  .hours-table td {
    padding: 4px 6px;
    text-align: center;
    line-height: 1.1;
    font-size: var(--font-size-sm);
  }

  .hours-table .date {
    font-weight: normal;
    width: 25%;
  }

  .hours-table .weekday {
    font-weight: bold;
    width: 25%;
  }

  .hours-table .hours {
    font-weight: normal;
    width: 50%;
  }

  .hours-table .today {
    background-color: rgb(0, 0, 0, 0.1);
    font-weight: bold;
  }

  /* Desktop table styling */
  @media screen and (min-width: 769px) {
    .content-overlay .hours-table {
      max-width: 100%;
      font-size: var(--font-base);
    }
    
    .content-overlay .hours-table td {
      padding: 8px 12px;
      text-align: left;
    }
  }