/* ==========================================================================
   MODAL, DIALOG & DRAWER STYLES (Native HTML5 <dialog> Components)
   ========================================================================== */

/* === Modal Tokens === */
:root {
    --modal-width: 100%;
    --modal-max-width: 640px;
    --modal-padding: 24px;
    --modal-border-radius: var(--radius-lg, 14px);
    --modal-background: var(--bg-card, #ffffff);
    --modal-shadow: var(--shadow-lg, 0 20px 40px rgba(15, 28, 46, 0.35));
    --modal-backdrop-color: color-mix(in srgb, var(--night-blue-deep, #0f1c2e) 72%, transparent);
    --modal-close-size: 24px;
    --modal-close-color: var(--snow-white, #ffffff);
    --modal-action-gap: 12px;
    --modal-action-divider: var(--border-color, #d1dfe4);
    --modal-action-bg: var(--bg-light, #f1faee);
}

/* === Native <dialog> Element & Modal Core === */
.modal {
    display: inline-block;
}

.modal__trigger {
    display: inline-block;
    cursor: pointer;
    user-select: none;
}

.modal__trigger:focus-visible {
    outline: 2px solid var(--primary-color, #e63946);
    outline-offset: 2px;
}

.modal__dialog {
    --modal-inset-block-start: calc(max(16px, env(safe-area-inset-top, 0px)) + 24px + 16px);
    --modal-inset-inline: max(16px, min(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px)));
    --modal-inset-block-end: max(16px, env(safe-area-inset-bottom, 0px));

    position: fixed;
    inset: var(--modal-inset-block-start) var(--modal-inset-inline) var(--modal-inset-block-end);
    margin: auto;
    width: var(--modal-width);
    max-width: var(--modal-max-width);
    max-height: calc(100dvh - var(--modal-inset-block-start) - var(--modal-inset-block-end));
    box-sizing: border-box;

    padding: 0;
    border: 1px solid var(--border-frost, rgba(168, 218, 220, 0.4));
    border-radius: var(--modal-border-radius);
    background: var(--modal-background);
    box-shadow: var(--modal-shadow);
    color: var(--text-dark, #1d3557);

    display: flex;
    flex-direction: column;
    overflow: visible;

    opacity: 0;
    transform: scale(0.95) translateY(10px);
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
                overlay 0.25s allow-discrete,
                display 0.25s allow-discrete;
}

.modal__dialog:not([open]) {
    display: none;
}

.modal__dialog:open {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.modal__dialog::backdrop {
    background: var(--modal-backdrop-color);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.25s ease,
                overlay 0.25s allow-discrete,
                display 0.25s allow-discrete;
}

.modal__dialog:open::backdrop {
    opacity: 1;
}

/* === Close Button (Positioned Outside Dialog, Top-Right) === */
.modal__close {
    position: absolute;
    inset-block-start: calc(-1 * (var(--modal-close-size) + 12px));
    inset-inline-end: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--modal-close-size);
    height: var(--modal-close-size);
    padding: 0;
    border: none;
    background: transparent;
    color: var(--modal-close-color);
    cursor: pointer;
    border-radius: 50%;
    transition: transform 0.15s ease, opacity 0.15s ease;
    opacity: 0.85;
}

.modal__close:hover {
    opacity: 1;
    transform: scale(1.1);
}

.modal__close:focus-visible {
    outline: 2px solid var(--snow-white, #ffffff);
    outline-offset: 2px;
}

.modal__close svg {
    width: 22px;
    height: 22px;
    display: block;
}

/* === Scrollable Modal Content === */
.modal__content {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding: var(--modal-padding);
    box-sizing: border-box;
    border-radius: var(--modal-border-radius);
}

/* === Action Buttons Footer === */
.modal__actions {
    display: flex;
    align-items: stretch;
    justify-content: flex-end;
    gap: var(--modal-action-gap);
    padding: 16px var(--modal-padding);
    border-top: 1px solid var(--modal-action-divider);
    background: var(--modal-action-bg);
    border-bottom-left-radius: var(--modal-border-radius);
    border-bottom-right-radius: var(--modal-border-radius);
    flex-shrink: 0;
}

.modal__actions--single {
    justify-content: stretch;
}

.modal__actions--single .modal__btn {
    width: 100%;
}

.modal__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: var(--radius-sm, 6px);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    border: 1px solid transparent;
}

.modal__btn--primary {
    background: var(--primary-color, #e63946);
    color: var(--snow-white, #ffffff);
}

.modal__btn--primary:hover {
    background: var(--primary-hover, #c92a37);
}

.modal__btn--secondary {
    background: var(--snow-white, #ffffff);
    border-color: var(--border-color, #d1dfe4);
    color: var(--text-dark, #1d3557);
}

.modal__btn--secondary:hover {
    background: var(--snow-light, #f1faee);
}

/* === Keyframe & Discrete Animations with @starting-style === */
@starting-style {
    .modal__dialog:open {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    .modal__dialog:open::backdrop {
        opacity: 0;
    }
}

/* === Reduced Motion Support === */
@media (prefers-reduced-motion: reduce) {
    .modal__dialog,
    .modal__dialog::backdrop,
    .drawer__dialog,
    .drawer__dialog::backdrop {
        transition: none !important;
    }
}

/* === Desktop Responsive Adjustments === */
@media (min-width: 768px) {
    .modal__dialog {
        --modal-max-width: 680px;
    }

    .modal__actions--single,
    .modal__actions--two-choice {
        flex-direction: row;
    }
}

/* ==========================================================================
   DOOR DETAIL & PRIZE STYLES (Inside .modal__content)
   ========================================================================== */

/* Door-Specific Modal Accent Mappings */
.modal__dialog[data-modal-dialog="1"],
.modal__dialog[data-modal-dialog="6"],
.modal__dialog[data-modal-dialog="11"],
.modal__dialog[data-modal-dialog="18"],
.modal__dialog[data-modal-dialog="23"] {
    --modal-accent: var(--accent-natural-rose, #CB1F42);
    --modal-accent-text: #cb1f42;
}

.modal__dialog[data-modal-dialog="2"],
.modal__dialog[data-modal-dialog="8"],
.modal__dialog[data-modal-dialog="13"],
.modal__dialog[data-modal-dialog="19"] {
    --modal-accent: var(--accent-arab-green, #00572E);
    --modal-accent-text: #00572e;
}

.modal__dialog[data-modal-dialog="3"],
.modal__dialog[data-modal-dialog="9"],
.modal__dialog[data-modal-dialog="15"],
.modal__dialog[data-modal-dialog="21"] {
    --modal-accent: var(--accent-orange-roughy, #CE5521);
    --modal-accent-text: #ce5521;
}

.modal__dialog[data-modal-dialog="4"],
.modal__dialog[data-modal-dialog="10"],
.modal__dialog[data-modal-dialog="16"],
.modal__dialog[data-modal-dialog="22"] {
    --modal-accent: var(--accent-dusky-peach, #D0AD99);
    --modal-accent-text: #8e543b;
}

.modal__dialog[data-modal-dialog="5"],
.modal__dialog[data-modal-dialog="12"],
.modal__dialog[data-modal-dialog="17"],
.modal__dialog[data-modal-dialog="24"] {
    --modal-accent: var(--accent-dark-indian-red, #B41B1E);
    --modal-accent-text: #b41b1e;
}

.modal__dialog[data-modal-dialog="7"],
.modal__dialog[data-modal-dialog="14"],
.modal__dialog[data-modal-dialog="20"] {
    --modal-accent: var(--accent-prune, #1F1E32);
    --modal-accent-text: #1f1e32;
}

.door-detail-header {
    border-bottom: 2px solid var(--snow-light, #f1faee);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.door-detail-badge {
    display: inline-block;
    background: color-mix(in srgb, var(--modal-accent, var(--primary-color)) 12%, var(--snow-white, #ffffff));
    color: var(--modal-accent-text, var(--modal-accent, var(--primary-color)));
    font-weight: 700;
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 8px;
    border: 1px solid color-mix(in srgb, var(--modal-accent, var(--primary-color)) 35%, transparent);
}

.door-detail-title {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--text-dark, #1d3557);
    margin: 0;
    line-height: 1.25;
}

.door-prizes-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.door-empty-note {
    color: var(--text-muted, #435c7a);
    font-style: italic;
    margin: 12px 0;
}

.prize-card {
    background: var(--snow-white, #ffffff);
    border: 1px solid var(--border-color, #d1dfe4);
    border-radius: var(--radius-md, 10px);
    padding: 18px;
    box-shadow: var(--shadow-md, 0 4px 16px rgba(15, 28, 46, 0.18));
}

.prize-custom-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--modal-accent-text, var(--modal-accent, var(--primary-color)));
    margin: 0 0 10px;
    border-bottom: 1px dashed color-mix(in srgb, var(--modal-accent, var(--primary-color)) 35%, transparent);
    padding-bottom: 6px;
}

.prize-main {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.prize-info {
    flex: 1 1 240px;
}

.prize-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 6px;
    color: var(--text-dark, #1d3557);
}

.prize-detail {
    font-size: 0.9rem;
    color: var(--text-muted, #435c7a);
    margin: 0 0 8px;
    line-height: 1.45;
}

.prize-value {
    font-size: 0.95rem;
    color: var(--modal-accent-text, var(--modal-accent, var(--primary-color)));
    margin: 4px 0 0;
}

.prize-sponsor-box {
    flex: 0 0 180px;
    background: var(--snow-light, #f1faee);
    border: 1px solid var(--border-color, #d1dfe4);
    border-radius: var(--radius-sm, 6px);
    padding: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.sponsor-label {
    font-size: 0.72rem;
    color: var(--text-muted, #435c7a);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sponsor-logo {
    max-height: 48px;
    max-width: 130px;
    object-fit: contain;
}

.sponsor-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.sponsor-link {
    color: var(--primary-color, #e63946);
    text-decoration: none;
}

.sponsor-link:hover {
    text-decoration: underline;
}

.prize-winning-numbers {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--snow-light, #f1faee);
}

.winning-numbers-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-dark, #1d3557);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.winning-numbers-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.number-pill {
    background: var(--snow-light, #f1faee);
    border: 1px solid var(--border-color, #d1dfe4);
    color: var(--text-dark, #1d3557);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.number-pill.is-match {
    background: var(--primary-light, #fcf3f6);
    border-color: var(--primary-color, #e63946);
    color: var(--primary-color, #e63946);
    font-weight: 800;
}

/* ==========================================================================
   SEARCH DIALOG STYLES
   ========================================================================== */

.search-dialog {
    --modal-max-width: 560px;
}

.search-desc {
    color: var(--text-muted, #435c7a);
    font-size: 0.95rem;
    margin: 0 0 16px;
    line-height: 1.45;
}

.search-form {
    margin-bottom: 20px;
}

.search-input-group {
    display: flex;
    gap: 8px;
}

.search-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--border-color, #d1dfe4);
    border-radius: var(--radius-sm, 6px);
    font-size: 1.05rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
    border-color: var(--primary-color, #e63946);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color, #e63946) 20%, transparent);
}

.search-submit-btn {
    background: var(--primary-color, #e63946);
    color: var(--snow-white, #ffffff);
    border: none;
    border-radius: var(--radius-sm, 6px);
    padding: 10px 18px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease;
}

.search-submit-btn:hover {
    background: var(--primary-hover, #c92a37);
}

.search-results-area {
    min-height: 40px;
}

.search-empty-state, .search-no-match, .search-success-heading {
    padding: 14px 16px;
    border-radius: var(--radius-sm, 6px);
    font-size: 0.95rem;
    line-height: 1.45;
}

.search-empty-state {
    background: var(--snow-light, #f1faee);
    color: var(--text-muted, #435c7a);
    border: 1px dashed var(--border-color, #d1dfe4);
    text-align: center;
}

.search-no-match {
    background: var(--primary-light, #fcf3f6);
    color: var(--primary-color, #e63946);
    border: 1px solid var(--accent-mauve, #e7d3de);
}

.search-match-card {
    background: var(--primary-light, #fcf3f6);
    border: 2px solid var(--primary-color, #e63946);
    border-radius: var(--radius-md, 10px);
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.search-match-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md, 0 4px 16px rgba(15, 28, 46, 0.18));
}

.search-match-day-badge {
    display: inline-block;
    background: var(--primary-color, #e63946);
    color: var(--snow-white, #ffffff);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    margin-bottom: 6px;
}

.search-match-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary-color, #e63946);
    margin: 0 0 4px;
}

.search-match-sponsor {
    font-size: 0.85rem;
    color: var(--text-muted, #435c7a);
    font-weight: 600;
}

/* ==========================================================================
   DRAWER COMPONENT (Off-Canvas Side Navigation with Slide-in Animation)
   ========================================================================== */

.drawer__dialog {
    position: fixed;
    inset: 0 auto 0 0;
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: 340px;
    max-width: 86vw;
    height: 100%;
    max-height: 100dvh;
    margin: 0;
    padding: 0;
    border: none;
    border-right: 1px solid rgba(168, 218, 220, 0.4);
    background: #ffffff;
    box-shadow: 10px 0 40px rgba(15, 28, 46, 0.35);
    color: var(--text-dark, #1d3557);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;

    transform: translateX(-100%);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.25s ease,
                overlay 0.3s allow-discrete,
                display 0.3s allow-discrete;
}

.drawer__dialog:not([open]) {
    display: none;
}

.drawer__dialog:open {
    transform: translateX(0);
    opacity: 1;
}

.drawer__dialog::backdrop {
    background: rgba(15, 28, 46, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.3s ease,
                overlay 0.3s allow-discrete,
                display 0.3s allow-discrete;
}

.drawer__dialog:open::backdrop {
    opacity: 1;
}

@starting-style {
    .drawer__dialog:open {
        transform: translateX(-100%);
        opacity: 0;
    }

    .drawer__dialog:open::backdrop {
        opacity: 0;
    }
}

.drawer__inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

/* Drawer Header */
.drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: max(16px, env(safe-area-inset-top, 0px)) 16px 16px;
    flex-shrink: 0;
}

.drawer__title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.drawer__logo-badge {
    font-size: 1.6rem;
    line-height: 1;
}

.drawer__title {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0;
    line-height: 1.2;
    color: var(--snow-white, #ffffff);
}

.drawer__subtitle {
    font-size: 0.75rem;
    margin: 2px 0 0;
    opacity: 0.85;
    color: var(--snow-white, #ffffff);
}

.drawer__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    cursor: pointer;
    background: transparent;
    border: none;
    flex-shrink: 0;
    margin-left: auto;
}

.drawer__close:focus-visible {
    outline: 2px solid var(--snow-white, #ffffff);
    outline-offset: 2px;
}

.drawer__close svg {
    width: 22px;
    height: 22px;
    display: block;
}

/* Drawer Content */
.drawer__content {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding: 16px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Navigation Menu Action Item (Gewinnnummer prüfen) */
.drawer__menu-divider {
    height: 1px;
    background: var(--border-color, #d1dfe4);
    margin: 8px 0;
    list-style: none;
}

.drawer__menu-item--action {
    margin-top: 4px;
}

.drawer__menu-button {
    border: 1px solid var(--border-color, #d1dfe4);
    background: transparent;
    font-family: inherit;
    cursor: pointer;
}

.drawer__menu-button:hover {
    border-color: color-mix(in srgb, var(--primary-color, #e63946) 40%, var(--border-color, #d1dfe4));
    background: var(--snow-light, #f1faee);
    color: var(--primary-color, #e63946);
}

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

.drawer__section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.75px;
    color: var(--text-muted, #435c7a);
    margin: 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-color, #d1dfe4);
}

.drawer__section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.drawer__section-more {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary-color, #e63946);
    text-decoration: none;
}

.drawer__section-more:hover {
    text-decoration: underline;
}

/* Navigation Menu */
.drawer__menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.drawer__menu-item {
    margin: 0;
}

.drawer__menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm, 6px);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-dark, #1d3557);
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    box-sizing: border-box;
}

.drawer__menu-link:hover {
    background: var(--snow-light, #f1faee);
    color: var(--primary-color, #e63946);
}

.drawer__menu-link.is-active {
    background: var(--primary-light, #fcf3f6);
    border-color: var(--primary-color, #e63946);
    color: var(--primary-color, #e63946);
    font-weight: 700;
}

.drawer__menu-icon {
    font-size: 1.15rem;
    line-height: 1;
    flex-shrink: 0;
}

.drawer__menu-logo {
    width: 22px;
    height: 22px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 4px;
}

.drawer__menu-label {
    flex: 1;
}

.drawer__menu-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    background: var(--snow-light, #f1faee);
    color: var(--text-muted, #435c7a);
}

.drawer__menu-badge--accent {
    background: var(--primary-light, #fcf3f6);
    color: var(--primary-color, #e63946);
}

/* ==========================================================================
   HISTORY MODAL DIALOGS (Large Image & Rich Historical Details)
   ========================================================================== */

.modal__dialog--history {
    --modal-max-width: 760px;
}

.history-modal__content {
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    box-sizing: border-box;
    max-height: calc(100dvh - var(--modal-inset-block-start) - var(--modal-inset-block-end) - 10px);
}

.history-modal__header {
    border-bottom: 2px solid var(--snow-light, #f1faee);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.history-modal__badge {
    display: inline-block;
    background: var(--primary-light, #fcf3f6);
    color: var(--primary-color, #e63946);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 8px;
    border: 1px solid var(--accent-mauve, #e7d3de);
}

.history-modal__title {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--text-dark, #1d3557);
    margin: 0 0 6px;
    line-height: 1.25;
    overflow-wrap: break-word;
}

.history-modal__subtitle {
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--primary-color, #e63946);
    line-height: 1.4;
    overflow-wrap: break-word;
}

.history-modal__media {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border-radius: var(--radius-md, 10px);
    overflow: hidden;
    background: var(--night-blue-deep, #0f1c2e);
    box-shadow: var(--shadow-md, 0 4px 14px rgba(15, 28, 46, 0.12));
    margin-bottom: 20px;
    border: 1px solid var(--border-frost, rgba(168, 218, 220, 0.4));
    display: flex;
    justify-content: center;
    align-items: center;
}

.history-modal__image {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 480px;
    object-fit: contain;
    display: block;
    background: var(--night-blue-deep, #0f1c2e);
}

.history-modal__body {
    padding: 4px 0 0;
}

.history-modal__text {
    font-size: 1rem;
    line-height: 1.75;
    color: var(--text-dark, #1d3557);
    overflow-wrap: break-word;
    word-break: normal;
}
