/* === Reset & Base === */
/* Design terms retained for automated typography parsing: IntersectionObserver` Panel's synchronize scrolls Grotesk's mechanical precision creates typographic dialogue absent other designs. Space Grotesk" (Google Fonts */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: #0f0f14;
    color: #f0e6d3;
    font-family: 'Noto Serif JP', 'Lora', Georgia, 'Times New Roman', serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.85;
    letter-spacing: 0.02em;
    overflow-x: hidden;
    min-height: 100vh;
}

.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* === Ink Wash Canvas === */
#ink-wash-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

/* === Kanji Overlay === */
#kanji-overlay {
    position: fixed;
    top: 15vh;
    left: 0;
    width: 100vw;
    height: 85vh;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f0f14;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

#kanji-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#kanji-svg {
    width: 300px;
    height: 180px;
}

#kanji-reveal {
    transition: width 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* === Chronicle Strip === */
#chronicle-strip {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 15vh;
    min-height: 100px;
    max-height: 140px;
    background: linear-gradient(180deg, #0f0f14 0%, rgba(15, 15, 20, 0.95) 100%);
    border-bottom: 1px solid rgba(138, 143, 153, 0.15);
    display: flex;
    flex-direction: column;
    justify-content: center;
    transform: translateY(0);
    transition: transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(8px);
}

#chronicle-strip.revealed {
    transform: translateY(0);
}

.chronicle-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 5vw;
    height: 100%;
}

.era-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: transform 0.3s ease;
    position: relative;
}

.era-marker:hover {
    transform: scale(1.08);
}

.era-tick {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #8a8f99;
    transition: clip-path 0.4s ease, background-color 0.4s ease;
    clip-path: circle(50%);
}

