/*
 * Tarot Web Interface - Art Nouveau Style
 * Inspired by Alphonse Mucha and the 1909 Rider-Waite deck
 */

/* =============================================================================
   CSS VARIABLES
   ============================================================================= */

:root {
    /* Color palette */
    --burgundy: #6B1839;
    --burgundy-dark: #4A1128;
    --forest: #2D5A27;
    --forest-dark: #1E3D1A;
    --gold: #C9A227;
    --gold-light: #E4C54A;
    --gold-pale: #F5E6B3;
    --cream: #F5F0E6;
    --parchment: #E8DCC4;
    --brown: #3D2B1F;
    --brown-light: #6B5344;

    /* Typography */
    --font-display: 'Cinzel', 'Times New Roman', serif;
    --font-body: 'Cormorant Garamond', 'Georgia', serif;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 2rem;
    --space-xl: 4rem;

    /* Border radius for organic shapes */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;

    /* Shadows */
    --shadow-soft: 0 2px 8px rgba(61, 43, 31, 0.15);
    --shadow-card: 0 4px 20px rgba(61, 43, 31, 0.25);
    --shadow-elevated: 0 8px 32px rgba(61, 43, 31, 0.3);
}

/* =============================================================================
   RESET & BASE
   ============================================================================= */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 18px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: 1.2rem;
    line-height: 1.7;
    letter-spacing: -0.01em;
    color: var(--brown);
    background: var(--cream);
    min-height: 100vh;
    position: relative;

    /* Subtle texture overlay */
    background-image:
        radial-gradient(ellipse at 20% 30%, rgba(201, 162, 39, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(107, 24, 57, 0.06) 0%, transparent 50%),
        linear-gradient(180deg, var(--cream) 0%, var(--parchment) 100%);
}

/* =============================================================================
   DECORATIVE CORNER ORNAMENTS
   ============================================================================= */

.corner-ornament {
    position: fixed;
    width: 120px;
    height: 120px;
    pointer-events: none;
    z-index: 100;
    opacity: 0.4;
}

.corner-ornament::before {
    content: '';
    position: absolute;
    width: 80px;
    height: 80px;
    border: 2px solid var(--gold);
}

.top-left {
    top: 20px;
    left: 20px;
}
.top-left::before {
    border-right: none;
    border-bottom: none;
    border-top-left-radius: 30px;
}

.top-right {
    top: 20px;
    right: 20px;
}
.top-right::before {
    right: 0;
    border-left: none;
    border-bottom: none;
    border-top-right-radius: 30px;
}

.bottom-left {
    bottom: 20px;
    left: 20px;
}
.bottom-left::before {
    bottom: 0;
    border-right: none;
    border-top: none;
    border-bottom-left-radius: 30px;
}

.bottom-right {
    bottom: 20px;
    right: 20px;
}
.bottom-right::before {
    right: 0;
    bottom: 0;
    border-left: none;
    border-top: none;
    border-bottom-right-radius: 30px;
}

/* =============================================================================
   HEADER
   ============================================================================= */

.site-header {
    padding: var(--space-lg) var(--space-xl);
    position: relative;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-decoration: none;
    color: var(--burgundy);
}

.logo-symbol {
    font-size: 1.5rem;
    color: var(--gold);
}

.logo-text {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: var(--space-lg);
}

.nav-link {
    font-family: var(--font-display);
    font-size: 0.875rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--brown);
    padding: var(--space-sm) 0;
    position: relative;
    transition: color 0.3s ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--gold);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
    color: var(--burgundy);
}

.nav-link:hover::after,
.nav-link.active::after {
    transform: scaleX(1);
}

/* Subtle nav links (e.g., Sign Out) */
.nav-link-subtle {
    color: var(--brown-light);
    font-size: 0.75rem;
}

.nav-link-subtle:hover {
    color: var(--burgundy);
}

.header-ornament {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 2px;
    background: linear-gradient(90deg,
        transparent,
        var(--gold) 20%,
        var(--gold) 80%,
        transparent
    );
}

/* =============================================================================
   MAIN CONTENT
   ============================================================================= */

