/* ===================================================
   UTILITY BUTTONS.CSS - AUFGERÄUMT & STRUKTURIERT
   
   Inhalt:
   1. Shared Styles
   2. Dark Mode Toggle
   3. Close Button
   4. Scroll CTA Buttons
   5. Standard Buttons (Primary/Secondary/Tertiary)
   6. Icon Animationen
   7. Toast Notifications
   8. Accessibility
   =================================================== */

/* ===================================================
   1. SHARED STYLES
   =================================================== */

/* Gemeinsame Tooltip-Basis */
.theme-toggle-btn::after,
.scroll-cta-btn::after {
  position: absolute;
  background: var(--color-surface-screen);
  color: var(--color-text-primary-default);
  padding: 0.6em;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--color-border-secondary-default);
  font-size: var(--font-size-label);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 1;
}

/* Gemeinsame Utility-Button-Basis (Toggle & Close) */
.btn-close,
#theme-toggle.theme-toggle-btn,
.lightbox-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-2);
  padding: 0.6em 0.9em;
  color: var(--color-text-primary-default);
  font-family: var(--font-family-2);
  font-size: var(--font-size-label);
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--color-button-border-secondary-default);
  background: var(--color-surface-container-default);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

/* Hover/Focus States */
.btn-close:hover,
.btn-close:focus-visible,
#theme-toggle.theme-toggle-btn:hover,
#theme-toggle.theme-toggle-btn:focus-visible,
.lightbox-close:hover,
.lightbox-close:focus-visible {
  color: var(--color-text-secondary-hover);
  border-color: var(--color-button-border-secondary-hover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Focus Ring für Tastatur */
.btn-close:focus-visible,
#theme-toggle.theme-toggle-btn:focus-visible,
.lightbox-close:focus-visible  {
  outline: 2px solid var(--color-focus-default);
  outline-offset: 3px;
}

/* Icon-Größe */
.btn-close svg,
#theme-toggle .theme-icon,
.lightbox-close svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  transition: transform 0.25s ease;
}

/* Glassmorphism - Light Mode */
.light-mode .btn-close,
.light-mode #theme-toggle.theme-toggle-btn,
.light-mode .lightbox-close  {
  background: rgba(255, 255, 255, 0.35);
  border-color: rgba(0, 0, 0, 0.25);
}

/* Glassmorphism - Dark Mode */
.dark-mode .btn-close,
.dark-mode #theme-toggle.theme-toggle-btn,
#theme-toggle.theme-toggle-btn
.dark-mode .lightbox-close {
  background: rgba(18, 18, 18, 0.55);
  border-color: rgba(255, 255, 255, 0.25);
}

/* ===================================================
   2. DARK MODE TOGGLE
   =================================================== */

#theme-toggle.theme-toggle-btn {
  position: fixed;
  bottom: 15px;
  left: 15px;
  z-index: 99999;
  animation: theme-toggle-intro 0.6s ease-out 1.2s 1;
}

@keyframes theme-toggle-intro {
  0%, 100% { 
    transform: scale(1); 
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  }
  50% { 
    transform: scale(1.08); 
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  }
}

/* Tooltip Desktop */
#theme-toggle.theme-toggle-btn::after {
  content: attr(data-tooltip);
  bottom: calc(100% + 8px);
  left: 0;
}

#theme-toggle.theme-toggle-btn:hover::after,
#theme-toggle.theme-toggle-btn:focus-visible::after {
  opacity: 1;
}

/* Icon Animationen */
@keyframes spin-bounce-sun {
  0%   { transform: rotate(0deg); }
  70%  { transform: rotate(360deg); }
  85%  { transform: rotate(330deg); }
  100% { transform: rotate(360deg); }
}

@keyframes spin-bounce-moon {
  0%   { transform: rotate(0deg); }
  70%  { transform: rotate(720deg); }
  85%  { transform: rotate(700deg); }
  100% { transform: rotate(720deg); }
}

.theme-toggle-btn:hover .theme-icon.sun,
.theme-toggle-btn:focus-visible .theme-icon.sun {
  animation: spin-bounce-sun 0.8s ease-in-out;
}

.theme-toggle-btn:hover .theme-icon.moon,
.theme-toggle-btn:focus-visible .theme-icon.moon {
  animation: spin-bounce-moon 0.8s ease-in-out;
}

/* ===================================================
   3. CLOSE BUTTON
   =================================================== */

.project-header {
  position: fixed;
  top: var(--spacing-4);
  right: var(--spacing-4);
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  padding: var(--spacing-4);
}

.btn-close,
.lightbox-close {
  margin-right: var(--spacing-3);
}

@keyframes spin-fast-close {
  0%   { transform: rotate(0deg); }
  70%  { transform: rotate(450deg); }
  100% { transform: rotate(450deg); }
}

