/* ===================================
   FRONTIER CODEX - MAIN STYLESHEET
   =================================== */

/* Base Styles & Typography */
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@400;600&family=Crimson+Text:ital,wght@0,400;0,600;1,400&display=swap');

:root {
    --dust-brown: #8B6134;
    --blood-rust: #8B3A1A;
    --ash-grey: #6B6B6B;
    --ember-orange: #CC5500;
    --parchment: #F4E8D0;
    --dark-leather: #3C2415;
    --faded-ink: #2C2416;
    --gold-accent: #B8860B;
}

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

body {
    font-family: 'Crimson Text', serif;
    background: linear-gradient(135deg, #D4C4B0 0%, #E8DCC0 100%);
    color: var(--faded-ink);
    min-height: 100vh;
    line-height: 1.6;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 50%, transparent 3%, var(--parchment) 3.5%),
        radial-gradient(circle at 85% 20%, transparent 2%, var(--parchment) 2.5%),
        radial-gradient(circle at 70% 80%, transparent 2.5%, var(--parchment) 3%);
    opacity: 0.3;
    pointer-events: none;
    z-index: -1;
}

/* Header */
.header {
    background: linear-gradient(180deg, var(--dark-leather) 0%, rgba(60, 36, 21, 0.95) 100%);
    color: var(--parchment);
    padding: 2rem;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    border-bottom: 3px solid var(--blood-rust);
    position: relative;
}

.header::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 8px;
    background: repeating-linear-gradient(
        90deg,
        var(--gold-accent),
        var(--gold-accent) 10px,
        transparent 10px,
        transparent 20px
    );
    opacity: 0.3;
}

.site-title {
    font-family: 'Oswald', sans-serif;
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 600;
    letter-spacing: 0.2rem;
    text-shadow: 
        3px 3px 6px rgba(0,0,0,0.7),
        -1px -1px 2px rgba(184, 134, 11, 0.3);
    margin-bottom: 0.5rem;
}

.site-subtitle {
    font-size: clamp(1rem, 2vw, 1.2rem);
    font-style: italic;
    color: var(--gold-accent);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

/* Navigation */
.main-nav {
    background: var(--parchment);
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    border-bottom: 2px solid var(--dust-brown);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.nav-list {
    list-style: none;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    padding: 0;
    margin: 0;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: block;
    padding: 1rem 1.5rem;
    color: var(--dark-leather);
    text-decoration: none;
    font-family: 'Oswald', sans-serif;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    transition: all 0.3s ease;
    position: relative;
    white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
    background: linear-gradient(180deg, rgba(139, 97, 52, 0.1) 0%, rgba(139, 97, 52, 0.2) 100%);
    color: var(--blood-rust);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 3px;
    background: var(--ember-orange);
    transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 80%;
}

/* Dropdown Styles */
.nav-item.has-dropdown > .nav-link::before {
    content: '▾';
    margin-left: 0.5rem;
    font-size: 0.8rem;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--parchment);
    border: 2px solid var(--dust-brown);
    border-top: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    min-width: 200px;
    z-index: 1000;
}

.nav-item.has-dropdown:hover .dropdown-menu,
.nav-item.has-dropdown:focus-within .dropdown-menu {
    display: block;
}

.dropdown-menu .nav-link {
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--dust-brown);
    font-size: 0.9rem;
}

.dropdown-menu .nav-link:last-child {
    border-bottom: none;
}

.dropdown-menu .nav-link::after {
    display: none;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--dark-leather);
    cursor: pointer;
    padding: 0.5rem;
}

/* Search Button */
.search-button {
    background: var(--ember-orange);
    color: var(--parchment);
    border: none;
    padding: 0.5rem 1rem;
    font-family: 'Oswald', sans-serif;
    font-size: 0.9rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.3s ease;
    margin-left: 1rem;
}

.search-button:hover {
    background: var(--blood-rust);
}

/* Search Modal */
.search-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    padding: 2rem;
    overflow-y: auto;
}

.search-modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.search-content {
    background: var(--parchment);
    border: 3px solid var(--dust-brown);
    padding: 2rem;
    max-width: 800px;
    width: 100%;
    margin-top: 5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    position: relative;
}

.search-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--ash-grey);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 2rem;
    height: 2rem;
}

.search-close:hover {
    color: var(--blood-rust);
}

.search-input {
    width: 100%;
    padding: 1rem;
    font-family: 'Crimson Text', serif;
    font-size: 1.1rem;
    border: 2px solid var(--dust-brown);
    background: rgba(255, 255, 255, 0.5);
    margin-bottom: 1.5rem;
}

.search-results {
    max-height: 60vh;
    overflow-y: auto;
}

