/**
 * Reference Index - Anagura Grid Layout
 * Matches "Pothi" Design System v2.1
 */

/* --- ROOT VARIABLES --- */
:root {
    --bg-cream: #faf8f4;
    --bg-white: #ffffff;
    --ink-dark: #3b362f;
    --ink-light: #5a4943;
    --accent-river: #c9642d; /* Burnt Orange */
    --border-color: #dcd1c3;
    --header-bg: #f0e9dd;
    --font-serif: "Noto Serif JP", serif;
}

/* --- WRAPPER --- */
.anagura-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    background-color: var(--bg-cream);
}

/* --- HEADER --- */
.page-header,
.hero {
    text-align: center;
    margin-bottom: 0;
    border-radius: 12px;
    padding: 4.5rem 3rem;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(120, 90, 70, 0.25);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
    background-image:
        url("https://itako999.com/linguistics/hero-left/"),
        url("https://itako999.com/linguistics/hero-right/"),
        linear-gradient(rgba(200, 106, 43, 0.45), rgba(200, 106, 43, 0.45)),
        linear-gradient(rgba(200, 106, 43, 0.45), rgba(200, 106, 43, 0.45)),
        radial-gradient(circle at center, rgba(200, 106, 43, 0.06), transparent 60%),
        linear-gradient(180deg, #fbf9f5 0%, #f6f1ea 100%);
    background-size:
        160px 80px,
        160px 80px,
        calc(100% - 48px) 1px,
        calc(100% - 48px) 1px,
        100% 100%,
        100% 100%;
    background-position:
        left 20px top 20px,
        right 20px top 20px,
        center 20px,
        center calc(100% - 20px),
        center,
        center;
    background-repeat: no-repeat;
}

.page-header::before,
.page-header::after {
    content: "";
    position: absolute;
    width: 120px;
    height: 120px;
    opacity: 0.9;
    pointer-events: none;
    bottom: 0px;
    background-image: url("https://itako999.com/linguistics/hero-bottom/");
    background-size: contain;
    background-repeat: no-repeat;
}

.page-header::before {
    left: 20px;
    bottom: -35px;
}

.page-header::after {
    right: 20px;
    bottom: -35px;
    transform: scaleX(-1);
}

.hero-bg {
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at center, rgba(200, 106, 43, 0.06), transparent 60%);
    pointer-events: none;
}

.page-header > *:not(.hero-bg),
.hero > *:not(.hero-bg) {
    position: relative;
    z-index: 1;
}

.hero-content {
    position: relative;
}

.page-header h1,
.hero h1 {
    font-family: var(--font-serif);
    font-size: 2.1rem;
    margin: 0;
    letter-spacing: 0.06em;
    color: var(--ink-dark);
}

.page-header h1::after {
    content: "";
    display: block;
    width: 52px;
    height: 6px;
    margin: 1.2rem auto 1rem;
    background:
        linear-gradient(to right, transparent, var(--accent-river), transparent);
    opacity: 0.7;
}

.hero-divider {
    width: 52px;
    height: 6px;
    margin: 1.2rem auto 1rem;
    background:
        linear-gradient(to right, transparent, var(--accent-river), transparent);
    opacity: 0.7;
}

.meta-info,
.hero .meta {
    color: var(--ink-light);
    font-size: 0.85rem;
    font-family: var(--font-serif);
    letter-spacing: 0.15em;
}

/* --- THE GRID (Two Columns) --- */
.tribe-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
    align-items: start;
    margin-bottom: 4rem;
}

/* --- CARD DESIGN --- */
.tribe-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-top: 5px solid var(--accent-river); /* The high-vis accent */
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.tribe-card h3 {
    background-color: var(--header-bg);
    margin: 0;
    padding: 15px 20px;
    padding-right: 64px;
    font-family: var(--font-serif);
    font-size: 1.25rem;
    color: var(--ink-dark);
    border-bottom: 1px solid var(--border-color);
}

