/* =========================================================
   linguistics-base.css (v1.2 - Standalone)
   Common Foundation for All Linguistics Pages
   
   Changes:
   - Added Global Resets (formerly in anagura-base.css)
   - Integrated necessary variables
   ========================================================= */

/* =========================================================
   1. GLOBAL RESET & BASE (Moved from anagura-base.css)
   ========================================================= */
html {
    box-sizing: border-box;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

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

/* Utility to remove list styles (often used by widgets) */
.list-unstyled {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* =========================================================
   2. CSS VARIABLES (Linguistics-Specific)
   ========================================================= */
:root {
    --bg: #faf8f4;
    --ink: #3b362f;
    --ink-soft: #5a4943;
    --ink-light: #6d655a;
    --rule: #dcd1c3;
    --accent-river: #c9642d;
    --accent: #e07a00;
    --accent-hover: #3b2411;
    --bg-tan: #f0e9dd; 
    --bg-white-trans: rgba(255, 255, 255, 0.7);
    
    /* Variables for shared component compatibility */
    --wood-orange: #e07a00;
    --wood-dark: #5a3a22;
    --text-dark: #3b2411;
    --text-light: #ffffff;
    --line-gray: #dcd1c3;
}

* { 
    margin: 0; 
    padding: 0; 
}

/* =========================================================
   3. BODY & LAYOUT FOUNDATIONS
   ========================================================= */
body { 
    margin: 0; 
    background: var(--bg); 
    color: var(--ink); 
    font-family: var(--sans); 
    line-height: 1.7; /* Standard line-height */
}

/* =========================================================
   4. TYPOGRAPHY OVERRIDES
   ========================================================= */
a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

.page-title {
    font-family: var(--serif); 
    font-size: 1.5rem; 
    margin: 0 0 .5rem 0;
    letter-spacing: .05em; 
    color: var(--ink);
}

.page-meta { 
    color: var(--ink-light); 
    font-size: .9rem; 
}

.fragment-title {
    font-family: var(--serif); 
    font-size: 1.2rem; 
    font-weight: 600; 
    margin: 0;
    color: var(--ink); 
    letter-spacing: 0.02em;
}

/* =========================================================
   5. UNIVERSAL CARD SYSTEM
   ========================================================= */

/* Base Card - All cards inherit this */
.card-base {
    background: #fff;
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-base:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

/* Card Typography */
.card-title {
    font-family: var(--serif); 
    font-size: 1.05rem; 
    font-weight: 600; 
    margin: 0 0 .4rem; 
    line-height: 1.45;
}

.card-title a {
    color: var(--ink); 
    text-decoration: none;
}

.card-title a:hover {
    color: var(--accent-river);
}

.card-meta {
    font-size: 0.8rem; 
    color: var(--ink-light); 
    margin-bottom: .4rem; 
    font-weight: 500;
}

.card-excerpt,
.card-ex {
    font-size: 0.92rem; 
    margin-top: .4rem; 
    color: var(--ink-soft); 
    line-height: 1.6;
}

/* =========================================================
   6. BUTTON STYLES
   ========================================================= */
.view-all-btn { 
    display: inline-block; 
    padding: 6px 14px; 
    background: var(--bg-tan); 
    border-radius: 20px; 
    font-size: 0.8rem; 
    font-weight: 600; 
    color: var(--ink); 
    text-decoration: none; 
    transition: all 0.2s ease;
}

.view-all-btn:hover { 
    background: var(--accent-river); 
    color: #fff; 
    transform: translateY(-1px); 
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* =========================================================
   7. LIST STYLES (Used in Multiple Places)
   ========================================================= */
.portal-list { 
    display: flex; 
    flex-direction: column; 
    border-top: 1px solid var(--rule); 
}

.portal-list-item {
    display: flex; 
    align-items: baseline; 
    gap: 12px; 
    padding: 12px 8px;
    border-bottom: 1px solid rgba(0,0,0,0.05); 
    text-decoration: none; 
    color: var(--ink); 
    transition: all 0.2s ease; 
    border-left: 3px solid transparent;
}

.portal-list-item:hover { 
    background: rgba(255,255,255,0.6); 
    color: var(--accent-river); 
    border-left-color: var(--accent-river);
    transform: translateX(4px);
}

.portal-list-item .meta-date { 
    font-family: var(--sans); 
    font-size: 0.75rem; 
    color: var(--ink-light); 
    white-space: nowrap; 
    min-width: 40px; 
}

.portal-list-item .meta-title { 
    font-family: var(--sans); 
    font-size: 0.95rem; 
    font-weight: 500; 
    line-height: 1.5; 
}

/* Compact variant for smaller lists */
.portal-list-item.small { 
    padding: 8px 6px; 
}

.portal-list-item.small .meta-title { 
    font-size: 0.85rem; 
}

/* =========================================================
   8. CATEGORY STYLES (Used in Home + Sidebar)
   ========================================================= */
.cat-accordion { 
    margin-bottom: 0.5rem; 
    border-bottom: 1px dashed var(--rule); 
}

.cat-accordion:last-child { 
    border-bottom: none; 
}

.cat-root-label { 
    font-size: 0.9rem; 
    color: var(--ink); 
    font-weight: 700; 
    padding: 10px 0; 
    cursor: pointer; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

.cat-root-label::-webkit-details-marker { 
    display: none; 
}

.cat-root-label .root-link { 
    text-decoration: none; 
    color: inherit; 
    flex-grow: 1; 
    transition: color 0.2s ease; 
}

.cat-root-label .root-link:hover { 
    color: var(--accent-river); 
}

.acc-icon::after { 
    content: '+'; 
    font-weight: 300; 
    font-size: 1.2rem; 
    color: var(--ink-light); 
}

details[open] .acc-icon::after { 
    content: '−'; 
}

.cat-chips { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px; 
    padding-bottom: 1.5rem; 
    padding-top: 0.5rem; 
}

.chip { 
    display: inline-block; 
    padding: 6px 12px; 
    background: #fff; 
    border: 1px solid rgba(201, 100, 45, 0.15); 
    border-radius: 20px; 
    color: var(--ink-soft); 
    font-size: 0.85rem; 
    font-weight: 500; 
    text-decoration: none; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.02); 
    transition: all 0.2s; 
}

.chip:hover { 
    background: var(--accent); 
    color: #fff; 
    border-color: var(--accent); 
    transform: scale(1.05); 
}

.empty-child { 
    font-size: 0.8rem; 
    color: #999; 
    padding-left: 4px; 
}

/* =========================================================
   9. HEADER OVERRIDES (Minimal)
   ========================================================= */
.site-header {
    background: #ffffff;
}
.site-title { 
    order: 1; 
    flex-grow: 1; 
    text-align: left; 
    margin-left: 0; 
    min-width: 0; 
}

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

.header-controls { 
    order: 2; 
    display: flex; 
    align-items: center; 
    gap: 16px; 
    flex-shrink: 0; 
}

.nav-toggle {
    order: 3; 
    display: block; 
    appearance: none; 
    border: 0; 
    background: none;
    color: #3b2411; 
    font-size: 26px; 
    line-height: 1; 
    cursor: pointer; 
    padding: 8px; 
    transition: all 0.3s ease; 
    flex-shrink: 0; 
}

.nav-toggle:hover { 
    color: var(--accent); 
    transform: rotate(90deg); 
}

/* =========================================================
   10. NAVIGATION OVERLAY (Used Everywhere)
   ========================================================= */
.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; } 
}

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

.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; 
}

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

.nav-section h3 { 
    color: var(--accent); 
    font-weight: 700; 
    font-size: 1.4rem; 
    margin-bottom: 16px; 
    padding-bottom: 8px; 
    border-bottom: 2px solid var(--accent); 
    font-family: var(--serif); 
}

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

.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(--accent); 
    padding-left: 12px; 
    border-color: var(--accent); 
}

