:root {
    --bg: #fcfaf7;
    --surface: #ffffff;
    --border: #e2ddd3;
    --ink: #1a1a1a;
    --muted: #666666;
    --torii-red: #d32f2f;
    --gold: #af8d32;
    --accent-bg: #f4f1ea;
    /* Expanded for 2K displays */
    --max-width: 1600px;
}

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

html { scroll-behavior: smooth; }

/* --- Keyframes --- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes cardIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes panelFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

body {
    background-color: var(--bg);
    color: var(--ink);
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

header {
    padding: 5rem 2rem 3rem;
    text-align: center;
    background: linear-gradient(to bottom, #f0ede6, var(--bg));
}

.kamon {
    font-size: 2.5rem;
    color: var(--torii-red);
    margin-bottom: 1rem;
    display: block;
    animation: fadeUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

h1 {
    font-family: 'Bodoni+Moda', serif;
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    animation: fadeUp 0.7s 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.subtitle {
    font-family: 'Noto Serif JP', serif;
    letter-spacing: 0.4em;
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
    animation: fadeUp 0.7s 0.1s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* --- Updated Controls for 2K Screens --- */
.search-container {
    max-width: var(--max-width);
    margin: 0 auto 3rem;
    padding: 0 2rem;
    animation: fadeUp 0.7s 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.filter-bar {
    background: var(--surface);
    padding: 1.2rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.04);
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
    border: 1px solid var(--border);
    align-items: center;
}

.filter-bar input {
    flex: 3;
    min-width: 300px;
    padding: 0.8rem 1.2rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

.filter-bar input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(175, 141, 50, 0.1); }

.filter-group { display: flex; align-items: center; gap: 0.5rem; }

.filter-bar select {
    padding: 0.8rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-size: 0.85rem;
    cursor: pointer;
    min-width: 140px;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}
.filter-bar select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(175, 141, 50, 0.1); }

.stats-badge {
    margin-left: auto;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    font-weight: 700;
    background: var(--accent-bg);
    padding: 0.5rem 1rem;
    border-radius: 20px;
}

/* --- Expanded Grid Layout --- */
.list-container {
    max-width: var(--max-width);
    margin: 0 auto 5rem;
    padding: 0 2rem;
}

.list-header {
    display: grid;
    grid-template-columns: 50px 1.2fr 1fr 1.5fr 1.2fr 100px;
    gap: 2rem;
    padding: 1rem 1.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--muted);
    border-bottom: 2px solid var(--ink);
}

.shrine-card {
    display: grid;
    grid-template-columns: 50px 1.2fr 1fr 1.5fr 1.2fr 100px;
    gap: 2rem;
    padding: 2.5rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    transition: background 0.2s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    align-items: start;
}

