/* ===================================================================
   PREMIUM DESIGN SYSTEM — graphite / cyan tech aesthetic
   Loaded after styles.css — overrides tokens & key surfaces
   =================================================================== */

:root {
    --primary: #7dd3fc;
    --primary-dark: #38bdf8;
    --primary-light: #bae6fd;
    --secondary: #64748b;
    --accent: #6366f1;
    --accent-light: #818cf8;

    --bg-primary: #0b0d10;
    --bg-secondary: #111318;
    --bg-elevated: #171a21;
    --bg-tertiary: #171a21;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-card-hover: rgba(255, 255, 255, 0.055);
    --bg-glass: rgba(148, 163, 184, 0.06);

    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;

    --border: rgba(148, 163, 184, 0.12);
    --border-hover: rgba(125, 211, 252, 0.35);
    --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);
    --shadow-glow: 0 0 48px rgba(56, 189, 248, 0.12);

    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.45, 0.64, 1);
    --transition-fast: 0.2s var(--ease-out-expo);
    --transition-base: 0.35s var(--ease-out-expo);
    --transition-slow: 0.6s var(--ease-out-expo);

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;

    --section-gap: clamp(5rem, 12vw, 8rem);
    --cursor-size: 12px;
}

html {
    color-scheme: dark;
}

html[data-theme="light"] {
    color-scheme: light;
}

/* Film grain + depth */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 9998;
    pointer-events: none;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    mix-blend-mode: overlay;
}

html[data-theme="light"] body::before {
    opacity: 0.015;
    mix-blend-mode: normal;
}