.main-content {
    min-height: calc(100vh - 200px);
    padding: var(--space-lg) var(--space-xl);
    max-width: 1400px;
    margin: 0 auto;
}

.page-title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 500;
    color: var(--burgundy);
    text-align: center;
    margin-bottom: var(--space-sm);
    letter-spacing: 0.05em;
}

.page-subtitle {
    font-family: var(--font-body);
    font-size: 1.125rem;
    font-style: italic;
    color: var(--brown-light);
    text-align: center;
    margin-bottom: var(--space-xl);
}

/* =============================================================================
   READING INTERFACE
   ============================================================================= */

.reading-container {
    max-width: 1000px;
    margin: 0 auto;
}

.spread-selector {
    text-align: center;
    padding: var(--space-xl) 0;
}

.spread-options {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    flex-wrap: wrap;
    margin-top: var(--space-lg);
}

.spread-btn {
    background: var(--parchment);
    border: 2px solid var(--gold-pale);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    width: 200px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
}

.spread-btn:hover {
    background: var(--cream);
    border-color: var(--gold);
    transform: translateY(-4px);
    box-shadow: var(--shadow-card);
}

.spread-icon {
    font-size: 1.5rem;
    color: var(--gold);
    letter-spacing: 4px;
}

.spread-name {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 500;
    color: var(--burgundy);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.spread-desc {
    font-size: 0.875rem;
    color: var(--brown-light);
    font-style: italic;
}

/* Reading area */
.reading-area {
    padding: var(--space-xl) 0;
    animation: fadeIn 0.5s ease;
}

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

.reading-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
}

.reading-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--burgundy);
}

.new-reading-btn {
    font-family: var(--font-display);
    font-size: 0.875rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: transparent;
    border: 1px solid var(--gold);
    color: var(--gold);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
}

.new-reading-btn:hover {
    background: var(--gold);
    color: var(--cream);
}

.cards-display {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

/* Individual drawn card */
.drawn-card {
    width: 280px;
    cursor: pointer;
    transition: transform 0.3s ease;
    animation: cardReveal 0.6s ease backwards;
}

.drawn-card:hover {
    transform: scale(1.02);
}

@keyframes cardReveal {
    from {
        opacity: 0;
        transform: translateY(30px) rotateY(90deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) rotateY(0);
    }
}

.drawn-card:nth-child(1) { animation-delay: 0.1s; }
.drawn-card:nth-child(2) { animation-delay: 0.3s; }
.drawn-card:nth-child(3) { animation-delay: 0.5s; }
.drawn-card:nth-child(4) { animation-delay: 0.7s; }
.drawn-card:nth-child(5) { animation-delay: 0.9s; }

.card-position {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--gold);
    text-align: center;
    margin-bottom: var(--space-sm);
}

/* =============================================================================
   CARD FRAME - Art Nouveau Style
   ============================================================================= */

.card-frame {
    position: relative;
    background: linear-gradient(135deg, var(--gold-pale) 0%, var(--parchment) 50%, var(--gold-pale) 100%);
    padding: 12px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}

.card-frame::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid var(--gold);
    border-radius: calc(var(--radius-md) - 4px);
    pointer-events: none;
}

.card-frame img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: calc(var(--radius-md) - 8px);
}

.card-frame.reversed img {
    transform: rotate(180deg);
}

/* Large card frame for detail page */
.card-frame.large {
    max-width: 350px;
    padding: 16px;
}

.card-frame.large::before {
    inset: 6px;
}

.card-info {
    text-align: center;
    padding: var(--space-md) 0;
}

.card-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 500;
    color: var(--burgundy);
    margin-bottom: var(--space-xs);
}

.card-orientation {
    font-size: 0.875rem;
    color: var(--brown-light);
    font-style: italic;
}

.card-orientation.reversed {
    color: var(--burgundy);
}

/* =============================================================================
   CARD BROWSER / DECK
   ============================================================================= */

.deck-container {
    max-width: 1200px;
    margin: 0 auto;
}

.deck-filters {
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
    margin-bottom: var(--space-xl);
}

