/* =========================================================
   anagura-unified.css v1.1
   Consolidated styles for all Anagura sites
   
   Merges: anagura-base.css + unified-header.css + anagura-nav.css
   
   Sections:
   1. Design Tokens (CSS Variables)
   2. Global Resets
   3. Base Typography
   4. Header System
   5. Overlay Navigation
   6. Footer
   7. Breadcrumb
   8. Accessibility & Print
   ========================================================= */

/* =========================================================
   SECTION 1: DESIGN TOKENS (CSS Variables)
   ========================================================= */
:root {
    /* Base tones for typography and backgrounds */
    --ink: #2a1e1a;
    --ink-soft: #5a4943;
    --paper: #fdfcf9;
    --bg-tan: #f0e9dd;
    --bg-deep: #1b1412;
    --bg-db-deep: #6a3f1f;

    /* Main accents used throughout navigation and buttons */
    --wood-orange: #e07a00;
    --wood-dark: #5a3a22;
    --text-dark: #3b2411;
    --text-light: #ffffff;
    --sky-blue: #005a9c;

    /* Secondary accents */
    --accent-gold: #d4af37;
    --accent-novel: #d77b18;
    --accent-novel-deep: #9a3900;
    --accent-db: #e86f24;
    --accent-highlight: #efc95a;

    /* Miscellaneous design tokens */
    --line-gray: #d9d4ce;
    --radius-main: 14px;
    --radius-small: 8px;
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.15);
    --shadow-hard: 0 14px 34px rgba(0, 0, 0, 0.35);
    --max-width-content: 1200px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Header-specific variables */
    --header-accent: #e07a00;
    --header-text: #3b2411;
    --header-bg: rgba(255, 255, 255, 0.98);
    --header-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

/* =========================================================
   SECTION 2: GLOBAL RESETS
   ========================================================= */
