/* ============================================
   Game of Thrones - Códice del Maestre Styles
   Updated Version with New Content
   ============================================ */

/* Fonts - Optimized for Readability & GoT Aesthetic */
@import url('https://fonts.googleapis.com/css2?family=IM+Fell+English+SC:wght@400&family=IM+Fell+English:ital,wght@0,400;0,700;1,400&family=Inter:wght@300;400;500;600;700&display=swap');

/* CSS Variables */
/* Game of Thrones Official Color Palette from HueHive */
:root {
    /* === House Colors === */
    --stark-grey: #808080;
    --lannister-gold: #FFD700;
    --targaryen-red: #B22222;
    --baratheon-black: #000000;
    --greyjoy-iron: #43464B;
    --martell-orange: #d9480f;
    --arryn-blue: #0284c7;
    
    /* === Legacy Variables (updated to use house colors) === */
    --gold: var(--lannister-gold);
    --amber-600: #d97706;
    --slate-900: #0f172a;
    --slate-950: var(--baratheon-black);
    --slate-800: var(--greyjoy-iron);
    --slate-700: #334155;
    --slate-500: var(--stark-grey);
    --slate-400: #94a3b8;
    --red-900: #7f1d1d;
    --red-800: #991b1b;
    --red-500: var(--targaryen-red);
    --blood: var(--targaryen-red);
    --blue-500: #3b82f6;
    --blue-900: #1e3a8a;
}

/* Base Styles */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1.125rem; /* 18px Base Font Size */
    background-color: var(--slate-950);
    color: #f1f5f9;
    scroll-behavior: smooth;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    line-height: 1.7;
    letter-spacing: 0.01em;
}

/* Gothic Headings - Game of Thrones Style */
h1 {
    font-family: 'IM Fell English SC', serif;
    letter-spacing: 0.05em;
}

h2, h3, h4, .title-font {
    font-family: 'IM Fell English', serif;
    letter-spacing: 0.02em;
}

/* Custom Scrollbar */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--slate-700);
    border-radius: 2px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--slate-500);
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    background: var(--slate-900);
    border: 1px solid var(--gold);
    color: var(--gold);
    padding: 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mobile-menu-btn:hover {
    background: var(--gold);
    color: var(--slate-950);
    transform: scale(1.05);
}

.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
}

/* Navigation Link Styles */
.nav-link {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--slate-400);
    border-left: 2px solid transparent;
    transition: all 0.3s ease;
    text-decoration: none;
    position: relative;
}

.nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 2px;
    background: var(--gold);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.nav-link:hover {
    color: white;
    background: var(--slate-900);
    padding-left: 1.25rem;
    border-left-color: var(--gold);
}

.nav-link:hover::before {
    transform: scaleY(1);
}

.nav-link.nav-active {
    color: white;
    background: var(--slate-900);
    border-left-color: var(--gold);
    font-weight: 600;
}

/* Section Styles */
section {
    scroll-margin-top: 6rem;
    padding-bottom: 1rem;
}

