/* ===================================================
   munju.wiki — styles.css
   Deep-burgundy, grainy-textured, broken-grid wiki
   =================================================== */

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

:root {
    --wine-dark: #4A1028;
    --parchment-light: #F5EDE0;
    --grid-rule: #6A3048;
    --mixed-media-blue: #486898;
    --grain-warm: #C8A888;
    --highlight-gold: #D8B058;
    --entry-cream: #EDE4D4;

    --font-mono: 'JetBrains Mono', monospace;
    --font-serif: 'Source Serif 4', 'Georgia', serif;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: var(--wine-dark);
    color: var(--parchment-light);
    font-family: var(--font-serif);
    font-weight: 400;
    font-size: clamp(15px, 1vw, 17px);
    line-height: 1.85;
    overflow-x: hidden;
    position: relative;
}

/* --- SVG Filter (hidden) --- */
.grain-svg {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* --- Global Grain Overlay --- */
.grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.12;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    mix-blend-mode: multiply;
}

/* --- Grid Lines Background --- */
.grid-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 1s ease;
}

.grid-lines.visible {
    opacity: 1;
}

.grid-svg {
    width: 100%;
    height: 100%;
}

.grid-line {
    stroke: var(--grid-rule);
    stroke-width: 1;
    opacity: 0.25;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 1s ease;
}

.grid-lines.visible .grid-line {
    stroke-dashoffset: 0;
}

.grid-line-v {
    transition-delay: calc(var(--line-index, 0) * 60ms);
}

.grid-line-h {
    transition-delay: calc(var(--line-index, 0) * 60ms + 300ms);
}

/* --- Hero Section --- */
.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 600px;
    z-index: 10;
    overflow: hidden;
}

.hero-domain {
    position: absolute;
    left: 30%;
    top: 40%;
    transform: translate(-50%, -50%);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: clamp(28px, 4vw, 64px);
    letter-spacing: -0.02em;
    color: var(--parchment-light);
    opacity: 0;
    transition: opacity 600ms ease;
    white-space: nowrap;
}

.hero-domain.visible {
    opacity: 1;
}

.hero-hangul {
    position: absolute;
    left: 60%;
    top: 55%;
    transform: translate(-50%, -50%);
    font-family: var(--font-serif);
    font-weight: 600;
    font-style: italic;
    font-size: clamp(36px, 5vw, 80px);
    color: var(--highlight-gold);
    opacity: 0;
    transition: opacity 600ms ease;
}

.hero-hangul.visible {
    opacity: 1;
}

.hero-subtitle {
    position: absolute;
    left: 30%;
    top: calc(40% + clamp(40px, 5vw, 70px));
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 12px;
    color: var(--grain-warm);
    letter-spacing: 0.05em;
    opacity: 0;
    transition: opacity 600ms ease 1200ms;
    white-space: nowrap;
}

.hero-subtitle.visible {
    opacity: 0.8;
}

/* --- Wiki Content: Broken Grid --- */
.wiki-content {
    position: relative;
    z-index: 10;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 0;
}

/* --- Wiki Entry (base) --- */
.wiki-entry {
    position: relative;
    background-color: rgba(237, 228, 212, 0.05);
    border: 1px solid transparent;
    transition: border-color 400ms ease, border-width 400ms ease, transform 200ms ease, opacity 300ms ease;
    opacity: 0;
    transform: translateY(30px);
    padding: 0;
}

.wiki-entry.revealed {
    opacity: 0.7;
    transform: translateY(0);
}

.wiki-entry.in-focus {
    opacity: 1;
    border-color: var(--highlight-gold);
}

.wiki-entry:hover {
    transform: translateX(4px);
}

.wiki-entry.revealed:hover {
    transform: translateX(4px) translateY(0);
}

.entry-inner {
    padding: 32px 28px;
}

/* --- Broken grid placement --- */
.entry-1 {
    grid-column: 2 / 8;
    margin-top: -48px;
    margin-right: -24px;
    z-index: 12;
}

.entry-2 {
    grid-column: 4 / 11;
    margin-top: 32px;
    margin-left: -32px;
    z-index: 11;
}

.entry-3 {
    grid-column: 1 / 7;
    margin-top: -16px;
    margin-left: -48px;
    z-index: 13;
}

.entry-4 {
    grid-column: 5 / 12;
    margin-top: 48px;
    margin-right: -64px;
    z-index: 11;
}

.entry-5 {
    grid-column: 2 / 9;
    margin-top: -8px;
    margin-left: 16px;
    z-index: 12;
}

.entry-6 {
    grid-column: 3 / 10;
    margin-top: 64px;
    margin-left: -24px;
    margin-bottom: 96px;
    z-index: 11;
}

/* --- Entry Typography --- */
.entry-meta {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 12px;
    color: var(--grain-warm);
    letter-spacing: 0.02em;
}

.meta-category {
    text-transform: uppercase;
    color: var(--highlight-gold);
}

.entry-title {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: clamp(24px, 3vw, 48px);
    letter-spacing: -0.02em;
    color: var(--parchment-light);
    margin-bottom: 16px;
    line-height: 1.2;
}

