/* ============================================================
   mujun.study — Analog-Terminal Scholarship
   Palette: Burnt Sienna #c75b12, Smoked Paprika #8b3a0a,
   Charcoal Ink #1a1510, Aged Foolscap #fdf6ec,
   Walnut Shell #3d2b1a, Dusty Umber #7a6652,
   Faded Sepia #e8ddd0, Ember Orange #e87a20,
   Turmeric Wash #f5a623, Oxidized Black #2c1f14
   ============================================================ */

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

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

body {
    font-family: 'Lora', Georgia, serif;
    color: #3d2b1a;
    background: #fdf6ec;
    overflow-x: hidden;
    line-height: 1.72;
    letter-spacing: 0.005em;
    font-size: clamp(1rem, 1.6vw, 1.15rem);
}

/* --- Paper Vignette Background --- */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 30%, #fdf6ec 40%, #e8ddd0 100%);
    pointer-events: none;
    z-index: 0;
    opacity: 0.6;
}

/* ============================================================
   TERMINAL OVERLAY — Full-screen boot sequence
   ============================================================ */
.terminal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #1a1510;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    transition: opacity 0.3s ease;
}

.terminal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.terminal-screen {
    padding: 12vh 8vw;
    width: 100%;
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(1rem, 2vw, 1.4rem);
    letter-spacing: 0.04em;
    line-height: 1.8;
    color: #e87a20;
}

.terminal-output .line {
    white-space: pre-wrap;
    margin-bottom: 0.3em;
}

.terminal-output .line .prompt {
    color: #c75b12;
}

