/*
===================================================================
 style.css (Version 15: Full-Width Desktop & Landscape Polish)
===================================================================
*/

/* ----------------------------------------------------------------- */
/* |                      1. ROOT VARIABLES                        | */
/* ----------------------------------------------------------------- */

:root {
    --bg-dark: #0D001F;
    --primary-purple: #1a0033;
    --secondary-purple: #4A007F; 
    --accent-gold: #FFD700;
    --glow-blue: #00BFFF;
    --text-light: #E0E0E0;
    --border-light: #330055;
    /*   Define header height as a variable for reuse. */
    --header-height: 65px; 
}
/*
===================================================================
  THEME FOR COLORIS PICKER
===================================================================
*/
.clr-picker,
.clr-field button,
.clr-field input {
    color: var(--text-light);
}

.clr-picker {
    background: var(--primary-purple);
    border: 1px solid var(--border-light);
    box-shadow: 0 0 20px var(--secondary-purple);
}

.clr-field input,
.clr-field button {
    border-color: var(--border-light);
}

.clr-field input:focus,
.clr-field button:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 5px var(--accent-gold);
}

.clr-alpha, .clr-hue, .clr-sat {
    background-image: none;
}

/* ----------------------------------------------------------------- */
/* |                      2. GENERAL STYLES                        | */
/* ----------------------------------------------------------------- */

body {
    background-color: var(--bg-dark);
    font-family: 'Roboto', sans-serif;
    color: var(--text-light);
    margin: 0;
    overflow-x: hidden;
    user-select: none;
}

h1, h2, h3 { 
    font-family: 'Cormorant Garamond', serif; 
    color: var(--text-light); 
    text-shadow: 0 0 8px rgba(127, 0, 255, 0.5); 
    text-align: center; 
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; margin-top: 1em; margin-bottom: 0.5em; }

/* Styles for section headers, both static (h3) and collapsible (summary) */
.control-section h3,
.control-section summary {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.2rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    position: relative; /* For positioning the arrow */
    list-style: none; /* Removes default marker from summary */
}

/* Make only the summary elements clickable */
.control-section summary {
    cursor: pointer;
    outline: none;
    transition: color 0.3s;
}

.control-section summary:hover {
    color: var(--accent-gold);
}

/* Hide the default dropdown arrow */
.control-section summary::-webkit-details-marker {
    display: none;
}

/* Create a custom arrow icon */
.control-section summary::after {
    content: '►';
    position: absolute;
    right: 5px;
    font-size: 0.8rem;
    color: var(--accent-gold);
    transition: transform 0.3s ease-in-out;
}

/* Rotate the arrow when the section is open */
.control-section details[open] > summary::after {
    transform: rotate(90deg);
}

/* Add some top margin to the content inside a details block */
.control-section details .control-group {
    margin-top: 1rem;
}

p.subtitle { text-align: center; font-size: 1.1rem; color: var(--text-light); opacity: 0.8; max-width: 600px; margin: 0 auto 1.5em auto; }
a { color: var(--accent-gold); text-decoration: none; }

.glowing-btn { 
    display: inline-block; 
    padding: 0.8em 1.5em; 
    border: 1px solid var(--accent-gold); 
    border-radius: 5px; 
    background-color: transparent; 
    color: var(--accent-gold); 
    font-family: 'Cormorant Garamond', serif; 
    font-size: 1.1rem; 
    font-weight: 700; 
    cursor: pointer; 
    transition: background-color 0.4s, box-shadow 0.4s; 
    margin-top: 1rem; 
}
.glowing-btn:hover { background-color: var(--accent-gold); color: var(--primary-purple); box-shadow: 0 0 20px var(--accent-gold); }

/* --- Themed Scrollbars --- */
::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-track { background: var(--primary-purple); }
::-webkit-scrollbar-thumb { background-color: var(--secondary-purple); border-radius: 6px; border: 2px solid var(--primary-purple); }
::-webkit-scrollbar-thumb:hover { background-color: var(--glow-blue); }


/* ----------------------------------------------------------------- */
/* |                   3. LAYOUT & STRUCTURE                       | */
/* ----------------------------------------------------------------- */