.btn-close:hover svg,
.btn-close:focus-visible svg,
.lightbox-close:hover svg,
.lightbox-close:focus-visible svg {
  animation: spin-fast-close 0.8s ease-in-out;
}

/* ===================================================
   4. SCROLL CTA BUTTONS
   =================================================== */

.scroll-cta-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  transform: translateY(100%);
  z-index: 99998;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-4);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.08);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-cta-container.visible {
  transform: translateY(0);
}

body.dark-mode .scroll-cta-container {
  background: rgba(18, 18, 18, 0.85);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.3);
}

/* Layout-Bereiche */
.scroll-cta-left {
  order: 2;
  margin-left: auto;
  flex: 0 0 auto;
}

.scroll-cta-center {
  order: 1;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--spacing-4);
}

.scroll-cta-right {
  width: 150px;
  flex: 0 0 auto;
}

/* CTA Buttons - Desktop First */
.scroll-cta-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-2);
  padding: 0.6em 1.2em;
  font-family: var(--font-family-2);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-regular);
  text-decoration: none;
  border: 1px solid var(--color-button-border-secondary-default);
  border-radius: var(--radius-2);
  background: transparent;
  color: var(--color-text-primary-default);
  cursor: pointer;
  transition: all 0.3s ease;
}

.scroll-cta-btn:hover {
  border-color: var(--color-button-border-secondary-hover);
  color: var(--color-text-primary-default);
}

/* Tertiary Style: Nach oben Button */
.scroll-cta-btn.scroll-top {
  border: none;
  padding: 0.4em 0.6em;
}

.scroll-cta-btn.scroll-top:hover {
  background: transparent;
  color: var(--color-text-secondary-hover);
}

/* CTA Icons */
.scroll-cta-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  flex-shrink: 0;
}

.scroll-cta-btn .icon-linkedin,
.scroll-cta-btn .icon-mail {
  width: 16px;
  height: 16px;
  stroke-width: 1.5;
}

/* Browser Fallback */
@supports not (backdrop-filter: blur(10px)) {
  .scroll-cta-container {
    background: rgba(255, 255, 255, 0.95);
  }
  body.dark-mode .scroll-cta-container {
    background: rgba(18, 18, 18, 0.95);
  }
}

/* ===================================================
   5. STANDARD BUTTONS
   =================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-3);
  padding: var(--spacing-3) var(--spacing-6);
  border-radius: var(--radius-2);
  font-size: var(--font-size-body-sm);
  font-family: var(--font-family-2);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.3s ease;
  width: auto;
  max-width: 100%;
  box-sizing: border-box;
}

/* Button Icons */
.btn .icon,
.btn .arrow-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.btn .icon-linkedin {
  width: 24px;
  height: 24px;
  stroke-width: 1;
}

/* Button Spacing */
.btn + .btn {
  margin-top: var(--spacing-4);
}

/* Primary Button */
.btn--primary {
  background: var(--color-button-background-primary-default);
  color: var(--color-button-foreground-primary-default);
  border: 1px solid var(--color-button-border-primary-default);
}

.btn--primary:hover,
.btn--primary:focus-visible {
  background: var(--color-button-background-primary-hover);
  color: var(--color-button-foreground-primary-default);
}

/* Secondary Button */
.btn--secondary {
  background: transparent;
  border: 1px solid var(--color-button-border-secondary-default);
  color: var(--color-button-foreground-secondary-default);
}

.btn--secondary:hover,
.btn--secondary:focus-visible {
  color: var(--color-button-foreground-secondary-hover);
  border-color: var(--color-button-border-secondary-hover);
}

/* Tertiary Button */
.btn--tertiary {
  background: transparent;
  border: none;
  color: var(--color-button-foreground-tertiary-default);
  padding: var(--spacing-2) var(--spacing-4);
}

.btn--tertiary:hover,
.btn--tertiary:focus-visible {
  color: var(--color-button-foreground-tertiary-hover);
}

/* Kontakt Section */
.kontakt .btn {
  align-items: center;
  height: auto;
  line-height: 1.2;
  margin-inline: 0;  
}

/* ===================================================
   6. ICON ANIMATIONEN
   =================================================== */

/* Mail Bounce */
@keyframes mail-bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.btn--primary.token-btn-copy-email:hover .icon,
.btn--primary.token-btn-copy-email:focus-visible .icon,
.scroll-cta-btn.email:hover .icon-mail,
.scroll-cta-btn.email:focus-visible .icon-mail {
  animation: mail-bounce 0.5s ease;
}

/* LinkedIn Diagonal Bounce */
@keyframes bounce-up-right {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(2px, -2px); }
}

.btn--secondary:hover .icon-linkedin,
.btn--secondary:focus-visible .icon-linkedin,
.scroll-cta-btn.linkedin:hover .icon-linkedin,
.scroll-cta-btn.linkedin:focus-visible .icon-linkedin {
  animation: bounce-up-right 0.5s ease;
}