/* Rule Cards */
.rule-card {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--slate-800);
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.rule-card:hover {
    background: rgba(15, 23, 42, 0.7);
    border-color: var(--slate-700);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Unified Subtitle Style inside Cards */
.rule-card h3, 
.rule-card h4, 
.rule-card .font-bold.text-amber-400,
.rule-card strong {
    color: var(--lannister-gold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.9em; /* Slightly smaller because uppercase makes it look bigger */
}

/* Exception for inline strong tags in paragraphs so they don't look like titles if they are part of a sentence */
.rule-card p strong {
    text-transform: none; /* Keep inline emphasis normal case */
    color: var(--lannister-gold); /* Keep color distinction */
    font-size: inherit;
}

/* Re-override for titles acting as headers */
.rule-card h3, .rule-card h4 {
    font-size: 1.1em;
    border-bottom: 1px solid rgba(255, 215, 0, 0.3);
    padding-bottom: 0.25rem;
    margin-bottom: 0.75rem;
    display: inline-block; /* Only underline the text */
    width: 100%; /* Or keep full width if preferred */
}

/* Highlight Boxes */
.highlight-box {
    background: rgba(120, 53, 15, 0.2);
    border-left: 4px solid var(--amber-600);
    padding: 1rem;
    margin: 1rem 0;
    font-style: italic;
    font-size: 0.875rem;
    color: #cbd5e1;
    border-radius: 0 0.5rem 0.5rem 0;
}

.technical-note {
    background: rgba(30, 58, 138, 0.2);
    border-left: 4px solid var(--blue-500);
    padding: 1rem;
    margin: 1rem 0;
    font-size: 0.75rem;
    color: #bfdbfe;
    border-radius: 0 0.5rem 0.5rem 0;
}

/* Theme Gradients */
.dragon-theme {
    background: linear-gradient(135deg, #450a0a 0%, #020617 100%);
}

.bank-theme {
    background: linear-gradient(135deg, #1e1b4b 0%, #020617 100%);
}

/* Highlight Gold */
.highlight-gold {
    color: var(--gold);
}

/* Scroll to Top Button */
.scroll-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--gold);
    color: var(--slate-950);
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 100;
    border: none;
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-to-top:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(251, 191, 36, 0.5);
}

/* Mobile Responsive Styles */
@media (max-width: 1023px) {
    /* Show mobile menu button */
    .mobile-menu-btn {
        display: block;
    }

    /* Sidebar becomes overlay */
    .sidebar-nav-wrapper {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 320px;
        height: 100vh;
        background: var(--slate-950);
        z-index: 999;
        transition: left 0.3s ease;
        overflow-y: auto;
        border-right: 1px solid var(--gold);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    }

    .sidebar-nav-wrapper.active {
        left: 0;
    }

    /* Mobile overlay */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0, 0, 0, 0.7);
        z-index: 998;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .mobile-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Adjust header for mobile */
    header h1 {
        font-size: 2rem !important;
        padding-right: 4rem;
    }

    header p {
        font-size: 0.875rem;
    }

    /* Main content adjustments */
    main {
        padding: 1.5rem !important;
    }

    section h2 {
        font-size: 1.75rem !important;
    }

    /* Rule cards stack properly */
    .rule-card {
        margin-bottom: 1rem;
    }

    /* Scroll to top button position */
    .scroll-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 2.5rem;
        height: 2.5rem;
    }
}

/* Tablet Adjustments */
@media (min-width: 768px) and (max-width: 1023px) {
    header h1 {
        font-size: 3rem !important;
    }

    main {
        padding: 2rem !important;
    }
}

/* Desktop Enhancements */
@media (min-width: 1024px) {
    .sidebar-nav-wrapper {
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;
    }

    /* Smooth hover transitions */
    .nav-link {
        cursor: pointer;
    }

    .rule-card {
        cursor: default;
    }
}

/* Print Styles */
@media print {
    .sidebar-nav-wrapper,
    .mobile-menu-btn,
    .scroll-to-top {
        display: none;
    }

    body {
        background: white;
        color: black;
    }

    section {
        page-break-inside: avoid;
    }
}
/* ==========================================
   Interactive Learning Section Styles
   ========================================== */

/* Game Selector Buttons */
.game-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.game-btn {
    padding: 0.75rem 1.5rem;
    background: var(--slate-800);
    border: 2px solid var(--slate-700);
    color: var(--slate-300);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
    font-weight: 600;
}

.game-btn:hover {
    background: #7c3aed;
    border-color: #a78bfa;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.game-btn.active {
    background: #7c3aed;
    border-color: #a78bfa;
    color: white;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

/* Mini Game Container */
.mini-game {
    display: none;
}

.mini-game.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Quiz Styles */
.quiz-option {
    padding: 1rem;
    background: var(--slate-800);
    border: 2px solid var(--slate-700);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.quiz-option:hover {
    background: var(--slate-700);
    border-color: #a78bfa;
    transform: translateX(4px);
}

.quiz-option.correct {
    background: rgba(34, 197, 94, 0.2);
    border-color: #22c55e;
    pointer-events: none;
}

.quiz-option.wrong {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    pointer-events: none;
}

.quiz-option.disabled {
    pointer-events: none;
    opacity: 0.6;
}

/* Progress Bar */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--slate-800);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #7c3aed, #a78bfa);
    transition: width 0.3s ease;
    border-radius: 4px;
}

/* Flashcard Styles */
.flashcard-container {
    perspective: 1000px;
    max-width: 600px;
    margin: 0 auto;
}

.flashcard {
    width: 100%;
    height: 350px;
    position: relative;
    cursor: pointer;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 1rem;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    border: 2px solid var(--slate-700);
}