.container { 
    width: 90%; 
    max-width: 1400px; 
    margin: 0 auto; 
    padding: 1rem; 
    position: relative; 
    z-index: 2; 
}

#starfield-canvas { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    z-index: 0; 
    /*   Makes the canvas invisible to mouse events, allowing clicks to pass through to the controls underneath. */
    pointer-events: none;
}

header { 
    background-color: rgba(13, 0, 31, 0.7); 
    backdrop-filter: blur(8px); 
    position: sticky; 
    top: 0; 
    z-index: 10; 
    border-bottom: 1px solid var(--border-light); 
    height: var(--header-height);
    box-sizing: border-box;
    display: flex;
    align-items: center;
}
header nav { display: flex; justify-content: space-between; align-items: center; padding: 0; } /* Removed vertical padding */
header .logo { font-family: 'Cormorant Garamond', serif; font-size: 1.5rem; font-weight: 700; }
header ul { list-style: none; display: flex; gap: 1.5rem; margin: 0; padding: 0; }
header .nav-link:hover, header .nav-link.active { color: var(--accent-gold); text-shadow: 0 0 10px var(--accent-gold); }



/* ----------------------------------------------------------------- */
/* |                       4. HOME PAGE                            | */
/* ----------------------------------------------------------------- */

#hero { 
    min-height: 30vh; /* Adjusted for better vertical centering */
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    align-items: center; 
    text-align: center; 
}
#card-of-the-day-container { display: flex; justify-content: center; align-items: center; min-height: 320px; }
.card-container-single .card-container { width: 180px; height: 315px; font-size: 1rem; }
.card-day-description { text-align: center; font-style: italic; max-width: 600px; margin: 1rem auto; opacity: 0.9; min-height: 2em; }
.learn-more-container { text-align: center; margin-top: 1.5rem; opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity 0.5s ease-out, transform 0.5s ease-out; }
.learn-more-container.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }

/*   This new rule specifically targets the card back for the "Card of the Day"
   and applies the celestial theme, without affecting the card backs in the Reading Room. */
#card-of-the-day-container .card-back {
    background-image: url('../img/backs/celestial.jpg');
    background-size: cover;
    background-position: center;
    border: none; /* Remove the default border to match the theme */
}

/* ----------------------------------------------------------------- */
/* |              5. READING ROOM (FULL-WIDTH DESKTOP)             | */
/* ----------------------------------------------------------------- */

/* --- Main Layout --- */
.reading-room-layout { 
    display: grid; 
    grid-template-columns: 350px 1fr; /* Fixed sidebar, flexible canvas */
    height: calc(100vh - var(--header-height)); /* Full viewport height minus header */
}

/* --- Control Panel (Sticky Sidebar) --- */
.control-panel { 
    background-color: rgba(13, 0, 31, 0.95);
    padding: 0 1.5rem 1.5rem; 
    display: flex; 
    flex-direction: column; 
    box-sizing: border-box; 
    height: 100%;
    overflow-y: auto;
    border-right: 1px solid var(--border-light);
}
.control-section { 

    padding: 0.75rem 0; 
}
.control-section:first-child { padding-top: 0; }
.control-section:not(:first-child) { border-top: 1px solid var(--border-light); }
.control-group { display: flex; flex-direction: column; gap: 0.75rem; }
.control-panel #deal-cards-btn { width: 100%; margin-top: auto; font-size: 1.5rem; }

/* --- Specific Controls --- */
#spread-selection { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.spread-btn { padding: 0.7em; border: 1px solid var(--secondary-purple); background-color: transparent; color: var(--text-light); cursor: pointer; transition: all 0.3s; text-align: center; }
.spread-btn.selected, .spread-btn:hover { background-color: var(--secondary-purple); border-color: var(--glow-blue); color: white; }
#shuffle-methods {
    margin-top: 1rem; 
}

/* --- System Selector --- */
.system-select {
    width: 100%;
    padding: 10px;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-light);
    color: var(--accent-gold);
    border-radius: 4px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 1rem;
    cursor: pointer;
}
.system-select:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 10px var(--secondary-purple);
}

