/*
 * TirzeCalc.de – responsives, höhenstabiles Layout
 */

/* Reset */
* { box-sizing: border-box; }

/* Viewport-Setup */
html, body { height: 100%; }
html { height: 100dvh; }

/* Theme Vars */
:root {
  --background: url('hintergrund.jpg');
  --background-fallback: #2563eb;
  --text-primary: #ffffff;
  --text-secondary: #e2e8f0;
  --card-background: rgba(15, 23, 42, 0.85);
  --border-color: rgba(255, 255, 255, 0.2);
  --primary-color: #60a5fa;
  --shadow-color: rgba(0, 0, 0, 0.5);
  --pen-color-active: var(--primary-color);
}

/* Light Mode */
body.light-mode {
  --background: url('hintergrund.jpg');
  --background-fallback: #93c5fd;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --card-background: rgba(255, 255, 255, 0.95);
  --border-color: rgba(30, 41, 59, 0.2);
  --shadow-color: rgba(0, 0, 0, 0.2);
}

/* Seitenraster: Header / Main / Footer passt sich Bildschirmhöhe an */
body {
  margin: 0;
  background: var(--background-fallback);
  background-image: var(--background);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: 'Inter','Segoe UI',sans-serif;
  transition: background .4s, color .4s;

  display: grid;
  grid-template-rows: auto 1fr auto;  /* Header – Inhalt – Footer */
  min-height: 100dvh;
}

/* Auf mobilen Geräten: Footer direkt unter dem Inhalt ohne Zwischenraum */
@media (max-width: 768px) {
  body {
    grid-template-rows: auto 1fr auto; /* Header bleibt sichtbar, Inhalt scrollbar, Footer unten */
  }
  
  .container {
    padding-bottom: 0; /* Entfernt unteren Padding des Containers */
  }
  
  footer {
    margin-top: 0; /* Entfernt oberen Margin des Footers */
    padding-top: 8px; /* Reduziert oberes Padding */
  }
}

/* Main Header */
.main-header {
  width: 100%;
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}

/* Light Mode Header */
body.light-mode .main-header {
  background: rgba(255, 255, 255, 0.9);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  position: relative;
}

/* Hamburger Button (links) */
.hamburger-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color .2s;
}

.hamburger-btn:hover {
  background: rgba(88,142,153,.1);
}

.hamburger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  transition: all 0.3s ease;
}

/* Site Title (zentriert) */
.site-title {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.3em;
  padding: 6px 12px;
  border-radius: 6px;
  transition: color .2s, background-color .2s;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.site-title:hover {
  color: var(--primary-color);
  background: rgba(88,142,153,.1);
}

/* Header Icons (rechts) */
.header-icons {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Language Toggle */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 6px;
}

.lang-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color .2s, font-weight .2s;
  font-size: 0.85em;
  padding: 2px 4px;
  border-radius: 2px;
}

.lang-btn.active-lang {
  color: var(--text-primary);
  font-weight: 700;
  background: rgba(88,142,153,.2);
}

.lang-separator {
  color: var(--text-secondary);
  opacity: 0.5;
}

/* Mode Toggle */
.mode-toggle-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.switch {
  position: relative;
  width: 40px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: var(--border-color);
  transition: .4s;
}

.slider:before {
  content: "";
  position: absolute;
  left: 3px;
  bottom: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: .4s;
}

input:checked + .slider {
  background: var(--primary-color);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.mode-icon {
  color: var(--text-secondary);
  opacity: .8;
  transition: opacity .3s, color .3s;
}

.mode-icon:hover {
  opacity: 1;
}

body.dark-mode .dark-icon {
  color: var(--text-primary);
  opacity: 1;
}

body.dark-mode .light-icon {
  opacity: .4;
}

body.light-mode .light-icon {
  color: var(--text-primary);
  opacity: 1;
}

body.light-mode .dark-icon {
  opacity: .4;
}

/* Share Button */
.share-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text-secondary);
  border-radius: 4px;
  transition: color .2s, background-color .2s;
}

