/* ==========================================================================
   Thai Festival Auto-Theme & Ambient Effects (Scoped strictly to [data-festival])
   Tasteful, high-contrast (>= 4.5:1), non-intrusive across Light / Dark / Two-Tone
   ========================================================================== */

html[data-festival] {
    --festival-ribbon: linear-gradient(90deg, #0078d4 0%, #38bdf8 100%);
    --festival-accent: var(--primary-color);
    --festival-badge-bg: rgba(255, 255, 255, 0.88);
    --festival-badge-border: rgba(15, 23, 42, 0.10);
    --festival-badge-text: #1e293b;
}

/* Sleek 3px Fixed Top Gradient Ribbon */
html[data-festival] body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--festival-ribbon);
    z-index: 950;
    pointer-events: none;
}

/* --- Per-Festival Light-Mode Palettes (All >= 4.5:1 button & link contrast) --- */
html[data-festival="christmas"] {
    --primary-color: #146b3a;
    --primary-dark: #0e4f2b;
    --bg-color: #f3f7f5;
    --festival-accent: #146b3a;
    --festival-ribbon: linear-gradient(90deg, #146b3a 0%, #c41e3a 50%, #d4af37 100%);
}

html[data-festival="new_year"] {
    --primary-color: #1d4ed8;
    --primary-dark: #1e40af;
    --bg-color: #f2f5fb;
    --festival-accent: #1d4ed8;
    --festival-ribbon: linear-gradient(90deg, #1d4ed8 0%, #3b82f6 52%, #f59e0b 100%);
}

html[data-festival="valentines"] {
    --primary-color: #be123c;
    --primary-dark: #9f1239;
    --bg-color: #fbf4f6;
    --festival-accent: #be123c;
    --festival-ribbon: linear-gradient(90deg, #e11d48 0%, #f472b6 100%);
}

html[data-festival="songkran"] {
    --primary-color: #c2410c;
    --primary-dark: #9a3412;
    --bg-color: #f4f8fb;
    --festival-accent: #0284c7;
    --festival-ribbon: linear-gradient(90deg, #0ea5e9 0%, #38bdf8 45%, #f97316 100%);
}

html[data-festival="loy_krathong"] {
    --primary-color: #4338ca;
    --primary-dark: #312e81;
    --bg-color: #f4f4fa;
    --festival-accent: #4338ca;
    --festival-ribbon: linear-gradient(90deg, #312e81 0%, #6366f1 55%, #f59e0b 100%);
}

html[data-festival="mothers_day"] {
    --primary-color: #0369a1;
    --primary-dark: #075985;
    --bg-color: #f2f8fc;
    --festival-accent: #0369a1;
    --festival-ribbon: linear-gradient(90deg, #0284c7 0%, #38bdf8 55%, #bae6fd 100%);
}

html[data-festival="queens_birthday"] {
    --primary-color: #6d28d9;
    --primary-dark: #5b21b6;
    --bg-color: #f6f4fb;
    --festival-accent: #6d28d9;
    --festival-ribbon: linear-gradient(90deg, #5b21b6 0%, #8b5cf6 60%, #c4b5fd 100%);
}

html[data-festival="chulalongkorn"] {
    --primary-color: #be185d;
    --primary-dark: #9d174d;
    --bg-color: #faf4f7;
    --festival-accent: #be185d;
    --festival-ribbon: linear-gradient(90deg, #be185d 0%, #ec4899 60%, #fbcfe8 100%);
}

/* Royal Gold Days — Dignified Gold with >= 4.9:1 White Button Contrast */
html[data-festival="coronation"],
html[data-festival="kings_birthday"],
html[data-festival="navamindra"],
html[data-festival="fathers_day"] {
    --primary-color: #a16207;
    --primary-dark: #854d0e;
    --bg-color: #faf8f2;
    --festival-accent: #a16207;
    --festival-ribbon: linear-gradient(90deg, #a16207 0%, #eab308 55%, #fde047 100%);
}

html[data-festival="coronation"] .btn-primary,
html[data-festival="kings_birthday"] .btn-primary,
html[data-festival="navamindra"] .btn-primary,
html[data-festival="fathers_day"] .btn-primary {
    color: #ffffff !important;
}

/* Refined Light-mode Active Nav Tint matching each festival */
html[data-festival] .nav-link:hover,
html[data-festival] .nav-link.active {
    background-color: color-mix(in srgb, var(--primary-color) 10%, transparent);
    color: var(--primary-color);
}

/* Preserve Dark-mode Surfaces & High-Contrast Accents when Base Theme is Dark */
html[data-festival][data-base-theme="dark"] {
    --bg-color: #1e1e1e;
    --card-bg: #252526;
    --festival-badge-bg: rgba(30, 30, 34, 0.88);
    --festival-badge-border: rgba(255, 255, 255, 0.12);
    --festival-badge-text: #f1f5f9;
}

html[data-festival="christmas"][data-base-theme="dark"] { --primary-color: #4ade80; --primary-dark: #22c55e; }
html[data-festival="new_year"][data-base-theme="dark"] { --primary-color: #60a5fa; --primary-dark: #3b82f6; }
html[data-festival="valentines"][data-base-theme="dark"] { --primary-color: #fb7185; --primary-dark: #f43f5e; }
html[data-festival="songkran"][data-base-theme="dark"] { --primary-color: #fb923c; --primary-dark: #f97316; }
html[data-festival="loy_krathong"][data-base-theme="dark"] { --primary-color: #a78bfa; --primary-dark: #8b5cf6; }
html[data-festival="mothers_day"][data-base-theme="dark"] { --primary-color: #38bdf8; --primary-dark: #0ea5e9; }
html[data-festival="queens_birthday"][data-base-theme="dark"] { --primary-color: #c084fc; --primary-dark: #a855f7; }
html[data-festival="chulalongkorn"][data-base-theme="dark"] { --primary-color: #f472b6; --primary-dark: #ec4899; }
html[data-festival="coronation"][data-base-theme="dark"],
html[data-festival="kings_birthday"][data-base-theme="dark"],
html[data-festival="navamindra"][data-base-theme="dark"],
html[data-festival="fathers_day"][data-base-theme="dark"] {
    --primary-color: #facc15;
    --primary-dark: #eab308;
}

html[data-festival][data-base-theme="dark"] .btn-primary {
    color: #0f172a !important;
}

html[data-festival][data-base-theme="twotone"] .sidebar .nav-link.active::before {
    background: var(--festival-ribbon) !important;
}

@media (prefers-color-scheme: dark) {
    html[data-festival][data-base-theme="auto"],
    html[data-festival][data-base-theme="blue"] {
        --bg-color: #1e1e1e;
        --card-bg: #252526;
        --festival-badge-bg: rgba(30, 30, 34, 0.88);
        --festival-badge-border: rgba(255, 255, 255, 0.12);
        --festival-badge-text: #f1f5f9;
    }
}

/* --- Ambient Particle Canvas --- */
#festivalCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 940;
}

/* --- Subtle Bottom-Left Festival Pill Badge --- */
#festivalBadge {
    position: fixed;
    bottom: 14px;
    left: 14px;
    z-index: 945;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 12px;
    border-radius: 999px;
    background: var(--festival-badge-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--festival-badge-border);
    color: var(--festival-badge-text);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.10);
    font-family: 'Sarabun', sans-serif;
    font-size: 0.8rem;
    line-height: 1.25;
    max-width: calc(100vw - 6rem);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#festivalBadge .festival-badge-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--festival-ribbon);
    color: #ffffff;
    font-size: 0.72rem;
    flex-shrink: 0;
}

#festivalBadge .festival-badge-label {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#festivalBadge .festival-badge-preview-tag {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.18);
    color: #b45309;
    white-space: nowrap;
}

html[data-festival][data-base-theme="dark"] #festivalBadge .festival-badge-preview-tag {
    color: #fcd34d;
}

#festivalBadge .festival-badge-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(100, 116, 139, 0.14);
    color: inherit;
    cursor: pointer;
    padding: 0;
    font-size: 0.78rem;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

#festivalBadge .festival-badge-btn:hover {
    background: rgba(100, 116, 139, 0.28);
}

@media (max-width: 768px) {
    #festivalBadge {
        bottom: 12px;
        left: 12px;
        font-size: 0.75rem;
        padding: 5px 8px 5px 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #festivalCanvas {
        display: none !important;
    }
}

@media print {
    html[data-festival] body::before,
    #festivalCanvas,
    #festivalBadge {
        display: none !important;
    }
}
