/* ========================================
   Martial.Quest - Goblincore Archival Aesthetic
   ======================================== */

:root {
    --bg-parchment: #F5F0E6;
    --card-cream: #FFFDF7;
    --accent-burgundy: #8B1A1A;
    --accent-rust: #C4785A;
    --accent-gold: #B8960C;
    --text-primary: #2A2118;
    --text-secondary: #6B5E52;
    --shadow-burgundy: rgba(139, 26, 26, 0.12);
    --shadow-burgundy-dark: rgba(139, 26, 26, 0.2);
}

/* ========================================
   Base & Reset
   ======================================== */

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-parchment);
    color: var(--text-primary);
    font-family: "Source Serif 4", serif;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    line-height: 1.65;
    font-weight: 400;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' result='noise' /%3E%3C/filter%3E%3Crect width='100' height='100' fill='%23F5F0E6' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    overflow-x: hidden;
}

h1, h2, h3 {
    font-family: "Space Grotesk", sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

h2 {
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    margin-bottom: 2rem;
    text-transform: capitalize;
}

h3 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
}

p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* ========================================
   Navigation Cluster (Fixed Top-Left)
   ======================================== */

.nav-cluster {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    width: 140px;
    height: 140px;
    z-index: 1000;
    pointer-events: none;
}

.nav-card {
    position: absolute;
    width: 100px;
    padding: 1rem;
    background-color: var(--card-cream);
    border: 1px solid var(--text-secondary);
    border-radius: 2px;
    font-family: "Space Grotesk", sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-burgundy);
    text-align: center;
    transform: rotate(var(--card-rot, 0deg));
    box-shadow: 0 var(--card-shadow, 2px) 8px var(--shadow-burgundy);
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.nav-card:hover {
    transform: rotate(var(--card-rot, 0deg)) translateY(-2px);
    box-shadow: 0 6px 12px var(--shadow-burgundy-dark);
}

.nav-card:nth-child(1) {
    top: 0;
    left: 0;
}

.nav-card:nth-child(2) {
    top: 20px;
    left: 30px;
}

.nav-card:nth-child(3) {
    top: 40px;
    left: 10px;
}

/* ========================================
   Hero Section - The Desk
   ======================================== */

.hero {
    width: 100vw;
    height: 100vh;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 2rem;
    padding: 3rem;
    position: relative;
    overflow: hidden;
    align-content: center;
    justify-items: center;
}

.hero::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(139, 26, 26, 0.1) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: heroRipple 1.2s ease-out 0.8s forwards;
}

@keyframes heroRipple {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(4);
    }
}

.hero-card {
    animation: cardFadeIn 0.6s ease-out both;
    min-height: 160px;
}

.hero-card:nth-child(1) { animation-delay: 0ms; }
.hero-card:nth-child(2) { animation-delay: 150ms; }
.hero-card:nth-child(3) { animation-delay: 300ms; }
.hero-card:nth-child(4) { animation-delay: 450ms; }
.hero-card:nth-child(5) { animation-delay: 600ms; }

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   Card Styles (Base)
   ======================================== */

.card {
    background-color: var(--card-cream);
    border: 1px solid var(--text-secondary);
    border-radius: 1px;
    padding: 1.5rem;
    transform: rotate(var(--card-rot, 0deg));
    box-shadow: 0 var(--card-shadow, 2px) 8px var(--shadow-burgundy);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.card:hover {
    transform: rotate(var(--card-rot, 0deg)) translateY(-2px);
    box-shadow: 0 calc(var(--card-shadow, 2px) + 4px) 12px var(--shadow-burgundy-dark);
}

.card::after {
    content: '';
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(139, 26, 26, 0.1) 0%, transparent 70%);
    transform: scale(0);
    opacity: 0;
}

.card.rippling::after {
    animation: rippleEffect 0.35s ease-out;
}

@keyframes rippleEffect {
    from {
        transform: scale(0);
        opacity: 1;
    }
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.card-label {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-burgundy);
    margin-bottom: 0.5rem;
}