.share-btn:hover {
  color: var(--primary-color);
  background: rgba(88,142,153,.1);
}

.share-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* Hamburger Menu Overlay */
.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 2000; /* Höher als Header z-index */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none; /* Deaktiviert Klicks wenn nicht sichtbar */
}

.menu-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto; /* Aktiviert Klicks wenn sichtbar */
}

.menu-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 280px;
  height: 100%;
  background: var(--card-background);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  pointer-events: auto; /* Sicherstellt dass Menü-Inhalt klickbar ist */
}

.menu-overlay.active .menu-content {
  transform: translateX(0);
}

.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.menu-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1.1em;
}

.menu-close {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color .2s;
}

.menu-close:hover {
  background: rgba(88,142,153,.1);
}

.menu-nav {
  flex: 1;
  padding: 20px 0;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: var(--text-primary);
  text-decoration: none;
  transition: background-color .2s, color .2s;
  border-left: 3px solid transparent;
}

.menu-item:hover {
  background: rgba(88,142,153,.1);
  color: var(--primary-color);
  border-left-color: var(--primary-color);
}

/* Menu Settings */
.menu-settings {
  padding: 20px;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.menu-setting-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.menu-setting-group:last-child {
  margin-bottom: 0;
}

.menu-setting-label {
  color: var(--text-primary);
  font-size: 0.9em;
  font-weight: 500;
}

/* Language Toggle in Menu */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 6px;
}

.lang-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color .2s, font-weight .2s;
  font-size: 0.85em;
  padding: 2px 4px;
  border-radius: 2px;
}

.lang-btn.active-lang {
  color: var(--text-primary);
  font-weight: 700;
  background: rgba(88,142,153,.2);
}

.lang-separator {
  color: var(--text-secondary);
  opacity: 0.5;
}

/* Mode Toggle in Menu */
.mode-toggle-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.switch {
  position: relative;
  width: 40px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: var(--border-color);
  transition: .4s;
}

.slider:before {
  content: "";
  position: absolute;
  left: 3px;
  bottom: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: .4s;
}

input:checked + .slider {
  background: var(--primary-color);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.mode-icon {
  color: var(--text-secondary);
  opacity: .8;
  transition: opacity .3s, color .3s;
}

.mode-icon:hover {
  opacity: 1;
}

body.dark-mode .dark-icon {
  color: var(--text-primary);
  opacity: 1;
}

body.dark-mode .light-icon {
  opacity: .4;
}

body.light-mode .light-icon {
  color: var(--text-primary);
  opacity: 1;
}

body.light-mode .dark-icon {
  opacity: .4;
}

.menu-footer {
  padding: 20px;
  text-align: center;
}

.by-staubi {
  color: var(--text-secondary);
  font-size: 0.9em;
  font-weight: 500;
}

/* Hauptinhalt (Main) – zentriert, scrollt bei Platzmangel */
.container {
  width: min(100%, 700px);
  margin: 0 auto;
  padding: 10px;
  overflow: auto;              /* nur der Inhalt scrollt, Seite bleibt im Viewport */
}

header { text-align: center; margin-bottom: 20px; }
h1 { font-weight: 300; letter-spacing: 1px; margin: 0 0 8px; font-size: 1.8em; }
.description { font-size: .95em; color: var(--text-secondary); max-width: 450px; margin: 0 auto; }

/* Karten */
.card {
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 4px 8px var(--shadow-color);
}
h2 {
  font-size: 1.2em; font-weight: 600; margin: 0 0 15px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border-color);
}

/* Pen-Kacheln – stabil, ohne aspect-ratio (verhindert „rissig“) */
.pen-selection {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  align-items: stretch;   /* alle Zellen gleich hoch */
}

/* Auf größeren Bildschirmen: 3 Buttons pro Zeile für symmetrische Anordnung */
@media (min-width: 769px) {
  .pen-selection {
    grid-template-columns: repeat(3, 1fr);
  }
}