.shrine-card { cursor: pointer; }
.shrine-card:not(.selected):hover { background: #fffdf9; transform: translateX(4px); }
.shrine-card.selected { background: #fffbf0; border-left: 3px solid var(--gold); padding-left: calc(1.5rem - 3px); }

.shrine-card.card-enter { animation: cardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
.panel-fade-in { animation: panelFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both; }

.index { font-family: 'Bodoni+Moda'; color: var(--border); font-size: 1.4rem; font-weight: 700; }

.deity-info .name { font-weight: 600; font-size: 1.1rem; display: block; color: var(--ink); line-height: 1.3; }
.deity-kanji { font-family: 'Noto Serif JP', serif; font-size: 0.8rem; color: var(--gold); display: block; margin-top: 0.15rem; margin-bottom: 0.3rem; font-weight: 400; }
.deity-info .identity { font-size: 0.8rem; color: var(--muted); font-style: italic; margin-bottom: 0.3rem; display: block; }
.deity-info .domain { font-size: 0.85rem; color: var(--muted); line-height: 1.5; margin-bottom: 0.35rem; }
.deity-info .deity-type-tag { margin-left: 0; }

.shrine-info .shrine-name { font-family: 'Noto Serif JP', serif; font-weight: 700; color: var(--torii-red); font-size: 1.1rem; display: block; margin-bottom: 0.2rem; }
.shrine-info .location { font-size: 0.85rem; font-weight: 600; color: var(--ink); }
.shrine-info .region-tag {
    display: inline-block;
    font-size: 0.65rem;
    background: var(--accent-bg);
    padding: 3px 8px;
    border-radius: 4px;
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.prayer-col, .time-col {
    font-size: 0.85rem;
    line-height: 1.6;
    color: #444;
}

.col-label {
    display: none;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gold);
    border-bottom: 1px solid var(--border);
    padding-bottom: 2px;
    margin-bottom: 0.4rem;
    width: fit-content;
}

.muted-dash { color: var(--border); }

.match-badge {
    display: inline-block;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: #fef3c7;
    color: #92400e;
    padding: 2px 6px;
    border-radius: 3px;
    margin-top: 5px;
    font-weight: 600;
}

/* --- Detail Panel --- */
.detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}
.detail-overlay.visible { opacity: 1; pointer-events: auto; }

.detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 50vw;
    height: 100vh;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 48px rgba(0,0,0,0.1);
    overflow-y: auto;
    scroll-behavior: smooth;
    z-index: 201;
    padding: 2.5rem;
    transform: translateX(110%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease;
}
.detail-panel.open { transform: translateX(0); box-shadow: -12px 0 60px rgba(0,0,0,0.13); }

.detail-handle { display: none; }

.detail-close {
    position: sticky;
    top: 0;
    float: right;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 1;
}
.detail-close:hover { background: var(--accent-bg); color: var(--ink); }

.panel-shrine-name {
    font-family: 'Noto Serif JP', serif;
    font-weight: 700;
    color: var(--torii-red);
    font-size: 1.3rem;
    display: block;
    margin-bottom: 0.3rem;
    padding-right: 2.5rem;
    line-height: 1.4;
}

.panel-location {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
    display: block;
    padding-bottom: 1.25rem;
    margin-bottom: 0;
    border-bottom: none;
}

/* Deity list */
.deities-list {
    padding: 0.75rem 0 1.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.deity-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.deity-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.4;
}

.deities-list .deity-kanji {
    display: inline;
    font-family: 'Noto Serif JP', serif;
    font-weight: 400;
    color: var(--muted);
    font-size: 0.8rem;
    margin: 0;
}

.deity-type-tag {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 1px 7px;
    border-radius: 3px;
    margin-left: 0.5rem;
    vertical-align: middle;
    position: relative;
    top: -1px;
}
.dt-origin     { background: #fef3c7; color: #92400e; }
.dt-deified    { background: #dbeafe; color: #1e40af; }
.dt-syncretic  { background: #f3e8ff; color: #6b21a8; }
.dt-imported   { background: #dcfce7; color: #166534; }

/* Shrine category tags */
.category-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 0.5rem;
}
.category-tag {
    display: inline-block;
    font-size: 0.55rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1px 6px;
    border-radius: 3px;
    white-space: nowrap;
}

/* Martial & Protective */
.cat-victory             { background: #fee2e2; color: #991b1b; }
.cat-protection          { background: #ffe4e6; color: #9f1239; }
.cat-warding             { background: #fecdd3; color: #881337; }

/* Commerce & Wealth */
.cat-business            { background: #ffedd5; color: #9a3412; }
.cat-prosperity          { background: #fef9c3; color: #854d0e; }

/* Knowledge */
.cat-academic            { background: #dbeafe; color: #1e40af; }
.cat-wisdom              { background: #e0e7ff; color: #3730a3; }

/* Relationships */
.cat-love                { background: #fce7f3; color: #9d174d; }
.cat-marriage            { background: #fbcfe8; color: #831843; }
.cat-fertility           { background: #f5d0fe; color: #86198f; }
.cat-childbirth          { background: #fae8ff; color: #7e22ce; }

/* Health & Vitality */
.cat-health              { background: #dcfce7; color: #166534; }
.cat-longevity           { background: #d1fae5; color: #065f46; }
.cat-purification        { background: #ccfbf1; color: #115e59; }

/* Journey */
.cat-travel              { background: #cffafe; color: #155e75; }
.cat-seafaring           { background: #bae6fd; color: #075985; }

/* Creative */
.cat-arts                { background: #ddd6fe; color: #5b21b6; }
.cat-craft               { background: #e9d5ff; color: #6b21a8; }

/* Sacred & Ceremonial */
.cat-imperial            { background: #fde68a; color: #78350f; }
.cat-national-protection { background: #e2e8f0; color: #334155; }
.cat-ancestral-rites     { background: #f5ebe0; color: #78350f; }
.cat-spirit-pacification { background: #e8eaf6; color: #283593; }

/* Nature */
.cat-harvest             { background: #ecfccb; color: #3f6212; }

.deity-domain {
    font-size: 0.78rem;
    color: #555;
    line-height: 1.5;
}

.deity-title {
    font-size: 0.73rem;
    color: var(--gold);
    font-style: italic;
}

.panel-section { margin-bottom: 1.75rem; }
.panel-section strong {
    color: var(--gold);
    font-weight: 700;
    display: block;
    margin-bottom: 0.6rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 1px solid var(--border);
    padding-bottom: 2px;
    width: fit-content;
}
.panel-section p { font-size: 0.85rem; line-height: 1.7; color: #444; }

/* Events section */
.events-section {
    margin-top: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.events-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--muted);
    margin-bottom: 1.25rem;
}

.event-row {
    margin-bottom: 0.25rem;
}

.event-row:not(:last-child) .event-body-inner::after {
    content: '❁ ❁ ❁';
    display: block;
    text-align: center;
    color: var(--border);
    font-size: 0.6rem;
    letter-spacing: 0.5em;
}

.event-toggle {
    width: 100%;
    background: none;
    border: none;
    padding: 0.9rem 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-align: left;
    border-radius: 4px;
    transition: background 0.15s;
}
.event-toggle:hover { background: var(--accent-bg); }

.event-toggle-main { flex: 1; min-width: 0; }

.event-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--ink);
    display: block;
    margin-bottom: 0.35rem;
    line-height: 1.4;
}

.event-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.event-time {
    font-size: 0.75rem;
    color: var(--muted);
    font-style: italic;
}

.event-chevron {
    font-size: 0.75rem;
    color: var(--muted);
    transition: transform 0.25s ease;
    flex-shrink: 0;
}
.event-row.open .event-chevron { transform: rotate(180deg); }

.event-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.event-body-inner {
    padding: 0.75rem 0.75rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.event-category {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 2px 7px;
    border-radius: 3px;
}

.ev-public { background: #dcfce7; color: #166534; }
.ev-pilgrimage { background: #ede9fe; color: #5b21b6; }


.type-pill {
    justify-self: start;
    font-size: 0.7rem;
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-align: center;
    width: 100%;
}

/* Shrine rank pills — Japanese traditional tones (和色)
   Hierarchy reads through warmth & saturation, not heavy dark fills */
.tHon { background: #1a1816; color: #faf5ed; }  /* 漆 Urushi — dark lacquer with warm parchment white, top rank */
.tSoh { background: #f0e0c0; color: #7a5520; }  /* 金茶 Kincha — gold-brown, head shrine network */
.tIch { background: #d8dee6; color: #3a4f68; }  /* 縹 Hanada — faded indigo, provincial first shrine */
.tKok { background: #e0d5e5; color: #5a3868; }  /* 藤 Fuji — wisteria, national/government prestige */
.tBep { background: #e5dbc8; color: #6b5228; }  /* 丁子 Chōji — clove, established important */
.tSho { background: #f0e8d0; color: #8a7340; }  /* 薄香 Usukō — light incense, subsidiary */
.tSon { background: #ece8e0; color: #7a7060; }  /* 白茶 Shiracha — pale tea, village shrine */
.tTem { background: #d0ddd5; color: #2d5a3e; }  /* 青磁 Seiji — celadon, temple-shrine syncretic */

@media (max-width: 1200px) {
    .list-header { display: none; }
    .shrine-card {
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
        margin-bottom: 1.5rem;
        border: 1px solid var(--border);
        border-radius: 12px;
    }
    .index { grid-column: span 2; }
    .type-pill { grid-column: span 2; width: auto; }
    .prayer-col, .time-col { grid-column: span 1; }
    .col-label { display: block; }

    /* Bottom sheet */
    .detail-panel {
        top: auto;
        right: 0;
        bottom: 0;
        width: 100%;
        height: auto;
        max-height: 85vh;
        border-left: none;
        border-top: 1px solid var(--border);
        border-radius: 16px 16px 0 0;
        transform: translateY(110%);
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        padding: 0 1.5rem 2rem;
    }
    .detail-panel.open { transform: translateY(0); box-shadow: 0 -8px 48px rgba(0,0,0,0.12); }

    .detail-handle {
        display: block;
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
        margin: 0.75rem auto 1.25rem;
    }
}

footer {
    text-align: center;
    padding: 6rem 2rem;
    font-size: 0.85rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

.highlight { background: #fff3b0; padding: 0 2px; border-radius: 2px; }

.disclaimer {
    max-width: 600px;
    margin: 0 auto 1.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--muted);
    opacity: 0.8;
}
