/* ==========================================================
   KPOPIMO COLOR THEME PILOT
   Loaded only by the approved pilot pages.
========================================================== */

html[data-theme-pilot] {
    color-scheme: light;
}

html[data-theme-pilot][data-theme="dark"] {
    color-scheme: dark;
    --bg-page: #171319;
    --bg-secondary: #201a23;
    --bg-card: #27202b;
    --bg-header: #1d1820;
    --bg-footer: #2f2439;
    --text-primary: #f4f0f5;
    --text-secondary: #c9c1cc;
    --text-muted: #a79bab;
    --border-subtle: #44394a;
    --border-control: #78677f;
    --brand-accent: #c9a8da;
    --link-color: #d7b8e8;
    --button-bg: #765187;
    --button-hover: #684476;
    --surface-hover: #32283a;
    --focus-ring: #d8a8f0;
    --input-bg: #211b25;
    --input-text: #f4f0f5;
    --input-placeholder: #a79bab;
    --color-primary: var(--brand-accent);
    --color-primary-dark: var(--button-hover);
    --color-text: var(--text-primary);
    --color-text-light: var(--text-secondary);
    --color-text-muted: var(--text-muted);
    --color-background: var(--bg-page);
    --color-surface: var(--bg-secondary);
    --border-color: var(--border-subtle);
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.28);
}

@media (prefers-color-scheme: dark) {
    html[data-theme-pilot]:not([data-theme]) {
        color-scheme: dark;
        --bg-page: #171319;
        --bg-secondary: #201a23;
        --bg-card: #27202b;
        --bg-header: #1d1820;
        --bg-footer: #2f2439;
        --text-primary: #f4f0f5;
        --text-secondary: #c9c1cc;
        --text-muted: #a79bab;
        --border-subtle: #44394a;
        --border-control: #78677f;
        --brand-accent: #c9a8da;
        --link-color: #d7b8e8;
        --button-bg: #765187;
        --button-hover: #684476;
        --surface-hover: #32283a;
        --focus-ring: #d8a8f0;
        --input-bg: #211b25;
        --input-text: #f4f0f5;
        --input-placeholder: #a79bab;
        --color-primary: var(--brand-accent);
        --color-primary-dark: var(--button-hover);
        --color-text: var(--text-primary);
        --color-text-light: var(--text-secondary);
        --color-text-muted: var(--text-muted);
        --color-background: var(--bg-page);
        --color-surface: var(--bg-secondary);
        --border-color: var(--border-subtle);
        --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.28);
    }
}

/* Header theme control */

html[data-theme-pilot] .site-header .container {
    grid-template-columns: auto 1fr;
}

html[data-theme-pilot] .main-nav {
    justify-self: stretch;
}

html[data-theme-pilot] .main-nav ul {
    width: 100%;
}

html[data-theme-pilot] .theme-nav-item {
    position: relative;
    margin-left: auto;
}

html[data-theme-pilot] .theme-picker {
    position: relative;
}

html[data-theme-pilot] .theme-toggle {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 0 14px;
    border: 1px solid var(--border-control);
    border-radius: var(--radius-pill);
    background: var(--bg-card);
    color: var(--text-primary);
    font: 600 14px/1 var(--font-primary);
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}

html[data-theme-pilot] .theme-toggle:hover {
    background: var(--surface-hover);
    border-color: var(--brand-accent);
}

html[data-theme-pilot] .theme-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

html[data-theme-pilot] .theme-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 1200;
    width: 190px;
    padding: 8px;
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    background: var(--bg-card);
    box-shadow: 0 18px 45px rgba(0, 0, 0, .2);
}

html[data-theme-pilot] .theme-menu[hidden] {
    display: none;
}

html[data-theme-pilot] .theme-menu fieldset {
    min-width: 0;
    border: 0;
}

html[data-theme-pilot] .theme-menu legend {
    width: 100%;
    padding: 8px 10px 6px;
    color: var(--text-muted);
    font: 700 11px/1.3 var(--font-primary);
    letter-spacing: .1em;
    text-transform: uppercase;
}

html[data-theme-pilot] .theme-option {
    min-height: 42px;
    display: grid;
    grid-template-columns: 18px 1fr 18px;
    align-items: center;
    gap: 9px;
    padding: 0 10px;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
}

html[data-theme-pilot] .theme-option:hover {
    background: var(--surface-hover);
}

html[data-theme-pilot] .theme-option input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--brand-accent);
}

html[data-theme-pilot] .theme-check {
    color: var(--brand-accent);
    font-weight: 800;
    opacity: 0;
}

