/* ========================================
   muhan.dev - Terminal Baroque
   A candlelit terminal in a mahogany library
   ======================================== */

/* CSS Custom Properties */
:root {
    --bg-primary: #1a0a0f;         /* Midnight Burgundy */
    --bg-secondary: #2d1118;       /* Claret Shadow */
    --bg-tertiary: #3f1a22;        /* Damask */
    --text-primary: #e8d5b7;       /* Candlelit Parchment */
    --text-secondary: #b89e7a;     /* Faded Manuscript */
    --accent-primary: #c9a84c;     /* Burnished Gold */
    --accent-secondary: #a88a3d;   /* Tarnished Gold */
    --terminal-green: #5a8a5a;     /* Phosphor Whisper */
    --error-red: #d4443b;          /* Ember Red */
    --margin-rule: #2a1520;        /* Burgundy-Gold margin rule */

    --font-display: 'Baloo 2', cursive;
    --font-body: 'Inconsolata', monospace;
    --font-accent: 'Cormorant Garamond', serif;

    --content-max-width: 680px;
    --station-gap: 200px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    font-weight: 400;
    letter-spacing: 0.01em;
    line-height: 1.75;
    overflow-x: hidden;
    position: relative;
}

/* Warm Vignette Overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(10,4,6,0.6) 100%);
    pointer-events: none;
    z-index: 1000;
}

/* Hairline decorative rules in margins */
.reading-room::before,
.reading-room::after {
    content: '';
    position: fixed;
    top: 0;
    height: 100%;
    width: 1px;
    background-color: #2a1520;
    opacity: 0.3;
    z-index: 1;
    pointer-events: none;
}

.reading-room::before {
    left: 15vw;
}

.reading-room::after {
    right: 15vw;
}

/* ========================================
   Candle Flicker Animation
   ======================================== */
@keyframes candleFlicker {
    0%   { opacity: 1; }
    15%  { opacity: 0.85; }
    30%  { opacity: 0.95; }
    45%  { opacity: 0.7; }
    60%  { opacity: 1; }
    75%  { opacity: 0.8; }
    85%  { opacity: 0.95; }
    100% { opacity: 1; }
}

/* ========================================
   Skeleton Shimmer Animation
   ======================================== */
@keyframes skeletonShimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* ========================================
   Typing Cursor Blink
   ======================================== */
@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ========================================
   Scroll Indicator Bounce
   ======================================== */
@keyframes scrollBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px); }
}

/* ========================================
   Smoke Drift
   ======================================== */
@keyframes smokeDrift {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(-30px) scale(1.05); }
}

/* ========================================
   Underline Draw
   ======================================== */
@keyframes underlineDraw {
    from { background-size: 0% 1px; }
    to { background-size: 100% 1px; }
}

/* ========================================
   The Threshold (Hero)
   ======================================== */
.threshold {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Position content at golden ratio */
.threshold-content {
    position: absolute;
    top: 61.8%;
    left: 38.2%;
    transform: translate(-50%, -50%);
}

/* Smoke/Haze Effect */
.threshold::after {
    content: '';
    position: absolute;
    top: 10%;
    left: 20%;
    width: 60%;
    height: 40%;
    background: radial-gradient(ellipse at center, rgba(63, 26, 34, 0.2) 0%, transparent 70%);
    filter: blur(40px);
    pointer-events: none;
    animation: smokeDrift 8s ease-in-out infinite alternate;
    z-index: 0;
}

.cursor-container {
    display: flex;
    align-items: center;
    position: relative;
    z-index: 1;
}

.site-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 3.5rem);
    letter-spacing: 0.02em;
    line-height: 1.3;
    color: var(--text-primary);
    white-space: nowrap;
}

.site-title .char-glow {
    display: inline-block;
    animation: none;
}

.cursor {
    display: inline-block;
    width: 2px;
    height: 28px;
    background-color: var(--accent-primary);
    animation: candleFlicker 3s infinite;
    margin-left: 2px;
    vertical-align: middle;
}

.cursor.hidden {
    display: none;
}

.subtitle {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    color: var(--text-primary);
    opacity: 0;
    margin-top: 0.5rem;
    position: relative;
    z-index: 1;
}

.subtitle.visible {
    opacity: 0.6;
}

.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-accent);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    color: var(--accent-secondary);
    opacity: 0;
    animation: scrollBounce 2s ease-in-out infinite;
    z-index: 1;
    transition: opacity 0.4s ease;
}

.scroll-indicator.visible {
    opacity: 1;
}

/* ========================================
   The Reading Room
   ======================================== */
.reading-room {
    max-width: var(--content-max-width);
    width: 55%;
    margin: 0 auto;
    padding: 0 1.5rem;
    padding-bottom: 120px; /* Space for fixed prompt */
    position: relative;
}

/* ========================================
   Content Stations
   ======================================== */
.content-station {
    margin-top: var(--station-gap);
    position: relative;
}