html {
    box-sizing: border-box;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

*, *::before, *::after {
    box-sizing: inherit;
}

body {
    margin: 0;
    padding: 0;
    color: var(--text-dark);
    background-color: var(--paper);
    font-family: "Noto Sans JP", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    overflow-x: hidden;
}

img, svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Utility class to remove default list styles */
.list-unstyled {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* =========================================================
   SECTION 3: BASE TYPOGRAPHY
   ========================================================= */
p {
    margin: 0 0 1rem 0;
}

a {
    color: var(--wood-orange);
    text-decoration: none;
    transition: var(--transition-smooth);
}

a:hover {
    color: var(--accent-novel-deep);
    text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
    margin: 1.5rem 0 1rem 0;
    font-weight: 600;
    line-height: 1.3;
    color: var(--wood-orange);
}

/* Serif title style (used for page titles) */
h1.page-title-serif {
    margin: 0;
    font-size: clamp(1.4rem, 3vw, 1.8rem);
    font-weight: 700;
    color: var(--text-dark, #3b2411);
    font-family: "Noto Serif JP", ui-serif, Georgia, serif;
    letter-spacing: 0.02em;
    flex: 1;
    text-align: left;
}

ul, ol {
    padding-left: 1.5rem;
    margin: 0 0 1rem 0;
}

/* =========================================================
   SECTION 4: HEADER SYSTEM
   ========================================================= */

/* --- CRITICAL BRANDING SUBSET --- */
@font-face {
    font-family: 'Anagura Title';
    src: url('../fonts/anagura-branding.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* --- MAIN HEADER CONTAINER --- */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--header-bg);
    backdrop-filter: blur(8px);
    border-bottom: 3px solid var(--header-accent);
    box-shadow: var(--header-shadow);
    flex-wrap: nowrap;
    gap: 16px;
}

/* --- NAVIGATION TOGGLE (HAMBURGER) --- */
.nav-toggle {
    order: 3;
    display: block;
    appearance: none;
    border: 0;
    background: none;
    color: var(--header-text);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 8px;
    transition: var(--transition-smooth);
    flex-shrink: 0;
}

.nav-toggle:hover,
.nav-toggle:focus {
    color: var(--header-accent);
    transform: rotate(90deg);
    outline: none;
}

/* --- SITE TITLE AREA --- */
.site-title {
    order: 1;
    flex-grow: 1;
    text-align: left;
    margin-left: 0;
    min-width: 0;
}

.site-title a {
    color: var(--header-text);
    text-decoration: none;
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 1.8rem);
    font-family: "Anagura Title", serif !important;
    letter-spacing: 0.02em;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subtitle {
    margin: 0;
    color: var(--header-accent);
    font-size: 0.9rem;
    font-family: "Noto Sans JP", sans-serif;
    font-weight: 500;
    opacity: 0.9;
    line-height: 1.2;
}

/* --- HEADER CONTROLS --- */
.header-controls {
    order: 2;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.script-selector,
.view-mode-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 8px;
    border-radius: 20px;
    border: 1px solid rgba(224, 122, 0, 0.3);
}

.script-selector label,
.view-mode-selector label {
    font-size: 0.75rem;
    color: var(--text-dark);
    font-weight: 600;
    opacity: 0.7;
}

.script-btn,
.view-btn {
    background: transparent;
    border: none;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
    transition: var(--transition-smooth);
    font-family: inherit;
}

.script-btn:hover,
.view-btn:hover {
    background: rgba(224, 122, 0, 0.1);
}

.script-btn.active,
.view-btn.active {
    background: var(--header-accent);
    color: white;
}

/* --- BODY OFFSET FOR FIXED HEADER --- */
body {
    padding-top: 70px;
}

/* Specific adjustments for dict-db */
body.archive,
body.post-type-archive-dictionary,
body.tax-dict_category,
body.tax-dict_language {
    padding-top: 70px;
}

/* --- RESPONSIVE HEADER DESIGN --- */
@media (max-width: 920px) {
    .view-mode-selector,
    .script-selector {
        display: none;
    }
}

@media (max-width: 768px) {
    .site-header {
        flex-direction: row;
        flex-wrap: nowrap;
        padding: 12px 16px;
        gap: 8px;
    }

    .nav-toggle {
        display: block;
        order: 3;
        margin: 0;
        padding-left: 8px;
    }

    .site-title {
        order: 1;
        flex-grow: 1;
        padding-left: 0;
    }

    .site-title a {
        font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    }

    .header-controls {
        order: 2;
        width: auto;
        margin-top: 0;
    }

    .subtitle {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .subtitle {
        display: none;
    }
}

/* =========================================================
   SECTION 5: OVERLAY NAVIGATION
   ========================================================= */

/* Overlay container */
.nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(27, 20, 18, 0.97);
    color: #f4f0e8;
    display: none;
    z-index: 999;
    overflow-y: auto;
    padding: 80px 40px 40px;
}

.nav-overlay.open {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Overlay content panel */
.nav-panel {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 40px;
}

/* Close button */
.nav-close {
    position: fixed;
    top: 20px;
    right: 30px;
    appearance: none;
    border: 0;
    background: rgba(224, 122, 0, 0.9);
    color: #fff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.3s ease;
    z-index: 1000;
}

.nav-close:hover {
    background: var(--wood-orange);
    transform: scale(1.1);
}

/* Nav sections */
.nav-section h3 {
    color: var(--wood-orange);
    font-weight: 700;
    font-size: 1.4rem;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--wood-orange);
    font-family: "Noto Serif JP", serif;
}

.nav-section ul {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 1rem;
}

.nav-section li {
    margin: 0;
}

.nav-section a {
    display: block;
    padding: 10px 0;
    color: #f4f0e8;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s ease;
    font-size: 1rem;
}

.nav-section a:hover {
    color: var(--wood-orange);
    padding-left: 12px;
    border-color: var(--wood-orange);
}

/* Widget content in overlay */
.nav-section .widget {
    margin-bottom: 0;
}

.nav-section .widget ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-section .widget li {
    margin: 0;
}

.nav-section .widget a {
    display: block;
    padding: 10px 0;
    color: #f4f0e8;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s ease;
}

.nav-section .widget a:hover {
    color: var(--wood-orange);
    padding-left: 12px;
}

/* Mobile overlay adjustments */
@media (max-width: 768px) {
    .nav-overlay {
        padding: 60px 20px 40px;
    }
    
    .nav-panel {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .nav-close {
        top: 10px;
        right: 15px;
        font-size: 28px;
        padding: 6px 12px;
    }
    
    .nav-section h3 {
        font-size: 1.2rem;
    }
}

/* =========================================================
   SECTION 6: FOOTER
   ========================================================= */
.site-footer {
    padding: 1.5rem 2rem;
    text-align: center;
    margin-top: 4rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.footer-nav {
    max-width: 1200px;
    margin: 0 auto 1rem;
    padding: 0;
}

.footer-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}

.footer-nav a {
    color: var(--wood-orange);
    text-decoration: none;
    font-weight: 600;
    font-family: "Noto Sans JP", system-ui, sans-serif;
    font-size: 0.9rem;
    transition: var(--transition-smooth);
    position: relative;
}

.footer-nav a::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--wood-orange);
    transition: width 0.3s ease;
}

.footer-nav a:hover::after {
    width: 100%;
}

.copyright {
    margin: 0;
    color: #777;
    font-family: "Noto Sans JP", system-ui, sans-serif;
    font-size: 0.85rem;
}

/* Dark footer variant (for dict-db and khokh-sudar) */
body.dark-footer .site-footer {
    background-color: var(--bg-deep);
    color: #f0e6d9;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-footer .footer-nav a {
    color: #ffe9c4;
}

body.dark-footer .footer-nav a:hover {
    color: #efc95a;
}

body.dark-footer .copyright {
    color: #ffe9c4;
    opacity: 0.8;
}

/* =========================================================
   SECTION 7: BREADCRUMB (itako-dict only)
   ========================================================= */
.breadcrumb {
    background: #fafaf8;
    border-bottom: 1px solid #e0e0e0;
    padding: 0.5rem 1rem;
}

.breadcrumb-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-width: 1200px;
    margin: 0 auto;
    font-size: 0.85rem;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
}

.breadcrumb-item:not(:last-child)::after {
    content: "\203A";
    margin-left: 0.5rem;
    color: #999;
}

.breadcrumb-link {
    color: var(--wood-orange);
    text-decoration: none;
    transition: var(--transition-smooth);
}

.breadcrumb-link:hover {
    text-decoration: underline;
}

.breadcrumb-current {
    color: #666;
}

@media (max-width: 768px) {
    .breadcrumb {
        display: none;
    }
}

/* =========================================================
   SECTION 7.6: HEADER SEARCH (dict-db)
   ========================================================= */
.header-search {
    position: relative;
    flex-grow: 1;
    max-width: 400px;
}

.header-search svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--header-accent);
    pointer-events: none;
}