.flashcard-front {
    background: linear-gradient(135deg, #7c3aed 0%, #1e293b 100%);
}

.flashcard-back {
    background: linear-gradient(135deg, #1e293b 0%, #7c3aed 100%);
    transform: rotateY(180deg);
}

/* Matching Game Styles */
.matching-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.matching-column {
    display: flex;
    flex-direction: column;
}

.match-item {
    padding: 1rem;
    background: var(--slate-800);
    border: 2px solid var(--slate-700);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.match-item:hover {
    background: var(--slate-700);
    border-color: #a78bfa;
    transform: scale(1.05);
}

.match-item.selected {
    background: #7c3aed;
    border-color: #a78bfa;
    box-shadow: 0 0 20px rgba(124, 58, 237, 0.5);
}

.match-item.matched {
    background: rgba(34, 197, 94, 0.3);
    border-color: #22c55e;
    pointer-events: none;
    opacity: 0.7;
}

.match-item.wrong {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Buttons */
.btn-primary {
    padding: 0.75rem 2rem;
    background: #7c3aed;
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: #6d28d9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: var(--slate-700);
    color: white;
    border: 2px solid var(--slate-600);
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: var(--slate-600);
    border-color: #a78bfa;
}

.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Feedback Messages */
.correct-answer {
    background: rgba(34, 197, 94, 0.2);
    border: 2px solid #22c55e;
    color: #86efac;
}

.wrong-answer {
    background: rgba(239, 68, 68, 0.2);
    border: 2px solid #ef4444;
    color: #fca5a5;
}

/* Mobile Responsive for Learning Games */
@media (max-width: 768px) {
    .game-btn {
        font-size: 0.75rem;
        padding: 0.5rem 1rem;
    }

    .flashcard {
        height: 300px;
    }

    .matching-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .quiz-option {
        font-size: 0.875rem;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
    }
}

/* Heading Size Hierarchy - Improved Visual Balance */
h1 {
    font-size: 3.5rem;
    line-height: 1.2;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 2.25rem;
    line-height: 1.3;
    margin-bottom: 1.25rem;
}

h3 {
    font-size: 1.75rem;
    line-height: 1.4;
    margin-bottom: 1rem;
}

h4 {
    font-size: 1.35rem;
    line-height: 1.4;
    margin-bottom: 0.875rem;
    font-weight: 600;
}

/* Responsive heading sizes */
@media (max-width: 768px) {
    h1 { font-size: 2.5rem; }
    h2 { font-size: 1.875rem; }
    h3 { font-size: 1.5rem; }
    h4 { font-size: 1.25rem; }
}

/* 3D Book Cover Styles - Re-applying */
.book-container {
    perspective: 1000px;
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.book {
    position: relative;
    width: 200px;
    height: 280px;
    transform-style: preserve-3d;
    transform: rotateY(-15deg);
    transition: transform 0.5s ease;
    box-shadow: 10px 20px 30px rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.book:hover {
    transform: rotateY(0deg) scale(1.05);
    z-index: 10;
}

.book-front {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-radius: 2px 6px 6px 2px;
    transform-origin: left;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.5rem;
    color: var(--lannister-gold);
    border: 2px solid var(--stark-grey);
}

.book-spine {
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 100%;
    background: #0f172a;
    transform: rotateY(90deg) translateZ(-10px);
    border-radius: 2px 0 0 2px;
}

.book-title {
    font-family: 'IM Fell English SC', serif;
    font-size: 1.25rem;
    text-align: center;
    line-height: 1.2;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--lannister-gold);
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
}

.book-icon {
    font-size: 3rem;
    text-align: center;
    margin: 1rem 0;
    opacity: 0.8;
}

.book-footer {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    text-align: center;
    color: var(--stark-grey);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Specific Book Designs */
.book-standard .book-front {
    background: linear-gradient(135deg, #2a1b1b 0%, #1a0f0f 100%);
    border-color: #854d0e;
}

.book-expansion .book-front {
    background: linear-gradient(135deg, #3d1010 0%, #1a0505 100%);
    border-color: #991b1b;
}

/* Override Book Covers with Real Images */
.book-standard .book-front {
    background: url('../images/boardstandar.png') no-repeat center center !important;
    background-size: cover !important;
    border: none !important;
}

.book-expansion .book-front {
    background: url('../images/boardexpansion.png') no-repeat center center !important;
    background-size: cover !important;
    border: none !important;
}

/* Hide text elements inside proper image covers */
.book-standard .book-front > *,
.book-expansion .book-front > * {
    display: none;
}

/* ==========================================
   House Cards Styles
   ========================================== */
/* ==========================================
   House Cards Styles
   ========================================== */
.house-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

/* Mega Card Layout */
.house-card {
    background: var(--slate-900);
    border: 1px solid var(--slate-700);
    border-radius: 1rem;
    overflow: hidden;
    position: relative;
    transition: all 0.4s ease;
    display: grid;
    grid-template-columns: 140px 1fr 1fr; /* Image | Info | Strategy */
    min-height: 250px;
}

@media (max-width: 1024px) {
    .house-card {
        grid-template-columns: 140px 1fr;
        grid-template-rows: auto auto;
    }
    
    .house-role {
        grid-column: 1 / -1;
        border-top: 1px solid var(--slate-800);
    }
}

@media (max-width: 640px) {
    .house-card {
        display: flex;
        flex-direction: column;
        grid-template-columns: 1fr;
    }
    
    .house-sigil-wrapper {
        width: 100%;
        height: 150px;
        border-right: none;
        border-bottom: 1px solid var(--slate-800);
    }
}



.house-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border-color: var(--gold);
}

.house-sigil-wrapper {
    height: 100%;
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at center, rgba(255,255,255,0.05) 0%, rgba(0,0,0,0.8) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-right: 1px solid var(--slate-800);
}

.house-sigil {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(0,0,0,0.5));
    transition: transform 0.5s ease;
}

.house-card:hover .house-sigil {
    transform: scale(1.1);
}

.house-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.5rem;
    background: rgba(0,0,0,0.2);
}

.house-strategy {
    padding: 1.5rem;
    background: rgba(0,0,0,0.3);
    border-left: 1px solid var(--slate-800);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.house-strategy h4 {
    color: var(--gold);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.house-strategy p {
    color: var(--slate-300);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.house-strategy p strong {
    color: var(--gold);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

@media (max-width: 1024px) {
    .house-strategy {
        grid-column: 1 / -1;
        border-left: none;
        border-top: 1px solid var(--slate-800);
    }
}

.house-name {
    font-family: 'IM Fell English SC', serif;
    font-size: 1.5rem;
    color: white;
    text-align: left;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--slate-700);
    padding-bottom: 0.25rem;
}

.house-motto {
    text-align: left;
    color: var(--slate-300);
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.house-motto-en {
    font-weight: bold;
    font-size: 1rem;
    display: block;
    color: var(--gold);
    font-style: italic;
}

.house-motto-es {
    font-size: 0.75rem;
    display: block;
    color: var(--slate-500);
    margin-top: 2px;
}

.house-details {
    font-size: 0.85rem;
    color: var(--slate-300);
}

.house-detail-item {
    margin-bottom: 0.5rem;
}

.house-detail-label {
    color: var(--gold);
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.75rem;
    display: block;
}

/* Specific House Borders/Glows (Left Border for Horizontal) */
.house-stark { border-left: 4px solid var(--stark-grey); }
.house-lannister { border-left: 4px solid var(--lannister-gold); }
.house-baratheon { border-left: 4px solid var(--lannister-gold); }
.house-greyjoy { border-left: 4px solid var(--greyjoy-iron); }
.house-tyrell { border-left: 4px solid var(--tyrell-green); }
.house-martell { border-left: 4px solid var(--martell-orange); }
.house-targaryen { border-left: 4px solid var(--targaryen-red); }
.house-arryn { border-left: 4px solid var(--arryn-blue); }

.house-stark:hover { box-shadow: 0 0 20px rgba(128,128,128,0.2); border-color: var(--stark-grey); }
.house-lannister:hover { box-shadow: 0 0 20px rgba(255,215,0,0.2); border-color: var(--lannister-gold); }
.house-targaryen:hover { box-shadow: 0 0 20px rgba(178,34,34,0.3); border-color: var(--targaryen-red); }
.house-arryn:hover { box-shadow: 0 0 20px rgba(2,132,199,0.3); border-color: var(--arryn-blue); }

/* Mobile Adjustments for House Cards */
@media (max-width: 640px) {
    .house-card {
        height: auto;
        /* Keep horizontal but maybe adjust padding */
    }
    
    .house-sigil-wrapper {
        width: 100px;
        padding: 0.5rem;
    }
    
    .house-name {
        font-size: 1.25rem;
    }
}
