/* ==========================================================================
   Haarlems Oktoberfest - Selfie Generator
   ========================================================================== */

@font-face {
    font-family: 'Deutsch Gothic';
    src: url('/assets/font/Deutsch-Gothic.woff2') format('woff2'),
         url('/assets/font/Deutsch-Gothic.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-primary: #0B7BC0;
    --color-primary-dark: #065A8F;
    --color-gold: #D4A843;
    --color-gold-dark: #B8912E;
    --color-dark: #1A1A2E;
    --color-dark-2: #242442;
    --color-white: #FFFFFF;
    --color-gray: #9CA3AF;
    --color-danger: #EF4444;
    --font-display: 'Deutsch Gothic', cursive;
    --font-body: 'DM Sans', system-ui, sans-serif;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--color-dark);
    color: var(--color-white);
    min-height: 100vh;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

/* Bavarian diamond pattern background (from coming-soon page) */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cpolygon points='30,0 60,30 30,60 0,30' fill='%230B7BC0' opacity='0.10'/%3E%3C/svg%3E");
    background-size: 60px 60px;
    z-index: 0;
    pointer-events: none;
}

/* Bavarian divider - blue/white diamond repeating band */
.bavarian-divider {
    height: 28px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Crect width='28' height='28' fill='%23FFFFFF'/%3E%3Cpolygon points='14,0 28,14 14,28 0,14' fill='%230B7BC0'/%3E%3C/svg%3E");
    background-repeat: repeat-x;
    background-size: 28px 28px;
    width: 100%;
}

/* All content above the background pattern */
.selfie-header,
.selfie-page,
.selfie-footer {
    position: relative;
    z-index: 1;
}

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

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

/* --- Header --- */
.selfie-header {
    background: rgba(26, 26, 46, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(212, 168, 67, 0.2);
    padding: 1.25rem 0;
}

.selfie-header__inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.selfie-header__logo {
    font-family: var(--font-display);
    color: var(--color-white);
    font-size: 1.75rem;
    font-weight: normal;
    letter-spacing: 0.02em;
    line-height: 1;
}

.selfie-header__logo:hover {
    color: var(--color-gold);
}

.selfie-header__back {
    color: var(--color-gold);
    font-size: 0.875rem;
    font-weight: 500;
}

/* --- Page container --- */
.selfie-page {
    flex: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 3rem 1.25rem 4rem;
    width: 100%;
}

.selfie-intro {
    text-align: center;
    margin-bottom: 2.5rem;
}

.selfie-page .bavarian-divider {
    margin-bottom: 2.5rem;
}

.selfie-page .bavarian-divider + .selfie-stage {
    margin-bottom: 2.5rem;
}

.selfie-page .selfie-stage + .bavarian-divider {
    margin-top: 0;
}

.selfie__title {
    font-family: var(--font-display);
    font-size: clamp(2.75rem, 8vw, 4.5rem);
    font-weight: normal;
    line-height: 1.05;
    margin-bottom: 1rem;
    letter-spacing: 0.01em;
    color: var(--color-white);
    text-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.selfie__subtitle {
    font-size: 1.125rem;
    color: var(--color-white);
    max-width: 520px;
    margin: 0 auto 0.75rem;
    font-weight: 500;
}

.selfie__privacy {
    font-size: 0.8rem;
    color: var(--color-gray);
    opacity: 0.75;
}

/* --- Stage + state switching --- */
.selfie-stage {
    background: rgba(36, 36, 66, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--radius-lg);
    border: 2px solid var(--color-gold);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(212, 168, 67, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    padding: 2.5rem 1.5rem;
    min-height: 460px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Gold inner frame accent */
.selfie-stage::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(212, 168, 67, 0.4);
    border-radius: calc(var(--radius-lg) - 6px);
    pointer-events: none;
}

.selfie-state {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.selfie-stage[data-state="choice"] .selfie-state--choice { display: flex; }
.selfie-stage[data-state="camera"] .selfie-state--camera { display: flex; }
.selfie-stage[data-state="loading"] .selfie-state--loading { display: flex; }
.selfie-stage[data-state="result"] .selfie-state--result { display: flex; }
.selfie-stage[data-state="error"] .selfie-state--error { display: flex; }

/* --- Buttons --- */
.selfie-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    min-height: 48px;
}

.selfie-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.selfie-btn--gold {
    background: var(--color-gold);
    color: var(--color-dark);
}

.selfie-btn--gold:hover:not(:disabled) {
    background: var(--color-gold-dark);
    color: var(--color-dark);
}

.selfie-btn--ghost {
    background: transparent;
    color: var(--color-gold);
    border-color: var(--color-gold);
}

.selfie-btn--ghost:hover:not(:disabled) {
    background: rgba(212, 168, 67, 0.12);
    color: var(--color-white);
}

/* --- Choice state --- */
.selfie-choice-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    width: 100%;
    max-width: 520px;
}

@media (min-width: 640px) {
    .selfie-choice-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.selfie-choice-card {
    background: var(--color-dark);
    border: 2px solid rgba(212, 168, 67, 0.35);
    border-radius: var(--radius-md);
    padding: 1.5rem 1.25rem;
    color: var(--color-white);
    font-family: inherit;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    min-height: 160px;
}

.selfie-choice-card:hover {
    border-color: var(--color-gold);
    background: rgba(212, 168, 67, 0.08);
    transform: translateY(-2px);
}

.selfie-choice-card__icon {
    font-size: 2.5rem;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.selfie-choice-card__label {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-white);
}

.selfie-choice-card__sub {
    font-size: 0.85rem;
    color: var(--color-gray);
}

.selfie-choice-tip {
    font-size: 0.85rem;
    color: var(--color-gray);
    text-align: center;
    max-width: 380px;
}

.selfie-privacy-note {
    font-size: 0.75rem;
    color: var(--color-gray);
    text-align: center;
    max-width: 380px;
    opacity: 0.7;
    margin-top: -0.5rem;
}

/* --- Camera state --- */
.selfie-camera {
    position: relative;
    width: 100%;
    max-width: 480px;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
    border: 3px solid var(--color-gold);
}

#selfie-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Mirror so users see themselves naturally */
    transform: scaleX(-1);
}

.selfie-camera__overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(
        ellipse 60% 75% at center 45%,
        transparent 60%,
        rgba(0, 0, 0, 0.45) 100%
    );
}

.selfie-camera-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 480px;
    gap: 1rem;
}