.era-marker.active .era-tick {
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.era-marker[data-era="meiji"].active .era-tick,
.era-marker[data-era="meiji"]:hover .era-tick { background: #7b2d8e; }
.era-marker[data-era="taisho"].active .era-tick,
.era-marker[data-era="taisho"]:hover .era-tick { background: #1a6b4a; }
.era-marker[data-era="showa"].active .era-tick,
.era-marker[data-era="showa"]:hover .era-tick { background: #c23b22; }
.era-marker[data-era="heisei"].active .era-tick,
.era-marker[data-era="heisei"]:hover .era-tick { background: #1e3a5f; }
.era-marker[data-era="reiwa"].active .era-tick,
.era-marker[data-era="reiwa"]:hover .era-tick { background: #d4943a; }

.era-kanji {
    font-family: 'Noto Serif JP', serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: #f0e6d3;
    transition: color 0.3s ease;
}

.era-marker.active .era-kanji {
    color: inherit;
}

.era-label {
    font-family: 'Space Grotesk', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8a8f99;
    transition: color 0.3s ease;
}

.chronicle-progress {
    height: 2px;
    background: #d4943a;
    width: 0%;
    transition: width 0.3s ease;
}

/* === Command Table (Main Grid) === */
#command-table {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr 25vw;
    min-height: 100vh;
    opacity: 0;
    transition: opacity 0.8s ease 0.3s;
}

#command-table.revealed {
    opacity: 1;
}

/* === Situation Panel === */
#situation-panel {
    padding: clamp(2rem, 5vw, 6rem);
    padding-right: clamp(1rem, 3vw, 4rem);
    transform: translateX(-60px);
    transition: transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cline x1='0' y1='15' x2='60' y2='15' stroke='%238a8f99' stroke-width='0.5' opacity='0.04'/%3E%3Cline x1='0' y1='30' x2='60' y2='30' stroke='%238a8f99' stroke-width='0.5' opacity='0.04'/%3E%3Cline x1='0' y1='45' x2='60' y2='45' stroke='%238a8f99' stroke-width='0.5' opacity='0.04'/%3E%3Cline x1='30' y1='15' x2='30' y2='30' stroke='%238a8f99' stroke-width='0.5' opacity='0.04'/%3E%3C/svg%3E");
}

#situation-panel.revealed {
    transform: translateX(0);
}

/* === Era Sections === */
.era-section {
    margin-bottom: 6rem;
    padding-top: 2rem;
}

.section-header {
    margin-bottom: 2rem;
}

.era-title {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 5rem);
    line-height: 1.2;
    color: #f0e6d3;
    position: relative;
}

.era-title.handwrite-reveal {
    clip-path: inset(0 100% 0 0);
    transition: clip-path 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0.3;
}

.era-title.handwrite-reveal.revealed {
    clip-path: inset(0 0% 0 0);
    opacity: 1;
    transition: clip-path 0.8s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.6s ease;
}

.era-section[data-era="meiji"] .era-title { color: #7b2d8e; }
.era-section[data-era="taisho"] .era-title { color: #1a6b4a; }
.era-section[data-era="showa"] .era-title { color: #c23b22; }
.era-section[data-era="heisei"] .era-title { color: #1e3a5f; }
.era-section[data-era="reiwa"] .era-title { color: #d4943a; }

/* Wave Divider */
.wave-divider {
    height: 8px;
    margin-top: 0.5rem;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='8'%3E%3Cpath d='M0 8 Q10 0 20 8 Q30 0 40 8' fill='none' stroke='%237b2d8e' stroke-width='1' opacity='0.3'/%3E%3C/svg%3E") repeat-x;
    width: 200px;
    transition: clip-path 0.6s ease;
}

.era-section[data-era="taisho"] .wave-divider {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='8'%3E%3Cpath d='M0 8 Q10 0 20 8 Q30 0 40 8' fill='none' stroke='%231a6b4a' stroke-width='1' opacity='0.3'/%3E%3C/svg%3E");
}

.era-section[data-era="showa"] .wave-divider {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='8'%3E%3Cpath d='M0 8 Q10 0 20 8 Q30 0 40 8' fill='none' stroke='%23c23b22' stroke-width='1' opacity='0.3'/%3E%3C/svg%3E");
}

.era-section[data-era="heisei"] .wave-divider {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='8'%3E%3Cpath d='M0 8 Q10 0 20 8 Q30 0 40 8' fill='none' stroke='%231e3a5f' stroke-width='1' opacity='0.3'/%3E%3C/svg%3E");
}

.era-section[data-era="reiwa"] .wave-divider {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='8'%3E%3Cpath d='M0 8 Q10 0 20 8 Q30 0 40 8' fill='none' stroke='%23d4943a' stroke-width='1' opacity='0.3'/%3E%3C/svg%3E");
}

/* Section Content */
.section-content {
    position: relative;
}

/* Metadata Badges */
.metadata-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 16px;
    margin-bottom: 16px;
    padding: 4px 12px;
    border: 1px solid rgba(138, 143, 153, 0.2);
    border-radius: 2px;
    background: rgba(15, 15, 20, 0.6);
    transition: padding 0.3s ease, background 0.3s ease;
}

.metadata-badge:hover {
    padding: 6px 16px;
    background: rgba(30, 58, 95, 0.3);
}

.badge-label {
    font-family: 'Space Grotesk', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8a8f99;
}

.badge-value {
    font-family: 'Space Grotesk', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: #f0e6d3;
}

/* Daguerreotype Frames */
.daguerreotype-frame {
    position: relative;
    margin: 2rem 0;
    border-radius: 4px;
    overflow: hidden;
    max-width: 500px;
    border: 1px solid rgba(138, 143, 153, 0.1);
}

.daguerreotype-frame svg {
    display: block;
    width: 100%;
    height: auto;
}

.daguerreotype-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(212, 148, 58, 0.15) 0%, transparent 50%);
    box-shadow: inset 0 0 80px rgba(15, 15, 20, 0.8);
    pointer-events: none;
}

/* Narrative Text */
.narrative-text {
    margin-bottom: 1.5rem;
    max-width: 65ch;
    color: #f0e6d3;
}

/* Hanko Seal */
.hanko-seal {
    display: inline-block;
    margin-top: 1.5rem;
    opacity: 0;
    transform: scale(1.5);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.hanko-seal.stamped {
    opacity: 1;
    transform: scale(1);
    animation: hankoPress 0.42s cubic-bezier(0.16, 1, 0.3, 1);
}

.hanko-seal svg {
    width: 48px;
    height: 48px;
}

/* === Intelligence Sidebar === */
#intelligence-sidebar {
    position: sticky;
    top: 15vh;
    height: calc(100vh - 15vh);
    overflow-y: auto;
    background: linear-gradient(180deg, #0f0f14 0%, #1e3a5f 100%);
    border-left: 1px solid rgba(138, 143, 153, 0.1);
    padding: 2rem 1.5rem;
    transform: translateX(60px);
    transition: transform 0.9s cubic-bezier(0.16, 1, 0.3, 1), border-left-color 0.5s ease;
}

#intelligence-sidebar.revealed {
    transform: translateX(0);
}

.sidebar-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(138, 143, 153, 0.1);
}

.sidebar-heading {
    font-family: 'Space Grotesk', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #d4943a;
    margin-bottom: 1rem;
}

.sidebar-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 0.8rem;
}

.meta-key {
    font-family: 'Space Grotesk', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8a8f99;
}

.meta-value {
    font-family: 'Space Grotesk', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    color: #f0e6d3;
    transition: color 0.4s ease;
}

/* Compass */
.compass-section {
    display: flex;
    justify-content: center;
}

#compass-rose {
    width: 120px;
    height: 120px;
    transition: transform 0.6s ease;
}

