:root {
    --paper: #f4ecd8;
    --bar-wood: #1c110a;
    --espresso: #2c1810;
    --bourbon: #8b6c4a;
    --neon-amber: #e8a020;
    --burnt-match: #c4441c;
    --mahogany: #3d2b1f;
    --stain: #d4c4a0;
}

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

::selection {
    background: var(--neon-amber);
    color: var(--bar-wood);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Work Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.72;
    color: var(--espresso);
    background: var(--paper);
    overflow-x: hidden;
}

/* ========================================
   SKELETON LOADING
   ======================================== */
.skeleton-reveal {
    position: relative;
}
.skeleton-reveal::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #e8dcc8 25%, #f4ecd8 50%, #e8dcc8 75%);
    background-size: 200% 100%;
    animation: skeletonPulse 1.5s ease-in-out infinite, skeletonReveal 0.6s ease-out forwards;
    animation-delay: calc(var(--i, 0) * 120ms), calc(var(--i, 0) * 120ms + 400ms);
    z-index: 2;
    pointer-events: none;
}
.skeleton-reveal.revealed::before {
    clip-path: inset(0 0 0 100%);
}

@keyframes skeletonPulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@keyframes skeletonReveal {
    0% { clip-path: inset(0 0 0 0); }
    100% { clip-path: inset(0 0 0 100%); }
}

/* ========================================
   COASTER NAV
   ======================================== */
.coaster-nav {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 1000;
}
.coaster-button {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--mahogany);
    color: var(--neon-amber);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 3px 3px 0px var(--bar-wood);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    user-select: none;
}
.coaster-button:hover {
    transform: scale(1.05);
    box-shadow: 4px 4px 0px var(--bar-wood);
}
.coaster-menu {
    position: absolute;
    bottom: 70px;
    left: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.coaster-menu.open {
    opacity: 1;
    pointer-events: auto;
}
.coaster-link {
    display: block;
    font-family: 'Jost', sans-serif;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--paper);
    background: var(--espresso);
    padding: 8px 16px;
    text-decoration: none;
    box-shadow: 3px 3px 0px var(--mahogany);
    transform: rotate(var(--angle, 0deg)) translateX(0);
    transform-origin: left center;
    transition: transform 0.3s ease, background 0.2s ease;
    white-space: nowrap;
}
.coaster-menu.open .coaster-link {
    transform: rotate(calc(var(--angle, 0deg) * 0.03)) translateX(0);
}
.coaster-link:hover {
    background: var(--burnt-match);
}

/* ========================================
   SECTION COMMON
   ======================================== */
.section {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
}

.section-tear {
    width: 100%;
    height: 20px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 20'%3E%3Cpath d='M0,10 Q30,2 60,10 T120,8 T180,12 T240,7 T300,11 T360,9 T420,13 T480,6 T540,10 T600,8 T660,14 T720,7 T780,11 T840,9 T900,12 T960,6 T1020,10 T1080,8 T1140,13 T1200,10' fill='none' stroke='%23d4c4a0' stroke-width='2'/%3E%3C/svg%3E") repeat-x;
    margin: 0 auto;
    opacity: 0.6;
}

.section-heading {
    font-family: 'Jost', sans-serif;
    font-weight: 700;
    font-size: clamp(2.8rem, 7vw, 6rem);
    text-transform: uppercase;
    letter-spacing: -0.02em;
    color: var(--espresso);
    margin-left: 12%;
    margin-right: 20%;
    margin-bottom: 2rem;
}

/* ========================================
   COFFEE STAINS
   ======================================== */
.coffee-stain {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    z-index: 0;
}
.coffee-stain::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle, transparent 55%, rgba(139,108,74,0.12) 58%, rgba(139,108,74,0.08) 65%, transparent 68%);
}
.coffee-stain--1 {
    width: 180px;
    height: 180px;
    top: 15%;
    right: 10%;
    transform: rotate(15deg);
}
.coffee-stain--2 {
    width: 140px;
    height: 140px;
    top: 30%;
    left: 5%;
    transform: rotate(-20deg);
}
.coffee-stain--3 {
    width: 200px;
    height: 200px;
    bottom: 20%;
    right: 15%;
    transform: rotate(40deg);
}

/* ========================================
   HASH FRAGMENTS
   ======================================== */
.hash-fragment {
    position: absolute;
    font-family: 'Jost', sans-serif;
    font-weight: 300;
    font-size: 14px;
    color: var(--espresso);
    opacity: 0.08;
    pointer-events: none;
    z-index: 0;
}

/* ========================================
   BINARY RAIN
   ======================================== */
.binary-rain {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}
.binary-col {
    position: absolute;
    font-family: 'Jost', sans-serif;
    font-size: 8px;
    font-weight: 300;
    color: var(--neon-amber);
    opacity: 0.05;
    line-height: 1.2;
    animation: binaryFall 12s linear infinite;
    white-space: pre;
}
@keyframes binaryFall {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100vh); }
}

