@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400&family=EB+Garamond:ital,wght@0,400;0,500;1,400&display=swap');

:root {
    /* ===== DARK MODE — "Midnight Glow Fairy" jewel tones ===== */
    --bg-color: #1B1523;               /* deep aubergine-black night sky */
    --text-color: #EDE6F5;             /* soft lilac-white */
    --accent-color: #A78BC9;           /* Purple Hebe, brightened for glow */
    --accent-soft: #C99BC9;            /* Lilac Sachet */
    --card-bg: rgba(79, 52, 102, 0.35);   /* Petunia, translucent */
    --border-color: rgba(167, 139, 201, 0.25);
    --gold: #B89B6E;                   /* muted candlelight gold */
    --wine: #6B3F5C;                   /* deep Petunia wine */
    --emerald: #7B7FB0;                /* Jacaranda, used as cool contrast */
    --ember: #D98DA0;                  /* Pink Carnation spark for hovers */
    --glass-bg: rgba(43, 30, 56, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(10, 5, 20, 0.7);
}

[data-theme="light"] {
    /* ===== LIGHT MODE — Lavender Fog / African Violet ===== */
    --bg-color: #F3EEF7;               /* Lavender Fog */
    --text-color: #3D2E4A;             /* deep plum ink */
    --accent-color: #8B6B9E;           /* African Violet, deepened for contrast */
    --accent-soft: #C77A94;            /* muted Pink Carnation */
    --card-bg: rgba(255, 255, 255, 0.65);
    --border-color: #D8C9E0;
    --gold: #B7937A;
    --wine: #A9647E;
    --emerald: #8489B8;                /* Jacaranda, softened */
    --ember: #D98DA0;
    --glass-bg: rgba(255, 255, 255, 0.55);
    --glass-shadow: 0 8px 24px 0 rgba(61, 46, 74, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    font-family: "EB Garamond", "Georgia", serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 15% 15%, rgba(167, 139, 201, 0.12) 0%, transparent 45%),
        radial-gradient(circle at 85% 75%, rgba(217, 141, 160, 0.10) 0%, transparent 45%);
    background-attachment: fixed;
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.7;
    font-size: 1.05rem;
    transition: background-color 0.4s ease, color 0.4s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

/* --- Glass Panels --- */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
    padding: 30px;
    margin-bottom: 40px;
    width: 100%;
}

/* --- Navbar --- */
.navbar {
    width: 100%;
    display: flex;
    justify-content: center;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 0;
    background: linear-gradient(to bottom, rgba(27,21,35,0.8), rgba(27,21,35,0.4));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

[data-theme="light"] .navbar {
    background: linear-gradient(to bottom, rgba(243,238,247,0.9), rgba(243,238,247,0.6));
}

.navbar-inner {
    width: 100%;
    max-width: 900px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.navbar a {
    color: var(--text-color);
    text-decoration: none;
    margin-right: 16px;
    font-weight: 600;
    letter-spacing: 0.4px;
    font-family: "Cormorant Garamond", serif;
    font-size: 1.15rem;
    position: relative;
    transition: color 0.25s ease;
}

.navbar a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -3px;
    width: 0%;
    height: 1px;
    background: var(--accent-color);
    transition: width 0.25s ease;
}

.navbar a:hover {
    color: var(--accent-color);
}

.navbar a:hover::after {
    width: 100%;
}

.container {
    width: 100%;
    max-width: 1000px;
    padding: 40px 20px;
    text-align: center;
    position: relative;
}

/* --- Botanical corner flourishes --- */
.container::before,
.container::after {
    content: "";
    position: absolute;
    width: 90px;
    height: 90px;
    background-repeat: no-repeat;
    opacity: 0.16;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M5 5 C 20 20, 15 45, 35 55 C 55 65, 60 40, 80 45' stroke='%23A78BC9' stroke-width='1.5' fill='none'/%3E%3Ccircle cx='35' cy='55' r='3' fill='%23A78BC9'/%3E%3Ccircle cx='80' cy='45' r='2.5' fill='%23A78BC9'/%3E%3Cpath d='M15 15 Q 25 5, 35 15' stroke='%23A78BC9' stroke-width='1.2' fill='none'/%3E%3C/svg%3E");
}

.container::before { top: 10px; left: 0; }
.container::after { bottom: 10px; right: 0; transform: rotate(180deg); }

/* --- Headings --- */
h1 {
    font-family: "Cormorant Garamond", "Playfair Display", serif;
    font-weight: 700;
    font-size: 3rem;
    color: var(--accent-color);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
    text-shadow: 0 0 18px rgba(167, 139, 201, 0.45);
}

h1::after {
    content: "❦ ✧ ❦";
    display: block;
    color: var(--accent-color);
    font-size: 1rem;
    letter-spacing: 6px;
    margin-top: 10px;
    opacity: 0.8;
}

h2 {
    font-family: "Cormorant Garamond", serif;
    font-weight: 600;
    font-style: italic;
    color: var(--accent-color);
    border-bottom: 1px solid var(--border-color);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 6px;
    margin-top: 40px;
    margin-bottom: 20px;
    font-size: 1.7rem;
}

h2::before {
    content: "✒️";
    font-size: 1rem;
    opacity: 0.85;
}

/* --- Forms / inputs --- */
form {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

label {
    font-family: "Cormorant Garamond", serif;
    font-weight: 600;
    letter-spacing: 0.3px;
}

input, textarea, select {
    font-family: "EB Garamond", inherit;
    font-size: 1.05rem;
    padding: 12px 18px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.35);
    color: var(--text-color);
    transition: all 0.3s ease;
}

[data-theme="light"] input,
[data-theme="light"] textarea,
[data-theme="light"] select {
    background-color: rgba(255,255,255,0.6);
}

textarea {
    border-radius: 14px;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(167, 139, 201, 0.35);
}

input[type="text"] {
    width: 320px;
    max-width: 65vw;
}

button {
    font-family: "Cormorant Garamond", serif;
    font-weight: 600;
    letter-spacing: 0.4px;
    font-size: 1.05rem;
    padding: 10px 26px;
    border-radius: 30px;
    border: 1px solid var(--accent-color);
    background: transparent;
    color: var(--accent-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

button:hover {
    background: var(--accent-color);
    color: var(--bg-color);
    box-shadow: 0 0 20px rgba(167, 139, 201, 0.5);
    transform: translateY(-2px);
}

.theme-toggle {
    background: none;
    border: 1px solid var(--accent-color);
    color: var(--text-color);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.95rem;
    transition: box-shadow 0.25s ease;
}

.theme-toggle:hover {
    background: transparent;
    color: var(--text-color);
    box-shadow: 0 0 12px rgba(167, 139, 201, 0.4);
    transform: none;
}

/* --- Book shelves / grids --- */
.shelf {
    margin-bottom: 20px;
}

.book-row, .book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 30px;
    perspective: 1200px;
    margin-top: 25px;
    padding: 20px 10px;
    text-align: left;
}

.book-row {
    display: flex;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) transparent;
}

.book-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    text-align: center;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.6s ease, border-color 0.6s ease;
    animation: fadeIn 0.5s ease backwards;
}

.book-card:nth-child(2) { animation-delay: 0.05s; }
.book-card:nth-child(3) { animation-delay: 0.1s; }
.book-card:nth-child(4) { animation-delay: 0.15s; }
.book-card:nth-child(5) { animation-delay: 0.2s; }
.book-card:nth-child(6) { animation-delay: 0.25s; }

.book-card a {
    text-decoration: none;
    color: var(--text-color);
}

.book-card:hover {
    transform: rotateY(-12deg) rotateX(8deg) scale(1.08) translateZ(30px);
    box-shadow:
        15px 20px 30px rgba(0, 0, 0, 0.7),
        inset 2px 2px 10px rgba(237, 230, 245, 0.12),
        -5px -5px 18px rgba(167, 139, 201, 0.3);
    border-color: var(--accent-color);
    z-index: 5;
}

.book-card img {
    max-width: 100%;
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 60% 60% 6px 6px / 30% 30% 6px 6px;
    border: 2px solid var(--gold);
    box-shadow: 0 4px 16px rgba(0,0,0,0.5), inset 0 0 12px rgba(0,0,0,0.3);
    transition: box-shadow 0.4s ease;
}

.book-card:hover img {
    box-shadow: 0 4px 22px rgba(184, 155, 110, 0.4), inset 0 0 12px rgba(0,0,0,0.3);
}

.book-card p {
    margin: 10px 0 2px 0;
    font-family: "Cormorant Garamond", serif;
    font-size: 1.05rem;
}

.book-card p:last-child {
    font-size: 0.9rem;
    color: var(--accent-soft);
    font-family: "EB Garamond", serif;
}

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

a {
    transition: color 0.2s ease;
}

.skeleton-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    height: 280px;
}

