/* ==========================================================================
   HyperDex Design-System – angelehnt an Apples "Liquid Glass"
   Wird von WebApp und Mobile eingebunden: _content/HyperDex.SharedUi/hyperdex.css
   ========================================================================== */

:root {
    color-scheme: light dark;

    --hd-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    /* Flächen & Text */
    --hd-bg: #e9edf6;
    --hd-text: #0d0f17;
    --hd-text-2: rgba(13, 15, 23, 0.62);
    --hd-text-3: rgba(13, 15, 23, 0.42);
    --hd-accent: #0a84ff;
    --hd-accent-text: #ffffff;
    --hd-danger: #ff3b30;

    /* Glas */
    --hd-glass-fill: rgba(255, 255, 255, 0.42);
    --hd-glass-fill-strong: rgba(255, 255, 255, 0.66);
    --hd-glass-fill-hover: rgba(255, 255, 255, 0.58);
    --hd-glass-border: rgba(255, 255, 255, 0.75);
    --hd-glass-rim-top: rgba(255, 255, 255, 0.95);
    --hd-glass-rim-bottom: rgba(255, 255, 255, 0.25);
    --hd-glass-sheen: rgba(255, 255, 255, 0.55);
    --hd-glass-blur: 24px;
    --hd-glass-saturate: 185%;
    --hd-shadow: 0 12px 40px rgba(28, 38, 80, 0.16), 0 2px 8px rgba(28, 38, 80, 0.08);
    --hd-shadow-lift: 0 22px 60px rgba(28, 38, 80, 0.24), 0 4px 14px rgba(28, 38, 80, 0.12);

    /* Hintergrund-Farbflächen, die durch das Glas schimmern */
    --hd-blob-1: #ffb340;
    --hd-blob-2: #ff4f7b;
    --hd-blob-3: #4f8dff;
    --hd-blob-4: #3fdc8a;
    --hd-blob-opacity: 0.55;

    /* Formen */
    --hd-radius-xl: 36px;
    --hd-radius-l: 28px;
    --hd-radius-m: 20px;
    --hd-radius-s: 14px;
    --hd-radius-pill: 999px;

    --hd-ease: cubic-bezier(0.32, 0.72, 0, 1);
    --hd-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dunkles Theme: automatisch (System) oder manuell über <html data-theme="dark"> */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --hd-bg: #07080d;
        --hd-text: #f5f6fb;
        --hd-text-2: rgba(245, 246, 251, 0.66);
        --hd-text-3: rgba(245, 246, 251, 0.42);
        --hd-accent: #0a84ff;

        --hd-glass-fill: rgba(255, 255, 255, 0.08);
        --hd-glass-fill-strong: rgba(30, 32, 44, 0.62);
        --hd-glass-fill-hover: rgba(255, 255, 255, 0.14);
        --hd-glass-border: rgba(255, 255, 255, 0.16);
        --hd-glass-rim-top: rgba(255, 255, 255, 0.32);
        --hd-glass-rim-bottom: rgba(255, 255, 255, 0.05);
        --hd-glass-sheen: rgba(255, 255, 255, 0.14);
        --hd-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
        --hd-shadow-lift: 0 22px 60px rgba(0, 0, 0, 0.6), 0 4px 14px rgba(0, 0, 0, 0.35);

        --hd-blob-opacity: 0.42;
    }
}

:root[data-theme="dark"] {
    --hd-bg: #07080d;
    --hd-text: #f5f6fb;
    --hd-text-2: rgba(245, 246, 251, 0.66);
    --hd-text-3: rgba(245, 246, 251, 0.42);
    --hd-accent: #0a84ff;

    --hd-glass-fill: rgba(255, 255, 255, 0.08);
    --hd-glass-fill-strong: rgba(30, 32, 44, 0.62);
    --hd-glass-fill-hover: rgba(255, 255, 255, 0.14);
    --hd-glass-border: rgba(255, 255, 255, 0.16);
    --hd-glass-rim-top: rgba(255, 255, 255, 0.32);
    --hd-glass-rim-bottom: rgba(255, 255, 255, 0.05);
    --hd-glass-sheen: rgba(255, 255, 255, 0.14);
    --hd-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
    --hd-shadow-lift: 0 22px 60px rgba(0, 0, 0, 0.6), 0 4px 14px rgba(0, 0, 0, 0.35);

    --hd-blob-opacity: 0.42;
    color-scheme: dark;
}

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

