/* ==========================================================================
   GERHARD WAGLER — Portfolio
   Modern, modular, privacy-first, SEO-friendly
   Light & Dark mode via CSS custom properties
   ========================================================================== */

/* ---------- CSS Reset & Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---------- Design Tokens (Light) ---------- */
:root,
[data-theme="light"] {
  --color-bg: #fafafa;
  --color-bg-alt: #f0f0f0;
  --color-surface: #ffffff;
  --color-surface-hover: #f5f5f5;
  --color-text: #1a1a1a;
  --color-text-secondary: #555;
  --color-text-muted: #888;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-soft: rgba(37, 99, 235, 0.08);
  --color-border: #d0d0d0;
  --color-border-hover: #b0b0b0;
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.13);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.16);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
  --transition: 0.2s ease;
  --container-max: 1200px;
  --sticky-bg: #e9d5ff;
  --sticky-border: #a855f7;
  --sticky-fold: #c084fc;
  --sticky-ink: #581c87;
}

/* ---------- Design Tokens (Dark) ---------- */
html:has(#darkMode:checked),
[data-theme="dark"] {
  --color-bg: #0f0f0f;
  --color-bg-alt: #1a1a1a;
  --color-surface: #1e1e1e;
  --color-surface-hover: #2a2a2a;
  --color-text: #e8e8e8;
  --color-text-secondary: #aaa;
  --color-text-muted: #666;
  --color-accent: #60a5fa;
  --color-accent-hover: #93c5fd;
  --color-accent-soft: rgba(96, 165, 250, 0.1);
  --color-border: #2e2e2e;
  --color-border-hover: #444;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --sticky-bg: #581c87;
  --sticky-border: #7e22ce;
  --sticky-fold: #9333ea;
  --sticky-ink: #e9d5ff;
}

/* ---------- Accessibility: Screen reader only ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Accessibility: Skip to main content ---------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 0.75rem 1.5rem;
  background: var(--color-accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0;
  color: #fff;
  outline: 2px solid #fff;
  outline-offset: -2px;
}

/* ---------- Typography ---------- */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.6;
  transition: background-color var(--transition), color var(--transition);
}

h1, h2, h3, h4 {
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--color-accent-hover);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ---------- Container ---------- */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background-color var(--transition), border-color var(--transition);
}

html:has(#darkMode:checked) .site-header,
[data-theme="light"] .site-header {
  background: rgba(250, 250, 250, 0.85);
}

html:not(:has(#darkMode:checked)) .site-header {
  background: rgba(250, 250, 250, 0.85);
}

html:has(#darkMode:checked) .site-header,
[data-theme="dark"] .site-header {
  background: rgba(15, 15, 15, 0.85);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 1rem;
}

.logo {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.logo:hover {
  color: var(--color-accent);
}

.logo-text {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.header-nav {
  display: flex;
  gap: 0;
  position: relative;
  align-items: stretch;
}

.header-nav a {
  position: relative;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition);
  padding: 0.3rem 1rem;
  z-index: 1;
}

.header-nav a:hover {
  color: var(--color-text);
}

/* Kanban card hidden by default */
.kanban-card {
  display: none;
}

/* ---------- Kanban Nav (desktop only) ---------- */
@media (min-width: 769px) {
  .kanban-nav {
    background: var(--color-bg-alt);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0;
    overflow: visible;
  }

  .kanban-nav a {
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.75rem 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .kanban-nav a + a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10%;
    height: 80%;
    border-left: 1.5px dashed var(--color-border);
  }

  .kanban-card {
    display: flex;
    position: absolute;
    top: calc(100% - 12px);
    left: 0;
    transform: rotate(2deg);
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease;
    pointer-events: auto;
    cursor: grab;
    z-index: 2;
    opacity: 0;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(1px 2px 3px rgba(0, 0, 0, 0.15));
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
  }

  .kanban-card.is-visible {
    opacity: 1;
  }

  .kanban-card.is-dragging {
    cursor: grabbing;
    transition: opacity 0.3s ease;
    transform: rotate(4deg) scale(1.1);
    filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.25));
  }
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---------- Buttons (header) ---------- */
.theme-toggle,
.lang-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-text);
  cursor: pointer;
  padding: 0;
  transition: all var(--transition);
}

.theme-toggle:hover,
.lang-toggle:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

#darkMode:focus-visible + .theme-toggle {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.lang-toggle {
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-sans);
}

.icon-sun { display: none; }