.content-station::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120%;
    height: 120%;
    background: radial-gradient(ellipse at center, rgba(63,26,34,0.3) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

/* Section Epigraphs */
.section-epigraph {
    display: block;
    font-family: var(--font-accent);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    color: var(--accent-secondary);
    opacity: 0.8;
    margin-bottom: 0.75rem;
    letter-spacing: 0.02em;
}

/* Section Headings */
.section-heading {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.02em;
    line-height: 1.3;
    color: var(--text-primary);
    margin-bottom: clamp(1.5rem, 4vh, 3rem);
}

/* Hairline Rules between sections */
.content-station + .content-station::after {
    content: '';
    position: absolute;
    top: calc(var(--station-gap) / -2);
    left: 30%;
    width: 40%;
    height: 1px;
    background-color: var(--accent-primary);
    opacity: 0.25;
}

/* ========================================
   Terminal Windows
   ======================================== */
.terminal-window {
    background-color: var(--bg-secondary);
    border-radius: 6px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
    margin-bottom: clamp(1.5rem, 4vh, 3rem);
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.terminal-window.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Skeleton state */
.terminal-window.skeleton .terminal-body {
    visibility: hidden;
}

.terminal-window.skeleton::after {
    content: '';
    display: block;
    height: 120px;
    background: linear-gradient(
        110deg,
        var(--bg-secondary) 30%,
        var(--bg-tertiary) 50%,
        var(--bg-secondary) 70%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s ease-in-out infinite;
}

.terminal-header {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid rgba(63, 26, 34, 0.4);
    transition: background-color 0.3s ease;
}

.terminal-window:hover .terminal-header {
    background-color: var(--bg-tertiary);
}

.terminal-dots {
    display: flex;
    gap: 6px;
    margin-right: 12px;
}

.terminal-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--accent-secondary);
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.terminal-window:hover .terminal-dot {
    opacity: 0.8;
}

.terminal-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    color: var(--text-primary);
}

.terminal-body {
    padding: 16px 18px;
}

.terminal-line {
    margin-bottom: 0.5rem;
}

.terminal-line.command {
    font-family: var(--font-body);
    font-weight: 700;
    color: var(--text-primary);
}

.terminal-line.output {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--text-primary);
    padding-left: 1rem;
}

.terminal-line.output::before {
    content: '';
}

.terminal-line .terminal-link {
    color: var(--accent-primary);
}

.terminal-line.meta {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--text-secondary);
    font-size: clamp(0.8rem, 1.4vw, 0.95rem);
    margin-top: 0.75rem;
    padding-left: 1rem;
}

.terminal-line.spacer {
    height: 0.75rem;
}

.terminal-link {
    color: var(--accent-primary);
    text-decoration: none;
    display: inline-block;
    padding-left: 1rem;
    margin-top: 0.5rem;
    background-image: linear-gradient(var(--accent-primary), var(--accent-primary));
    background-size: 0% 1px;
    background-repeat: no-repeat;
    background-position: left bottom;
    transition: background-size 0.3s ease;
}

.terminal-link:hover {
    background-size: 100% 1px;
}

/* ========================================
   Fixed Bottom Terminal Prompt
   ======================================== */
.terminal-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-primary);
    border-top: 1px solid rgba(168, 138, 61, 0.3);
    padding: 12px 20px;
    z-index: 999;
    font-family: var(--font-body);
    font-size: clamp(0.85rem, 1.5vw, 1rem);
}

.prompt-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.prompt-user {
    color: var(--text-secondary);
    font-weight: 400;
}

.prompt-host {
    color: var(--accent-primary);
    font-weight: 700;
}

.prompt-path {
    color: var(--terminal-green);
    font-weight: 400;
    margin-right: 0.5rem;
}

.prompt-commands {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
}

.prompt-cmd {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 400;
    padding: 2px 6px;
    transition: color 0.2s ease;
    cursor: pointer;
    background-image: linear-gradient(var(--accent-primary), var(--accent-primary));
    background-size: 0% 1px;
    background-repeat: no-repeat;
    background-position: left bottom;
}

.prompt-cmd:hover {
    color: var(--accent-primary);
    background-size: 100% 1px;
}

.prompt-cmd.processing {
    color: var(--terminal-green);
}

.prompt-separator {
    color: var(--text-secondary);
    opacity: 0.4;
    margin: 0 4px;
}

.prompt-cursor {
    display: inline-block;
    width: 8px;
    height: 16px;
    background-color: var(--accent-primary);
    animation: candleFlicker 3s infinite;
    margin-left: 6px;
    vertical-align: middle;
}

/* ========================================
   Reveal Animation Classes
   ======================================== */
.content-station .section-epigraph,
.content-station .section-heading {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.content-station.station-revealed .section-epigraph {
    opacity: 0.8;
    transform: translateY(0);
}

.content-station.station-revealed .section-heading {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.1s;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    .reading-room {
        width: 90%;
        padding: 0 1rem;
    }

    .threshold-content {
        left: 50%;
        top: 50%;
    }

    :root {
        --station-gap: 120px;
    }

    .reading-room::before,
    .reading-room::after {
        display: none;
    }

    /* Mobile prompt abbreviations */
    .prompt-cmd {
        font-size: 0;
    }

    .prompt-cmd::after {
        font-size: clamp(0.85rem, 1.5vw, 1rem);
    }

    .prompt-cmd[data-short="proj"]::after {
        content: 'proj';
    }

    .prompt-cmd[data-short="abt"]::after {
        content: 'abt';
    }

    .prompt-cmd[data-short="msg"]::after {
        content: 'msg';
    }
}

@media (max-width: 480px) {
    .terminal-body {
        padding: 12px 14px;
    }

    .threshold-content {
        left: 50%;
    }
}

/* ========================================
   Reduced Motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .cursor {
        animation: cursorBlink 1.5s step-end infinite;
    }

    .threshold::after {
        animation: none;
    }

    .scroll-indicator {
        animation: none;
    }

    .terminal-window {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .terminal-window.skeleton::after {
        animation: none;
    }

    .content-station .section-epigraph,
    .content-station .section-heading {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .content-station .section-epigraph {
        opacity: 0.8;
    }

    .prompt-cursor {
        animation: cursorBlink 1.5s step-end infinite;
    }

    .site-title .char-glow {
        animation: none;
    }
}