/* =========================================================
   11. SCRIPT SELECTOR (Header Control)
   ========================================================= */
.script-selector { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    padding: 6px 12px; 
    background: rgba(255, 255, 255, 0.8); 
    border: 1px solid var(--accent); 
    border-radius: 20px; 
}

.script-selector label { 
    font-size: 0.8rem; 
    color: #5a4943; 
    font-weight: 600; 
}

.script-btn { 
    appearance: none; 
    border: 0; 
    background: transparent; 
    color: #5a4943; 
    font-size: 0.8rem; 
    padding: 4px 10px; 
    border-radius: 12px; 
    cursor: pointer; 
    transition: all 0.3s ease; 
    font-family: var(--sans); 
}

.script-btn.active { 
    background: var(--accent); 
    color: #fff; 
    font-weight: 600; 
}

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

.script-btn:disabled { 
    opacity: 0.4; 
    cursor: not-allowed; 
}

/* =========================================================
   12. SKIP LINK (Accessibility)
   ========================================================= */
.skip-to-content { 
    position: absolute; 
    top: -100px; 
    left: 1rem; 
    background: var(--accent); 
    color: white; 
    padding: 0.5rem 1rem; 
    text-decoration: none; 
    z-index: 9999; 
    font-weight: 600; 
}

.skip-to-content:focus { 
    top: 1rem; 
}