.filter-btn {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: transparent;
    border: 1px solid var(--gold-pale);
    color: var(--brown);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--cream);
}

.card-section {
    margin-bottom: var(--space-xl);
}

.card-section.hidden {
    display: none;
}

.section-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--burgundy);
    text-align: center;
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
}

.section-ornament {
    color: var(--gold);
    font-size: 1rem;
}

.section-subtitle {
    font-style: italic;
    color: var(--brown-light);
    text-align: center;
    margin-bottom: var(--space-lg);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-lg);
}

.card-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s ease;
}

.card-thumb:hover {
    transform: translateY(-8px);
}

.card-thumb .card-frame {
    width: 100%;
    transition: box-shadow 0.3s ease;
}

.card-thumb:hover .card-frame {
    box-shadow: var(--shadow-elevated);
}

.card-name {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--brown);
    text-align: center;
    margin-top: var(--space-sm);
}

/* =============================================================================
   CARD DETAIL PAGE
   ============================================================================= */

.card-detail-container {
    max-width: 1000px;
    margin: 0 auto;
}

.back-link {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--gold);
    margin-bottom: var(--space-lg);
    transition: color 0.3s ease;
}

.back-link:hover {
    color: var(--burgundy);
}

.card-detail-layout {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: var(--space-xl);
    align-items: start;
}

@media (max-width: 768px) {
    .card-detail-layout {
        grid-template-columns: 1fr;
    }
}

.card-detail-image {
    position: sticky;
    top: var(--space-lg);
}

.card-detail-title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 500;
    color: var(--burgundy);
    margin-bottom: var(--space-sm);
}

.card-type-badge {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-lg);
}

.card-type-badge.major {
    background: var(--burgundy);
    color: var(--cream);
}

.card-type-badge.minor {
    background: var(--forest);
    color: var(--cream);
}

.card-section-block {
    margin-bottom: var(--space-lg);
    padding: var(--space-md);
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--gold);
}

.card-section-block h2 {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--brown);
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.card-section-block.upright h2 {
    color: var(--forest);
}

.card-section-block.reversed h2 {
    color: var(--burgundy);
}

.orientation-icon {
    font-size: 0.75rem;
}

.themes {
    font-size: 0.875rem;
    color: var(--brown-light);
    margin-bottom: var(--space-sm);
    font-style: italic;
}

.card-text {
    font-size: 1rem;
    line-height: 1.7;
}

/* =============================================================================
   MODAL / OVERLAY
   ============================================================================= */

.card-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(61, 43, 31, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: var(--space-lg);
    animation: fadeIn 0.3s ease;
}

.card-overlay.active {
    display: flex;
}

.card-detail-modal {
    background: var(--cream);
    border-radius: var(--radius-lg);
    max-width: 420px;
    max-height: 95vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-elevated);
}

.close-modal {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    background: transparent;
    border: none;
    font-size: 2rem;
    color: var(--brown-light);
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
}

.close-modal:hover {
    color: var(--burgundy);
}

.modal-content {
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.modal-card-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.modal-card-image {
    flex-shrink: 0;
    margin-bottom: var(--space-md);
}

.modal-card-image .card-frame {
    width: 240px;
}

.modal-card-info {
    text-align: center;
}

.modal-card-info h2 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    color: var(--burgundy);
    margin-bottom: var(--space-xs);
}

/* Modal keywords as pills */
.modal-keywords {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: var(--space-sm);
}

.modal-keywords .keyword-tag {
    font-size: 0.8rem;
    padding: 0.3rem 0.8rem;
}

.modal-meaning {
    width: 100%;
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--gold-pale);
}

.modal-meaning h3 {
    font-family: var(--font-display);
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: var(--space-sm);
}

.modal-meaning .card-text {
    font-size: 1.15rem;
    line-height: 1.8;
    text-align: left;
}

/* Drop cap in modal meaning - spans 2 lines */
.modal-meaning .card-text p:first-child::first-letter {
    font-family: var(--font-display);
    font-size: 3em;
    float: left;
    line-height: 0.65;
    margin-top: 0.1em;
    margin-right: 0.05em;
    color: var(--burgundy);
}