/* ========================================
   CIRCUIT TRACES
   ======================================== */
.section--gist::after,
.section--stack::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background:
        linear-gradient(90deg, transparent 49.5%, rgba(139,108,74,0.06) 49.5%, rgba(139,108,74,0.06) 50.5%, transparent 50.5%) 70% 0 / 200px 100%,
        linear-gradient(0deg, transparent 49.5%, rgba(139,108,74,0.06) 49.5%, rgba(139,108,74,0.06) 50.5%, transparent 50.5%) 0 40% / 100% 200px;
}

/* ========================================
   INTRO SECTION
   ======================================== */
.section--intro {
    background: var(--bar-wood);
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: radial-gradient(ellipse at 30% 20%, rgba(232,160,32,0.08) 0%, transparent 60%);
}
.intro-content {
    text-align: center;
    padding: 2rem;
    z-index: 1;
    max-width: 900px;
}
.intro-title {
    font-family: 'Jost', sans-serif;
    font-weight: 700;
    font-size: clamp(2.8rem, 7vw, 6rem);
    text-transform: uppercase;
    letter-spacing: -0.02em;
    color: var(--neon-amber);
    line-height: 1.05;
    margin-bottom: 1.5rem;
}
.intro-title.skeleton-reveal::before {
    background: linear-gradient(90deg, #2c1810 25%, #3d2b1f 50%, #2c1810 75%);
    background-size: 200% 100%;
}
.intro-subtitle {
    font-family: 'Work Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 2vw, 1.3rem);
    color: var(--bourbon);
    line-height: 1.7;
    max-width: 600px;
    margin: 0 auto;
}
.intro-subtitle.skeleton-reveal::before {
    background: linear-gradient(90deg, #2c1810 25%, #3d2b1f 50%, #2c1810 75%);
    background-size: 200% 100%;
}

/* ========================================
   THE GIST SECTION
   ======================================== */
.section--gist {
    background: var(--paper);
    padding: 6rem 0 8rem;
    background-image: radial-gradient(ellipse at 70% 50%, rgba(232,160,32,0.06) 0%, transparent 50%);
}
.gist-container {
    position: relative;
    margin-left: 12%;
    margin-right: 20%;
}

/* Napkin Cards (Plane 2) */
.napkin-card {
    position: relative;
    background: #fefcf5;
    padding: 2rem 2.5rem;
    margin-bottom: 3rem;
    box-shadow: 4px 4px 0px var(--espresso);
    transform: rotate(var(--rotation, 0deg));
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: grab;
    z-index: 2;
}
.napkin-card:hover {
    transform: rotate(calc(var(--rotation, 0deg) + 0.5deg));
    box-shadow: 6px 6px 0px var(--espresso);
}
.napkin-card p {
    margin-bottom: 0.8rem;
    color: var(--espresso);
}
.napkin-card p:last-of-type {
    margin-bottom: 0;
}
.napkin-card strong {
    font-weight: 600;
    color: var(--bar-wood);
}
.napkin-card em {
    font-style: italic;
    color: var(--burnt-match);
}
.napkin-card--1 { margin-left: 0; max-width: 520px; }
.napkin-card--2 { margin-left: 15%; max-width: 480px; }
.napkin-card--3 { margin-left: 5%; max-width: 340px; }

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

/* Annotations */
.annotation {
    position: absolute;
    font-family: 'Caveat', cursive;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    color: var(--burnt-match);
    transform: rotate(var(--rot, -1deg));
    white-space: nowrap;
    pointer-events: none;
}

/* ========================================
   THE STACK SECTION
   ======================================== */
.section--stack {
    background: var(--paper);
    padding: 6rem 0 8rem;
    background-image: radial-gradient(ellipse at 20% 80%, rgba(232,160,32,0.05) 0%, transparent 55%);
}
.stack-intro {
    font-family: 'Caveat', cursive;
    font-size: clamp(1rem, 2vw, 1.3rem);
    color: var(--bourbon);
    margin-left: 12%;
    margin-bottom: 3rem;
    transform: rotate(-1deg);
}
.stack-container {
    position: relative;
    margin-left: 12%;
    margin-right: 15%;
}
.stack-sheet {
    position: relative;
    background: #fefcf5;
    padding: 2.5rem 3rem;
    margin-bottom: 1rem;
    box-shadow: 4px 4px 0px var(--mahogany);
    transform: translateX(calc(var(--sheet) * 4px)) rotate(calc(var(--sheet) * 0.3deg - 0.6deg));
    transition: transform 0.5s ease, box-shadow 0.4s ease;
    z-index: calc(10 - var(--sheet));
    cursor: grab;
}
.stack-sheet:hover {
    transform: translateX(calc(var(--sheet) * 4px)) translateY(-8px) scale(1.01);
    box-shadow: 8px 12px 0px var(--mahogany);
    z-index: 20;
}
.stack-sheet h3 {
    font-family: 'Jost', sans-serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    text-transform: uppercase;
    letter-spacing: -0.01em;
    color: var(--espresso);
    margin-bottom: 0.5rem;
}
.stack-sheet p {
    color: var(--espresso);
    max-width: 600px;
}

/* ========================================
   THE CHAT SECTION
   ======================================== */
.section--chat {
    background: var(--bar-wood);
    min-height: auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-image: radial-gradient(ellipse at 50% 50%, rgba(232,160,32,0.06) 0%, transparent 60%);
}
.chat-intro {
    padding: 2rem 12%;
    flex-shrink: 0;
}
.chat-arrow {
    font-family: 'Caveat', cursive;
    font-size: 1.5rem;
    color: var(--neon-amber);
    animation: arrowBounce 2s ease-in-out infinite;
    display: inline-block;
}
@keyframes arrowBounce {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(12px); }
}
.chat-track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    flex: 1;
    align-items: center;
    gap: 2rem;
    padding: 0 10vw;
    -webkit-overflow-scrolling: touch;
}
.chat-track::-webkit-scrollbar {
    height: 4px;
}
.chat-track::-webkit-scrollbar-track {
    background: var(--bar-wood);
}
.chat-track::-webkit-scrollbar-thumb {
    background: var(--mahogany);
    border-radius: 2px;
}
.chat-exchange {
    flex: 0 0 auto;
    scroll-snap-align: center;
    min-width: 300px;
    max-width: 420px;
}
.chat-bubble {
    padding: 1.8rem 2rem;
    position: relative;
}
.chat-bubble--a {
    background: #fefcf5;
    color: var(--espresso);
    font-family: 'Jost', sans-serif;
    font-weight: 700;
    font-size: clamp(0.95rem, 1.5vw, 1.15rem);
    text-transform: uppercase;
    letter-spacing: -0.01em;
    transform: rotate(-1.2deg);
    box-shadow: 4px 4px 0px var(--mahogany);
}
.chat-bubble--b {
    background: transparent;
    border: 1.5px solid var(--bourbon);
    color: var(--stain);
    font-family: 'Caveat', cursive;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    transform: rotate(0.8deg);
}
.chat-bubble p {
    margin: 0;
}