/* --- Styles for the Card Back Selector --- */
.card-back {
    /*   Using specific properties instead of the 'background' shorthand
       to prevent background-position and background-size from being reset. */
    background-color: var(--primary-purple);
    background-image: none;
    background-size: cover;
    background-position: center;
    border: 2px solid var(--secondary-purple);
}
.card-back-theme-artdeco .card-back {
    background-image: url('../img/backs/artdeco.jpg');
    background-size: cover;
    background-position: center;
    border: none;
}
.card-back-theme-botanical .card-back {
    background-image: url('../img/backs/botanical.jpg');
    background-size: cover;
    background-position: center;
    border: none;
}
.card-back-theme-celestial .card-back {
    background-image: url('../img/backs/celestial.jpg');
    background-size: cover;
    background-position: center;
    border: none;
}

.card-back-option input[type="radio"] {
    display: none; /* Hide the actual radio button */
}
.card-back-thumbnail {
    cursor: pointer;
    display: block;
    border-radius: 6px;
    overflow: hidden;
    border: 3px solid transparent;
    transition: border-color 0.3s, box-shadow 0.3s;
    aspect-ratio: 1 / 1.75; /* Enforce tarot card aspect ratio */
}
.card-back-thumbnail:hover {
    border-color: var(--secondary-purple);
}
.card-back-option input[type="radio"]:checked + .card-back-thumbnail {
    border-color: var(--accent-gold);
    box-shadow: 0 0 15px var(--accent-gold);
}
.card-back-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
/* Replace it with this rule */
.card-back-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); /* <-- Reduced size */
    gap: 0.75rem;
}
.default-back {
    background-color: var(--primary-purple);
    border: 2px solid var(--secondary-purple);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    text-align: center;
}
/* --- Styles for the collapsible shuffle explanation --- */
.shuffle-details-container {
    margin-top: 1.5rem; /* Add space above the summary */
}
.shuffle-details-container summary {
    cursor: pointer;
    font-style: italic;
    color: var(--accent-gold);
    opacity: 0.8;
    transition: opacity 0.3s;
    outline: none; /* Removes the focus ring on click */
    padding-bottom: 0.5rem;
}
.shuffle-details-container summary:hover {
    opacity: 1;
}
/* Hides the default arrow/marker */
.shuffle-details-container summary::-webkit-details-marker {
    display: none;
}
.shuffle-details-container summary {
    list-style: none;
}

#custom-spread-controls { margin-top: 1.5rem; }
#custom-spread-controls.hidden { display: none; }
#custom-spread-controls input { width: 60px; background-color: var(--bg-dark); color: var(--text-light); border: 1px solid var(--border-light); padding: 5px; border-radius: 4px; }
.spread-info-text { font-size: 0.85rem; font-style: italic; opacity: 0.8; min-height: 2.5em; margin-top: 1rem; }
#shuffle-methods { display: flex; flex-direction: column; gap: 0.75rem; }
.shuffle-input-group { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.shuffle-input { flex-grow: 1; box-sizing: border-box; background-color: var(--bg-dark); border: 1px solid var(--border-light); color: var(--text-light); padding: 10px; border-radius: 4px; font-size: 1rem; resize: vertical; min-height: 50px; }
.generate-btn { padding: 0.5rem; font-size: 1.2rem; background: var(--secondary-purple); border: 1px solid var(--border-light); color: var(--text-light); cursor: pointer; border-radius: 4px; display: none; }
.shuffle-explanation { background-color: rgba(0,0,0,0.3); border: 1px solid var(--border-light); padding: 1rem; margin-top: 1rem; border-radius: 8px; font-family: monospace; font-size: 0.8rem; }
.shuffle-math-text { margin-top: 0.5rem; font-weight: bold; word-break: break-all; }
.slider-group .slider-wrapper { display: flex; align-items: center; gap: 0.5rem; }
input[type="range"] { flex-grow: 1; }
.reset-btn { font-size: 1.2rem; background: none; border: 1px solid var(--border-light); color: var(--text-light); cursor: pointer; border-radius: 4px; padding: 0.2rem 0.5rem; }

/* --- Canvas and Action Buttons (Desktop) --- */
.reading-canvas { 
    height: 100%; 
    background-color: transparent; 
    overflow: hidden; 
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    cursor: grab;
    position: relative;
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none;     /* IE 10+ */
    user-select: none;         /* Standard syntax */
}

.reading-canvas.cloth-theme-pattern1::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../img/cloth/pattern.png');
    background-repeat: repeat;
    opacity: 0.15; /*   Lowered opacity to make it a subtle background texture. */
    z-index: 0;
    pointer-events: none; /* Ensures it doesn't interfere with clicks */
}
.reading-canvas:active { cursor: grabbing; }

