/* ============================================
   daitoua.com - Sepia-Nostalgic Dark-Academia
   Historical Archive & Timeline
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --archive-dark: #2a1f14;
    --document: #f0e8d4;
    --ink: #2c2418;
    --sepia: #8a7a5a;
    --brass: #a08448;
    --highlight: #c4a860;
    --red-seal: #8b2c2c;
    --light-text: #d4c8b0;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Noto Serif', Georgia, serif;
    font-weight: 400;
    line-height: 1.8;
    color: var(--ink);
    background: var(--archive-dark);
    overflow-x: hidden;
}

/* --- Typewriter Text --- */
.typewriter {
    font-family: 'Courier Prime', 'Courier New', Courier, monospace;
    font-weight: 400;
    letter-spacing: 0.08em;
}

/* ============================================
   HERO SECTION
   ============================================ */
#hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--archive-dark);
    position: relative;
    padding: 40px 20px;
}

.hero-card {
    position: relative;
    width: 100%;
    max-width: 560px;
    background: var(--document);
    padding: 48px 40px 56px;
    box-shadow:
        0 2px 12px rgba(42, 31, 20, 0.4),
        0 0 0 1px rgba(138, 122, 90, 0.2),
        inset 0 0 60px rgba(138, 122, 90, 0.05);
    overflow: hidden;
}

/* Ruled lines on catalog card */
.hero-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: repeating-linear-gradient(
        transparent,
        transparent 27px,
        rgba(138, 122, 90, 0.08) 27px,
        rgba(138, 122, 90, 0.08) 28px
    );
    pointer-events: none;
    z-index: 0;
}

/* Worn-edge effect */
.hero-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    box-shadow:
        inset 0 0 30px rgba(160, 132, 72, 0.08),
        inset 0 0 80px rgba(42, 31, 20, 0.04);
    pointer-events: none;
    z-index: 0;
}

.hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

.hero-label {
    font-size: 0.7rem;
    color: var(--sepia);
    text-transform: uppercase;
    margin-bottom: 32px;
}

.hero-title {
    font-family: 'Noto Serif', Georgia, serif;
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw, 3.6rem);
    color: var(--ink);
    line-height: 1.2;
    margin-bottom: 8px;
}

.hero-title-sub {
    display: block;
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    font-weight: 400;
    color: var(--sepia);
    letter-spacing: 0.15em;
    margin-top: 8px;
}

.hero-period {
    font-size: 0.85rem;
    color: var(--brass);
    margin-bottom: 28px;
    margin-top: 16px;
}

.hero-description {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.9rem;
    color: var(--ink);
    line-height: 1.7;
    margin-bottom: 24px;
    opacity: 0.85;
}

.hero-ref {
    font-size: 0.65rem;
    color: var(--sepia);
    opacity: 0.6;
    text-transform: uppercase;
}

/* Scroll indicator */
.scroll-indicator {
    margin-top: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 0.5;
    animation: pulse-scroll 2.5s ease-in-out infinite;
}

.scroll-line {
    display: block;
    width: 2px;
    height: 40px;
    background: var(--sepia);
}

.scroll-text {
    font-size: 0.6rem;
    color: var(--light-text);
}

@keyframes pulse-scroll {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.7; }
}

/* ============================================
   TIMELINE SECTION
   ============================================ */
#timeline {
    background: var(--archive-dark);
    padding: 80px 20px 120px;
}

.timeline-container {
    position: relative;
    max-width: 960px;
    margin: 0 auto;
}

/* Timeline spine */
.timeline-container::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--sepia);
    transform: translateX(-50%);
}