.terminal-cursor {
    display: inline-block;
    width: 0.6em;
    height: 1.1em;
    background: #e87a20;
    vertical-align: text-bottom;
    animation: cursorBlink 0.7s step-end infinite;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- Terminal Split Halves (crack animation) --- */
.terminal-split {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #1a1510;
    z-index: 999;
    pointer-events: none;
    opacity: 0;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.8s ease;
}

.terminal-split--top {
    clip-path: polygon(0 0, 100% 0, 0 100%);
}

.terminal-split--bottom {
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.terminal-split.active {
    opacity: 1;
}

.terminal-split.split-away.terminal-split--top {
    transform: translateY(-100vh);
}

.terminal-split.split-away.terminal-split--bottom {
    transform: translateY(100vh);
}

/* ============================================================
   TIMELINE SPINE — Fixed vertical rule
   ============================================================ */
.timeline-spine {
    position: fixed;
    top: 0;
    left: 8vw;
    width: 1px;
    height: 100vh;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.timeline-spine.visible {
    opacity: 1;
}

.timeline-line {
    width: 1px;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(199, 91, 18, 0) 0%,
        rgba(199, 91, 18, 0.4) 20%,
        rgba(199, 91, 18, 1) 45%,
        rgba(199, 91, 18, 1) 55%,
        rgba(199, 91, 18, 0.4) 80%,
        rgba(199, 91, 18, 0) 100%
    );
}

/* ============================================================
   TIMELINE ENTRIES
   ============================================================ */
.main-content {
    position: relative;
    z-index: 10;
    padding: clamp(6rem, 12vh, 10rem) 0;
    opacity: 0;
    transition: opacity 0.6s ease 0.2s;
}

.main-content.visible {
    opacity: 1;
}

.timeline-entry {
    position: relative;
    margin-left: 12vw;
    margin-right: 12vw;
    margin-bottom: clamp(4rem, 8vh, 8rem);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

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

/* --- Timeline Node (circle on the spine) --- */
.timeline-node {
    position: absolute;
    left: calc(-4vw - 4px);
    top: 2rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid #c75b12;
    background: transparent;
    z-index: 60;
    transition: background 0.4s ease, transform 0.3s ease;
    animation: nodePulse 3s ease-in-out infinite;
}

.timeline-node.filled {
    background: #c75b12;
}

@keyframes nodePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* --- Timeline Tick (connector from spine to entry) --- */
.timeline-tick {
    position: absolute;
    left: calc(-4vw + 4px);
    top: calc(2rem + 3px);
    width: calc(4vw - 4px);
    height: 1px;
    background: #2c1f14;
    opacity: 0.2;
    transition: opacity 0.4s ease;
}

.timeline-entry.in-view .timeline-tick {
    opacity: 1;
}

/* --- Timestamp Label --- */
.timestamp {
    position: absolute;
    left: calc(-4vw - 100px);
    top: 1.5rem;
    width: 90px;
    text-align: right;
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    font-weight: 400;
    color: #7a6652;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* ============================================================
   ENTRY CARDS — Graph paper style
   ============================================================ */
.entry-card {
    position: relative;
    background-color: #fdf6ec;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 23px,
            #e8ddd0 23px,
            #e8ddd0 24px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 23px,
            #e8ddd0 23px,
            #e8ddd0 24px
        ),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 95px,
            #d4c8b8 95px,
            #d4c8b8 96px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 95px,
            #d4c8b8 95px,
            #d4c8b8 96px
        );
    background-size: 24px 24px, 24px 24px, 96px 96px, 96px 96px;
    padding: clamp(2rem, 4vw, 3.5rem);
    box-shadow: 4px 4px 0 rgba(120, 70, 20, 0.08);
    clip-path: polygon(
        0% 3px, 4% 0%, 8% 2px, 13% 1px, 18% 3px, 23% 0%, 28% 2px,
        33% 1px, 38% 3px, 43% 0%, 48% 2px, 53% 1px, 58% 4px, 63% 0%,
        68% 2px, 73% 1px, 78% 3px, 83% 0%, 88% 2px, 93% 1px, 98% 3px, 100% 0%,
        100% calc(100% - 3px), 97% 100%, 93% calc(100% - 2px), 88% calc(100% - 1px),
        83% calc(100% - 3px), 78% 100%, 73% calc(100% - 2px), 68% calc(100% - 1px),
        63% calc(100% - 4px), 58% 100%, 53% calc(100% - 2px), 48% calc(100% - 1px),
        43% calc(100% - 3px), 38% 100%, 33% calc(100% - 2px), 28% calc(100% - 1px),
        23% calc(100% - 3px), 18% 100%, 13% calc(100% - 2px), 8% calc(100% - 1px),
        4% calc(100% - 3px), 0% 100%
    );
}

.entry-card--no-tear {
    clip-path: none;
    border-radius: 2px;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

/* Handwritten Titles — Caveat */
.handwritten-title {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.3;
    color: #3d2b1a;
    margin-bottom: 1rem;
    transform: rotate(-1deg);
    position: relative;
}

h1.handwritten-title {
    font-size: clamp(2.2rem, 5vw, 4.2rem);
    margin-bottom: 0.5rem;
}

h2.handwritten-title {
    font-size: clamp(1.5rem, 3vw, 2.6rem);
}

h3.handwritten-title {
    font-size: clamp(1.2rem, 2.2vw, 1.8rem);
}

/* Heading Reveal Animation */
.heading-reveal {
    background: linear-gradient(90deg, transparent 50%, #fdf6ec 50%);
    background-size: 200% 100%;
    background-position: 100% 0;
    -webkit-background-clip: text;
    background-clip: text;
    transition: background-position 0.6s ease;
}

.heading-reveal.revealed {
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
}

/* Monospace Labels — IBM Plex Mono */
.mono-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.85rem, 1.4vw, 1rem);
    font-weight: 400;
    letter-spacing: 0.04em;
    color: #7a6652;
}

.mono-accent {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.85rem, 1.4vw, 1rem);
    letter-spacing: 0.04em;
}

/* Body Text — Lora */
.entry-body {
    margin-bottom: 1.2rem;
    max-width: 65ch;
}

.entry-body em {
    font-style: italic;
    color: #8b3a0a;
}

.entry-subtitle {
    margin-bottom: 1.5rem;
    color: #7a6652;
}

/* ============================================================
   COUNTER-ANIMATE NUMBERS
   ============================================================ */
.counter-number {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    color: #f5a623;
    font-size: 1.2em;
    display: inline;
    text-shadow: 0 0 8px rgba(245, 166, 35, 0.3);
    transition: text-shadow 0.4s ease;
}

.counter-number.counted {
    text-shadow: none;
}

/* ============================================================
   TERMINAL INLINE (final entry)
   ============================================================ */
.terminal-inline {
    margin-top: 1.5rem;
    padding: 1.5rem 2rem;
    background: #1a1510;
    color: #e87a20;
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.85rem, 1.4vw, 1rem);
    letter-spacing: 0.04em;
    line-height: 2;
    border-radius: 3px;
}

.terminal-inline .prompt-char {
    color: #c75b12;
}

.terminal-inline .terminal-text {
    color: #e87a20;
}

.blink-cursor {
    animation: cursorBlink 0.7s step-end infinite;
    color: #e87a20;
}

/* ============================================================
   ISOMETRIC ICONS
   ============================================================ */
.icon-container {
    width: clamp(80px, 12vw, 130px);
    margin: 0.5rem 0;
}

.icon-float-right {
    float: right;
    margin-left: 1.5rem;
    margin-bottom: 0.5rem;
}

.icon-float-left {
    float: left;
    margin-right: 1.5rem;
    margin-bottom: 0.5rem;
}