.entry-body {
    font-family: var(--font-serif);
    font-weight: 400;
    font-size: clamp(15px, 1vw, 17px);
    line-height: 1.85;
    color: var(--entry-cream);
    margin-bottom: 16px;
}

.entry-quote {
    font-family: var(--font-serif);
    font-weight: 600;
    font-style: italic;
    font-size: clamp(18px, 2vw, 24px);
    line-height: 1.6;
    color: var(--highlight-gold);
    border-left: 2px solid var(--grid-rule);
    padding-left: 20px;
    margin: 24px 0;
    opacity: 0.9;
}

.entry-refs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 12px;
    color: var(--grain-warm);
}

.ref-link a,
.wiki-link {
    color: var(--mixed-media-blue);
    text-decoration: none;
    position: relative;
    transition: color 200ms ease;
}

.wiki-link::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 0;
    height: 1px;
    background-color: var(--mixed-media-blue);
    transition: width 300ms ease;
}

.wiki-link:hover::after {
    width: 100%;
}

.wiki-link:hover {
    color: var(--highlight-gold);
}

/* --- Sidebar Panels --- */
.sidebar-panel {
    position: sticky;
    top: 120px;
    z-index: 14;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 500ms ease, transform 500ms ease;
}

.sidebar-panel.revealed {
    opacity: 1;
    transform: translateX(0);
}

.panel-1 {
    grid-column: 9 / 13;
    margin-top: -200px;
}

.panel-2 {
    grid-column: 9 / 13;
    margin-top: 40px;
}

.panel-3 {
    grid-column: 10 / 13;
    margin-top: -80px;
    margin-bottom: 48px;
}

.panel-inner {
    padding: 20px;
    background-color: rgba(74, 16, 40, 0.85);
    border: 1px solid var(--grid-rule);
    position: relative;
}

.panel-decoration {
    width: 100%;
    height: 8px;
    background: linear-gradient(90deg, var(--grid-rule) 0%, transparent 40%, var(--highlight-gold) 80%, transparent 100%);
    margin-bottom: 16px;
    opacity: 0.6;
}

.panel-text {
    font-family: var(--font-serif);
    font-weight: 400;
    font-size: 14px;
    line-height: 1.7;
    color: var(--grain-warm);
    margin-bottom: 12px;
}

.panel-diagram {
    width: 100%;
    max-width: 160px;
    margin: 8px auto 0;
}

.panel-diagram svg {
    width: 100%;
    height: auto;
}

.panel-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(106, 48, 72, 0.5);
}

.stat-label {
    color: var(--grain-warm);
}

.stat-value {
    color: var(--highlight-gold);
    font-weight: 700;
}

/* --- Overlap Hover Effects --- */
.wiki-entry::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--wine-dark);
    opacity: 0.85;
    z-index: -1;
    transition: opacity 200ms ease;
}

.wiki-entry:hover::before {
    opacity: 0.95;
}

/* --- Footer --- */
.wiki-footer {
    position: relative;
    z-index: 10;
    padding: 64px 24px 48px;
    border-top: 1px solid var(--grid-rule);
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-brand {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 18px;
    color: var(--parchment-light);
    letter-spacing: -0.02em;
}

.footer-meta {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 12px;
    color: var(--grain-warm);
}

.footer-links {
    display: flex;
    gap: 24px;
    margin-top: 8px;
}

.footer-links .wiki-link {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 12px;
}

/* --- Selection --- */
::selection {
    background-color: var(--highlight-gold);
    color: var(--wine-dark);
}

/* --- Responsive Adjustments --- */
@media (max-width: 900px) {
    .wiki-content {
        display: flex;
        flex-direction: column;
        gap: 24px;
    }

    .wiki-entry {
        margin: 0 !important;
    }

    .entry-1,
    .entry-2,
    .entry-3,
    .entry-4,
    .entry-5,
    .entry-6 {
        grid-column: 1 / -1;
        margin-left: -12px !important;
        margin-right: -12px !important;
    }

    .sidebar-panel {
        position: relative;
        top: auto;
    }

    .panel-1,
    .panel-2,
    .panel-3 {
        grid-column: 1 / -1;
        margin: 0 !important;
    }

    .hero-domain {
        left: 50%;
        top: 35%;
        font-size: clamp(24px, 7vw, 48px);
    }

    .hero-hangul {
        left: 50%;
        top: 52%;
        font-size: clamp(32px, 10vw, 64px);
    }

    .hero-subtitle {
        left: 50%;
        top: calc(35% + 60px);
        font-size: 11px;
        white-space: normal;
        text-align: center;
        max-width: 80%;
    }
}

@media (max-width: 600px) {
    .entry-inner {
        padding: 20px 16px;
    }

    .entry-meta {
        flex-wrap: wrap;
        gap: 8px;
    }

    .entry-refs {
        flex-direction: column;
        gap: 8px;
    }

    .footer-links {
        flex-wrap: wrap;
        gap: 16px;
    }
}