html[data-theme-pilot] .theme-option:has(input:checked) .theme-check {
    opacity: 1;
}

html[data-theme-pilot] :is(a, button, input):focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
}

html[data-theme-pilot] .logo-dark {
    display: none;
}

/* Critical first-paint rules mirror the full dark treatment before main.js
   resolves the active system preference. */

html[data-theme-pilot][data-theme="dark"] body,
html[data-theme-pilot][data-theme="dark"] :is(
    .breadcrumb,
    .article-hero,
    .article-header,
    .article-content,
    .related-articles,
    .outfits,
    .latest-outfits,
    .explore-beauty,
    .latest-articles,
    .blog-section,
    .about-story,
    .about-editorial,
    .about-behind,
    .contact-content,
    .shop-temporary-notice
) {
    background: var(--bg-page);
    color: var(--text-primary);
}

html[data-theme-pilot][data-theme="dark"] .site-header {
    background: var(--bg-header);
}

html[data-theme-pilot][data-theme="dark"] :is(
    .ai-transparency-bar,
    .categories,
    .about-philosophy,
    .beauty,
    .shop-look,
    .details-gallery,
    .newsletter,
    .collection-story
) {
    background: var(--bg-secondary);
}

html[data-theme-pilot][data-theme="dark"] .logo-light {
    display: none;
}

html[data-theme-pilot][data-theme="dark"] .logo-dark {
    display: block;
}

@media (prefers-color-scheme: dark) {
    html[data-theme-pilot]:not([data-theme]) body,
    html[data-theme-pilot]:not([data-theme]) :is(
        .breadcrumb,
        .article-hero,
        .article-header,
        .article-content,
        .related-articles,
        .outfits,
        .latest-outfits,
        .explore-beauty,
        .latest-articles,
        .blog-section,
        .about-story,
        .about-editorial,
        .about-behind,
        .contact-content,
        .shop-temporary-notice
    ) {
        background: var(--bg-page);
        color: var(--text-primary);
    }

    html[data-theme-pilot]:not([data-theme]) .site-header {
        background: var(--bg-header);
    }

    html[data-theme-pilot]:not([data-theme]) :is(
        .ai-transparency-bar,
        .categories,
        .about-philosophy,
        .beauty,
        .shop-look,
        .details-gallery,
        .newsletter,
        .collection-story
    ) {
        background: var(--bg-secondary);
    }

    html[data-theme-pilot]:not([data-theme]) .logo-light {
        display: none;
    }

    html[data-theme-pilot]:not([data-theme]) .logo-dark {
        display: block;
    }
}

/* Dark surfaces and text. The selectors remain pilot-scoped so non-pilot
   pages keep their current rendering even though they share base CSS. */

html[data-theme-pilot][data-resolved-theme="dark"] body {
    background: var(--bg-page);
    color: var(--text-primary);
}

html[data-theme-pilot][data-resolved-theme="dark"] .site-header {
    background: var(--bg-header);
    border-color: var(--border-subtle);
}

html[data-theme-pilot][data-resolved-theme="dark"] .logo-light {
    display: none;
}

html[data-theme-pilot][data-resolved-theme="dark"] .logo-dark {
    display: block;
}

html[data-theme-pilot][data-resolved-theme="dark"] .ai-transparency-bar,
html[data-theme-pilot][data-resolved-theme="dark"] .categories,
html[data-theme-pilot][data-resolved-theme="dark"] .about-philosophy,
html[data-theme-pilot][data-resolved-theme="dark"] .beauty,
html[data-theme-pilot][data-resolved-theme="dark"] .shop-look,
html[data-theme-pilot][data-resolved-theme="dark"] .details-gallery,
html[data-theme-pilot][data-resolved-theme="dark"] .collection-story {
    background: var(--bg-secondary);
}

html[data-theme-pilot][data-resolved-theme="dark"] :is(
    .outfits,
    .latest-outfits,
    .explore-beauty,
    .latest-articles,
    .blog-section,
    .about-story,
    .about-editorial,
    .about-behind,
    .breadcrumb,
    .article-hero,
    .article-header,
    .article-content,
    .related-articles,
    .contact-content,
    .shop-temporary-notice
) {
    background: var(--bg-page);
}

html[data-theme-pilot][data-resolved-theme="dark"] .shop-category-hero {
    background: linear-gradient(to bottom, var(--bg-page), var(--bg-secondary));
}

html[data-theme-pilot][data-resolved-theme="dark"] :is(
    .newsletter-box,
    .details-meta-card,
    .included-card,
    .retailer-card,
    .contact-card
) {
    background: var(--bg-card);
    border-color: var(--border-subtle);
}