.canvas-placeholder-text { 
    position: absolute; /* Position relative to canvas */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center; 
    font-size: 1.2rem; 
    opacity: 0.5;
    z-index: 1;
}



.reveal-all-container { 
    position: absolute; /* Position within the canvas */
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}
.reveal-all-container.hidden { display: none; }

/*   These new rules create the "Blueprint Mode" effect before cards are dealt. */
.reading-canvas::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(13, 0, 31, 0.7); /* A dark, semi-opaque overlay */
    z-index: 2; /* Sits above the cloth background but below the placeholders */
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

.reading-canvas.blueprint-mode::before {
    opacity: 1; /* Makes the overlay visible */
}

/* --- Mobile-Only Elements (Hidden on Desktop) --- */
#drawer-close-btn { display: none; }
#mobile-controls-trigger { display: none; }


.custom-color-picker-input {
    width: 100%;
    height: 100%;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 0.8rem;
    text-align: center;
    background-color: transparent;
    color: var(--text-light);
}

/* Styles for the little color swatch next to the input field */
.clr-field .clr-preview {
    border-radius: 4px;
}
/* ----------------------------------------------------------------- */
/* |                       6. CARD STYLING                         | */
/* ----------------------------------------------------------------- */

.reading-cloth {
    position: relative; /* ANNOTATION: Establishes the canvas for absolute positioning. */
    width: 100%;
    min-height: 100%;
    transition: transform 0.3s ease-out;
    transform-origin: center center;
    touch-action: none;
}
.position-container {
    position: absolute; /* ANNOTATION: Allows each card to be placed by top/left coordinates. */
    width: 120px;
    height: 210px;
}
.position-label { position: absolute; bottom: -25px; left: 50%; transform: translateX(-50%); width: 150%; text-align: center; font-size: 0.8rem; color: var(--text-light); opacity: 0.7; transition: opacity 0.3s; pointer-events: none; }
.position-container:hover .position-label { opacity: 1; font-weight: bold; }

/* The container for the overlapping cards */
.overlap-group {
    cursor: pointer; /* Indicate it's interactive */
}

/* Base transition for ALL position-containers within an overlap-group */
.overlap-group .position-container {
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.4s ease-out; /* Smooth transition */
}

/* NEW/UPDATED: Base state for the top overlapping card (for animation) */
.overlap-top-card {
    /* ANNOTATION: This defines the starting point for animation for translateY and rotateZ. */
    /* The base rotation (e.g., rotate(90deg)) will come from its .rotate-XXX class and combine. */
    transform: translateY(0) rotateZ(0);
    z-index: 2;
}

/* When hovering over the group, the top card slides away and fades out */
.overlap-group:hover .overlap-top-card {
    /* ANNOTATION: Apply additional transforms. These will combine with the base rotation class. */
    transform: translateY(-120px) rotateZ(15deg); /* Adjust slide/turn amounts as needed */
    opacity: 0.65; /* Desired transparency */
    z-index: 10; /* Ensure it's above during animation */
}

/* When hovering over the group, the bottom card becomes fully visible and stays put */
.overlap-group:hover .overlap-bottom-card {
    opacity: 1; /* Ensure full visibility */
    transform: translateY(0); /* Ensure it doesn't move */
    z-index: 9; /* Keep it below the top card's animation */
}

/* Ensure the initial z-index for the bottom card */
.overlap-bottom-card {
    z-index: 1;
}

/* ANNOTATION: New base rotation classes (used by JS instead of inline styles) */
.rotate-0 {
    transform: rotate(0deg);
}
.rotate-90 {
    transform: rotate(90deg);
}
.rotate-180 {
    transform: rotate(180deg);
}
.rotate-270 {
    transform: rotate(270deg);
}