.header-search input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid #dcd1c3;
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.9);
    transition: all 0.2s ease;
}

.header-search input:focus {
    outline: none;
    border-color: var(--header-accent);
    box-shadow: 0 0 0 3px rgba(224, 122, 0, 0.15);
}

@media (max-width: 768px) {
    .header-search {
        max-width: 100%;
    }
}

/* =========================================================
   SECTION 8: ACCESSIBILITY & PRINT
   ========================================================= */

/* Skip to content link */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--wood-orange);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 200;
    font-weight: 600;
    font-family: "Noto Sans JP", sans-serif;
    border-radius: 0 0 4px 0;
}

.skip-to-content:focus {
    top: 0;
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Focus visible for keyboard navigation */
.dict-nav-primary a:focus-visible,
.menu-toggle:focus-visible,
.nav-toggle:focus-visible,
.footer-nav a:focus-visible,
.nav-submenu a:focus-visible {
    outline: 3px solid var(--wood-orange);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Print styles */
@media print {
    .site-header {
        position: static;
        background: white;
        border: 1px solid #ccc;
        box-shadow: none;
    }

    .nav-toggle,
    .menu-toggle,
    .header-controls {
        display: none !important;
    }

    .dict-nav-primary,
    .dict-nav-secondary {
        max-height: none !important;
    }

    .site-footer,
    .breadcrumb {
        background: white;
        border: 1px solid #ccc;
    }
}

/* =========================================================
   SECTION 9: GLOBAL COMPONENTS (Ornaments & Dividers)
   ========================================================= */

/* 1. Define Symbol Variables */
:root {
    --icon-suikh: url('/shared-assets/svg/khatan-suikh.svg');     /* Queen's Earrings */
    --icon-buguivch: url('/shared-assets/svg/khaan-buguivch.svg'); /* King's Bracelet */
    --icon-divider-default: url('/shared-assets/svg/divider-2.svg'); /* Default Knot */
}

/* 2. Base Flexible Divider Structure 
   Usage: Add class "anagura-divider" to an HR or Separator block */
hr.anagura-divider,
.wp-block-separator.anagura-divider {
    border: 0;
    background-color: transparent !important;
    
    /* Flex Layout for Centering */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    
    /* Sizing */
    width: 100%;
    max-width: var(--max-width-content, 1200px);
    margin: 2.5rem auto;
    height: 40px;
    
    /* Default Center Symbol */
    background-image: var(--icon-divider-default);
    background-repeat: no-repeat;
    background-position: center center;
    background-size: auto 75%;
    opacity: 0.9;
}

/* 3. The Fading Lines */
hr.anagura-divider::before,
hr.anagura-divider::after,
.wp-block-separator.anagura-divider::before,
.wp-block-separator.anagura-divider::after {
    content: "";
    flex-grow: 1;
    height: 2px;
    border-radius: 1px;
}

/* Left Line: Transparent -> Gray */
hr.anagura-divider::before,
.wp-block-separator.anagura-divider::before {
    background: linear-gradient(to right, transparent, var(--line-gray, #d9d4ce));
}

/* Right Line: Gray -> Transparent */
hr.anagura-divider::after,
.wp-block-separator.anagura-divider::after {
    background: linear-gradient(to right, var(--line-gray, #d9d4ce), transparent);
}

/* 4. Symbol Modifiers (Add these classes alongside "anagura-divider") */

/* Class: "suikh" (Queen's Earrings) */
hr.anagura-divider.suikh,
.wp-block-separator.anagura-divider.suikh {
    background-image: var(--icon-suikh);
    background-size: auto 100%; /* Taller for detail */
}

/* Class: "buguivch" (King's Bracelet) */
hr.anagura-divider.buguivch,
.wp-block-separator.anagura-divider.buguivch {
    background-image: var(--icon-buguivch);
    background-size: auto 90%;
}

/* Class: "royal-pair" (King & Queen) */
hr.anagura-divider.royal-pair,
.wp-block-separator.anagura-divider.royal-pair {
    background-image: var(--icon-buguivch), var(--icon-suikh);
    /* Position King Left, Queen Right */
    background-position: center left 35%, center right 35%;
    background-size: auto 80%;
    gap: 50px; /* Increase gap to fit two icons */
}