html[data-theme-pilot][data-resolved-theme="dark"] :is(
    .love-box,
    .note-box,
    .details-image,
    .included-icon
) {
    background: var(--bg-secondary);
    border-color: var(--border-subtle);
}

html[data-theme-pilot][data-resolved-theme="dark"] :is(
    h1, h2, h3, h4,
    .article-header h1,
    .article-content h2,
    .related-info h3,
    .shop-info h3,
    .contact-content h2,
    .contact-card h3,
    .details-brand,
    .details-content h1,
    .meta-value,
    .love-signature,
    .included-card h3,
    .note-signature,
    .retailer-name,
    .retailer-link,
    .breadcrumb .current,
    .affiliate-notice strong
) {
    color: var(--text-primary);
}

html[data-theme-pilot][data-resolved-theme="dark"] :is(
    .section-header p,
    .outfit-info p,
    .beauty-info p,
    .article-info p,
    .story-text,
    .story-text p,
    .philosophy-text,
    .philosophy-text p,
    .editorial-text,
    .behind-text,
    .behind-content p,
    .article-subtitle,
    .article-look,
    .article-content p,
    .article-content li,
    .article-intro,
    .article-quote p,
    .related-info p,
    .shop-info p,
    .shop-look .section-header p,
    .contact-content p,
    .contact-card p,
    .details-description,
    .details-text p,
    .love-box p,
    .included-card p,
    .editorial-disclaimer h3,
    .note-box p,
    .retailer-card p,
    .related-products .section-header p,
    .affiliate-notice,
    .shop-category-hero p,
    .shop-temporary-notice p
) {
    color: var(--text-secondary) !important;
}

html[data-theme-pilot][data-resolved-theme="dark"] :is(
    .ai-transparency-text,
    .ai-transparency-text span,
    .article-meta,
    .details-category,
    .meta-label,
    .section-label,
    .editorial-disclaimer p,
    .breadcrumb span
) {
    color: var(--text-muted);
}

html[data-theme-pilot][data-resolved-theme="dark"] :is(
    .ai-transparency-text a,
    .breadcrumb a,
    .article-content a,
    .contact-email,
    .details-content a,
    .details-text a,
    .note-box a
) {
    color: var(--link-color);
}

html[data-theme-pilot][data-resolved-theme="dark"] :is(
    .ai-transparency-text a,
    .breadcrumb a,
    .article-content a,
    .contact-email,
    .details-content a,
    .details-text a,
    .note-box a
):hover {
    color: var(--text-primary);
}

html[data-theme-pilot][data-resolved-theme="dark"] :is(
    .hero-button,
    .shop-button,
    .pick-button
) {
    background: var(--button-bg);
    color: var(--text-primary);
}

html[data-theme-pilot][data-resolved-theme="dark"] :is(
    .hero-button,
    .shop-button,
    .pick-button
):hover {
    background: var(--button-hover);
}

html[data-theme-pilot][data-resolved-theme="dark"] .category-navigation a:hover,
html[data-theme-pilot][data-resolved-theme="dark"] .category-navigation a.active {
    background: var(--button-bg);
    color: var(--text-primary);
}

html[data-theme-pilot][data-resolved-theme="dark"] .article-quote {
    border-color: var(--brand-accent);
}

html[data-theme-pilot][data-resolved-theme="dark"] .affiliate-notice {
    border-color: var(--border-subtle);
}

html[data-theme-pilot][data-resolved-theme="dark"] .article-hero.hero-static .article-hero-viewport {
    background: var(--bg-secondary);
}

/* Newsletter and MailerLite embeds are intentionally scoped to this section. */

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter {
    background: var(--bg-secondary);
}

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter :is(
    h2,
    .ml-form-embedContent h4
) {
    color: var(--text-primary) !important;
}

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter :is(
    p,
    .ml-form-embedContent p
) {
    color: var(--text-secondary) !important;
}

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter :is(
    input,
    .form-control
) {
    border-color: var(--border-control) !important;
    background: var(--input-bg) !important;
    color: var(--input-text) !important;
}

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter :is(
    input,
    .form-control
)::placeholder {
    color: var(--input-placeholder) !important;
    opacity: 1;
}

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter :is(
    input,
    .form-control
):focus {
    border-color: var(--focus-ring) !important;
    box-shadow: 0 0 0 4px rgba(216, 168, 240, .18) !important;
}

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter :is(
    button,
    button.primary
) {
    background: var(--button-bg) !important;
    color: var(--text-primary) !important;
}

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter :is(
    button,
    button.primary
):hover {
    background: var(--button-hover) !important;
}