/* --- Timeline Cards --- */
.timeline-card {
    position: relative;
    margin-bottom: 60px;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.timeline-card.in-view {
    opacity: 1;
    transform: translateY(0);
}

/* Left cards */
.card-left {
    margin-right: 52%;
    text-align: right;
}

/* Right cards */
.card-right {
    margin-left: 52%;
    text-align: left;
}

/* Timeline node */
.card-node {
    position: absolute;
    top: 28px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--sepia);
    background: var(--archive-dark);
    z-index: 2;
    transition: background 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

.card-left .card-node {
    right: -30px;
    transform: translateX(50%);
}

.card-right .card-node {
    left: -30px;
    transform: translateX(-50%);
}

.timeline-card.in-view .card-node {
    background: var(--brass);
    border-color: var(--highlight);
    box-shadow: 0 0 8px rgba(196, 168, 96, 0.4);
}

/* --- Catalog Card Styling --- */
.catalog-card {
    position: relative;
    background: var(--document);
    padding: 24px 32px;
    background-image: repeating-linear-gradient(
        transparent,
        transparent 27px,
        rgba(138, 122, 90, 0.08) 27px,
        rgba(138, 122, 90, 0.08) 28px
    );
    box-shadow:
        0 2px 8px rgba(42, 31, 20, 0.3),
        0 0 0 1px rgba(138, 122, 90, 0.15),
        inset 0 0 40px rgba(138, 122, 90, 0.03);
    overflow: hidden;
}

/* Worn edge for catalog cards */
.catalog-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    box-shadow:
        inset 0 0 20px rgba(160, 132, 72, 0.06),
        inset 0 0 60px rgba(42, 31, 20, 0.03);
    pointer-events: none;
}

.card-date {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--brass);
    margin-bottom: 12px;
    text-transform: uppercase;
}

.card-title {
    font-family: 'Noto Serif', Georgia, serif;
    font-weight: 700;
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    color: var(--ink);
    line-height: 1.3;
    margin-bottom: 16px;
}

.card-body {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--ink);
    line-height: 1.8;
    margin-bottom: 12px;
    text-align: left;
    opacity: 0.9;
}

.card-source {
    font-size: 0.7rem;
    color: var(--sepia);
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(138, 122, 90, 0.15);
    text-align: left;
}

/* --- Red Seal (朱印) --- */
.red-seal {
    position: absolute;
    top: 20px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--red-seal);
    color: var(--document);
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    box-shadow: 0 1px 4px rgba(139, 44, 44, 0.3);
}

.card-left .red-seal {
    right: 20px;
}

.card-right .red-seal {
    right: 20px;
}

/* ============================================
   SOURCE DRAWER
   ============================================ */
#source-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    transform: translateY(calc(100% - 36px));
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#source-drawer.open {
    transform: translateY(0);
}

.drawer-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 20px;
    background: var(--ink);
    border-top: 2px solid var(--sepia);
    cursor: pointer;
    user-select: none;
    transition: background 0.3s ease;
}

.drawer-tab:hover {
    background: #3a3228;
}

.drawer-tab-text {
    font-size: 0.65rem;
    color: var(--light-text);
    text-transform: uppercase;
}

.drawer-arrow {
    font-size: 0.6rem;
    color: var(--brass);
    transition: transform 0.4s ease;
}

#source-drawer.open .drawer-arrow {
    transform: rotate(180deg);
}

.drawer-content {
    background: var(--ink);
    max-height: 40vh;
    overflow-y: auto;
    border-top: 1px solid rgba(138, 122, 90, 0.15);
}

.drawer-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 32px 32px;
}

.drawer-title {
    font-family: 'Noto Serif', Georgia, serif;
    font-weight: 700;
    font-size: 1rem;
    color: var(--light-text);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(138, 122, 90, 0.2);
}

.source-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.source-entry {
    font-size: 0.7rem;
    color: var(--light-text);
    line-height: 1.6;
    margin-bottom: 10px;
    opacity: 0.8;
}

.source-entry em {
    color: var(--highlight);
    font-style: italic;
}

/* --- Drawer scrollbar styling --- */
.drawer-content::-webkit-scrollbar {
    width: 6px;
}

.drawer-content::-webkit-scrollbar-track {
    background: var(--archive-dark);
}

.drawer-content::-webkit-scrollbar-thumb {
    background: var(--sepia);
    border-radius: 3px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .timeline-container::before {
        left: 20px;
    }

    .card-left,
    .card-right {
        margin-left: 48px;
        margin-right: 0;
        text-align: left;
    }

    .card-left .card-node,
    .card-right .card-node {
        left: -28px;
        right: auto;
        transform: translateX(-50%);
    }

    .card-left .red-seal,
    .card-right .red-seal {
        right: 16px;
    }

    .source-columns {
        grid-template-columns: 1fr;
    }

    .hero-card {
        padding: 36px 28px 44px;
    }
}

@media (max-width: 480px) {
    .timeline-container::before {
        left: 12px;
    }

    .card-left,
    .card-right {
        margin-left: 32px;
    }

    .card-left .card-node,
    .card-right .card-node {
        left: -20px;
    }

    .catalog-card {
        padding: 20px 20px;
    }

    .drawer-inner {
        padding: 20px 16px 24px;
    }
}