.search-result-item {
    padding: 1rem;
    border-bottom: 1px solid var(--dust-brown);
    margin-bottom: 1rem;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-title {
    font-family: 'Oswald', sans-serif;
    font-size: 1.2rem;
    color: var(--blood-rust);
    margin-bottom: 0.5rem;
}

.search-result-title a {
    color: var(--blood-rust);
    text-decoration: none;
}

.search-result-title a:hover {
    color: var(--ember-orange);
}

.search-result-excerpt {
    color: var(--ash-grey);
    line-height: 1.6;
}

.search-highlight {
    background: rgba(204, 85, 0, 0.3);
    font-weight: 600;
}

.no-results {
    text-align: center;
    padding: 2rem;
    color: var(--ash-grey);
    font-style: italic;
}

/* Breadcrumb Navigation */
.breadcrumb {
    background: rgba(139, 97, 52, 0.1);
    padding: 0.75rem 2rem;
    border-bottom: 1px solid var(--dust-brown);
}

.breadcrumb-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.breadcrumb-item {
    font-family: 'Oswald', sans-serif;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.breadcrumb-item a {
    color: var(--ash-grey);
    text-decoration: none;
    transition: color 0.3s ease;
}

.breadcrumb-item a:hover {
    color: var(--blood-rust);
}

.breadcrumb-separator {
    color: var(--ash-grey);
}

.breadcrumb-item:last-child {
    color: var(--dark-leather);
    font-weight: 600;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--ember-orange);
    color: var(--parchment);
    border: 2px solid var(--dust-brown);
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    z-index: 999;
}

.back-to-top.visible {
    display: flex;
}

.back-to-top:hover {
    background: var(--blood-rust);
    transform: translateY(-3px);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* Main Content */
.main-content {
    background: var(--parchment);
    border: 2px solid var(--dust-brown);
    padding: 2rem;
    box-shadow: 3px 3px 10px rgba(0,0,0,0.2);
    min-height: 600px;
}

.content-header {
    border-bottom: 3px solid var(--dust-brown);
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.content-title {
    font-family: 'Oswald', sans-serif;
    font-size: clamp(2rem, 4vw, 2.5rem);
    color: var(--dark-leather);
    text-transform: uppercase;
    letter-spacing: 0.1rem;
}

.content-subtitle {
    font-style: italic;
    color: var(--ash-grey);
    margin-top: 0.5rem;
    font-size: clamp(1rem, 2vw, 1.2rem);
}

/* Content Sections */
.content-section {
    margin-bottom: 2rem;
}

.section-title {
    font-family: 'Oswald', sans-serif;
    font-size: 1.8rem;
    color: var(--blood-rust);
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--ember-orange);
}

.content-text {
    line-height: 1.8;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

/* Quote Block */
.quote-block {
    background: rgba(139, 97, 52, 0.05);
    border-left: 4px solid var(--ember-orange);
    padding: 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
    position: relative;
}

.quote-block::before {
    content: '"';
    position: absolute;
    top: -10px;
    left: 10px;
    font-size: 3rem;
    color: var(--ember-orange);
    opacity: 0.3;
    font-family: 'Crimson Text', serif;
}

/* Character Cards */
.character-card {
    background: linear-gradient(135deg, var(--parchment) 0%, rgba(244, 232, 208, 0.7) 100%);
    border: 2px solid var(--dust-brown);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.1);
}

.character-portrait {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0;
    padding: 0.5rem;
}

.portrait-media, .portrait-fallback {
    max-width: 200px;
    width: 100%;
    height: auto;
    aspect-ratio: 9/16;
    object-fit: cover;
    border: 2px solid var(--dust-brown);
    border-radius: 4px;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.3);
    background: rgba(139, 97, 52, 0.1);
}

.portrait-img {
    max-width: 200px;
    width: 100%;
    height: auto;
    border: 2px solid var(--dust-brown);
    border-radius: 4px;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.3);
}

.character-name {
    font-family: 'Oswald', sans-serif;
    font-size: 1.6rem;
    color: var(--dark-leather);
    margin-bottom: 0.5rem;
    text-align: center;
}

.character-title {
    color: var(--blood-rust);
    font-style: italic;
    margin-bottom: 1rem;
    text-align: center;
}

.character-description {
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* Info Box */
.info-box {
    background: rgba(184, 134, 11, 0.05);
    border: 1px solid var(--gold-accent);
    padding: 1rem;
    margin: 1.5rem 0;
}

.info-box-title {
    font-family: 'Oswald', sans-serif;
    font-size: 1.2rem;
    color: var(--dark-leather);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

/* Lists */
.frontier-list {
    list-style: none;
    margin: 1rem 0;
}

.frontier-list li {
    position: relative;
    padding-left: 2rem;
    margin-bottom: 0.8rem;
    line-height: 1.6;
}

.frontier-list li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--ember-orange);
    font-size: 1.2rem;
}

/* Navigation Cards (for homepage) */
.nav-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.nav-card {
    background: var(--parchment);
    border: 2px solid var(--dust-brown);
    padding: 1.5rem;
    text-decoration: none;
    color: var(--dark-leather);
    transition: all 0.3s ease;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.1);
}