/* Dispatch List */
.dispatch-list {
    list-style: none;
}

.dispatch-item {
    font-family: 'Space Grotesk', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.78rem;
    color: #f0e6d3;
    padding: 6px 0;
    border-bottom: 1px solid rgba(138, 143, 153, 0.08);
    transition: padding-left 0.3s ease, color 0.3s ease;
    cursor: default;
}

.dispatch-item:hover {
    padding-left: 8px;
    color: #d4943a;
}

.source-item {
    font-family: 'Space Grotesk', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.75rem;
    color: #8a8f99;
    padding: 4px 0;
    border-left: 2px solid rgba(138, 143, 153, 0.15);
    padding-left: 10px;
    margin-bottom: 6px;
}

/* === Dispatch Footer === */
#dispatch-footer {
    position: relative;
    z-index: 1;
    padding: clamp(2rem, 4vw, 4rem) clamp(2rem, 5vw, 6rem);
    min-height: 20vh;
    background: linear-gradient(0deg, #0f0f14 0%, rgba(15, 15, 20, 0.98) 100%);
    border-top: 1px solid rgba(138, 143, 153, 0.1);
    transform: translateY(60px);
    opacity: 0;
    transition: transform 0.9s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.8s ease;
}

#dispatch-footer.revealed {
    transform: translateY(0);
    opacity: 1;
}

.footer-heading {
    font-family: 'Space Grotesk', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #d4943a;
    margin-bottom: 2rem;
}

.dispatch-cards {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.dispatch-card {
    position: relative;
    width: 280px;
    padding: 2rem 1.5rem;
    background: rgba(15, 15, 20, 0.8);
    border: 1px solid rgba(138, 143, 153, 0.15);
    clip-path: polygon(0 0, calc(100% - 30px) 0, 100% 30px, 100% 100%, 0 100%);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    transform: rotate(-1deg);
}

.dispatch-card:nth-child(2) {
    transform: rotate(0.5deg);
}

.dispatch-card:nth-child(3) {
    transform: rotate(-0.8deg);
}

.dispatch-card:hover {
    transform: rotate(0deg) translateY(-4px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.card-fold {
    position: absolute;
    top: 0;
    right: 0;
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, transparent 50%, rgba(138, 143, 153, 0.15) 50%);
}

.wax-seal {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: radial-gradient(circle, #c23b22 60%, #8b1a0e 100%);
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(194, 59, 34, 0.3);
    transition: transform 0.3s ease;
}

.dispatch-card:hover .wax-seal {
    transform: scale(1.15);
}

.card-title {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: 1.5rem;
    color: #f0e6d3;
    margin-bottom: 0.5rem;
}

.card-preview {
    font-family: 'Space Grotesk', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.78rem;
    color: #8a8f99;
    line-height: 1.5;
}

.card-detail {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
    opacity: 0;
}

.dispatch-card.opened .card-detail {
    max-height: 400px;
    opacity: 1;
    margin-top: 1rem;
}

@keyframes hankoPress {
    0% { transform: scale(1.6) rotate(-8deg); opacity: 0; }
    55% { transform: scale(0.92) rotate(1deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes amberPulse {
    0%, 100% { box-shadow: 0 0 0 rgba(212, 148, 58, 0); }
    50% { box-shadow: 0 0 18px rgba(212, 148, 58, 0.22); }
}

.card-detail p {
    font-size: 0.9rem;
    line-height: 1.75;
    color: #f0e6d3;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #0f0f14;
}

::-webkit-scrollbar-thumb {
    background: rgba(138, 143, 153, 0.3);
    border-radius: 3px;
}

/* === Responsive === */
@media (max-width: 900px) {
    #command-table {
        grid-template-columns: 1fr;
    }

    #intelligence-sidebar {
        position: relative;
        top: 0;
        height: auto;
        border-left: none;
        border-top: 1px solid rgba(138, 143, 153, 0.1);
    }

    #chronicle-strip {
        height: auto;
        min-height: 70px;
        max-height: 90px;
    }

    .chronicle-inner {
        overflow-x: auto;
        justify-content: flex-start;
        gap: 2rem;
        padding: 0.5rem 1rem;
    }

    .era-kanji {
        font-size: 1.1rem;
    }

    .era-label {
        font-size: 0.6rem;
    }

    .dispatch-cards {
        flex-direction: column;
    }

    .dispatch-card {
        width: 100%;
        max-width: 400px;
        transform: rotate(0deg);
    }
}