/* =============================================================================
   FOOTER
   ============================================================================= */

.site-footer {
    padding: var(--space-lg) var(--space-xl);
    text-align: center;
    position: relative;
}

.footer-ornament {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 150px;
    height: 2px;
    background: linear-gradient(90deg,
        transparent,
        var(--gold) 20%,
        var(--gold) 80%,
        transparent
    );
}

.footer-text {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--brown-light);
}

/* =============================================================================
   AI INTERPRETATION
   ============================================================================= */

.interpretation-section {
    margin-top: var(--space-xl);
    text-align: center;
}

.interpret-btn {
    font-family: var(--font-display);
    font-size: 0.875rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--burgundy) 0%, var(--burgundy-dark) 100%);
    border: none;
    color: var(--cream);
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    box-shadow: var(--shadow-soft);
}

.interpret-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.interpret-icon {
    font-size: 1.25rem;
    color: var(--gold-light);
}

.interpretation-panel {
    margin-top: var(--space-lg);
    padding: var(--space-xl);
    background: rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gold-pale);
    text-align: left;
    animation: fadeIn 0.5s ease;
}

.interpretation-text {
    font-size: 1.15rem;
    line-height: 1.85;
    color: var(--brown);
    text-align: left;
}

/* Drop cap for Renaissance feel - targets first paragraph */
.interpretation-text p:first-child::first-letter {
    font-family: var(--font-display);
    font-size: 3em;
    float: left;
    line-height: 0.65;
    margin-top: 0.1em;
    margin-right: 0.05em;
    color: var(--burgundy);
}

.loading-text {
    color: var(--brown-light);
    font-style: italic;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* =============================================================================
   CHAT SECTION
   ============================================================================= */

.chat-section {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--gold-pale);
    animation: fadeIn 0.5s ease;
}

/* Reveal Questions Button */
.reveal-questions-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin: var(--space-lg) auto;
    padding: var(--space-sm) var(--space-lg);
    background: var(--burgundy);
    color: var(--gold-light);
    border: 1px solid var(--gold);
    border-radius: var(--radius-md);
    font-family: var(--font-display);
    font-size: 0.875rem;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.reveal-questions-btn:hover {
    background: var(--burgundy-dark);
    box-shadow: 0 0 20px rgba(201, 162, 39, 0.3);
}

.reveal-icon {
    font-size: 1.2em;
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Suggested Questions */
.suggested-questions {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin: var(--space-lg) 0;
}

.question-btn {
    padding: var(--space-md) var(--space-lg);
    background: transparent;
    border: 1px solid var(--gold);
    border-radius: var(--radius-md);
    color: var(--brown);
    font-family: var(--font-body);
    font-size: 1rem;
    font-style: italic;
    text-align: left;
    cursor: pointer;
    opacity: 0;
    animation: revealText 0.4s ease-out forwards;
    transition: all 0.3s ease;
}

.question-btn:hover {
    background: var(--gold-pale);
    border-color: var(--gold-light);
    transform: translateX(4px);
}

/* Finish reading button - slightly different styling */
.question-btn.finish-btn {
    font-style: normal;
    font-weight: 500;
    border-color: var(--burgundy);
    color: var(--burgundy);
}

.question-btn.finish-btn:hover {
    background: rgba(107, 24, 57, 0.1);
    border-color: var(--burgundy-dark);
}

/* Closing message styling */
.closing-message {
    border-left: 3px solid var(--gold);
    background: linear-gradient(to right, rgba(201, 162, 39, 0.05), transparent);
}

.chat-messages {
    margin-bottom: var(--space-md);
}

.chat-message {
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    border-radius: var(--radius-md);
    line-height: 1.6;
    white-space: pre-wrap;
}

.chat-message.user {
    background: var(--gold-pale);
    margin-left: 20%;
    text-align: right;
    color: var(--brown);
}

.chat-message.assistant {
    background: rgba(255, 255, 255, 0.8);
    margin-right: 20%;
    border: 1px solid var(--gold-pale);
    text-align: left;
}

/* Drop cap for assistant responses - targets first paragraph */
.chat-message.assistant p:first-child::first-letter {
    font-family: var(--font-display);
    font-size: 3em;
    float: left;
    line-height: 0.65;
    margin-top: 0.1em;
    margin-right: 0.05em;
    color: var(--burgundy);
}

.chat-form {
    display: flex;
    gap: var(--space-sm);
}

.chat-input {
    flex: 1;
    font-family: var(--font-body);
    font-size: 1rem;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--gold-pale);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.8);
    color: var(--brown);
    transition: border-color 0.3s ease;
}