/* =========================================================
   13. FOOTER (Common Across All Pages)
   ========================================================= */
.site-footer { 
    margin-top: 0; 
    clear: both; 
    text-align: center; 
}

.site-footer .copyright { 
    margin: 1rem auto 1rem; 
    max-width: 90%; 
    color: var(--text-dark); 
}

/* =========================================================
   14. RESPONSIVE - MOBILE
   ========================================================= */
@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; 
    }
    
    .header-controls { 
        order: 2; 
        width: auto; 
        margin-top: 0; 
    }
    
    .script-selector { 
        display: none; 
    }
}

/* --------------------------------------------------------- */
/* Top Image Styling: Spacing & "Click to Enlarge" Hint      */
/* --------------------------------------------------------- */

/* Target the first image block in the article content */
.article-content > .wp-block-image:first-of-type {
    margin-bottom: 3rem;       /* Add space between image and TOC */
    position: relative;        /* Required for positioning */
    display: block;
}

/* Add the text line below the image with SVG Icon */
.article-content > .wp-block-image:first-of-type::after {
    content: "クリックで拡大";   /* Text only */
    
    /* Layout */
    display: table;
    margin-left: auto;
    
    /* Text Styling */
    font-size: 0.85rem;
    color: #888;
    margin-top: 0.5rem;
    font-weight: normal;
    font-family: inherit;
    
    /* Interaction */
    cursor: pointer;           /* Make it look like a link */
    pointer-events: auto;      /* Allow clicking */
    transition: color 0.2s;    /* Smooth hover effect */
    
    /* SVG Icon (Search Magnifier) */
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cpath d='m21 21-4.35-4.35'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 1.1em 1.1em;
    background-position: left center;
    padding-left: 1.4em;
    line-height: 1.4;
}

/* Hover effect for the text line */
.article-content > .wp-block-image:first-of-type:hover::after {
    color: #555;               /* Darker grey on hover */
    text-decoration: underline;
}

/* --------------------------------------------------------- */
/* Flexible Divider: Fading Lines + Fixed Center Symbol      */
/* --------------------------------------------------------- */

.article-content hr,
.article-content .wp-block-separator {
    border: 0;
    background-color: transparent !important;
    
    /* Layout */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;         /* Space for the symbol */
    
    /* Sizing */
    width: 100%;
    margin: 2rem auto;
    height: 40px;
    
    /* Center Symbol */
    background-image: url("https://itako999.com/shared-assets/svg/divider-2.svg");
    background-repeat: no-repeat;
    background-position: center center;
    background-size: auto 75%;
}

/* Shared Line Styles */
.article-content hr::before,
.article-content hr::after,
.article-content .wp-block-separator::before,
.article-content .wp-block-separator::after {
    content: "";
    flex-grow: 1;             /* Stretch to fill space */
    height: 2px;              /* Line thickness */
    opacity: 0.9;
}