/*   In blueprint mode, make labels fully opaque and add a shadow for readability. */
.blueprint-mode .position-label {
    opacity: 1;
    text-shadow: 0 0 6px rgba(0,0,0,0.9);
}
.card-container { 
    position: relative; 
    width: 100%; 
    height: 100%; 
    perspective: 1000px; 
    cursor: pointer; 
    /* ANNOTATION: This is the missing piece. It disables the tap highlight
       on the container that the user actually clicks to initiate the flip. */
    -webkit-tap-highlight-color: transparent;
}
.tarot-card { 
    position: absolute; 
    width: 100%; 
    height: 100%; 
    transform-style: preserve-3d; 
    transition: transform 0.8s; 
    /* ANNOTATION: This removes the default blue/gray tap highlight on mobile browsers. */
    -webkit-tap-highlight-color: transparent;
}
.card-container.flipped .tarot-card { transform: rotateY(180deg); }
.card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; border-radius: 8px; box-shadow: 0 0 15px rgba(0,0,0,0.5); overflow: hidden; }
.card-back { background: var(--primary-purple); border: 2px solid var(--secondary-purple); }
.card-front { transform: rotateY(180deg); }
.card-front img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.card-front img.reversed { transform: rotate(180deg); }
/*   Replaced the dashed outline with a solid, glowing placeholder for better visibility in blueprint mode. */
.card-placeholder {
    width: 100%;
    height: 100%;
    border: 1px solid var(--glow-blue);
    border-radius: 10px;
    background: rgba(13, 0, 31, 0.7);
    box-shadow: 0 0 10px rgba(0, 191, 255, 0.5);
}

/* ----------------------------------------------------------------- */
/* |                  7. SHUFFLE ZONE MODAL                       | */
/* ----------------------------------------------------------------- */

.shuffle-zone-content {
    display: grid;
    grid-template-rows: 1fr auto; /* Stage on top, controls on bottom */
    height: 100%;
    max-height: 450px;
    padding: 1rem 0;
    box-sizing: border-box;
    gap: 1rem;
}

#visual-deck-container {
    width: 100%; /* Allow it to take full width of the modal content area */
    display: flex; /* Use flex to center its own child (the deck) */
    justify-content: center;
    align-items: center;
    position: relative;
    perspective: 1000px;
    flex-grow: 1; /* ANNOTATION: This is the key fix. It makes this container take all available vertical space. */
    min-height: 0; /* A flexbox fix to prevent overflow issues */
}

/* This is the base style for the deck in the shuffle zone. It has no image by default. */
.visual-deck {
    width: 100%;
    max-width: 120px; /* Set a max-width to match animation cards */
    aspect-ratio: 1 / 1.75; /* ANNOTATION: This is the key fix for the shape. */
    background-color: var(--primary-purple); /* Fallback color */
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    box-shadow: 
        0 2px 2px rgba(0,0,0,0.5),
        0 4px 4px rgba(0,0,0,0.4),
        0 6px 6px rgba(0,0,0,0.3),
        0 8px 8px rgba(0,0,0,0.2),
        0 10px 10px rgba(0,0,0,0.1);
    position: relative;
    border: 2px solid var(--secondary-purple);
}

/* ANNOTATION: These new rules dynamically apply the selected theme to the visual deck */
.card-back-theme-artdeco .visual-deck {
    background-image: url('../img/backs/artdeco.jpg');
    border: none;
}
.card-back-theme-botanical .visual-deck {
    background-image: url('../img/backs/botanical.jpg');
    border: none;
}
.card-back-theme-celestial .visual-deck {
    background-image: url('../img/backs/celestial.jpg');
    border: none;
}

/* ANNOTATION: Corrected path for the cloth pattern */
.reading-canvas.cloth-theme-pattern1::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../img/cloth/pattern.png'); /* Corrected path */
    background-repeat: repeat;
    opacity: 0.15;
    z-index: 0;
    pointer-events: none;
}

#shuffle-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.shuffle-btn {
    padding: 0.6em 1.2em;
    border: 1px solid var(--secondary-purple);
    background-color: transparent;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 5px;
}

.shuffle-btn:hover {
    background-color: var(--secondary-purple);
    border-color: var(--glow-blue);
}