/* --- Basis ---------------------------------------------------------------- */

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

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--hd-bg);
    color: var(--hd-text);
    font-family: var(--hd-font);
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 {
    margin: 0;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

h1:focus {
    outline: none;
}

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

button {
    font: inherit;
    color: inherit;
}

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

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--hd-accent) 60%, transparent);
    outline-offset: 2px;
}

/* --- Hintergrund ------------------------------------------------------------ */

.hd-backdrop {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

    .hd-backdrop span {
        position: absolute;
        width: 55vmax;
        height: 55vmax;
        border-radius: 50%;
        filter: blur(70px);
        opacity: var(--hd-blob-opacity);
        animation: hd-drift 26s ease-in-out infinite alternate;
    }

        .hd-backdrop span:nth-child(1) { background: var(--hd-blob-1); top: -20vmax; left: -15vmax; }
        .hd-backdrop span:nth-child(2) { background: var(--hd-blob-2); top: 10vmax; right: -22vmax; animation-delay: -8s; }
        .hd-backdrop span:nth-child(3) { background: var(--hd-blob-3); bottom: -25vmax; left: 10vmax; animation-delay: -16s; }
        .hd-backdrop span:nth-child(4) { background: var(--hd-blob-4); bottom: -10vmax; right: 5vmax; width: 35vmax; height: 35vmax; animation-delay: -4s; }

@keyframes hd-drift {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(6vmax, 4vmax) scale(1.08); }
    100% { transform: translate(-4vmax, 7vmax) scale(0.95); }
}

/* --- Glas-Material ----------------------------------------------------------- */

.glass {
    position: relative;
    isolation: isolate;
    background: var(--hd-glass-fill);
    -webkit-backdrop-filter: blur(var(--hd-glass-blur)) saturate(var(--hd-glass-saturate));
    backdrop-filter: blur(var(--hd-glass-blur)) saturate(var(--hd-glass-saturate));
    border: 1px solid var(--hd-glass-border);
    border-radius: var(--hd-radius-l);
    box-shadow:
        inset 0 1px 1px var(--hd-glass-rim-top),
        inset 0 -1px 1px var(--hd-glass-rim-bottom),
        var(--hd-shadow);
}

    /* Lichtreflex auf der Oberfläche */
    .glass::before {
        content: "";
        position: absolute;
        inset: 0;
        z-index: -1;
        border-radius: inherit;
        pointer-events: none;
        background:
            radial-gradient(120% 60% at 15% 0%, var(--hd-glass-sheen) 0%, transparent 55%),
            linear-gradient(160deg, transparent 60%, color-mix(in srgb, var(--hd-glass-sheen) 45%, transparent) 100%);
    }

.glass-strong {
    background: var(--hd-glass-fill-strong);
}

/* Fallback für Umgebungen ohne backdrop-filter */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .glass {
        background: var(--hd-glass-fill-strong);
    }
}

/* --- Buttons ----------------------------------------------------------------- */

.glass-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 40px;
    padding: 0 1.1rem;
    border-radius: var(--hd-radius-pill);
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.35s var(--hd-spring), background 0.2s;
}

    .glass-button:hover {
        background: var(--hd-glass-fill-hover);
    }

    .glass-button:active {
        transform: scale(0.95);
    }

.glass-icon-button {
    width: 40px;
    min-height: 40px;
    padding: 0;
}

/* --- Fehleranzeige ----------------------------------------------------------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 50%;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 1000;
    width: min(560px, calc(100% - 32px));
    padding: 0.9rem 3rem 0.9rem 1.2rem;
    border-radius: var(--hd-radius-m);
    background: color-mix(in srgb, var(--hd-danger) 22%, var(--hd-glass-fill-strong));
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--hd-glass-border);
    box-shadow: var(--hd-shadow);
    color: var(--hd-text);
}

    #blazor-error-ui .reload {
        font-weight: 600;
    }

    #blazor-error-ui .dismiss {
        position: absolute;
        right: 1rem;
        top: 0.85rem;
        cursor: pointer;
    }

.blazor-error-boundary {
    padding: 1rem 1.2rem;
    border-radius: var(--hd-radius-m);
    background: color-mix(in srgb, var(--hd-danger) 85%, transparent);
    color: white;
}

    .blazor-error-boundary::after {
        content: "Es ist ein Fehler aufgetreten.";
    }

/* --- Seitenaufbau ----------------------------------------------------------- */

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

    .page-header .actions {
        display: flex;
        gap: 8px;
        flex: none;
    }