.chat-input:focus {
    outline: none;
    border-color: var(--gold);
}

.chat-input::placeholder {
    color: var(--brown-light);
    font-style: italic;
}

.chat-submit {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--gold);
    border: none;
    color: var(--cream);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
}

.chat-submit:hover {
    background: var(--burgundy);
}

/* =============================================================================
   TEXT REVEAL ANIMATION (Streaming)
   ============================================================================= */

.text-reveal {
    display: inline;
    animation: revealText 0.4s ease-out forwards;
    opacity: 0;
}

@keyframes revealText {
    from {
        opacity: 0;
        filter: blur(2px);
    }
    to {
        opacity: 1;
        filter: blur(0);
    }
}

/* =============================================================================
   SETTINGS MODAL
   ============================================================================= */

.settings-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: var(--space-sm) 0;
    color: var(--brown-light);
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    line-height: 1;
}

.settings-btn:hover {
    color: var(--gold);
}

.settings-btn::after {
    display: none;
}

/* Ensure nav-links items are vertically aligned */
.nav-links {
    align-items: center;
}

.nav-links li {
    display: flex;
    align-items: center;
}

.settings-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(61, 43, 31, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: var(--space-lg);
    animation: fadeIn 0.3s ease;
}

.settings-overlay.active {
    display: flex;
}

.settings-modal {
    background: var(--cream);
    border-radius: var(--radius-lg);
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-elevated);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--gold-pale);
}

.settings-header h2 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    color: var(--burgundy);
    margin: 0;
}

.close-settings {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--brown-light);
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-settings:hover {
    color: var(--burgundy);
}

.settings-content {
    padding: var(--space-lg);
}

.setting-group {
    margin-bottom: var(--space-lg);
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-group.hidden {
    display: none;
}

.setting-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    cursor: pointer;
}

.toggle-slider {
    position: relative;
    width: 48px;
    height: 26px;
    background: var(--parchment);
    border: 1px solid var(--gold-pale);
    border-radius: 13px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--cream);
    border-radius: 50%;
    box-shadow: var(--shadow-soft);
    transition: transform 0.3s ease;
}

.setting-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.setting-toggle input:checked + .toggle-slider {
    background: var(--gold);
    border-color: var(--gold);
}

.setting-toggle input:checked + .toggle-slider::after {
    transform: translateX(22px);
}

.toggle-label {
    font-family: var(--font-display);
    font-size: 0.875rem;
    letter-spacing: 0.05em;
    color: var(--brown);
}

.setting-description {
    font-size: 0.875rem;
    color: var(--brown-light);
    font-style: italic;
    margin-top: var(--space-sm);
    margin-left: 60px;
}

/* =============================================================================
   CARD FLIP ANIMATION
   ============================================================================= */

.card-flip-container {
    perspective: 1000px;
    cursor: pointer;
}