/* --- Cut Animation Styles --- */
.deck-half {
    width: 120px; /* Give it a fixed width */
    height: auto; /* Height will be set by aspect-ratio */
    aspect-ratio: 1 / 1.75; /* Enforce correct card shape */
    position: absolute;
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

.deck-half-bottom {
    animation: cut-bottom-half-animation 0.8s ease-in-out forwards;
}

.deck-half-top {
    animation: cut-top-half-animation 0.8s ease-in-out forwards;
}

@keyframes cut-bottom-half-animation {
    0%   { transform: translate(0, 0); z-index: 1; }
    50%  { transform: translate(-80px, 0); z-index: 1; }
    100% { transform: translate(0, 0); z-index: 1; }
}

@keyframes cut-top-half-animation {
    0%   { transform: translate(0, 0); z-index: 2; }
    25%  { transform: translate(80px, 0); z-index: 2; }
    50%  { transform: translate(80px, -60px); z-index: 3; } /* Lifts above */
    75%  { transform: translate(-80px, -60px); z-index: 3; }
    100% { transform: translate(0, 0); z-index: 2; }
}

/* --- Deal Animation Styles --- */
.flying-card {
    /* These cards exist outside the normal flow, on a layer above everything. */
    position: fixed;
    z-index: 2000; /* Ensure they are on top of all other UI */
    width: 120px; /* Matches the size of the final cards */
    height: 210px;
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    /* This transition is the magic that creates the "flying" effect. */
    transition: all 0.6s cubic-bezier(0.5, 0, 0.2, 1);
}

/* ----------------------------------------------------------------- */
/* |                       8. GRIMOIRE & MODAL                     | */
/* ----------------------------------------------------------------- */

.grimoire-controls { max-width: 800px; margin: 2rem auto; display: flex; flex-direction: column; gap: 1.5rem; }
#grimoire-search { font-size: 1.2rem; padding: 12px; width: 100%; box-sizing: border-box; background-color: var(--bg-dark); border: 1px solid var(--border-light); color: var(--text-light); border-radius: 4px; text-align: center; }
#grimoire-search:focus { outline: none; border-color: var(--accent-gold); box-shadow: 0 0 10px var(--accent-gold); }
.grimoire-filters { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.grimoire-filter-btn { padding: 0.5em 1em; border: 1px solid var(--secondary-purple); background-color: transparent; color: var(--text-light); cursor: pointer; transition: all 0.3s; border-radius: 4px; }
.grimoire-filter-btn.active, .grimoire-filter-btn:hover { background-color: var(--secondary-purple); border-color: var(--glow-blue); color: white; }
#grimoire-results-count { text-align: center; opacity: 0.8; font-style: italic; }

.grimoire-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 3rem 1.5rem; margin-top: 2rem; justify-items: center; }
/*   Renamed from .grimoire-card to match the class being created in main.js. This is the primary fix. */
.grimoire-card-container { width: 150px; display: flex; flex-direction: column; align-items: center; cursor: pointer; transition: transform 0.3s ease-out; }
.grimoire-card-container:hover { transform: scale(1.05); }
.grimoire-card-container img { width: 100%; height: auto; border-radius: 8px; box-shadow: 0 0 15px rgba(0,0,0,0.5); background-color: var(--primary-purple); }
.grimoire-card-container .grimoire-card-name { margin-top: 0.75rem; font-family: 'Cormorant Garamond', serif; font-weight: bold; font-size: 0.9rem; color: var(--text-light); text-align: center; }
.no-results { grid-column: 1 / -1; text-align: center; font-size: 1.2rem; opacity: 0.7; }

/* Modal Styles */
.modal-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.8); backdrop-filter: blur(5px); z-index: 100; display: flex; justify-content: center; align-items: center; opacity: 0; transition: opacity 0.3s ease-in-out; pointer-events: none; }
.modal-container:not(.hidden) { opacity: 1; pointer-events: all; }
.modal-content { background-color: var(--primary-purple); border: 1px solid var(--secondary-purple); box-shadow: 0 0 30px var(--secondary-purple); border-radius: 10px; padding: 2rem; width: 90%; max-width: 800px; max-height: 90vh; overflow-y: auto; position: relative; transform: scale(0.95); transition: transform 0.3s ease-in-out; }
.modal-container:not(.hidden) .modal-content { transform: scale(1); }
.close-modal { position: absolute; top: 15px; right: 20px; font-size: 2rem; color: var(--text-light); background: none; border: none; cursor: pointer; }
#modal-card-content { display: flex; gap: 2rem; flex-direction: column; }
#modal-card-content img { max-width: 200px; border-radius: 8px; align-self: center; }
#modal-card-content h3 { text-align: center; margin-bottom: 0.5rem; font-size: 2rem; }
#modal-card-content p { line-height: 1.6; }
.meaning-section { padding: 0.5rem; border-radius: 4px; transition: background-color 0.3s; border: 1px solid transparent; }
.meaning-section.highlight { background-color: rgba(74, 0, 127, 0.5); border-color: var(--glow-blue); }
#modal-card-content details { border: 1px solid var(--border-light); border-radius: 4px; margin-bottom: 0.5rem; }
#modal-card-content summary { font-weight: bold; cursor: pointer; padding: 0.5rem; }
#modal-card-content .details-content { padding: 0 0.5rem 0.5rem 0.5rem; }
.dict-link { font-style: italic; color: var(--accent-gold); border-bottom: 1px dotted var(--accent-gold); cursor: help; text-decoration: none; }

