/* =================================================================
   Songrequest – Gastansicht
   Aesthetic: Late-night neon. Dark base, warm gradient atmosphere,
   distinctive grotesque type, generous spacing, satisfying motion.

   Theme-Switch:
   - Dark ist der Default und sitzt in :root.
   - Light wird per body.theme-light (immer) oder body.theme-auto
     (wenn das OS auf "light" steht) am Ende der Datei überschrieben.
   ================================================================= */

:root {
    --bg-deep:     #0a0812;
    --bg-card:     rgba(255, 255, 255, 0.04);
    --bg-card-hi:  rgba(255, 255, 255, 0.08);
    --border:      rgba(255, 255, 255, 0.08);
    --border-hi:   rgba(255, 255, 255, 0.18);

    --text:        #f4f1ea;
    --text-dim:    rgba(244, 241, 234, 0.62);
    --text-mute:   rgba(244, 241, 234, 0.4);

    --accent:      #1DB954;
    --accent-hi:   #1ed760;

    /* warmes Gegenlicht – sorgt für die Neon-Stimmung */
    --hot:         #ff6b4a;
    --pink:        #ff3d8a;
    --gold:        #ffd166;

    --error:       #ef4444;
    --warn:        #f5a524;

    --radius-sm:   10px;
    --radius:      16px;
    --radius-lg:   22px;

    --ease:        cubic-bezier(0.22, 1, 0.36, 1);

    /* Theme-spezifische Werte – werden im Light-Block am Dateiende überschrieben */
    --bg-atmo-pink:   rgba(255, 61, 138, 0.28);
    --bg-atmo-orange: rgba(255, 107, 74, 0.22);
    --bg-atmo-green:  rgba(29, 185, 84, 0.18);
    --brand-bg:       rgba(0, 0, 0, 0.3);
    --title-grad-1:   #ffffff;
    --title-grad-2:   #ffd166;
    --title-grad-3:   #ff6b4a;
    --e-badge-bg:     rgba(255, 255, 255, 0.1);
    --statusbar-bg:   rgba(10, 8, 18, 0.85);
    --toast-bg:       rgba(10, 8, 18, 0.96);
    --toast-shadow:   0 12px 40px rgba(0, 0, 0, 0.6),
                      0 0 0 1px rgba(255, 255, 255, 0.04);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-deep);
    color: var(--text);
    font-family: 'Bricolage Grotesque', system-ui, -apple-system, sans-serif;
    font-feature-settings: "ss01", "cv11";
    font-size: 16px;
    line-height: 1.5;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    /* Sicheres Bottom-Padding für iPhone-Home-Indicator usw. */
    padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- Hintergrund-Atmosphäre ---------- */
.bg-gradient {
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(800px 600px at 110% -10%,  var(--bg-atmo-pink),   transparent 60%),
        radial-gradient(700px 700px at -10% 30%,   var(--bg-atmo-orange), transparent 60%),
        radial-gradient(900px 900px at 50% 120%,   var(--bg-atmo-green),  transparent 65%);
    filter: saturate(1.1);
}

.bg-noise {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.08 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    opacity: 0.5;
    pointer-events: none;
    mix-blend-mode: overlay;
}

/* ---------- Layout ---------- */
.app {
    position: relative;
    max-width: 540px;
    margin: 0 auto;
    padding: 28px 20px 120px;
    min-height: 100dvh;
}

/* ---------- Header ---------- */
.app-header {
    margin-bottom: 32px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 10px;
    background: var(--brand-bg);
    border: 1px solid var(--border);
    border-radius: 99px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-dim);
    backdrop-filter: blur(8px);
    margin-bottom: 18px;
}

.brand-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 0 rgba(29, 185, 84, 0.6);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(29, 185, 84, 0.5); }
    50%      { box-shadow: 0 0 0 6px rgba(29, 185, 84, 0); }
}

.event-title {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-weight: 700;
    font-size: clamp(2.2rem, 9vw, 3rem);
    line-height: 1.02;
    letter-spacing: -0.02em;
    margin: 0 0 12px;
    font-variation-settings: "opsz" 96;

    /* Verlauf vom hellen Akzent ins warme Gegenlicht (Dark) bzw. von dunkler
       Wein-Note über Coral nach Burnt-Amber (Light). */
    background: linear-gradient(135deg,
                  var(--title-grad-1) 0%,
                  var(--title-grad-2) 40%,
                  var(--title-grad-3) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.event-subtitle {
    color: var(--text-dim);
    margin: 0;
    font-size: 1rem;
    max-width: 32ch;
}

/* ---------- Felder ---------- */
.field {
    margin-bottom: 18px;
    opacity: 0;
    transform: translateY(12px);
    animation: rise 0.6s var(--ease) forwards;
    animation-delay: calc(var(--i, 0) * 80ms + 100ms);
}
.field[data-stagger="1"] { --i: 1; }
.field[data-stagger="2"] { --i: 2; }

@keyframes rise {
    to { opacity: 1; transform: translateY(0); }
}

.field-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-mute);
    margin-bottom: 8px;
    padding-left: 4px;
}