.skeleton-img, .skeleton-text {
    border-radius: 60% 60% 6px 6px / 30% 30% 6px 6px;
    background: linear-gradient(90deg, var(--border-color) 25%, var(--card-bg) 50%, var(--border-color) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
}

.skeleton-img { height: 200px; }
.skeleton-text { height: 14px; margin-top: 10px; border-radius: 4px; }

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.spice {
    filter: drop-shadow(0 0 4px rgba(217, 141, 160, 0.6));
}

/* --- Arch Frame Hero: castle image --- */
.arch-frame {
    position: relative;
    max-width: 640px;
    min-height: 420px;
    margin: 20px auto 50px;
    padding: 70px 30px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: 220px 220px 14px 14px / 110px 110px 14px 14px;
    background-image:
        linear-gradient(180deg, rgba(27,21,35,0.5) 0%, rgba(27,21,35,0.72) 55%, rgba(27,21,35,0.9) 100%),
        url("/static/images/hero-v2.png");
    background-size: cover;
    background-position: center;
    box-shadow: 0 0 60px rgba(167, 139, 201, 0.25), inset 0 0 40px rgba(0,0,0,0.5);
    overflow: hidden;
}

.arch-frame h1,
.arch-frame form,
.arch-frame p {
    position: relative;
    z-index: 3;
}

/* --- Simple arch variant (search/login/register) --- */
.arch-frame.simple {
    background-image:
        radial-gradient(circle at 30% 20%, rgba(167, 139, 201, 0.18) 0%, transparent 50%),
        radial-gradient(circle at 70% 80%, rgba(217, 141, 160, 0.12) 0%, transparent 50%);
    background-color: var(--glass-bg);
    box-shadow: 0 0 50px rgba(217, 141, 160, 0.18), inset 0 0 35px rgba(0,0,0,0.5);
}

.stars-field {
    position: absolute;
    inset: 0;
    z-index: 0;
    opacity: 0.55;
    background-image:
        radial-gradient(1.5px 1.5px at 20% 20%, #fff, transparent),
        radial-gradient(1px 1px at 40% 12%, #fff, transparent),
        radial-gradient(1.5px 1.5px at 65% 25%, #fff, transparent),
        radial-gradient(1px 1px at 80% 15%, #fff, transparent),
        radial-gradient(1.5px 1.5px at 30% 35%, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 55% 8%, #fff, transparent),
        radial-gradient(1.5px 1.5px at 90% 30%, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 10% 40%, rgba(255,255,255,0.7), transparent);
    animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle {
    0% { opacity: 0.4; }
    100% { opacity: 0.7; }
}

/* --- Sidebar Dashboard Layout --- */
.app-shell {
    display: flex;
    width: 100%;
    min-height: 100vh;
    align-items: stretch;
}

.sidebar {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 28px 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-right: 1px solid var(--border-color);
    z-index: 50;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) transparent;
}

.sidebar-brand {
    font-family: "Cormorant Garamond", serif;
    font-size: 1.35rem;
    color: var(--accent-color);
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 0 0 12px rgba(167, 139, 201, 0.4);
    animation: slideDown 0.5s ease backwards;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-nav a {
    color: var(--text-color);
    text-decoration: none;
    padding: 10px 14px;
    border-radius: 8px;
    font-family: "Cormorant Garamond", serif;
    font-size: 1.08rem;
    letter-spacing: 0.3px;
    transition: background 0.2s ease, color 0.2s ease;
    animation: slideDown 0.45s ease backwards;
}

.sidebar-nav a:nth-child(1) { animation-delay: 0.05s; }
.sidebar-nav a:nth-child(2) { animation-delay: 0.1s; }
.sidebar-nav a:nth-child(3) { animation-delay: 0.15s; }
.sidebar-nav a:nth-child(4) { animation-delay: 0.2s; }
.sidebar-nav a:nth-child(5) { animation-delay: 0.25s; }
.sidebar-nav a:nth-child(6) { animation-delay: 0.3s; }
.sidebar-nav a:nth-child(7) { animation-delay: 0.35s; }
.sidebar-nav a:nth-child(8) { animation-delay: 0.4s; }
.sidebar-nav a:nth-child(9) { animation-delay: 0.45s; }
.sidebar-nav a:nth-child(10) { animation-delay: 0.5s; }

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(167, 139, 201, 0.16);
    color: var(--accent-color);
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.sidebar-footer a, .sidebar-footer button {
    animation: slideDown 0.4s ease backwards;
    animation-delay: 0.55s;
}

.sidebar-footer a {
    color: var(--accent-soft);
    text-decoration: none;
    font-family: "Cormorant Garamond", serif;
    font-size: 1.05rem;
}

.sidebar-footer a:hover {
    color: var(--accent-color);
}

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

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

/* --- Activity calendar day squares --- */
.calendar-day {
    aspect-ratio: 1;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
}

.calendar-day.active-day {
    background: var(--accent-color);
}

@media (max-width: 768px) {
    .app-shell {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 14px;
        padding: 14px;
    }
    .sidebar-brand { margin-bottom: 0; font-size: 1.1rem; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 4px; }
    .sidebar-footer { flex-direction: row; }
}

@media (max-width: 600px) {
    h1 { font-size: 2.3rem; }
    input[type="text"] { width: 100%; max-width: 100%; }
    .book-row, .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 18px;
        perspective: 800px;
    }
    .book-card:hover {
        transform: rotateY(-6deg) rotateX(4deg) scale(1.04) translateZ(12px);
    }
    .container::before, .container::after {
        width: 50px;
        height: 50px;
    }
    .arch-frame { padding: 50px 16px 30px; border-radius: 140px 140px 10px 10px / 70px 70px 10px 10px; min-height: 320px; }
}

/* --- Forbidden Library mood atmospheres (palette-adaptive) --- */
.mood-library, .mood-gallery, .mood-cellar, .mood-countess,
.mood-ending-escape, .mood-ending-guardian, .mood-ending-cursed, .mood-ending-lost {
    background-size: cover;
    background-position: center;
    background-blend-mode: multiply;
}

.mood-library {
    background-image: linear-gradient(rgba(0,0,0,0.45), rgba(0,0,0,0.45)), url("/static/images/story/library.jpg");
}
.mood-gallery {
    background-image: linear-gradient(rgba(0,0,0,0.45), rgba(0,0,0,0.45)), url("/static/images/story/gallery.jpg");
}
.mood-cellar {
    background-image: linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url("/static/images/story/cellar.jpg");
}
.mood-countess {
    background-image: linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4)), url("/static/images/story/countess.jpg");
}
.mood-ending-escape {
    background-image: linear-gradient(rgba(0,0,0,0.35), rgba(0,0,0,0.35)), url("/static/images/story/ending_escape.jpg");
}
.mood-ending-guardian {
    background-image: linear-gradient(rgba(0,0,0,0.35), rgba(0,0,0,0.35)), url("/static/images/story/ending_guardian.jpg");
}
.mood-ending-cursed {
    background-image: linear-gradient(rgba(0,0,0,0.45), rgba(0,0,0,0.45)), url("/static/images/story/ending_cursed.jpg");
}
.mood-ending-lost {
    background-image: linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url("/static/images/story/ending_lost.jpg");
}


/* --- Force readable text over illustrated story scenes --- */
.mood-library, .mood-gallery, .mood-cellar, .mood-countess,
.mood-ending-escape, .mood-ending-guardian, .mood-ending-cursed, .mood-ending-lost {
    color: #F5F0E8;
}
.mood-library h1, .mood-gallery h1, .mood-cellar h1, .mood-countess h1,
.mood-ending-escape h1, .mood-ending-guardian h1, .mood-ending-cursed h1, .mood-ending-lost h1,
.mood-library h2, .mood-gallery h2, .mood-cellar h2, .mood-countess h2 {
    color: #F5F0E8 !important;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}
.mood-library p, .mood-gallery p, .mood-cellar p, .mood-countess p,
.mood-ending-escape p, .mood-ending-guardian p, .mood-ending-cursed p, .mood-ending-lost p {
    text-shadow: 0 1px 6px rgba(0,0,0,0.85);
}