.pen-button {
  display: flex; align-items: center; justify-content: center;
  width: 100%;
  min-height: clamp(56px, 12vw, 90px);   /* statt aspect-ratio -> keine Subpixel-Probleme */
  padding: 0 8px;

  background: var(--card-background);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: clamp(0.95rem, 2.8vw, 1.05rem);
  text-align: center;
  transition: border-color .2s, box-shadow .2s, background-color .2s;

  white-space: nowrap;          /* kein Umbruch */
  word-break: keep-all;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.pen-button:hover:not(.active) { border-color: var(--primary-color); }
.pen-button.active {
  background: var(--pen-color-active);
  color: var(--background);
  border-color: var(--pen-color-active);
  box-shadow: 0 0 10px rgba(88,142,153,.5);
}

/* Dosis/Slider */
.dose-display { text-align: center; font-size: 2.6em; font-weight: 700; margin-bottom: 8px; color: var(--primary-color); }
.dose-slider-wrapper { position: relative; width: 100%; margin: 20px 0; padding: 0 12px; }
input[type="range"] {
  width: 100%; height: 6px; margin: 0; cursor: pointer; -webkit-appearance: none;
  background: var(--border-color); border-radius: 3px;
}
.slider-ticks { display: flex; justify-content: space-between; margin-top: 8px; padding: 0 6px; }
.tick { width: 6px; height: 6px; border-radius: 50%; background: var(--text-secondary); opacity: .5; }
.tick.active { background: var(--primary-color); opacity: 1; transform: scale(1.2); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary-color); border: 3px solid var(--card-background); box-shadow: 0 0 5px var(--shadow-color);
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary-color); border: 3px solid var(--card-background); box-shadow: 0 0 5px var(--shadow-color);
}
.dose-info { display: flex; justify-content: space-between; font-size: .85em; color: var(--text-secondary); padding: 0 5px; }
.dose-info span { font-weight: 600; }

/* Ergebnis */
.result-box {
  padding: 25px 18px; text-align: center;
  background: var(--card-background); color: var(--text-primary);
  border: 2px solid var(--primary-color); border-radius: 8px; margin-top: 20px;
}
.result-box h3 { margin: 0 0 4px; font-weight: 500; color: var(--text-secondary); }
.kicks-result { font-size: 4.0em; font-weight: 900; line-height: 1; color: var(--primary-color); }


/* Responsive Tweaks */
@media (max-width: 768px) {
  /* Header Anpassungen für Mobile */
  .main-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.9);
    min-height: 50px; /* Sichert Header-Höhe auf Mobile */
  }
  
  /* Light Mode Mobile Header */
  body.light-mode .main-header {
    background: rgba(255, 255, 255, 0.95);
  }
  
  .header-content {
    padding: 10px 12px;
    min-height: 50px; /* Sichert Header-Inhalt-Höhe */
  }
  
  .site-title {
    font-size: 1.2em;
    padding: 8px 12px;
    font-weight: 700;
  }
  
  .hamburger-btn {
    padding: 6px;
  }
  
  .hamburger-btn span {
    width: 18px;
  }
  
  .share-btn {
    padding: 5px;
  }
  
  /* Container Anpassungen für bessere Mobile-Ansicht */
  .container {
    padding-top: 5px; /* Reduziert oberes Padding für mehr Platz */
  }
  
  .dose-display { font-size: 2.2em; }
  input[type="range"] { height: 8px; }
  input[type="range"]::-webkit-slider-thumb,
  input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; }
  .tick { width: 7px; height: 7px; }
}
@media (max-width: 480px) {
  .top-bar { padding: 10px 8px; }
  .container { padding: 8px 6px; }
  .card { padding: 12px; margin-bottom: 12px; }
  .pen-selection { gap: 10px; }
  .pen-button { min-height: clamp(52px, 15vw, 84px); font-size: clamp(0.9rem, 3.2vw, 1rem); }
  .dose-display { font-size: 1.8em; }
  .result-box { padding: 15px 12px; }
  h1 { font-size: 1.2em; }
  h2 { font-size: .95em; }
}
@media (max-width: 360px) {
  .pen-selection { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