.layout-chakra-spread .position-container {
    flex-shrink: 0;
}
/* ----------------------------------------------------------------- */
/* |               9. MOBILE RESPONSIVE STYLES                     | */
/* ----------------------------------------------------------------- */

@media (max-width: 900px) {
    /* Revert Reading Room to a simple block layout for stacking on mobile */
    .reading-room-layout { 
        display: block;
        height: auto; /* Let content determine height */
    }

    /* Ensure canvas has a minimum height on mobile */
    .reading-canvas {
        min-height: 80vh;
        z-index: 1;
    }

    /* Control Panel Drawer Styling */
    .control-panel { 
        position: fixed; 
        bottom: 0; 
        left: 0; 
        right: 0; 
        width: 100%; 
        height: auto; 
        max-height: 85vh; 
        overflow-y: auto; 
        z-index: 1000;
        border-right: none;
        border-top-left-radius: 20px; 
        border-top-right-radius: 20px; 
        transform: translateY(100%); 
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1); 
        padding-top: 2.5rem;
        padding-bottom: 5rem; /* Space for the fixed action bar */
    }
    .control-panel.is-open { transform: translateY(0); box-shadow: 0 -10px 40px rgba(0,0,0,0.5); }
    #drawer-close-btn { display: block; top: 5px; right: 5px; z-index: 1001; }
    #mobile-controls-trigger { display: inline-block; }

    /* Hide desktop-only elements and show mobile ones */
    .slider-group { display: none; }
    .reveal-all-container { position: static; transform: none; text-align: center; } /* Reset desktop positioning */
    
    .canvas-placeholder-text {
        width: 80%;
        z-index: 5;
    }
    
    .canvas-hint {
        display: none;
        position: absolute;
        /* ANNOTATION: Positions the hint near the top, not the center. */
        top: 20px; 
        left: 50%;
        /* We only need to translate on the X-axis now */
        transform: translateX(-50%); 
        z-index: 10;
        width: auto;
        padding: 0.8em 1.2em; /* Slightly smaller padding */
        background-color: rgba(13, 0, 31, 0.8);
        border: 1px solid var(--border-light);
        border-radius: 8px;
        font-family: 'Cormorant Garamond', serif;
        font-size: 1.1rem;
        color: var(--text-light);
        opacity: 1; /* Start fully visible */
        transition: opacity 0.4s ease-out, transform 0.4s ease-out;
        pointer-events: none;
    }

    .canvas-hint.hidden {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9); /* Add a subtle shrink effect */
    }

    /* Mobile Action Bar Layout */
#mobile-action-bar {
    /* ANNOTATION: Switched to CSS Grid for a robust two-column layout. */
    display: grid;
    grid-template-columns: 1fr 1fr;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0 1rem 1rem 1rem;
    gap: 1rem;
    z-index: 100;
}

    /*   Polish for landscape mode on mobile devices. */
    @media (orientation: landscape) {
        #hero {
            min-height: 0; /* Let content define height */
            padding: 1rem 0;
        }
        header {
            height: 50px; /* Make header shorter */
        }
        
    }
}