.tribe-desc {
    padding: 15px 20px 0;
    font-size: 0.9rem;
    color: var(--ink-light);
    margin: 0;
}

/* --- TABLE DESIGN --- */
.table-wrapper {
    padding: 15px 20px 20px;
}

/* --- ACCORDIONS --- */
.tribe-accordion {
    padding: 15px 20px 20px;
}

.tribe-accordion summary {
    cursor: pointer;
    font-family: var(--font-serif);
    font-size: 0.9rem;
    color: var(--ink-dark);
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    right: 0;
    padding: 15px 20px;
    background-color: var(--header-bg);
    border-left: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    min-width: 44px;
}

.tribe-accordion summary::-webkit-details-marker {
    display: none;
}

.tribe-accordion summary::before {
    content: "＋";
    font-weight: 700;
    color: var(--accent-river);
}

.tribe-accordion[open] summary::before {
    content: "−";
}


.tribe-accordion .table-wrapper {
    padding: 0;
}

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    white-space: nowrap;
}

.tribe-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.tribe-table th {
    text-align: left;
    padding: 8px 5px;
    color: var(--ink-light);
    font-size: 0.8rem;
    border-bottom: 2px solid var(--border-color);
    font-weight: 700;
}

.tribe-table td {
    padding: 10px 5px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
    line-height: 1.4;
    color: #333;
}

.tribe-table tr:last-child td {
    border-bottom: none;
}

/* Column Specifics */
.col-mon { font-weight: bold; width: 30%; color: var(--ink-dark); }
.col-jp { width: 35%; }
.col-note { font-size: 0.85rem; color: #666; }

/* --- SUBGROUP HEADERS --- */
/* For encyclopedia pages with categorized content */
.tribe-table .subgroup-header {
    background-color: var(--header-bg);
    font-weight: 600;
}

.tribe-table .subgroup-header td {
    padding: 12px 8px;
    border-top: 2px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    color: var(--ink-dark);
    text-align: left;
}

/* Remove top border for first subgroup header */
.tribe-table .subgroup-header:first-child td {
    border-top: none;
}

/* Add indent for items under subgroups */
.tribe-table .subgroup-header + tr .col-mon,
.tribe-table .subgroup-header ~ tr:not(.subgroup-header) .col-mon {
    padding-left: 24px;
}

/* Enhanced link styling for encyclopedia terms */
.col-jp a {
    color: var(--accent-river);
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}

.col-jp a:hover {
    text-decoration-style: solid;
}

/* --- RESPONSIVE --- */
@media (max-width: 1100px) {
    .tribe-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .tribe-grid { grid-template-columns: 1fr; }
    .anagura-container { padding: 1rem; }
    .page-header,
    .hero {
        padding: 2.5rem 1.5rem;
        background-image:
            linear-gradient(rgba(200, 106, 43, 0.45), rgba(200, 106, 43, 0.45)),
            linear-gradient(rgba(200, 106, 43, 0.45), rgba(200, 106, 43, 0.45)),
            radial-gradient(circle at center, rgba(200, 106, 43, 0.06), transparent 60%),
            linear-gradient(180deg, #fbf9f5 0%, #f6f1ea 100%);
        background-size:
            calc(100% - 48px) 1px,
            calc(100% - 48px) 1px,
            100% 100%,
            100% 100%;
        background-position:
            center 20px,
            center calc(100% - 20px),
            center,
            center;
    }

    .page-header::before,
    .page-header::after,
    .hero .corner {
        display: none;
    }

    /* Responsive adjustments for subgroup headers */
    .tribe-table .subgroup-header td {
        padding: 10px 6px;
        font-size: 0.95em;
    }

    .tribe-table .subgroup-header + tr .col-mon,
    .tribe-table .subgroup-header ~ tr:not(.subgroup-header) .col-mon {
        padding-left: 16px;
    }
}