.nav-card:hover {
    transform: translateY(-5px);
    box-shadow: 4px 4px 12px rgba(0,0,0,0.2);
    border-color: var(--ember-orange);
}

.nav-card h3 {
    font-family: 'Oswald', sans-serif;
    font-size: 1.4rem;
    color: var(--blood-rust);
    margin-bottom: 0.5rem;
}

.nav-card p {
    font-size: 1rem;
    line-height: 1.4;
}

/* Tabs */
.tab-container {
    margin: 2rem 0;
}

.tab-list {
    display: flex;
    list-style: none;
    border-bottom: 2px solid var(--dust-brown);
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
}

.tab-button {
    padding: 0.8rem 1.5rem;
    background: rgba(139, 97, 52, 0.1);
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-family: 'Oswald', sans-serif;
    font-size: 1rem;
    text-transform: uppercase;
    color: var(--dark-leather);
    transition: all 0.3s ease;
}

.tab-button:hover {
    background: rgba(139, 97, 52, 0.2);
}

.tab-button.active {
    background: var(--parchment);
    border-bottom-color: var(--ember-orange);
    color: var(--blood-rust);
}

.tab-content {
    padding: 1.5rem;
    background: var(--parchment);
    border: 1px solid var(--dust-brown);
    border-top: none;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Table */
.travel-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.95rem;
}

.travel-table th,
.travel-table td {
    padding: 0.8rem;
    border: 1px solid var(--dust-brown);
    text-align: left;
}

.travel-table th {
    background: rgba(139, 97, 52, 0.1);
    font-family: 'Oswald', sans-serif;
    text-transform: uppercase;
    color: var(--dark-leather);
    font-weight: 600;
}

.travel-table tr:hover {
    background: rgba(139, 97, 52, 0.05);
}

/* Footer */
.footer {
    background: var(--dark-leather);
    color: var(--parchment);
    text-align: center;
    padding: 2rem;
    margin-top: 3rem;
}

.footer::before {
    content: '';
    display: block;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, 
        var(--blood-rust) 0%, 
        var(--ember-orange) 25%, 
        var(--gold-accent) 50%, 
        var(--ember-orange) 75%, 
        var(--blood-rust) 100%);
    margin-bottom: 1rem;
}

/* Skip Link for Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--ember-orange);
    color: var(--parchment);
    padding: 0.5rem 1rem;
    text-decoration: none;
    z-index: 9999;
}

.skip-link:focus {
    top: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .site-title {
        font-size: 2rem;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .nav-list {
        display: none;
        flex-direction: column;
        width: 100%;
        position: absolute;
        top: 100%;
        left: 0;
        background: var(--parchment);
        border-bottom: 2px solid var(--dust-brown);
        box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    }
    
    .nav-list.mobile-active {
        display: flex;
    }
    
    .nav-item {
        width: 100%;
        border-bottom: 1px solid var(--dust-brown);
    }
    
    .nav-link {
        border-right: none;
        width: 100%;
    }
    
    .dropdown-menu {
        position: static;
        display: none;
        border: none;
        border-top: 1px solid var(--dust-brown);
        box-shadow: none;
    }
    
    .nav-item.has-dropdown.mobile-open .dropdown-menu {
        display: block;
    }
    
    .search-button {
        margin: 0.5rem 1rem;
        width: calc(100% - 2rem);
    }
    
    .container {
        padding: 0 1rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .nav-cards {
        grid-template-columns: 1fr;
    }
    
    .portrait-media, .portrait-fallback {
        max-width: 150px;
    }
    
    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .site-title {
        font-size: 1.5rem;
        letter-spacing: 0.1rem;
    }
    
    .nav-link {
        padding: 0.8rem 1rem;
        font-size: 1rem;
    }
    
    .search-content {
        padding: 1rem;
        margin-top: 2rem;
    }
}

/* Print Styles */
@media print {
    .header,
    .main-nav,
    .footer,
    .back-to-top,
    .search-button,
    .breadcrumb {
        display: none;
    }
    
    .main-content {
        border: none;
        box-shadow: none;
    }
}

/* Music Toggle Button */
.music-toggle {
    background: var(--ember-orange);
    color: var(--parchment);
    border: none;
    padding: 0.5rem 1rem;
    font-family: 'Oswald', sans-serif;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 0.5rem;
    position: relative;
    min-width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.music-toggle:hover {
    background: var(--blood-rust);
    transform: scale(1.05);
}

.music-toggle.playing .music-icon {
    animation: musicPulse 1s ease-in-out infinite;
}

.music-toggle.paused {
    background: var(--ash-grey);
    opacity: 0.7;
}

.music-toggle.paused .music-icon::after {
    content: ' ✕';
    font-size: 0.8rem;
    position: absolute;
    top: 0;
    right: 0;
}

@keyframes musicPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .music-toggle {
        margin: 0.5rem 1rem;
        width: calc(100% - 2rem);
    }
}