/* Ambient background — cold, cinematic */
.animated-bg {
    background:
        radial-gradient(ellipse 80% 50% at 15% -10%, rgba(56, 189, 248, 0.09) 0%, transparent 55%),
        radial-gradient(ellipse 60% 40% at 90% 100%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
        linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.orb-1 {
    background: radial-gradient(circle, rgba(56, 189, 248, 0.35) 0%, transparent 70%);
}

.orb-2 {
    background: radial-gradient(circle, rgba(100, 116, 139, 0.4) 0%, transparent 70%);
}

.orb-3 {
    background: radial-gradient(circle, rgba(99, 102, 241, 0.2) 0%, transparent 70%);
}

/* Typography — editorial hierarchy */
.hero-eyebrow,
.section-kicker {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 1rem;
}

/* Hero title: line 1 = first name, line 2 = last name, line 3 = role */
.hero-title {
    overflow: visible;
    text-overflow: unset;
}

.hero-headline {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 100%;
    overflow: visible;
    text-align: center;
    gap: 0.02em;
}

.hero-name-line,
.hero-role-line {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow: visible;
    overflow-wrap: normal;
    word-break: keep-all;
    hyphens: none;
    line-height: 1.05;
    letter-spacing: -0.03em;
    font-weight: 800;
    background: linear-gradient(135deg, #f8fafc 0%, #94a3b8 55%, #7dd3fc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: clamp(1.75rem, 9.5vw, 4rem);
}

.hero-name-line--last {
    margin-bottom: 0.12em;
}

.hero-role-line {
    font-size: clamp(1.05rem, 4.2vw, 1.65rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.25;
    margin-top: 0.2em;
    background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    word-break: normal;
    overflow-wrap: break-word;
    max-width: 18em;
}

[data-theme="light"] .hero-name-line {
    background: linear-gradient(135deg, #0f172a 0%, #334155 70%, #0ea5e9 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

[data-theme="light"] .hero-role-line {
    background: linear-gradient(135deg, #475569 0%, #64748b 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

@media (min-width: 1025px) {
    .hero-headline {
        align-items: flex-start;
    }

    .hero-name-line,
    .hero-role-line {
        text-align: left;
    }

    .hero-role-line {
        max-width: 14em;
    }
}

@media (max-width: 380px) {
    .hero-name-line {
        font-size: clamp(1.5rem, 11vw, 2.25rem);
    }

    .hero-role-line {
        font-size: clamp(0.95rem, 4.5vw, 1.2rem);
    }
}

.hero-subtitle {
    font-size: clamp(1.05rem, 2vw, 1.2rem);
    line-height: 1.75;
    color: var(--text-secondary);
    max-width: 34rem;
}

.section-title {
    font-size: clamp(2.1rem, 4.5vw, 3.25rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #f1f5f9 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 1;
    transform: none;
}

.section-title-left {
    text-align: left;
}

.section-description {
    font-size: clamp(1rem, 1.8vw, 1.125rem);
    color: var(--text-secondary);
    line-height: 1.7;
}

/* Sections — unique rhythm */
section {
    padding: var(--section-gap) 0;
}

#home.hero {
    min-height: min(100vh, 920px);
    padding-top: clamp(7rem, 14vh, 9rem);
}

.cases-section {
    position: relative;
}

.cases-section::before {
    content: '';
    position: absolute;
    inset: 10% 0 auto;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    pointer-events: none;
}

.services-section .service-card {
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    transition: transform 0.5s var(--ease-out-expo), border-color 0.35s, box-shadow 0.5s;
    transform-style: preserve-3d;
}

.services-section .service-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.about-trust {
    background: linear-gradient(180deg, transparent 0%, rgba(23, 26, 33, 0.5) 50%, transparent 100%);
}

.blog-teaser .blog-card {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-card);
    transition: transform 0.45s var(--ease-out-expo), border-color 0.35s, box-shadow 0.45s;
}

.blog-teaser .blog-card:hover {
    transform: translateY(-6px) rotate(-0.35deg);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.contact {
    position: relative;
}

.contact::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(600px, 80%);
    height: 200px;
    background: radial-gradient(ellipse, rgba(56, 189, 248, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

/* Portfolio cards — visible by default (GSAP must not leave them hidden) */
#cases-container,
#blog-projects-container {
    position: relative;
    z-index: 1;
}

.portfolio-card--compact {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    opacity: 1;
    visibility: visible;
    transition:
        transform 0.45s var(--ease-out-expo),
        border-color 0.35s ease,
        background 0.35s ease;
}

/* Glow halo behind the card on hover */
.portfolio-card--compact::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: calc(var(--radius-lg) + 6px);
    z-index: -1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.45s var(--ease-out-expo);
    box-shadow:
        0 0 28px 10px rgba(56, 189, 248, 0.22),
        0 0 56px 22px rgba(56, 189, 248, 0.1);
}

@media (hover: hover) {
    .portfolio-card--compact:hover {
        transform: translateY(-5px);
        border-color: rgba(125, 211, 252, 0.35);
        background: linear-gradient(
            165deg,
            rgba(255, 255, 255, 0.08) 0%,
            rgba(255, 255, 255, 0.03) 100%
        );
        box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    }

    .portfolio-card--compact:hover::before {
        opacity: 1;
    }
}

.portfolio-card--compact:focus-within::before {
    opacity: 0.85;
}

.portfolio-card--compact:focus-within {
    outline: none;
    border-color: rgba(125, 211, 252, 0.45);
}

.portfolio-preview {
    background: var(--bg-tertiary);
}

.portfolio-preview img {
    transition: transform 0.7s var(--ease-out-expo);
}

@media (hover: hover) {
    .portfolio-card--compact:hover .portfolio-preview img {
        transform: scale(1.04);
    }
}

.case-stack-tag {
    background: rgba(125, 211, 252, 0.08);
    border: 1px solid rgba(125, 211, 252, 0.15);
    color: var(--primary-light);
}

/* Buttons — premium, magnetic-ready */
.btn {
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: transform 0.35s var(--ease-spring), box-shadow 0.35s, border-color 0.35s, background 0.35s;
}

.btn-primary {
    background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 50%, #6366f1 100%);
    background-size: 200% 200%;
    box-shadow: var(--shadow-sm), 0 0 32px rgba(56, 189, 248, 0.2);
}

.btn-primary:hover {
    background-position: 100% 0;
    box-shadow: var(--shadow-md), 0 0 40px rgba(56, 189, 248, 0.28);
    transform: translateY(-2px);
}

.btn-secondary {
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.btn-secondary:hover {
    border-color: var(--border-hover);
    background: rgba(125, 211, 252, 0.06);
}

.btn:focus-visible,
.nav-link:focus-visible,
.lang-btn:focus-visible,
.theme-toggle:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px rgba(125, 211, 252, 0.55);
}

/* Logo */
.logo-text {
    background: linear-gradient(135deg, #e2e8f0, #7dd3fc);
    -webkit-background-clip: text;
    background-clip: text;
}

.nav-link {
    position: relative;
}

.nav-link::after {
    display: none;
}

/* Pill nav — graphite glass */
:root {
    --pill-bg: rgba(17, 19, 24, 0.72);
    --pill-bg-scrolled: rgba(11, 13, 16, 0.88);
    --pill-border: rgba(148, 163, 184, 0.12);
    --pill-border-hover: rgba(125, 211, 252, 0.22);
    --pill-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    --pill-shadow-scrolled: 0 16px 48px rgba(0, 0, 0, 0.55);
}

/* Motion utilities */
.motion-will-reveal {
    opacity: 0;
    transform: translateY(28px);
}

.motion-revealed {
    opacity: 1;
    transform: translateY(0);
}

.reduce-motion .motion-will-reveal,
.reduce-motion .motion-revealed {
    opacity: 1 !important;
    transform: none !important;
}

/* Custom cursor dot (desktop only) */
@media (hover: hover) and (pointer: fine) {
    .cursor-glow {
        position: fixed;
        width: var(--cursor-size);
        height: var(--cursor-size);
        border-radius: 50%;
        background: rgba(125, 211, 252, 0.85);
        pointer-events: none;
        z-index: 10001;
        mix-blend-mode: screen;
        transform: translate(-50%, -50%);
        transition: width 0.25s, height 0.25s, opacity 0.25s;
        opacity: 0;
    }

    .cursor-glow.is-visible {
        opacity: 0.7;
    }

    .cursor-glow.is-hover {
        width: 40px;
        height: 40px;
        opacity: 0.35;
    }
}

/* ===== LIGHT THEME (premium overrides — aligned with styles.css) ===== */
:root[data-theme="light"] {
    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --primary-light: #38bdf8;
    --secondary: #64748b;
    --accent: #6366f1;

    --bg-primary: #ffffff;
    --bg-secondary: #ffffff;
    --bg-elevated: #f4f4f5;
    --bg-card: rgba(24, 24, 27, 0.02);
    --bg-card-hover: rgba(24, 24, 27, 0.04);
    --bg-glass: rgba(24, 24, 27, 0.03);

    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-tertiary: #71717a;

    --border: rgba(24, 24, 27, 0.08);
    --border-hover: rgba(24, 24, 27, 0.16);
    --shadow-glow: 0 0 24px rgba(24, 24, 27, 0.06);

    --pill-bg: #ffffff;
    --pill-bg-scrolled: #ffffff;
    --pill-border: rgba(24, 24, 27, 0.06);
    --pill-border-hover: rgba(24, 24, 27, 0.1);
    --pill-shadow: 0 6px 20px rgba(24, 24, 27, 0.05), 0 1px 2px rgba(24, 24, 27, 0.03);
    --pill-shadow-scrolled: 0 12px 32px rgba(24, 24, 27, 0.08), 0 2px 6px rgba(24, 24, 27, 0.04);
}

/* Solid page background — Safari mis-blends layered gradients during theme toggle */
html[data-theme="light"],
html[data-theme="light"] body {
    background-color: #ffffff;
    color: var(--text-primary);
}

/* Hide decorative layers completely (styles.css intent; was overridden here before) */
html[data-theme="light"] .animated-bg {
    background: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none;
}

html[data-theme="light"] .gradient-orb,
html[data-theme="light"] .orb-1,
html[data-theme="light"] .orb-2,
html[data-theme="light"] .orb-3 {
    opacity: 0 !important;
    visibility: hidden !important;
    animation: none !important;
}

[data-theme="light"] .portfolio-card--compact,
[data-theme="light"] .services-section .service-card,
[data-theme="light"] .blog-teaser .blog-card {
    background: #ffffff;
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.04);
}

/* Light theme — dark soft glow behind card */
[data-theme="light"] .portfolio-card--compact::before {
    box-shadow:
        0 0 24px 10px rgba(15, 23, 42, 0.1),
        0 0 48px 18px rgba(15, 23, 42, 0.06);
}

@media (hover: hover) {
    [data-theme="light"] .portfolio-card--compact:hover {
        transform: translateY(-5px);
        background: #ffffff;
        border-color: rgba(15, 23, 42, 0.12);
        box-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
    }

    [data-theme="light"] .portfolio-card--compact:hover::before {
        opacity: 1;
        box-shadow:
            0 0 32px 14px rgba(15, 23, 42, 0.14),
            0 0 64px 26px rgba(15, 23, 42, 0.07);
    }
}

[data-theme="light"] .portfolio-card--compact:focus-within {
    border-color: rgba(14, 165, 233, 0.4);
}

[data-theme="light"] .btn-primary {
    background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

[data-theme="light"] .btn-primary:hover {
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
}

/* Blog & project subpages */
.blog-page {
    padding-top: clamp(6rem, 12vh, 8rem);
}

.blog-page-intro {
    max-width: 42rem;
    margin: 0 auto 3rem;
    text-align: center;
    color: var(--text-secondary);
    line-height: 1.7;
}

.blog-article {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: clamp(1.5rem, 4vw, 2.5rem);
    margin-bottom: 2rem;
    background: var(--bg-card);
}

/* ===== PROJECT DETAIL PAGE ===== */
.project-page {
    position: relative;
    z-index: 1;
}

.project-page .container {
    max-width: 820px;
}

#project-content,
#project-content * {
    visibility: visible;
}

#project-content > * {
    opacity: 1;
}

.project-detail-article {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.project-detail-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.project-detail-category {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--primary);
}

.project-detail-header .project-detail-title {
    font-size: clamp(1.75rem, 5vw, 2.75rem);
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin: 0;
    color: var(--text-primary);
    -webkit-text-fill-color: unset;
    background: none;
    width: 100%;
    overflow-wrap: break-word;
    word-break: normal;
}

.project-detail-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    width: 100%;
}

.case-detail-block {
    padding: clamp(1.25rem, 3vw, 1.75rem);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.case-detail-block--summary {
    border-color: rgba(125, 211, 252, 0.2);
}

.case-detail-summary {
    font-size: clamp(1.05rem, 2.2vw, 1.2rem);
    line-height: 1.75;
    color: var(--text-primary);
    margin-top: 0.5rem;
}

.case-detail-list {
    margin: 0.75rem 0 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.case-detail-list li {
    position: relative;
    padding-left: 1.35rem;
    color: var(--text-secondary);
    line-height: 1.65;
    font-size: 1rem;
    overflow-wrap: break-word;
    word-break: normal;
}

.case-detail-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.55em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
}

.case-detail-block--implemented .case-label {
    color: #7dd3fc;
}

.case-detail-block--planned .case-label {
    color: #94a3b8;
}

.project-detail-preview {
    margin-bottom: 0.25rem;
}

.project-not-found {
    text-align: center;
    padding: 3rem 1rem;
}

.project-not-found p {
    color: var(--text-secondary);
    margin: 1rem 0 1.5rem;
}

[data-theme="light"] .project-detail-header .project-detail-title {
    color: var(--text-primary);
}

/* Legal pages (Impressum / Datenschutz) */
.legal-page {
    padding-top: clamp(7rem, 14vw, 9rem);
}

.legal-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(24px) saturate(160%);
}

.legal-content h1 {
    background: linear-gradient(
        135deg,
        var(--text-primary) 0%,
        var(--primary) 52%,
        var(--primary-dark) 100%
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.03em;
}

.legal-content h2 {
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.legal-content a {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px solid rgba(125, 211, 252, 0.35);
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.legal-content a:hover {
    color: var(--primary-light);
    border-bottom-color: var(--primary);
}

.legal-footer a {
    color: var(--primary);
    font-weight: 500;
}

.legal-footer a:hover {
    color: var(--primary-light);
}

[data-theme="light"] .legal-content {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(24, 24, 27, 0.1);
    box-shadow: 0 1px 3px rgba(24, 24, 27, 0.04), 0 8px 28px rgba(24, 24, 27, 0.06);
}

[data-theme="light"] .legal-content h1 {
    background: linear-gradient(135deg, #0f172a 0%, #0284c7 55%, #0369a1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

[data-theme="light"] .legal-content a {
    color: #0369a1;
    border-bottom-color: rgba(3, 105, 161, 0.35);
}

[data-theme="light"] .legal-content a:hover {
    color: #0284c7;
}

/* Safari: skip transitions while toggling theme (avoids gray flash) */
html.theme-switching,
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .gradient-orb {
        animation: none !important;
    }
}