.large-title {
    font-size: clamp(2.1rem, 6vw, 3rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    overflow-wrap: break-word; /* nur Wörter trennen, die allein zu lang sind ("anywhere" ließe Titel auf Buchstabenbreite schrumpfen) */
}

.subtitle {
    margin: 6px 0 0;
    color: var(--hd-text-2);
    font-weight: 500;
}

.section-title {
    margin: 32px 0 10px 4px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--hd-text-2);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin: 0 0 10px -4px;
    color: var(--hd-accent);
    font-weight: 600;
    text-decoration: none;
}

    .back-link svg {
        width: 22px;
        height: 22px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2.4;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 18px;
}

@media (max-width: 520px) {
    .card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 24px;
    text-align: center;
    border-radius: var(--hd-radius-xl);
}

    .empty-state h2 {
        font-size: 1.4rem;
    }

    .empty-state p {
        margin: 0 0 8px;
        max-width: 380px;
        color: var(--hd-text-2);
    }

    .empty-state .empty-icon {
        width: 56px;
        height: 56px;
        fill: none;
        stroke: var(--hd-text-3);
        stroke-width: 1.6;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

/* Gemeinsame Icon-Größe in Glas-Buttons */
.glass-button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.glass-button.destructive {
    color: var(--hd-danger);
}

/* --- Primärer Button ----------------------------------------------------------- */

.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 46px;
    padding: 0 1.4rem;
    border: 0;
    border-radius: var(--hd-radius-pill);
    background: linear-gradient(180deg, color-mix(in srgb, var(--hd-accent) 80%, white), var(--hd-accent));
    color: var(--hd-accent-text);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    box-shadow:
        inset 0 1px 1px rgba(255, 255, 255, 0.55),
        0 8px 22px color-mix(in srgb, var(--hd-accent) 38%, transparent);
    transition: transform 0.35s var(--hd-spring), opacity 0.2s;
}

    .primary-button:active {
        transform: scale(0.96);
    }

    .primary-button:disabled {
        opacity: 0.45;
        cursor: default;
        transform: none;
    }

    .primary-button.destructive {
        --hd-accent: var(--hd-danger);
    }

/* --- Eingabefeld --------------------------------------------------------------- */

.glass-input {
    width: 100%;
    height: 50px;
    padding: 0 16px;
    border: 1px solid var(--hd-glass-border);
    border-radius: var(--hd-radius-m);
    background: var(--hd-glass-fill);
    color: var(--hd-text);
    font: inherit;
    font-size: 1.05rem;
    outline: 0;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s;
}

    .glass-input::placeholder {
        color: var(--hd-text-3);
    }

    .glass-input:focus {
        box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08), 0 0 0 4px color-mix(in srgb, var(--hd-accent) 28%, transparent);
    }

/* --- Kartenbild mit Platzhalter (CardImage) ---------------------------------- */

.card-img {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    overflow: hidden;
}

    .card-img img {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: inherit;
    }

.card-img-fallback {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 10%;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.2;
    opacity: 0.55;
    overflow-wrap: anywhere;
}

/* --- Nachladen beim Scrollen (LoadMoreSentinel) ------------------------------- */

.load-more {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 24px 0;
}

.load-more-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--hd-text-3);
    animation: load-more-bounce 1s ease-in-out infinite;
}

    .load-more-dot:nth-child(2) { animation-delay: 0.15s; }
    .load-more-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes load-more-bounce {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(-6px); opacity: 1; }
}

/* --- Aktionen in der Kartendetailansicht ------------------------------------- */

.detail-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

    .detail-actions .note {
        margin: 0;
        color: var(--hd-text-2);
        font-size: 0.9rem;
    }

    .detail-actions .variant-pill {
        align-self: flex-start;
        padding: 4px 12px;
        border-radius: var(--hd-radius-pill);
        background: linear-gradient(135deg, #7c5cff, #2fb7ff);
        color: #fff;
        font-size: 0.82rem;
        font-weight: 700;
    }

    .detail-actions .glass-button,
    .detail-actions .primary-button {
        min-height: 46px;
    }

/* --- Binder-Designs ------------------------------------------------------------
   Jedes Design ist eine Klasse auf einem .binder-surface-Element.
   Verfügbare Variablen: --binder-color (gewählte Farbe), --binder-ink (Schriftfarbe).
   Neues Design: Klasse hier anlegen + Eintrag in Binder/BinderDesigns.cs.
   -------------------------------------------------------------------------------- */

.binder-surface {
    --binder-color: #1c1c1e;
    --binder-ink: #ffffff;
    position: relative;
    background-color: var(--binder-color);
    color: var(--binder-ink);
}

/* Klassisch: matter Kunstleder-Look */
.design-classic {
    background-image:
        linear-gradient(160deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0) 38%, rgba(0, 0, 0, 0.22) 100%),
        radial-gradient(rgba(255, 255, 255, 0.05) 0.6px, transparent 0.8px),
        radial-gradient(rgba(0, 0, 0, 0.12) 0.6px, transparent 0.8px);
    background-size: 100% 100%, 3px 3px, 4px 4px;
    background-position: 0 0, 0 0, 1px 2px;
}

