/* Custom Paper Texture & Neo-Brutalist Collage Styles */
body {
    background-color: #F9EFE0;
    color: #18181B;
    background-image:
        radial-gradient(#18181b11 1px, transparent 0),
        radial-gradient(#18181b0a 1px, #F9EFE0 0);
    background-size: 28px 28px;
    background-position: 0 0, 14px 14px;
    overflow-x: hidden;
}

/* Crosshatch grid pattern from the logo & slides */
.bg-grid-doodle {
    background-size: 16px 16px;
    background-image:
        linear-gradient(to right, rgba(24, 24, 27, 0.14) 1.5px, transparent 1.5px),
        linear-gradient(to bottom, rgba(24, 24, 27, 0.14) 1.5px, transparent 1.5px);
}

.bg-coral-grid {
    background-size: 18px 18px;
    background-image:
        linear-gradient(to right, rgba(235, 107, 86, 0.35) 1.5px, transparent 1.5px),
        linear-gradient(to bottom, rgba(235, 107, 86, 0.35) 1.5px, transparent 1.5px);
}

/* Highlighter & Washi Tape Effects from Slides */
.washi-tape-purple {
    background: #CFC2FF;
    border: 2.5px solid #18181B;
    box-shadow: 3px 3px 0px #18181B;
    transform: rotate(-3deg);
}

.highlighter-lime {
    background: linear-gradient(104deg, rgba(205, 235, 55, 0) 0.9%, #CEE938 2.4%, #C7E529 97%, rgba(205, 235, 55, 0) 98%);
    padding: 0.15em 0.45em;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* Torn Paper Card Effect (like Slide 19 & NASA slide) */
.torn-paper-card {
    background: #FAF0E1;
    position: relative;
    border: 3px solid #18181B;
    box-shadow: 7px 7px 0px #18181B;
}

/* Brutalist Button Press Animation */
.btn-brutal {
    transition: all 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
    border: 2.5px solid #18181B;
    box-shadow: 4px 4px 0px #18181B;
}

.btn-brutal:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px #18181B;
}

.btn-brutal:active {
    transform: translate(3px, 3px);
    box-shadow: 1px 1px 0px #18181B;
}

.btn-brutal:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: 2px 2px 0px #18181B;
}

/* Floating Doodle Animations */
@keyframes floatSlow {
    0%, 100% {
        transform: translateY(0px) rotate(-2deg);
    }
    50% {
        transform: translateY(-7px) rotate(2deg);
    }
}

.animate-float {
    animation: floatSlow 4s ease-in-out infinite;
}

/* ===================================================================
   Dialog Motion System (Modern Web Guidance: animate-to-from-top-layer)
   - Entry: @starting-style  | Exit: transition back to the closed state
   - `display` + `overlay` are transitioned (allow-discrete) so the dialog
     stays in the top layer while it animates out.
   - Browsers without discrete display/overlay transitions (Firefox, older
     Safari) use the `data-closing` attribute set by js/dialog-motion.js.
   =================================================================== */
:root {
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.32, 0.64, 1);
    --ease-in-soft: cubic-bezier(0.4, 0, 0.9, 0.6);
}

dialog:modal {
    overscroll-behavior: contain;
    max-height: calc(100dvh - 2rem);
}

/* ---------- Centered dialogs: closed / exit state ---------- */
dialog:not(#navDrawer) {
    opacity: 0;
    transition-property: opacity, display, overlay;
    transition-duration: 0.2s;
    transition-timing-function: var(--ease-in-soft);
    /* Separate declaration so the shorthand never resets it */
    transition-behavior: allow-discrete;
}

@media (prefers-reduced-motion: no-preference) {
    dialog:not(#navDrawer) {
        transform: translateY(1.5rem) scale(0.95);
        transition-property: opacity, transform, display, overlay;
    }
}

/* ---------- Centered dialogs: open state (+ starting style) ---------- */
dialog:not(#navDrawer)[open]:not([data-closing]) {
    opacity: 1;
    transition-duration: 0.35s;
    transition-timing-function: var(--ease-out-expo);
}

@starting-style {
    dialog:not(#navDrawer)[open]:not([data-closing]) {
        opacity: 0;
    }
}

@media (prefers-reduced-motion: no-preference) {
    dialog:not(#navDrawer)[open]:not([data-closing]) {
        transform: translateY(0) scale(1);
        transition-duration: 0.35s, 0.55s, 0.55s, 0.55s;
        transition-timing-function: var(--ease-out-expo), var(--ease-spring), var(--ease-out-expo), var(--ease-out-expo);
    }

    @starting-style {
        dialog:not(#navDrawer)[open]:not([data-closing]) {
            transform: translateY(1.5rem) scale(0.95);
        }
    }

    /* Content cascades in after the card lands */
    dialog:not(#navDrawer)[open]:not([data-closing]) > div > * {
        animation: dialogItemIn 0.55s var(--ease-out-expo) backwards;
    }
    dialog:not(#navDrawer)[open]:not([data-closing]) > div > :nth-child(1) { animation-delay: 70ms; }
    dialog:not(#navDrawer)[open]:not([data-closing]) > div > :nth-child(2) { animation-delay: 115ms; }
    dialog:not(#navDrawer)[open]:not([data-closing]) > div > :nth-child(3) { animation-delay: 160ms; }
    dialog:not(#navDrawer)[open]:not([data-closing]) > div > :nth-child(4) { animation-delay: 205ms; }
    dialog:not(#navDrawer)[open]:not([data-closing]) > div > :nth-child(5) { animation-delay: 250ms; }
    dialog:not(#navDrawer)[open]:not([data-closing]) > div > :nth-child(n+6) { animation-delay: 295ms; }
}

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

/* ---------- Backdrop (fade + progressive blur) ---------- */
dialog::backdrop {
    overflow: hidden;
    overscroll-behavior: contain;
    background-color: rgb(24 24 27 / 0);
    backdrop-filter: blur(0);
    transition-property: background-color, backdrop-filter, display, overlay;
    transition-duration: 0.25s;
    transition-timing-function: ease-in;
    transition-behavior: allow-discrete;
}

dialog[open]:not([data-closing])::backdrop {
    background-color: rgb(24 24 27 / 0.65);
    backdrop-filter: blur(4px);
    transition-duration: 0.4s;
    transition-timing-function: ease-out;
}

@starting-style {
    dialog[open]:not([data-closing])::backdrop {
        background-color: rgb(24 24 27 / 0);
        backdrop-filter: blur(0);
    }
}

/* ---------- Slide-Out Navigation Drawer ---------- */
#navDrawer {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(22rem, 85vw);
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    background-color: #F9EFE0;
    background-image:
        radial-gradient(#18181b11 1px, transparent 0),
        radial-gradient(#18181b0a 1px, #F9EFE0 0);
    background-size: 28px 28px;
    background-position: 0 0, 14px 14px;
    color: #18181B;
    border: 0;
    border-right: 4px solid #18181B;
    box-shadow: 8px 0px 0px #18181B;
    overflow-y: auto;
    opacity: 1;
    transform: translateX(-105%);
    transition-property: transform, display, overlay;
    transition-duration: 0.3s;
    transition-timing-function: cubic-bezier(0.5, 0, 0.75, 0);
    transition-behavior: allow-discrete;
}

#navDrawer[open] {
    display: flex;
    flex-direction: column;
}

#navDrawer[open]:not([data-closing]) {
    transform: translateX(0);
    transition-duration: 0.5s;
    transition-timing-function: var(--ease-out-expo);
}

@starting-style {
    #navDrawer[open]:not([data-closing]) {
        transform: translateX(-105%);
    }
}

@media (prefers-reduced-motion: no-preference) {
    /* Menu items slide in one after another */
    #navDrawer[open]:not([data-closing]) .drawer-link {
        animation: drawerItemIn 0.55s var(--ease-out-expo) backwards;
    }
    #navDrawer[open]:not([data-closing]) li:nth-child(1) .drawer-link { animation-delay: 120ms; }
    #navDrawer[open]:not([data-closing]) li:nth-child(2) .drawer-link { animation-delay: 165ms; }
    #navDrawer[open]:not([data-closing]) li:nth-child(3) .drawer-link { animation-delay: 210ms; }
    #navDrawer[open]:not([data-closing]) li:nth-child(4) .drawer-link { animation-delay: 255ms; }
    #navDrawer[open]:not([data-closing]) li:nth-child(5) .drawer-link { animation-delay: 300ms; }
    #navDrawer[open]:not([data-closing]) li:nth-child(n+6) .drawer-link { animation-delay: 345ms; }
}

@keyframes drawerItemIn {
    from {
        opacity: 0;
        transform: translateX(-24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ---------- Reduced motion: short fade only ---------- */
@media (prefers-reduced-motion: reduce) {
    dialog:not(#navDrawer),
    dialog:not(#navDrawer)[open]:not([data-closing]),
    dialog::backdrop,
    dialog[open]:not([data-closing])::backdrop {
        transition-duration: 0.1s;
    }

    #navDrawer,
    #navDrawer[open]:not([data-closing]) {
        transition-property: opacity, display, overlay;
        transition-duration: 0.1s;
        transform: none;
        opacity: 0;
    }

    #navDrawer[open]:not([data-closing]) {
        opacity: 1;
    }

    @starting-style {
        #navDrawer[open]:not([data-closing]) {
            opacity: 0;
            transform: none;
        }
    }
}

/* Branded Select Styling (Modern Web Guidance: branded-select-styling) */
.brand-select {
    width: 100%;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

@supports (appearance: base-select) {
    .brand-select,
    .brand-select::picker(select) {
        appearance: base-select;
    }

    .brand-select {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .brand-select::picker(select) {
        background-color: #F9EFE0;
        color: #18181B;
        border: 2px solid #18181B;
        border-radius: 0.75rem;
        padding: 0.35rem;
        margin-top: 0.35rem;
        box-shadow: 4px 4px 0px #18181B;
    }

    .brand-select::picker-icon {
        color: #18181B;
        transition: transform 0.2s ease;
    }

    .brand-select:open::picker-icon {
        transform: rotate(180deg);
    }

    .brand-select option {
        padding: 0.55rem 0.75rem;
        border-radius: 0.5rem;
        color: #18181B;
        font-weight: 700;
        cursor: pointer;
        transition: background-color 0.12s ease;
    }

    .brand-select option:hover,
    .brand-select option:focus {
        background-color: #FFF07C;
    }

    .brand-select option:checked {
        background-color: #D2FF52;
    }

    .brand-select option::checkmark {
        color: #18181B;
    }
}

/* Clean native <details> disclosure marker reset */
.clean-disclosure summary {
    list-style: none;
}

.clean-disclosure summary::-webkit-details-marker {
    display: none;
}

/* Custom Neo-Brutalist SVG Icons (Logo Design Language) */
.ck-ico {
    display: inline-block;
    flex-shrink: 0;
    vertical-align: middle;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #F9EFE0;
    border-left: 2px solid #18181B;
}

::-webkit-scrollbar-thumb {
    background: #FF7A00;
    border: 2px solid #18181B;
}

::-webkit-scrollbar-thumb:hover {
    background: #B983FF;
}