.card-title {
    font-family: "Space Grotesk", sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.card-text {
    font-family: "Source Serif 4", serif;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.card-date {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.85rem;
    color: var(--accent-burgundy);
    margin-bottom: 1rem;
}

.card-content {
    font-family: "Space Grotesk", sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-burgundy);
}

.card-viz {
    width: 100%;
    max-width: 150px;
    height: auto;
    margin: 1rem 0 0 0;
    display: block;
}

.card-stamp {
    width: 80px;
    height: 80px;
    margin: 1rem auto;
    display: block;
    opacity: 0.8;
}

.redacted-lines {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
}

.redacted-lines::before,
.redacted-lines::after {
    content: '';
    display: block;
    height: 8px;
    background: repeating-linear-gradient(
        90deg,
        var(--accent-burgundy) 0px,
        var(--accent-burgundy) 3px,
        transparent 3px,
        transparent 8px
    );
    border-radius: 1px;
}

.redacted-lines::before {
    width: 100%;
}

.redacted-lines::after {
    width: 85%;
}

.card-bars {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.3rem;
    height: 80px;
    align-items: flex-end;
}

.card-bars::before,
.card-bars::after,
.card-bars {
    background: linear-gradient(
        to top,
        var(--accent-burgundy),
        var(--accent-burgundy)
    ) bottom / calc(100% / 8 - 0.3rem) var(--bar-height, 40px) no-repeat;
    background-image:
        linear-gradient(to top, var(--accent-burgundy) 0%, var(--accent-burgundy) 100%),
        linear-gradient(to top, var(--accent-burgundy) 0%, var(--accent-burgundy) 100%),
        linear-gradient(to top, var(--accent-burgundy) 0%, var(--accent-burgundy) 100%),
        linear-gradient(to top, var(--accent-burgundy) 0%, var(--accent-burgundy) 100%),
        linear-gradient(to top, var(--accent-burgundy) 0%, var(--accent-burgundy) 100%),
        linear-gradient(to top, var(--accent-burgundy) 0%, var(--accent-burgundy) 100%),
        linear-gradient(to top, var(--accent-burgundy) 0%, var(--accent-burgundy) 100%),
        linear-gradient(to top, var(--accent-burgundy) 0%, var(--accent-burgundy) 100%);
    background-size: calc(100% / 8 - 0.3rem) 30px, calc(100% / 8 - 0.3rem) 45px, calc(100% / 8 - 0.3rem) 35px, calc(100% / 8 - 0.3rem) 50px, calc(100% / 8 - 0.3rem) 40px, calc(100% / 8 - 0.3rem) 48px, calc(100% / 8 - 0.3rem) 38px, calc(100% / 8 - 0.3rem) 42px;
    background-position: 0 100%, calc(100% / 8) 100%, calc(2 * 100% / 8) 100%, calc(3 * 100% / 8) 100%, calc(4 * 100% / 8) 100%, calc(5 * 100% / 8) 100%, calc(6 * 100% / 8) 100%, calc(7 * 100% / 8) 100%;
    background-repeat: no-repeat;
    opacity: 0.08;
    width: 100%;
    height: 80px;
}

/* ========================================
   Archive Section
   ======================================== */

.archive {
    padding: 4rem 3rem;
    min-height: 100vh;
}

.section-title {
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 2.5rem;
    text-transform: capitalize;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.card-grid .card {
    animation: cardBounceIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55) both;
}

.card-grid .card:nth-child(1) { animation-delay: 0ms; }
.card-grid .card:nth-child(2) { animation-delay: 50ms; }
.card-grid .card:nth-child(3) { animation-delay: 100ms; }
.card-grid .card:nth-child(4) { animation-delay: 150ms; }
.card-grid .card:nth-child(5) { animation-delay: 200ms; }
.card-grid .card:nth-child(6) { animation-delay: 250ms; }
.card-grid .card:nth-child(7) { animation-delay: 300ms; }
.card-grid .card:nth-child(8) { animation-delay: 350ms; }
.card-grid .card:nth-child(9) { animation-delay: 400ms; }
.card-grid .card:nth-child(10) { animation-delay: 450ms; }

@keyframes cardBounceIn {
    from {
        opacity: 0;
        transform: translateY(20px) rotate(var(--card-rot, 0deg));
    }
    to {
        opacity: 1;
        transform: translateY(0) rotate(var(--card-rot, 0deg));
    }
}

.card.wide {
    grid-column: span 2;
}

/* ========================================
   Timeline Section
   ======================================== */

.timeline {
    padding: 4rem 3rem;
    min-height: 100vh;
    background-color: var(--bg-parchment);
}

.timeline-svg {
    width: 100%;
    height: 200px;
    margin: 2rem 0;
    display: block;
}

.timeline-line {
    animation: timelineDraw 1.5s ease-out forwards;
}

@keyframes timelineDraw {
    from {
        stroke-dashoffset: 900;
    }
    to {
        stroke-dashoffset: 0;
    }
}

.timeline-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.timeline-card {
    background-color: var(--card-cream);
    border: 1px solid var(--text-secondary);
    border-radius: 1px;
    padding: 1.5rem;
    transform: rotate(var(--card-rot, 0deg));
    box-shadow: 0 4px 8px var(--shadow-burgundy);
    animation: cardBounceIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55) both;
}