/* ========================================
   LAST CALL SECTION
   ======================================== */
.section--lastcall {
    background: var(--bar-wood);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6rem 0;
    background-image: radial-gradient(ellipse at 60% 40%, rgba(232,160,32,0.06) 0%, transparent 50%);
}
.lastcall-content {
    margin-left: 12%;
    margin-right: 20%;
    z-index: 1;
    max-width: 650px;
}
.lastcall-text {
    font-family: 'Work Sans', sans-serif;
    font-weight: 400;
    color: var(--bourbon);
    margin-bottom: 1.5rem;
    line-height: 1.8;
}
.lastcall-text.skeleton-reveal::before {
    background: linear-gradient(90deg, #2c1810 25%, #3d2b1f 50%, #2c1810 75%);
    background-size: 200% 100%;
}

/* Matchbook */
.matchbook {
    display: inline-block;
    margin-top: 2rem;
    position: relative;
}
.matchbook-link {
    display: block;
    font-family: 'Jost', sans-serif;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--paper);
    background: var(--espresso);
    padding: 14px 28px;
    text-decoration: none;
    border-bottom: none;
    transition: background 0.2s ease;
}
.matchbook-link:hover {
    background: var(--mahogany);
}
.matchbook-strip {
    height: 6px;
    background: var(--burnt-match);
    width: 100%;
}
.matchbook.skeleton-reveal::before {
    background: linear-gradient(90deg, #2c1810 25%, #3d2b1f 50%, #2c1810 75%);
    background-size: 200% 100%;
}

/* ========================================
   LINKS
   ======================================== */
a {
    color: inherit;
    text-decoration: none;
    border-bottom: 2px solid var(--burnt-match);
    transition: border-bottom-width 0.2s ease;
}
a:hover {
    border-bottom-width: 4px;
}
.matchbook-link,
.coaster-link {
    border-bottom: none;
}
.coaster-link:hover {
    border-bottom: none;
}

/* ========================================
   CUSTOM CURSOR (bar-wood sections)
   ======================================== */
.section--intro,
.section--chat,
.section--lastcall {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Ccircle cx='8' cy='8' r='6' fill='%23e8a020' opacity='0.7'/%3E%3C/svg%3E") 8 8, auto;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .gist-container,
    .section-heading,
    .stack-intro,
    .stack-container,
    .lastcall-content {
        margin-left: 6%;
        margin-right: 6%;
    }
    .napkin-card--1,
    .napkin-card--2,
    .napkin-card--3 {
        margin-left: 0;
        max-width: 100%;
    }
    .chat-exchange {
        min-width: 260px;
    }
    .coaster-nav {
        bottom: 16px;
        left: 16px;
    }
    .coaster-button {
        width: 52px;
        height: 52px;
        font-size: 22px;
    }
}