.card-flipper {
    position: relative;
    width: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.card-flipper.flipped {
    transform: rotateY(180deg);
}

.card-back,
.card-front {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.card-back {
    position: relative;
}

.card-front {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    transform: rotateY(180deg);
}

/* Subtle glow on unflipped cards to indicate interactivity */
.card-flip-container:hover .card-flipper:not(.flipped) .card-frame {
    box-shadow: var(--shadow-elevated), 0 0 20px rgba(201, 162, 39, 0.3);
}

/* Card info fade in */
.card-info.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

/* Reveal All button */
.reveal-all-btn {
    display: block;
    margin: var(--space-lg) auto;
    font-family: var(--font-display);
    font-size: 0.875rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: transparent;
    border: 1px solid var(--gold-pale);
    color: var(--brown-light);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
}

.reveal-all-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.reveal-all-btn.hidden {
    display: none;
}

/* =============================================================================
   PROGRESSIVE DISCLOSURE - Description Panel
   ============================================================================= */

.action-btn {
    font-family: var(--font-display);
    font-size: 0.875rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--forest) 0%, var(--forest-dark) 100%);
    border: none;
    color: var(--cream);
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    box-shadow: var(--shadow-soft);
    margin: var(--space-md) auto;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.action-btn .action-icon {
    font-size: 1.25rem;
    color: var(--gold-light);
}

.description-btn {
    background: linear-gradient(135deg, var(--forest) 0%, var(--forest-dark) 100%);
}

.description-panel {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: transparent;
    animation: fadeIn 0.5s ease;
}

.description-text {
    text-align: left;
}

.card-description {
    padding: var(--space-md) var(--space-md) var(--space-lg) var(--space-lg);
    margin-bottom: var(--space-lg);
    border-left: 4px solid var(--gold);
    background: rgba(245, 243, 235, 0.4);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.card-description:last-child {
    margin-bottom: 0;
}

.card-description h4 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--burgundy);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--gold-pale);
}

.card-description .position-label {
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: normal;
    font-style: italic;
    text-transform: none;
    letter-spacing: 0;
    color: var(--brown-light);
}

.card-description .description {
    font-size: 1.05rem;
    line-height: 1.85;
    color: var(--brown);
    margin-bottom: var(--space-lg);
}

/* Drop cap for description text */
.card-description .description::first-letter {
    font-family: var(--font-display);
    font-size: 3em;
    float: left;
    line-height: 0.65;
    margin-top: 0.1em;
    margin-right: 0.05em;
    color: var(--burgundy);
    font-weight: 500;
}

/* Keywords as pills/tags */
.keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--gold-pale);
}

.keyword-tag {
    background: linear-gradient(135deg, var(--gold-pale) 0%, rgba(201, 162, 39, 0.2) 100%);
    padding: 0.4rem 1rem;
    border-radius: 2rem;
    font-size: 0.9rem;
    font-style: normal;
    font-family: var(--font-display);
    letter-spacing: 0.05em;
    color: var(--brown);
    border: 1px solid rgba(201, 162, 39, 0.3);
    text-transform: lowercase;
}

/* Fallback for comma-separated keywords */
.card-description .keywords {
    font-size: 0.875rem;
    color: var(--brown-light);
    margin-bottom: var(--space-sm);
}

.card-description .keywords strong {
    color: var(--gold);
}

.card-description .meaning {
    font-size: 1.05rem;
    line-height: 1.85;
    color: var(--brown);
}

.card-description .meaning strong {
    color: var(--forest);
}

/* =============================================================================
   PROGRESSIVE DISCLOSURE - Continue Section
   ============================================================================= */

.continue-section {
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--gold-pale);
    animation: fadeIn 0.5s ease;
}

.continue-options {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.continue-btn {
    font-family: var(--font-display);
    font-size: 0.875rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: transparent;
    border: 2px solid var(--gold-pale);
    color: var(--brown);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    min-width: 180px;
}

.continue-btn:hover {
    border-color: var(--gold);
    background: var(--gold-pale);
    transform: translateY(-2px);
}

.continue-icon {
    font-size: 1.5rem;
    color: var(--gold);
}

/* Card Selection Dialog */
.card-selection {
    animation: fadeIn 0.3s ease;
    text-align: center;
}

.selection-prompt {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--brown);
    margin-bottom: var(--space-md);
}

.card-selection-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.card-select-btn {
    font-family: var(--font-display);
    font-size: 0.875rem;
    padding: var(--space-sm) var(--space-md);
    background: var(--parchment);
    border: 1px solid var(--gold-pale);
    border-radius: var(--radius-md);
    color: var(--brown);
    cursor: pointer;
    transition: all 0.3s ease;
}

.card-select-btn:hover {
    background: var(--gold-pale);
    border-color: var(--gold);
    transform: scale(1.05);
}