.field-input {
    display: block;
    width: 100%;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 500;
    -webkit-appearance: none;
    appearance: none;
    transition: background 0.2s, border-color 0.2s, transform 0.1s;
}
.field-input:focus {
    outline: none;
    border-color: var(--border-hi);
    background: var(--bg-card-hi);
}
.field-input::placeholder { color: var(--text-mute); }

/* Search hat einen Spinner-Slot */
.search-wrap { position: relative; }
.search-spinner {
    position: absolute;
    right: 18px;
    top: 50%;
    width: 18px;
    height: 18px;
    margin-top: -9px;
    border: 2px solid var(--border-hi);
    border-top-color: var(--hot);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
}
.search-spinner.active {
    opacity: 1;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Ergebnisse ---------- */
.results {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    opacity: 0;
    transform: translateY(12px);
    animation: rise 0.6s var(--ease) forwards;
    animation-delay: 260ms;
}

.result {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: background 0.2s, border-color 0.2s, transform 0.15s var(--ease);
    animation: drop 0.45s var(--ease) backwards;
}
.result:hover { background: var(--bg-card-hi); }

@keyframes drop {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.result.is-sending { opacity: 0.5; pointer-events: none; }
.result.is-sent {
    border-color: var(--accent);
    background: rgba(29, 185, 84, 0.1);
}

.result-art {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: var(--bg-card-hi);
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.result-art.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-mute);
    font-size: 22px;
}

.result-info {
    min-width: 0;
}
.result-title {
    font-weight: 600;
    font-size: 0.98rem;
    line-height: 1.25;
    margin: 0 0 2px;

    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
}
.result-artist {
    color: var(--text-dim);
    font-size: 0.85rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
}
.result-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    font-size: 0.72rem;
    color: var(--text-mute);
}
.result-meta .e-badge {
    display: inline-block;
    background: var(--e-badge-bg);
    color: var(--text-dim);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

/* Action-Button im Result */
.btn-wish {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 99px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    min-height: 40px;
    min-width: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-wish:hover { background: var(--accent-hi); }
.btn-wish:active { transform: scale(0.96); }
.btn-wish:disabled {
    background: var(--bg-card-hi);
    color: var(--text-mute);
    cursor: not-allowed;
}
.btn-wish.is-loading {
    background: var(--bg-card-hi);
    color: var(--text);
    cursor: progress;
}

/* ---------- Empty/Hint ---------- */
.empty-hint {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-mute);
    opacity: 0;
    animation: rise 0.6s var(--ease) forwards;
    animation-delay: 360ms;
}
.empty-icon {
    font-size: 3rem;
    color: var(--hot);
    margin-bottom: 8px;
    font-weight: 400;
    opacity: 0.85;
}
.empty-hint p { margin: 0; line-height: 1.5; }
.empty-hint.hidden { display: none; }

/* ---------- Status-Card ---------- */
.state-card {
    margin-top: 30px;
    padding: 24px;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border);
}
.state-card strong { display: block; font-size: 1.2rem; margin-bottom: 6px; }
.state-card p     { margin: 0; color: var(--text-dim); }
.state-error      { border-color: rgba(239, 68, 68, 0.4); }
.state-paused     { border-color: rgba(245, 165, 36, 0.4); }