/* Left Line: Fades IN (Transparent -> Grey) */
.article-content hr::before,
.article-content .wp-block-separator::before {
    background: linear-gradient(to right, transparent, #ccc);
}

/* Right Line: Fades OUT (Grey -> Transparent) */
.article-content hr::after,
.article-content .wp-block-separator::after {
    background: linear-gradient(to right, #ccc, transparent);
}

/* =========================================================
   15. GENERIC TABLE STYLES (Combating WP Injected Styles)
   ========================================================= */

/* 1. Reset WP Block Table Container (The "Thick Line" Killer) */
body .article-content .wp-block-table thead,
body .article-content .wp-block-table tfoot {
    /* WP injects "border-bottom: 3px solid" here. We MUST kill it. */
    border: none !important; 
    border-bottom: 1px solid #000000 !important; /* Force it to match our thin logic */
}

/* 2. Table Container & Outer Border */
body .article-content table:not(.translit-table):not(.chrono-table):not(.tibetan-translit):not(.mongol-translit):not(.devanagari-translit),
body .article-content .wp-block-table table {
    width: 100%;
    border-collapse: collapse !important; 
    background: #fffefb; 
    margin: 2rem auto;
    
    /* Outer Frame: 1.5px Black */
    border: 1.5px solid #000000 !important; 
    
    font-family: var(--sans);
}

/* 3. Header Cells: Beige & Thin Line */
body .article-content table:not(.translit-table):not(.chrono-table):not(.tibetan-translit):not(.mongol-translit) thead th,
body .article-content .wp-block-table table thead th,
body .article-content .wp-block-table table th {
    background-color: #e0d8cc !important; 
    color: #333333 !important;
    font-weight: 700 !important;
    padding: 0.7rem 0.9rem !important;
    text-align: left;
    
    /* Header Bottom: 1px Dark Grey */
    border-bottom: 1px solid #666666 !important;
    
    border-right: 1px solid #ccc !important;
    border-top: none !important;
    border-left: none !important;
}

/* 4. Body Cells: Standard Styling */
body .article-content table:not(.translit-table):not(.chrono-table):not(.tibetan-translit):not(.mongol-translit) td,
body .article-content .wp-block-table table td {
    padding: 0.7rem 0.9rem !important;
    vertical-align: top;
    font-size: 0.9rem;
    line-height: 1.6;
    
    /* Inner Borders: Thin Beige */
    border-bottom: 1px solid #e8e2d8 !important; 
    border-right: 1px solid #f0f0f0 !important;  
    
    /* Reset inherited WP styles */
    border-top: none !important;
    border-left: none !important;
}

/* 5. Clean up Edges */
/* Remove right borders from last column */
body .article-content table:not(.translit-table):not(.chrono-table):not(.tibetan-translit):not(.mongol-translit) th:last-child,
body .article-content table:not(.translit-table):not(.chrono-table):not(.tibetan-translit):not(.mongol-translit) td:last-child,
body .article-content .wp-block-table table th:last-child,
body .article-content .wp-block-table table td:last-child {
    border-right: none !important;
}

/* Remove bottom border from last row */
body .article-content table:not(.translit-table):not(.chrono-table):not(.tibetan-translit):not(.mongol-translit) tr:last-child td,
body .article-content .wp-block-table table tr:last-child td {
    border-bottom: none !important;
}

/* 6. Responsive Scroll */
@media (max-width: 768px) {
    .article-content .wp-block-table,
    .article-content table:not(.translit-table):not(.chrono-table):not(.tibetan-translit):not(.mongol-translit) {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* =========================================================
   WordPress Block Table Styles - Add to END of linguistics-base.css
   Replaces removed wp-block-table styles
   ========================================================= */

/* WordPress Block Table Container */
.wp-block-table {
    margin: 0 0 1em 0;
    overflow-x: auto;
}

.wp-block-table table {
    width: 100%;
    min-width: 240px;
    border-collapse: collapse;
    border-spacing: 0;
}

/* Default Table Styles */
.wp-block-table table {
    border: 1px solid #ddd;
}

.wp-block-table td,
.wp-block-table th {
    padding: 0.5em;
    border: 1px solid #ddd;
    word-break: normal;
}

/* Striped Style */
.wp-block-table.is-style-stripes tbody tr:nth-child(odd) {
    background-color: #f0f0f0;
}

/* Regular Style (default borders) */
.wp-block-table:not(.is-style-stripes) td,
.wp-block-table:not(.is-style-stripes) th {
    border: 1px solid #ddd;
}

/* Table Alignment */
.wp-block-table.alignleft,
.wp-block-table.aligncenter,
.wp-block-table.alignright {
    display: table;
    width: auto;
}

.wp-block-table.alignleft {
    margin-right: 1em;
}

.wp-block-table.aligncenter {
    margin-left: auto;
    margin-right: auto;
}

.wp-block-table.alignright {
    margin-left: 1em;
}

/* Caption */
.wp-block-table figcaption {
    color: #555;
    font-size: 0.8em;
    text-align: center;
    padding-top: 0.5em;
}

/* Responsive */
@media (max-width: 768px) {
    .wp-block-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}