.cancel-selection-btn,
.cancel-input-btn {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: transparent;
    border: none;
    color: var(--brown-light);
    padding: var(--space-sm);
    cursor: pointer;
    transition: color 0.3s ease;
}

.cancel-selection-btn:hover,
.cancel-input-btn:hover {
    color: var(--burgundy);
}

/* Custom Question Input */
.custom-question-input {
    animation: fadeIn 0.3s ease;
    text-align: center;
}

.question-form {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.question-input {
    flex: 1;
    font-family: var(--font-body);
    font-size: 1rem;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--gold-pale);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.8);
    color: var(--brown);
    transition: border-color 0.3s ease;
}

.question-input:focus {
    outline: none;
    border-color: var(--gold);
}

.question-input::placeholder {
    color: var(--brown-light);
    font-style: italic;
}

.question-submit {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--gold);
    border: none;
    color: var(--cream);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
}

.question-submit:hover {
    background: var(--burgundy);
}

/* Card Dialogue Styling */
.chat-message.system {
    background: transparent;
    text-align: center;
    color: var(--brown-light);
    padding: var(--space-md);
    margin: var(--space-sm) 0;
}

.chat-message.card-voice {
    background: linear-gradient(to right, rgba(107, 24, 57, 0.08), transparent);
    border-left: 3px solid var(--burgundy);
}

.card-dialogue-input {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-md);
    animation: fadeIn 0.3s ease;
}

.dialogue-form {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.dialogue-text-input {
    flex: 1;
    font-family: var(--font-body);
    font-size: 1rem;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--burgundy);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.8);
    color: var(--brown);
    transition: border-color 0.3s ease;
}

.dialogue-text-input:focus {
    outline: none;
    border-color: var(--gold);
}

.dialogue-text-input::placeholder {
    color: var(--brown-light);
    font-style: italic;
}

.dialogue-submit {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--burgundy);
    border: none;
    color: var(--cream);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
}

.dialogue-submit:hover {
    background: var(--burgundy-dark);
}

.end-dialogue-btn {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: transparent;
    border: 1px solid var(--brown-light);
    color: var(--brown-light);
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    display: block;
    margin: 0 auto;
}

.end-dialogue-btn:hover {
    border-color: var(--burgundy);
    color: var(--burgundy);
}

.error-text {
    color: var(--burgundy);
    font-style: italic;
}

/* =============================================================================
   STREAMING MARKDOWN PARAGRAPH STYLING
   ============================================================================= */

.interpretation-text p,
.chat-message.assistant p {
    margin-bottom: var(--space-md);
}

.interpretation-text p:last-child,
.chat-message.assistant p:last-child {
    margin-bottom: 0;
}

/* Strong text in markdown */
.interpretation-text strong,
.chat-message.assistant strong {
    color: var(--burgundy);
    font-weight: 600;
}

/* Card names highlighted in body text (distinct from .card-name used in card browser) */
.card-mention {
    font-family: var(--font-body) !important;
    font-weight: 700 !important;
    color: var(--burgundy);
    font-variant: normal;
    text-transform: none;
    font-size: inherit !important;
    letter-spacing: inherit !important;
}

/* Explicitly prevent drop cap styling on non-first paragraphs */
.interpretation-text p:not(:first-child)::first-letter,
.chat-message.assistant p:not(:first-child)::first-letter {
    float: none !important;
    font-size: inherit !important;
    line-height: inherit !important;
    margin: 0 !important;
    color: inherit !important;
}

/* Emphasis in markdown */
.interpretation-text em,
.chat-message.assistant em {
    color: var(--brown);
    font-style: italic;
}

/* Lists in markdown */
.interpretation-text ul,
.interpretation-text ol,
.chat-message.assistant ul,
.chat-message.assistant ol {
    margin: var(--space-sm) 0 var(--space-md) var(--space-lg);
}

.interpretation-text li,
.chat-message.assistant li {
    margin-bottom: var(--space-xs);
}

/* =============================================================================
   RESPONSIVE SIDE-BY-SIDE MODAL (Large Screens)
   ============================================================================= */