.iso-icon {
    width: 100%;
    height: auto;
    opacity: 0;
    transform: translate3d(-20px, 20px, 0) scale(0.8);
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.iso-icon.icon-visible {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
}

.iso-icon path,
.iso-icon line,
.iso-icon rect,
.iso-icon ellipse,
.iso-icon circle:not(.sand-particle) {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 0.8s ease 0.2s;
}

.iso-icon.icon-visible path,
.iso-icon.icon-visible line,
.iso-icon.icon-visible rect,
.iso-icon.icon-visible ellipse,
.iso-icon.icon-visible circle:not(.sand-particle) {
    stroke-dashoffset: 0;
}

/* ============================================================
   DECORATIVE MOTIFS
   ============================================================ */

/* Washi Tape Strips */
.washi-tape {
    position: absolute;
    width: 48px;
    height: 12px;
    opacity: 0.6;
    z-index: 5;
    border-radius: 1px;
}

.washi-tape--left {
    top: 8px;
    left: 12px;
    background: rgba(245, 166, 35, 0.2);
    transform: rotate(-3deg);
}

.washi-tape--right {
    top: 8px;
    right: 12px;
    background: rgba(199, 91, 18, 0.15);
    transform: rotate(4deg);
}

/* Coffee Ring Stains */
.coffee-ring {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 2;
}

.coffee-ring--1 {
    width: 80px;
    height: 75px;
    top: 20%;
    right: 8%;
    background: radial-gradient(ellipse, transparent 55%, rgba(139, 58, 10, 0.04) 65%, transparent 75%);
    transform: rotate(15deg);
}

.coffee-ring--2 {
    width: 65px;
    height: 60px;
    bottom: 15%;
    left: 5%;
    background: radial-gradient(ellipse, transparent 50%, rgba(139, 58, 10, 0.035) 60%, transparent 72%);
    transform: rotate(-20deg);
}

.coffee-ring--3 {
    width: 90px;
    height: 85px;
    top: 10%;
    left: 60%;
    background: radial-gradient(ellipse, transparent 55%, rgba(139, 58, 10, 0.03) 65%, transparent 75%);
    transform: rotate(35deg);
}

/* Ink Splatters */
.ink-splatter {
    position: absolute;
    pointer-events: none;
    z-index: 2;
}

.ink-splatter--1::before,
.ink-splatter--1::after,
.ink-splatter--2::before,
.ink-splatter--2::after,
.ink-splatter--3::before,
.ink-splatter--3::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(44, 31, 20, 0.08);
}

.ink-splatter--1 {
    top: 2rem;
    left: 2rem;
}
.ink-splatter--1::before {
    width: 4px;
    height: 4px;
    top: 0;
    left: 0;
}
.ink-splatter--1::after {
    width: 3px;
    height: 3px;
    top: 6px;
    left: 8px;
}

.ink-splatter--2 {
    top: 3rem;
    right: 4rem;
}
.ink-splatter--2::before {
    width: 5px;
    height: 5px;
    top: 0;
    left: 0;
}
.ink-splatter--2::after {
    width: 3px;
    height: 3px;
    top: -4px;
    left: 10px;
}

.ink-splatter--3 {
    bottom: 3rem;
    left: 6rem;
}
.ink-splatter--3::before {
    width: 4px;
    height: 4px;
    top: 0;
    left: 0;
}
.ink-splatter--3::after {
    width: 6px;
    height: 5px;
    top: 4px;
    left: -6px;
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    background: #2c1f14;
    padding: 2.5rem 8vw;
    position: relative;
    z-index: 10;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    color: #7a6652;
    letter-spacing: 0.04em;
}

.footer-kanji {
    font-size: clamp(1.8rem, 3vw, 2.4rem);
    color: #c75b12;
    opacity: 0.6;
    font-weight: 400;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .timeline-spine {
        left: 4vw;
    }

    .timeline-entry {
        margin-left: 10vw;
        margin-right: 4vw;
    }

    .timeline-node {
        left: calc(-6vw - 4px);
    }

    .timeline-tick {
        left: calc(-6vw + 4px);
        width: calc(6vw - 4px);
    }

    .timestamp {
        position: relative;
        left: 0;
        top: 0;
        text-align: left;
        margin-bottom: 0.5rem;
        display: block;
        width: auto;
    }

    .icon-float-right,
    .icon-float-left {
        float: none;
        margin: 1rem auto;
        display: block;
    }

    .icon-container {
        width: 100px;
    }

    .entry-card {
        padding: clamp(1.5rem, 3vw, 2.5rem);
    }

    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .timeline-spine {
        display: none;
    }

    .timeline-entry {
        margin-left: 4vw;
        margin-right: 4vw;
    }

    .timeline-node,
    .timeline-tick {
        display: none;
    }

    .terminal-screen {
        padding: 8vh 6vw;
        font-size: clamp(0.8rem, 3.5vw, 1rem);
    }
}