/* Arrow Down (für Scroll nach unten) */
@keyframes bounce-down {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

.btn--primary.btn--with-arrow:hover .arrow-icon,
.btn--primary.btn--with-arrow:focus-visible .arrow-icon,
a[href^="#"]:not([href*="top"]):hover .arrow-icon,
a[href^="#"]:not([href*="top"]):focus-visible .arrow-icon {
  animation: bounce-down 0.5s ease;
}

/* Arrow Up (für Scroll nach oben) */
@keyframes bounce-up {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.scroll-cta-btn.scroll-top:hover svg,
.scroll-cta-btn.scroll-top:focus-visible svg {
  animation: bounce-up 0.5s ease;
}

/* ===================================================
   7. TOAST NOTIFICATIONS
   =================================================== */

#dg-toast-container {
  position: fixed;
  bottom: 100px;
  right: var(--spacing-6);
  z-index: 100000;
  pointer-events: none;
}

.dg-toast {
  background: var(--color-surface-container-default);
  color: var(--color-text-primary-default);
  padding: var(--spacing-3) var(--spacing-5);
  border-radius: var(--radius-2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: var(--font-size-xxs);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  margin-bottom: var(--spacing-2);
}

.dg-toast--show {
  opacity: 1;
  transform: translateY(0);
}

/* ===================================================
   8. ACCESSIBILITY
   =================================================== */

/* Skip Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-bg);
  color: var(--color-text);
  padding: 0.5rem 1rem;
  z-index: 100;
  text-decoration: none;
  transition: top 0.3s ease;
}

.skip-link:focus {
  top: 0;
}

/* Visually Hidden */
.visually-hidden,
.u-hide-visually {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus States */
:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-focus-default);
  outline-offset: 3px;
}

/* Link Styles */
a {
  color: var(--color-link-primary-default);
  text-decoration-thickness: 1px;
}

a:hover,
a:focus {
  color: var(--color-link-primary-hover);
  outline: none;
}

/* Smooth Scroll für alle Geräte */
html {
  scroll-behavior: smooth;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  .arrow-icon,
  .icon-linkedin,
  .icon-mail,
  .theme-icon {
    animation: none !important;
    transition: none !important;
  }
  html {
    scroll-behavior: auto;
  }
}



/* ===================================================
   RESPONSIVE - MOBILE
   =================================================== */
@media (max-width: 768px) {
  
  /* Dark Mode Toggle - Rechts unten */
  #theme-toggle.theme-toggle-btn {
    left: auto;
    right: 16px;
    bottom: 16px;
    min-width: 52px;
    min-height: 52px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  #theme-toggle.theme-toggle-btn::after {
    left: auto;
    right: 0;
    bottom: calc(100% + 8px);
  }
  
  #theme-toggle .theme-toggle-text {
    display: none;
  }
  
  #theme-toggle .theme-icon {
    width: 22px;
    height: 22px;
    margin: 0;
  }
  
  /* Close Button - Gleiche Größe wie Toggle */
  .project-header {
    top: 16px;
    right: 16px;
    padding: var(--spacing-2);
  }
  
  .btn-close,
  .lightbox-close {
    min-width: 52px;
    min-height: 52px;
    padding: 0;
    margin-right: 0;
    font-size: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Close Button - Gleiche Größe wie Toggle - SPEZIFISCHER */
  .project-header {
    top: 16px;
    right: 16px;
    padding: 0; /* ← WICHTIG: Kein Padding im Container */
  }
  
  .btn-close,
  a.btn-close,
  .lightbox-close,
  a.lightbox-close  { /* ← Beide Selektoren */
    gap:0;
  }
  
  /* CTA Container */
  .scroll-cta-container {
    padding: 12px var(--spacing-4);
    justify-content: center;
  }
  
  .scroll-cta-left,
  .scroll-cta-right {
    display: none;
  }
  
  .scroll-cta-center {
    position: static;
    transform: none;
    gap: var(--spacing-3);
  }
  
  .scroll-cta-btn {
    padding: 0.7em 1.2em;
    font-size: var(--font-size-xs);
    min-width: 44px;
    min-height: 44px;
  }
  
  .scroll-cta-btn svg {
    width: 16px;
    height: 16px;
  }
  
  /* Toast Position */
  #dg-toast-container {
    right: 50%;
    transform: translateX(50%);
    bottom: 140px;
  }
  
  /* Standard Buttons - Höher für Touch */
  .btn {
    display: flex;
    width: 100%;
    justify-content: center;
    min-height: 48px;
    padding: var(--spacing-4) var(--spacing-6);
  }
  
  .btn + .btn {
    margin-left: 0;
  }
  
  .kontakt .btn {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    min-height: 48px;
  }
}