html:has(#darkMode:checked) .icon-sun,
[data-theme="dark"] .icon-sun { display: inline; }

html:has(#darkMode:checked) .icon-moon,
[data-theme="dark"] .icon-moon { display: none; }

/* ---------- Mobile menu toggle ---------- */
.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  cursor: pointer;
  padding: 10px;
}

.mobile-menu-toggle span {
  display: block;
  height: 2px;
  background: var(--color-text);
  border-radius: 1px;
  transition: all var(--transition);
}

.mobile-menu-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ---------- Hero ---------- */
.hero {
  padding: 6rem 0 4rem;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, var(--color-accent), #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

.hero-subtitle {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  color: var(--color-text-secondary);
  margin-bottom: 1.5rem;
}

.hero-intro {
  max-width: 680px;
  margin: 0 auto;
  font-size: 1.05rem;
  color: var(--color-text-secondary);
  line-height: 1.7;
}

/* ---------- Sections ---------- */
.section {
  padding: 5rem 0;
}

.section-alt {
  background: var(--color-bg-alt);
  transition: background-color var(--transition);
}

.section-title {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  text-align: center;
}

.section-desc {
  text-align: center;
  color: var(--color-text-secondary);
  margin-bottom: 3rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Prose (About section) ---------- */
.prose {
  max-width: 720px;
  margin: 0 auto;
}

.prose p {
  color: var(--color-text-secondary);
  line-height: 1.8;
  margin-bottom: 1.5rem;
}

.prose h3 {
  font-size: 1.15rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--color-text);
}

/* ---------- About Tiles ---------- */
.about-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.about-tile {
  gap: 0.5rem;
}

.about-tile-icon {
  color: var(--color-accent);
  flex-shrink: 0;
  margin-bottom: 0.25rem;
}

.about-tile .tile-title {
  font-size: 1.1rem;
}

.about-tile .tile-desc {
  font-size: 0.9rem;
  line-height: 1.7;
}

.about-tile:hover {
  transform: none;
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

/* ---------- Engagement Tiles ---------- */
.engagement-tile {
  gap: 0.25rem;
}

.engagement-tile:hover {
  transform: none;
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

.engagement-tile .tile-title {
  font-size: 1.15rem;
}

.engagement-meta {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-accent);
  margin-bottom: 0.35rem;
}

.engagement-tile .tile-desc {
  font-size: 0.9rem;
  line-height: 1.7;
}

.engagement-context {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: auto;
  padding-top: 0.5rem;
}

/* ---------- Tile Grid (Projects) ---------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 2rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--color-text);
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.tile:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  color: var(--color-text);
}

.tile-screenshot {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 0.25rem;
}

.tile-icon {
  color: var(--color-accent);
}

.tile-title {
  font-size: 1.3rem;
  font-weight: 700;
}

.tile-desc {
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  flex: 1;
}

.tile-link {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-accent);
  transition: color var(--transition);
}

.tile:hover .tile-link {
  color: var(--color-accent-hover);
}

/* ---------- Tile Grid (Contact links) ---------- */
.tile-grid-links {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.tile-sm {
  align-items: center;
  text-align: center;
  padding: 1.5rem;
  gap: 0.5rem;
}

.tile-sm span {
  font-weight: 600;
  font-size: 0.95rem;
}

.tile-cta {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

.tile-cta:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  color: #fff;
}

.tile-cta svg {
  color: #fff;
}

/* ---------- Certification Grid ---------- */
.cert-category {
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.cert-category:first-of-type {
  margin-top: 0;
}

.cert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.cert-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-text);
  text-align: center;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  position: relative;
}

.cert-tile:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.cert-tile img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 4px;
}

.cert-name {
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--color-text-secondary);
}

.cert-no-link {
  cursor: default;
}

.cert-no-link:hover {
  transform: none;
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

/* Expired badge */
.cert-expired {
  opacity: 0.6;
}

.cert-badge-expired {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #dc2626;
  background: rgba(220, 38, 38, 0.1);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

html:has(#darkMode:checked) .cert-badge-expired,
[data-theme="dark"] .cert-badge-expired {
  color: #f87171;
  background: rgba(248, 113, 113, 0.15);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 2rem 0;
  transition: border-color var(--transition);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.footer-privacy {
  flex-basis: 100%;
  text-align: center;
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
  background: var(--color-accent-soft);
  border-radius: var(--radius-sm);
  color: var(--color-accent);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.footer-links a {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.footer-links a:hover {
  color: var(--color-text);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .header-nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    padding: 1rem 1.5rem;
    gap: 0.75rem;
    align-items: flex-end;
    text-align: right;
  }

  .header-nav.open {
    display: flex;
  }

  .mobile-menu-toggle {
    display: flex;
  }

  .hero {
    padding: 4rem 0 3rem;
  }

  .section {
    padding: 3rem 0;
  }

  .tile-grid {
    grid-template-columns: 1fr;
  }

  .about-grid {
    grid-template-columns: 1fr;
  }

  .tile-grid-links {
    grid-template-columns: repeat(2, 1fr);
  }

  .cert-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
  }

  .cert-tile img {
    width: 60px;
    height: 60px;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .tile-grid-links {
    grid-template-columns: 1fr;
  }

  .cert-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- Animations ---------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Animation paused by default; JS adds .anim-visible to trigger */
@media (prefers-reduced-motion: no-preference) {
  .anim-entry {
    opacity: 0;
    animation: fadeInUp 0.4s ease both paused;
  }

  .anim-entry.anim-visible {
    animation-play-state: running;
  }

  .tile.anim-entry:nth-child(1) { animation-delay: 0.05s; }
  .tile.anim-entry:nth-child(2) { animation-delay: 0.1s; }
  .tile.anim-entry:nth-child(3) { animation-delay: 0.15s; }
}

/* Users who prefer reduced motion see no animation */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Focus styles for accessibility ---------- */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Ensure focus ring is visible on dark CTA tiles */
.tile-cta:focus-visible {
  outline-color: #fff;
}

/* ---------- Selection ---------- */
::selection {
  background: var(--color-accent);
  color: #fff;
}

/* ---------- Scrollbar (subtle) ---------- */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* ---------- Legal Pages (Impressum / Datenschutz) ---------- */
.container-narrow {
  max-width: 780px;
}

.legal-page h1 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

.legal-page h2 {
  font-size: 1.25rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.legal-page p,
.legal-page ul {
  margin-bottom: 1rem;
  line-height: 1.7;
  color: var(--color-text-secondary);
}

.legal-page ul {
  padding-left: 1.5rem;
}

.legal-page li {
  margin-bottom: 0.4rem;
}

.legal-page a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.legal-page a:hover {
  color: var(--color-accent-hover);
}

.legal-address {
  font-style: normal;
  margin-bottom: 1rem;
  line-height: 1.7;
  color: var(--color-text-secondary);
}

.legal-back {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.legal-meta {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 2rem;
}