@media (min-width: 900px) {
    .card-detail-modal {
        max-width: 800px;
    }

    .modal-content {
        flex-direction: row;
        align-items: flex-start;
        text-align: left;
        gap: var(--space-lg);
    }

    .modal-card-header {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        gap: var(--space-md);
        flex-shrink: 0;
        max-width: 340px;
    }

    .modal-card-image {
        flex-shrink: 0;
        margin-bottom: 0;
    }

    .modal-card-image .card-frame {
        width: 280px;
    }

    .modal-card-info {
        text-align: left;
    }

    .modal-card-info h2 {
        text-align: left;
    }

    .modal-keywords {
        justify-content: flex-start;
        flex-wrap: wrap;
        max-width: 100%;
    }

    .modal-meaning {
        flex: 1;
        min-width: 250px;
        border-top: none;
        border-left: 1px solid var(--gold-pale);
        padding-top: 0;
        padding-left: var(--space-lg);
        margin-top: 0;
    }
}

/* =============================================================================
   PERMANENT DIALOGUE INPUT
   ============================================================================= */

.dialogue-input-container {
    margin: var(--space-lg) 0;
    padding: var(--space-md);
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-md);
    border: 1px solid var(--gold-pale);
}

.dialogue-input-container .dialogue-form {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: 0;
}

.dialogue-input-container .dialogue-input {
    flex: 1;
    font-family: var(--font-body);
    font-size: 1rem;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--gold-pale);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.8);
    color: var(--brown);
    transition: border-color 0.3s ease;
}

.dialogue-input-container .dialogue-input:focus {
    outline: none;
    border-color: var(--gold);
}

.dialogue-input-container .dialogue-input::placeholder {
    color: var(--brown-light);
    font-style: italic;
}

.dialogue-input-container .dialogue-submit {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--gold);
    border: none;
    color: var(--cream);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
}

.dialogue-input-container .dialogue-submit:hover {
    background: var(--burgundy);
}

/* =============================================================================
   CHAT ACTIONS (Go Deeper + Finish Reading)
   ============================================================================= */

.chat-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-xl);
    margin: var(--space-xl) auto var(--space-lg);
    padding: var(--space-md) 0;
    flex-wrap: wrap;
}

.finish-reading-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    color: var(--brown-light);
    border: 1px solid rgba(107, 83, 68, 0.4);
    border-radius: var(--radius-md);
    font-family: var(--font-display);
    font-size: 0.875rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
}

.finish-reading-btn:hover {
    background: rgba(107, 24, 57, 0.1);
    color: var(--burgundy);
    border-color: var(--burgundy);
}

.finish-icon {
    font-size: 1em;
}

/* Speak with a Card button */
.speak-card-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    color: var(--gold);
    border: 1px solid var(--gold);
    border-radius: var(--radius-md);
    font-family: var(--font-display);
    font-size: 0.875rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
}

.speak-card-btn:hover {
    background: rgba(201, 162, 39, 0.15);
    box-shadow: 0 0 12px rgba(201, 162, 39, 0.2);
}

.speak-icon {
    font-size: 1.1em;
}

/* =============================================================================
   RESPONSIVE - MOBILE OVERRIDES
   Must be at END of file to override base styles (CSS cascade)
   ============================================================================= */

@media (max-width: 768px) {
    /* Base scaling */
    :root {
        font-size: 14px;
    }

    /* Layout adjustments */
    .main-content {
        padding: var(--space-md);
    }

    .spread-options {
        flex-direction: column;
        align-items: center;
    }

    .spread-btn {
        width: 100%;
        max-width: 300px;
    }

    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: var(--space-md);
    }

    .corner-ornament {
        display: none;
    }

    /* ===========================================
       MOBILE TEXT SIZES
       All body text = 16px for readability
       Labels/secondary = 13px
       =========================================== */

    /* Body text - consistent 17px for readability */
    .card-description .description,
    .card-description .meaning,
    .interpretation-text {
        font-size: 17px;
    }

    /* Position labels - slightly smaller, bold for visibility */
    .card-position {
        font-size: 13px;
        font-weight: 600;
    }
}