/* --- Larger screen modal adjustments --- */
@media (min-width: 768px) {
    #modal-card-content { 
        flex-direction: row; 
        align-items: flex-start; 
    }
    #modal-card-content img { 
        width: 200px; 
        flex-shrink: 0; 
    }
}

.shuffle-card {
    width: 120px; /* Give it a fixed width */
    height: auto;
    aspect-ratio: 1 / 1.75; /* Enforce correct card shape */
    position: absolute;
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease-in-out;
    transform: translate(0, 0) rotate(0deg);
    opacity: 0;
}

/*
===================================================================
  10. SPREAD CREATOR STYLES
===================================================================
*/

/* --- Creator Layout --- */
#spread-creator-view #creator-canvas-wrapper {
    position: relative;
    overflow: hidden;
}

#spread-creator-view #creator-canvas,
#spread-creator-view #creator-card-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 1600px;
    height: 1200px;
    transform-origin: top left;
    transition: transform 0.3s ease-out;
}

#spread-creator-view #creator-canvas {
    z-index: 1;
    pointer-events: auto;
}

#spread-creator-view #creator-card-container {
    z-index: 2;
    pointer-events: none;
}

/* --- Creator Card Placeholders --- */
#spread-creator-view .creator-card-placeholder {
    width: 120px;
    height: 210px;
    pointer-events: auto;
    cursor: grab;
}

#spread-creator-view .creator-card-placeholder:active {
    cursor: grabbing;
    z-index: 100;
}

#spread-creator-view .creator-card-placeholder.selected .card-placeholder {
    border-color: var(--accent-gold);
    box-shadow: 0 0 15px var(--accent-gold);
}

/* --- Creator Sidebar Controls --- */
#spread-creator-view .control-panel label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.9rem;
    opacity: 0.8;
}

#spread-creator-view .control-panel input[type="text"],
#spread-creator-view .control-panel input[type="number"],
#spread-creator-view .control-panel textarea {
    width: 100%;
    box-sizing: border-box;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-light);
    color: var(--text-light);
    padding: 8px;
    border-radius: 4px;
    font-size: 1rem;
}

#spread-creator-view .control-panel textarea {
    resize: vertical;
    min-height: 80px;
}

#spread-creator-view .control-panel input:focus,
#spread-creator-view .control-panel textarea:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 10px var(--accent-gold);
}

#spread-creator-view .nudge-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
    justify-items: center;
}

#spread-creator-view .nudge-buttons button {
    background: var(--secondary-purple);
    border: 1px solid var(--border-light);
    color: var(--text-light);
    border-radius: 4px;
    font-size: 1.2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
}
#spread-creator-view #nudge-up { grid-column: 2 / 3; }
#spread-creator-view #nudge-left { grid-column: 1 / 2; grid-row: 2 / 3; }
#spread-creator-view #nudge-right { grid-column: 3 / 4; grid-row: 2 / 3; }
#spread-creator-view #nudge-down { grid-column: 2 / 3; grid-row: 3 / 4; }

/* --- Saved Spreads List --- */
#spread-creator-view .saved-spreads-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#spread-creator-view .saved-spreads-list li {
    background-color: rgba(0,0,0,0.2);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

#spread-creator-view .saved-spread-name {
    font-weight: bold;
}

#spread-creator-view .saved-spread-actions {
    display: flex;
    gap: 0.5rem;
}

#spread-creator-view .saved-spread-actions .glowing-btn {
    padding: 0.4em 0.8em;
    margin-top: 0;
    font-size: 0.9rem;
}

#spread-creator-view .no-saved-spreads-text {
    font-style: italic;
    opacity: 0.7;
    text-align: center;
}

.meaning-section.dimmed {
    opacity: 0.5;
    border-color: transparent;
}
.meaning-section.highlight {
    opacity: 1;
    background-color: rgba(74, 0, 127, 0.5); 
    border: 1px solid var(--glow-blue);
    box-shadow: 0 0 10px rgba(0, 191, 255, 0.2);
}