/* MailerLite injects a form-specific ID stylesheet after the site CSS. The
   two non-matching :not() IDs deliberately give these pilot-scoped rules
   enough specificity without coupling the theme to one generated form ID. */

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter
    .ml-form-embedContainer:not(#kpopimo-theme-specificity):not(#kpopimo-theme-specificity-2)
    .ml-form-embedWrapper {
    background: var(--bg-card) !important;
    border-color: var(--border-subtle) !important;
}

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter
    .ml-form-embedContainer:not(#kpopimo-theme-specificity):not(#kpopimo-theme-specificity-2)
    :is(.ml-form-embedContent, .ml-form-embedPermissionsContent, .ml-form-successContent) {
    color: var(--text-secondary) !important;
}

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter
    .ml-form-embedContainer:not(#kpopimo-theme-specificity):not(#kpopimo-theme-specificity-2)
    :is(.ml-form-embedContent, .ml-form-embedPermissionsContent, .ml-form-successContent)
    :is(p, span, a) {
    color: var(--text-secondary) !important;
}

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter
    .ml-form-embedContainer:not(#kpopimo-theme-specificity):not(#kpopimo-theme-specificity-2)
    :is(input.form-control, textarea.form-control) {
    border-color: var(--border-control) !important;
    background: var(--input-bg) !important;
    color: var(--input-text) !important;
}

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter
    .ml-form-embedContainer:not(#kpopimo-theme-specificity):not(#kpopimo-theme-specificity-2)
    :is(input.form-control, textarea.form-control)::placeholder {
    color: var(--input-placeholder) !important;
    opacity: 1 !important;
}

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter
    .ml-form-embedContainer:not(#kpopimo-theme-specificity):not(#kpopimo-theme-specificity-2)
    :is(input.form-control, textarea.form-control):focus {
    border-color: var(--focus-ring) !important;
    box-shadow: 0 0 0 4px rgba(216, 168, 240, .18) !important;
}

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter
    .ml-form-embedContainer:not(#kpopimo-theme-specificity):not(#kpopimo-theme-specificity-2)
    input.form-control:-webkit-autofill {
    -webkit-text-fill-color: var(--input-text) !important;
    caret-color: var(--input-text);
    box-shadow: 0 0 0 1000px var(--input-bg) inset !important;
}

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter
    .ml-form-embedContainer:not(#kpopimo-theme-specificity):not(#kpopimo-theme-specificity-2)
    .ml-error :is(input, textarea, select) {
    border-color: #ff6b6b !important;
}

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter
    .ml-form-embedContainer:not(#kpopimo-theme-specificity):not(#kpopimo-theme-specificity-2)
    .ml-error :is(.label-description, .label-description p, .label-description p a, label:first-child) {
    color: #ff6b6b !important;
}

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter
    .ml-form-embedContainer:not(#kpopimo-theme-specificity):not(#kpopimo-theme-specificity-2)
    button.primary {
    background: var(--button-bg) !important;
    color: var(--text-primary) !important;
}

html[data-theme-pilot][data-resolved-theme="dark"] .newsletter
    .ml-form-embedContainer:not(#kpopimo-theme-specificity):not(#kpopimo-theme-specificity-2)
    button.primary:hover {
    background: var(--button-hover) !important;
}

html[data-theme-pilot][data-resolved-theme="dark"] .site-footer {
    background: var(--bg-footer);
}

@media (max-width: 768px) {
    html[data-theme-pilot] .site-header .container {
        grid-template-columns: 1fr auto;
    }

    html[data-theme-pilot] .site-header.mobile-nav-open .main-nav {
        background: var(--bg-header);
        border-color: var(--border-subtle);
    }

    html[data-theme-pilot] .theme-nav-item {
        margin: 6px 0 0;
        padding-top: 8px;
        border-top: 1px solid var(--border-subtle);
    }

    html[data-theme-pilot] .theme-toggle {
        width: 100%;
        min-height: 48px;
        justify-content: flex-start;
        padding: 0 14px;
        border: 0;
        border-radius: 10px;
        background: transparent;
    }

    html[data-theme-pilot] .theme-menu {
        position: static;
        width: 100%;
        margin-top: 4px;
        box-shadow: none;
    }

    html[data-theme-pilot][data-resolved-theme="dark"] .main-nav a:hover,
    html[data-theme-pilot][data-resolved-theme="dark"] .main-nav a:focus-visible {
        background: var(--surface-hover);
    }
}

@media (prefers-reduced-motion: reduce) {
    html[data-theme-pilot] .theme-toggle {
        transition: none;
    }
}