/* ---------- Status-Bar (fixed bottom) ---------- */
.status-bar {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--statusbar-bg);
    border: 1px solid var(--border);
    border-radius: 99px;
    font-size: 0.82rem;
    color: var(--text-dim);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 5;
    transition: opacity 0.3s;
    bottom: calc(20px + env(safe-area-inset-bottom));
}
.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-mute);
}
.status-bar.ok    .status-dot { background: var(--accent); }
.status-bar.warn  .status-dot { background: var(--warn); }
.status-bar.full  .status-dot { background: var(--hot); }

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 70px;
    transform: translate(-50%, 30px);
    background: var(--toast-bg);
    border: 1px solid var(--border-hi);
    border-radius: var(--radius);
    padding: 14px 20px;
    color: var(--text);
    font-weight: 500;
    box-shadow: var(--toast-shadow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease), transform 0.4s var(--ease);
    z-index: 10;
    max-width: calc(100vw - 40px);
    text-align: center;
    bottom: calc(70px + env(safe-area-inset-bottom));
}
.toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
    pointer-events: auto;
}
.toast.success { border-color: var(--accent); }
.toast.error   { border-color: var(--error); }
.toast .toast-title { font-weight: 700; }
.toast .toast-sub   { font-weight: 400; color: var(--text-dim); font-size: 0.85rem; margin-top: 2px; }

/* ---------- Small mobile tweaks ---------- */
@media (max-width: 360px) {
    .app { padding-left: 16px; padding-right: 16px; }
    .field-input { padding: 16px; font-size: 1rem; }
    .result { grid-template-columns: 48px 1fr auto; gap: 10px; padding: 10px; }
    .result-art { width: 48px; height: 48px; }
}

/* ---------- Reduced motion respect ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001s !important;
        animation-delay: 0s !important;
        transition-duration: 0.001s !important;
    }
}

/* =================================================================
   LIGHT-THEME OVERRIDES
   Aktiv bei body.theme-light (immer), und bei body.theme-auto wenn
   das OS auf "light" steht.
   Hinweis: gleiche Werte stehen bewusst in zwei Selektor-Blöcken,
   weil sich "immer light" und "media-gewrapptes auto" nicht in
   einem einzigen Selektor zusammenfassen lassen. Bei Anpassungen
   beide Blöcke gleichzeitig pflegen.
   ================================================================= */

body.theme-light {
    /* Palette */
    --bg-deep:        #fdfaf2;
    --bg-card:        rgba(255, 255, 255, 0.68);
    --bg-card-hi:     rgba(255, 255, 255, 0.84);
    --border:         rgba(28, 19, 10, 0.12);
    --border-hi:      rgba(28, 19, 10, 0.22);
    --text:           #1c130a;
    --text-dim:       rgba(28, 19, 10, 0.65);
    --text-mute:      rgba(28, 19, 10, 0.45);

    /* Atmosphäre – sanfter, pastelliger */
    --bg-atmo-pink:   rgba(255, 61, 138, 0.16);
    --bg-atmo-orange: rgba(255, 140, 70, 0.14);
    --bg-atmo-green:  rgba(29, 185, 84, 0.12);

    /* UI-Akzente */
    --brand-bg:       rgba(255, 255, 255, 0.65);
    --title-grad-1:   #5a1c3d;
    --title-grad-2:   #d24e22;
    --title-grad-3:   #9a4b08;
    --e-badge-bg:     rgba(28, 19, 10, 0.10);
    --statusbar-bg:   rgba(255, 255, 255, 0.92);
    --toast-bg:       rgba(255, 255, 255, 0.96);
    --toast-shadow:   0 12px 40px rgba(0, 0, 0, 0.15),
                      0 0 0 1px rgba(28, 19, 10, 0.06);
}

@media (prefers-color-scheme: light) {
    body.theme-auto {
        --bg-deep:        #fdfaf2;
        --bg-card:        rgba(255, 255, 255, 0.68);
        --bg-card-hi:     rgba(255, 255, 255, 0.84);
        --border:         rgba(28, 19, 10, 0.12);
        --border-hi:      rgba(28, 19, 10, 0.22);
        --text:           #1c130a;
        --text-dim:       rgba(28, 19, 10, 0.65);
        --text-mute:      rgba(28, 19, 10, 0.45);

        --bg-atmo-pink:   rgba(255, 61, 138, 0.16);
        --bg-atmo-orange: rgba(255, 140, 70, 0.14);
        --bg-atmo-green:  rgba(29, 185, 84, 0.12);

        --brand-bg:       rgba(255, 255, 255, 0.65);
        --title-grad-1:   #5a1c3d;
        --title-grad-2:   #d24e22;
        --title-grad-3:   #9a4b08;
        --e-badge-bg:     rgba(28, 19, 10, 0.10);
        --statusbar-bg:   rgba(255, 255, 255, 0.92);
        --toast-bg:       rgba(255, 255, 255, 0.96);
        --toast-shadow:   0 12px 40px rgba(0, 0, 0, 0.15),
                          0 0 0 1px rgba(28, 19, 10, 0.06);
    }
}