/* Glanz: lackierte Oberfläche mit starkem Lichtreflex */
.design-gloss {
    background-image:
        linear-gradient(145deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.12) 30%, rgba(255, 255, 255, 0) 46%, rgba(0, 0, 0, 0.28) 100%),
        radial-gradient(120% 80% at 80% 110%, rgba(255, 255, 255, 0.18), transparent 60%);
}

/* Carbon: Kohlefaser-Gewebe in der gewählten Farbe */
.design-carbon {
    background-image:
        linear-gradient(160deg, rgba(255, 255, 255, 0.16) 0%, transparent 42%, rgba(0, 0, 0, 0.34) 100%),
        linear-gradient(45deg, rgba(0, 0, 0, 0.35) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, 0.35) 75%),
        linear-gradient(45deg, rgba(0, 0, 0, 0.35) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, 0.35) 75%),
        linear-gradient(-45deg, rgba(255, 255, 255, 0.06) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.06) 75%);
    background-size: 100% 100%, 8px 8px, 8px 8px, 8px 8px;
    background-position: 0 0, 0 0, 4px 4px, 0 0;
}

/* Holo: schimmernde Regenbogenfolie über der gewählten Farbe */
.design-holo {
    background-image:
        linear-gradient(160deg, rgba(255, 255, 255, 0.4) 0%, transparent 38%, rgba(0, 0, 0, 0.22) 100%),
        conic-gradient(from 200deg at 65% 35%,
            rgba(255, 120, 200, 0.6), rgba(120, 200, 255, 0.6), rgba(140, 255, 190, 0.6),
            rgba(255, 240, 130, 0.6), rgba(255, 160, 120, 0.6), rgba(255, 120, 200, 0.6));
    background-size: 100% 100%, 220% 220%;
    animation: holo-shift 9s ease-in-out infinite alternate;
}

@keyframes holo-shift {
    from { background-position: 0 0, 0% 0%; }
    to { background-position: 0 0, 100% 100%; }
}

/* --- Hilfsklassen ------------------------------------------------------------ */

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

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

/* --- Schalter (iOS-Stil) ---------------------------------------------------- */

.toggle-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-radius: var(--hd-radius-m);
    background: var(--hd-glass-fill);
    border: 1px solid var(--hd-glass-border);
    cursor: pointer;
}

.toggle-title {
    display: block;
    font-weight: 600;
}

.toggle-hint {
    display: block;
    margin-top: 2px;
    font-size: 0.82rem;
    color: var(--hd-text-2);
}

.switch {
    flex: none;
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    width: 52px;
    height: 32px;
    margin: 0;
    border-radius: 999px;
    background: color-mix(in srgb, var(--hd-text) 18%, transparent);
    cursor: pointer;
    transition: background 0.25s;
}

    .switch::after {
        content: "";
        position: absolute;
        top: 2px;
        left: 2px;
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background: #fff;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
        transition: transform 0.35s var(--hd-spring);
    }

    .switch:checked {
        background: #34c759;
    }

        .switch:checked::after {
            transform: translateX(20px);
        }

    .switch:disabled {
        opacity: 0.45;
        cursor: not-allowed;
    }

    .switch:focus-visible {
        outline: 3px solid color-mix(in srgb, var(--hd-accent) 55%, transparent);
        outline-offset: 2px;
    }

/* --- Einträge im Drei-Punkte-Menü (MoreMenu) ------------------------------------ */

.hd-menu-item {
    display: block;
    width: 100%;
    padding: 11px 12px;
    border: 0;
    border-radius: calc(var(--hd-radius-m) - 4px);
    background: transparent;
    color: var(--hd-text);
    font: inherit;
    font-size: 0.94rem;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}

    .hd-menu-item:hover {
        background: var(--hd-glass-fill-hover);
    }

    .hd-menu-item.is-danger {
        color: var(--hd-danger);
    }