.selfie-camera-actions__spacer {
    width: 80px;
    visibility: hidden;
}

.selfie-shutter {
    position: relative;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}

.selfie-shutter__ring {
    position: absolute;
    inset: 0;
    border: 4px solid var(--color-gold);
    border-radius: 50%;
}

.selfie-shutter__dot {
    position: absolute;
    inset: 8px;
    background: var(--color-gold);
    border-radius: 50%;
    transition: transform 0.1s ease;
}

.selfie-shutter:active .selfie-shutter__dot {
    transform: scale(0.9);
}

/* --- Loading state --- */
.selfie-spinner {
    width: 56px;
    height: 56px;
    border: 4px solid rgba(212, 168, 67, 0.2);
    border-top-color: var(--color-gold);
    border-radius: 50%;
    animation: selfie-spin 1s linear infinite;
}

@keyframes selfie-spin {
    to { transform: rotate(360deg); }
}

.selfie-loading-text {
    font-size: 1.125rem;
    font-weight: 600;
    text-align: center;
}

.selfie-loading-sub {
    font-size: 0.85rem;
    color: var(--color-gray);
    text-align: center;
}

@media (prefers-reduced-motion: reduce) {
    .selfie-spinner {
        animation: none;
        border-top-color: rgba(212, 168, 67, 0.6);
    }
}

/* --- Result state --- */
.selfie-result-wrap {
    width: 100%;
    max-width: 360px;
    display: flex;
    justify-content: center;
}

#selfie-frame-canvas {
    width: 100%;
    height: auto;
    max-width: 100%;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.selfie-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    max-width: 360px;
}

@media (min-width: 640px) {
    .selfie-actions {
        flex-direction: row;
        max-width: 540px;
        justify-content: center;
    }
    .selfie-actions .selfie-btn {
        flex: 1;
    }
}

.selfie-share-fallback {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    background: var(--color-dark);
    border: 1px solid rgba(212, 168, 67, 0.3);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 540px;
}

.selfie-share-fallback p {
    font-size: 0.9rem;
    color: var(--color-gray);
    margin-bottom: 1rem;
    text-align: center;
}

.selfie-share-fallback__actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

@media (min-width: 480px) {
    .selfie-share-fallback__actions {
        flex-direction: row;
    }
    .selfie-share-fallback__actions .selfie-btn {
        flex: 1;
    }
}

/* --- Error state --- */
.selfie-error-icon {
    font-size: 3rem;
    color: var(--color-gold);
}

.selfie-error-text {
    font-size: 1rem;
    color: var(--color-white);
    text-align: center;
    max-width: 380px;
}

/* --- Footer --- */
.selfie-footer {
    text-align: center;
    padding: 2rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.8rem;
    color: var(--color-gray);
}

.selfie-footer a {
    color: var(--color-gold);
    margin: 0 0.25rem;
}

.selfie-footer p {
    margin-bottom: 0.25rem;
}

/* --- Cookie Banner --- */
.selfie-cookie-banner {
    position: fixed;
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%);
    width: calc(100% - 2rem);
    max-width: 640px;
    background: var(--color-dark-2);
    border: 1px solid rgba(212, 168, 67, 0.35);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    z-index: 1000;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    color: var(--color-white);
}

.selfie-cookie-banner__content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    text-align: center;
}

.selfie-cookie-banner__content p {
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
}

.selfie-cookie-banner__buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.selfie-cookie-banner__buttons .selfie-btn {
    min-height: 40px;
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
}

@media (min-width: 640px) {
    .selfie-cookie-banner__content {
        flex-direction: row;
        text-align: left;
    }
    .selfie-cookie-banner__buttons {
        flex-shrink: 0;
    }
}