.timeline-card:nth-child(1) { animation-delay: 100ms; }
.timeline-card:nth-child(2) { animation-delay: 150ms; }
.timeline-card:nth-child(3) { animation-delay: 200ms; }
.timeline-card:nth-child(4) { animation-delay: 250ms; }

/* ========================================
   Collection Section (Featured Cards)
   ======================================== */

.collection {
    padding: 4rem 3rem;
    min-height: 100vh;
    background-color: var(--bg-parchment);
}

.collection-cards {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    margin-bottom: 3rem;
}

.card.featured {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    padding: 2.5rem;
    min-height: 320px;
    animation: cardBounceIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55) both;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card.featured:nth-child(1) { animation-delay: 0ms; }
.card.featured:nth-child(2) { animation-delay: 100ms; }
.card.featured:nth-child(3) { animation-delay: 200ms; }

.card.featured .card-stamp,
.card.featured .card-viz {
    align-self: flex-end;
    margin-right: 1rem;
    margin-top: 1.5rem;
}

/* ========================================
   Final Card (끝)
   ======================================== */

.final-card {
    width: 200px;
    height: 200px;
    margin: 3rem auto;
    background-color: var(--card-cream);
    border: 1px solid var(--text-secondary);
    border-radius: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(var(--card-rot, 0deg));
    box-shadow: 0 8px 16px var(--shadow-burgundy);
    position: relative;
    animation: cardBounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) both;
    animation-delay: 300ms;
}

.final-card::after {
    content: '';
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(139, 26, 26, 0.2) 0%, transparent 70%);
    transform: scale(0);
    opacity: 0;
}

.final-card.rippling::after {
    animation: rippleEffect 0.4s ease-out;
    width: 200px;
    height: 200px;
    left: 0;
    top: 0;
}

.final-text {
    font-family: "Space Grotesk", sans-serif;
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: 0.05em;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
    .hero {
        padding: 2rem 1.5rem;
        gap: 1.5rem;
        height: auto;
        min-height: 100vh;
    }

    .archive,
    .timeline,
    .collection {
        padding: 2.5rem 1.5rem;
    }

    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 1.5rem;
    }

    .card.wide {
        grid-column: span 1;
    }

    .section-title {
        font-size: 1.8rem;
        margin-bottom: 1.5rem;
    }

    .card {
        padding: 1.2rem;
        min-height: 140px;
    }

    .card.featured {
        max-width: 100%;
        padding: 1.5rem;
    }

    .nav-cluster {
        width: 120px;
        height: 120px;
        top: 1rem;
        left: 1rem;
    }

    .nav-card {
        width: 90px;
        padding: 0.8rem;
        font-size: 0.8rem;
    }

    .final-text {
        font-size: 2.5rem;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 0.9rem;
    }

    .hero {
        padding: 1.5rem 1rem;
        gap: 1rem;
    }

    .archive,
    .timeline,
    .collection {
        padding: 1.5rem 1rem;
    }

    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

    .section-title {
        font-size: 1.4rem;
        margin-bottom: 1rem;
    }

    .card {
        padding: 1rem;
    }

    .card-viz {
        max-width: 120px;
    }

    .card-stamp {
        width: 60px;
        height: 60px;
    }

    .nav-cluster {
        width: 100px;
        height: 100px;
        top: 0.75rem;
        left: 0.75rem;
    }

    .nav-card {
        width: 80px;
        padding: 0.6rem;
        font-size: 0.7rem;
    }

    .final-card {
        width: 150px;
        height: 150px;
    }

    .final-text {
        font-size: 2rem;
    }

    .timeline-svg {
        height: 150px;
    }
}
