/* ==========================================================================
   CSS Variables & Foundations
   ========================================================================== */
:root {
    /* Color Palette */
    --color-bg: #111111;
    --color-interior: #0a0a0a;
    --color-text-main: #e0e0e0;
    --color-text-muted: #888888;
    
    /* Folder Colors */
    --folder-blue: #2D7DD2;
    --folder-green: #45B649;
    --folder-red: #E63946;
    --folder-purple: #7B2D8E;
    --folder-cream: #F1FAEE;
    --folder-orange: #F4A261;
    
    /* Typography */
    --font-display: 'Anton', sans-serif;
    --font-serif: 'Playfair Display', serif;
    --font-sans: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    /* Layout & Geometry */
    --tab-width: clamp(200px, 30vw, 350px);
    --tab-height: 48px;
    --folder-border: 1px solid rgba(255, 255, 255, 0.15);
    --border-radius: 6px;
    --extracted-border-width: 40px;
    
    /* Animation Timings */
    --transition-fast: 0.2s ease;
    --transition-slow: 0.8s cubic-bezier(0.85, 0, 0.15, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}


html, body {
    width: 100%;
    min-height: 100vh;
    background-color: var(--color-bg);
    color: var(--color-text-main);
    font-family: var(--font-sans);
    overflow-x: hidden;
}

body.folder-open {
    overflow: hidden; /* Prevent scrolling when a folder is full screen */
}

/* ==========================================================================
   Noise Texture
   ========================================================================== */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03; /* Extremely fine noise */
    mix-blend-mode: screen;
}

/* ==========================================================================
   Typography & Masthead
   ========================================================================== */
.masthead {
    padding: 2rem 5%;
    border-bottom: 1px solid #222;
    margin-bottom: 2rem;
    position: relative;
    z-index: 10;
}

.masthead-title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 10vw, 8rem);
    line-height: 1;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    color: #ffffff;
    margin-bottom: 0.5rem;
}

.acca-dot {
    display: inline-block;
    width: 0.22em;
    height: 0.22em;
    background-color: #ff1f6d;
    border-radius: 50%;
    margin-left: 0.08em;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none;
    vertical-align: baseline;
}

.acca-dot:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 15px rgba(255, 31, 109, 0.6);
}

.masthead-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-text-muted);
    letter-spacing: 0.05em;
}

/* ==========================================================================
   Folder Stack Geometry
   ========================================================================== */
.archive-stack {
    position: relative;
    width: 90%;
    max-width: 1200px;
    margin: 0 auto 4rem auto;
    display: flex;
    flex-direction: column;
    gap: 15vh; /* Creates the overlapping stacked look vertically */
    padding-bottom: 20vh;
}

.folder {
    position: relative;
    width: 100%;
    /* Ensure folders establish a containing block for their content */
}

/* Specific Folder Colors */
.folder--blue { --folder-accent: var(--folder-blue); }
.folder--green { --folder-accent: var(--folder-green); }
.folder--red { --folder-accent: var(--folder-red); }
.folder--purple { --folder-accent: var(--folder-purple); }
.folder--orange { --folder-accent: var(--folder-orange); }

/* The clickable tab */
.folder-tab {
    appearance: none;
    background: var(--folder-accent);
    border: none;
    text-decoration: none;
    height: var(--tab-height);
    width: var(--tab-width);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    cursor: pointer;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    position: relative;
    z-index: 2;
    /* Stagger tabs horizontally based on folder index using inline calc in JS, or defaults here */
    transform-origin: bottom left;
}

.folder[data-index="0"] .folder-tab { margin-left: 0%; }
.folder[data-index="1"] .folder-tab { margin-left: 15%; }
.folder[data-index="2"] .folder-tab { margin-left: 30%; }
.folder[data-index="3"] .folder-tab { margin-left: 45%; }

/* Tab Typography */
.tab-number {
    font-family: var(--font-mono);
    font-weight: 700;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
}

.tab-label {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    color: #ffffff;
    white-space: nowrap;
}

/* Tab Hover (Lift effect) */
.folder:not(.folder--active):not(.folder--hidden) .folder-tab:hover {
    transform: translateY(-6px);
    box-shadow: 0 -10px 20px rgba(0, 0, 0, 0.3), 0 0 15px var(--folder-accent);
}

/* The hidden content wrapper */
.folder-content {
    display: none;
    position: absolute;
    top: var(--tab-height);
    left: 0;
    width: 100%;
    height: 100%; /* Will be manipulated by GSAP during active state */
    background: var(--folder-accent);
    z-index: 1;
}

/* ==========================================================================
   Active / Extraction State (Driven by GSAP FLIP)
   ========================================================================== */
.folder--active {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 100 !important;
    margin: 0 !important;
    padding: var(--extracted-border-width) !important;
    background: var(--color-interior) !important; /* The black interior */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* In active state, the background is the border */
.folder--active::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--folder-accent);
    z-index: -1;
}
.folder--active::after {
    content: '';
    position: absolute;
    top: var(--extracted-border-width); 
    left: var(--extracted-border-width); 
    right: var(--extracted-border-width); 
    bottom: var(--extracted-border-width);
    background: var(--color-interior);
    z-index: -1;
}

/* Rotate tab to act as a spine */
.folder--active .folder-tab {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%) rotate(90deg) !important;
    transform-origin: center center;
    margin: 0;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    pointer-events: none; /* Disable click when open */
}

/* Reveal content interior */
.folder--active .folder-content {
    display: block;
    position: static;
    width: 100%;
    height: 100%;
    background: transparent;
    overflow-y: auto;
    /* Custom scrollbar for interior */
    scrollbar-width: thin;
    scrollbar-color: var(--folder-accent) var(--color-interior);
}

/* Hide other folders */
.folder--hidden {
    opacity: 0;
    pointer-events: none;
    /* GSAP will animate translateY */
}

/* ==========================================================================
   Content Interior Details
   ========================================================================== */
.content-interior {
    max-width: 800px;
    margin: 0 auto;
    padding: 4rem 2rem;
    opacity: 0; /* Handled by GSAP entrance */
}

.section-title {
    font-family: var(--font-serif);
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    line-height: 1.1;
    color: #fff;
    margin-bottom: 2rem;
}

.data-callout {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--folder-accent);
    border-left: 2px solid var(--folder-accent);
    padding-left: 1rem;
    margin-bottom: 3rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.prose {
    font-size: 1.125rem;
    line-height: 1.7;
    color: #cccccc;
    max-width: 65ch;
}

.prose p {
    margin-bottom: 1.5rem;
}

/* Close Button */
.close-btn {
    position: absolute;
    top: 1.5rem;
    right: 2rem;
    appearance: none;
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    cursor: pointer;
    letter-spacing: 0.1em;
    padding: 0.5rem;
    transition: color var(--transition-fast);
    z-index: 10;
    opacity: 0; /* Handled by GSAP */
}

.close-btn:hover {
    color: #fff;
}

/* ==========================================================================
   Send a Note Form
   ========================================================================== */
.note-form-container {
    margin-top: 3rem;
    position: relative;
    max-width: 400px;
    perspective: 1000px; /* For 3D folding effect */
}

.note-form {
    background: #fdfbf7; /* Off-white paper color */
    color: #111;
    padding: 1.5rem;
    border-radius: 2px;
    box-shadow: 2px 4px 10px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

/* When the folding animation triggers */
.note-form.is-folding {
    transform: scale(0) rotate(15deg);
    opacity: 0;
}

#anon-message {
    background: transparent;
    border: none;
    border-bottom: 1px solid #ccc;
    color: #111;
    font-family: var(--font-serif);
    font-size: 1.1rem;
    line-height: 1.6;
    resize: none;
    min-height: 100px;
    outline: none;
}

#anon-message::placeholder {
    color: #999;
}

#anon-submit {
    align-self: flex-end;
    background: transparent;
    border: 1px solid #111;
    color: #111;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

#anon-submit:hover {
    background: #111;
    color: #fff;
}

#anon-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Paper Plane Animation */
#paper-plane {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    color: #fdfbf7;
    pointer-events: none;
    z-index: 10;
}

#paper-plane.is-flying {
    animation: flyAway 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes flyAway {
    0% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 1;
    }
    20% {
        transform: translate(-30%, -30%) scale(1.2) rotate(15deg);
        opacity: 1;
    }
    100% {
        /* Fly to top left corner off-screen */
        transform: translate(-100vw, -100vh) scale(0.5) rotate(-45deg);
        opacity: 0;
    }
}

.note-success {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    color: var(--folder-purple);
    padding: 2rem 0;
}

/* ==========================================================================
   Footer & Social Icons
   ========================================================================== */
.site-footer {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    right: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-text-muted);
    pointer-events: none; /* Let clicks pass through empty space */
}

.site-footer span {
    letter-spacing: 0.05em;
}

.footer-links {
    pointer-events: auto; /* Re-enable clicks for links */
}

.social-icons {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.social-icon {
    color: var(--color-text-muted);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.social-icon:hover {
    color: #fff;
    transform: translateY(-3px);
}

.social-icon svg {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */
.toast {
    position: fixed;
    bottom: 4rem; /* Above the footer */
    left: 50%;
    transform: translateX(-50%);
    background: #111;
    color: var(--folder-purple);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 0.75rem 1.5rem;
    border: 1px solid rgba(123, 45, 142, 0.5);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.toast.show {
    opacity: 1;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 768px) {
    :root {
        --extracted-border-width: 20px;
    }
    
    .archive-stack {
        gap: 5vh;
        padding-bottom: 10vh;
    }
    
    /* Remove horizontal stagger on mobile */
    .folder[data-index] .folder-tab { margin-left: 0%; width: 90%; max-width: none; }
    
    .folder--active .folder-tab {
        /* On small screens, hide spine or keep it smaller */
        display: none;
    }
    
    .close-btn {
        top: 1rem;
        right: 1rem;
    }
}

/* Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}


/* ==========================================================================
   Interactive Rope & Peel Overlay
   ========================================================================== */
.rope-anchor {
    position: fixed;
    top: 0;
    right: 0;
    width: 200px;
    height: 100vh;
    z-index: 900;
    pointer-events: none;
    overflow: visible;
}

.rope-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}

.rope-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 56px;
    height: 56px;
    background: var(--folder-orange);
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 50%;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: bold;
    letter-spacing: 0.05em;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4), inset 0 -2px 4px rgba(0,0,0,0.1);
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
    will-change: transform;
    /* JS positions this via transform: translate(x, y) */
}

.rope-handle:hover {
    box-shadow: 0 6px 20px rgba(244,162,97,0.5), inset 0 -2px 4px rgba(0,0,0,0.1);
}

.rope-handle.grabbing {
    cursor: grabbing;
}

.rope-hit-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.peel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #F4EFE6;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.025' numOctaves='4' result='n'/%3E%3CfeDiffuseLighting in='n' lighting-color='%23fff' surfaceScale='1.2'%3E%3CfeDistantLight azimuth='60' elevation='50'/%3E%3C/feDiffuseLighting%3E%3CfeBlend mode='multiply' in2='SourceGraphic'/%3E%3C/filter%3E%3Crect width='256' height='256' fill='%23F4EFE6' filter='url(%23p)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    z-index: 999;
    clip-path: circle(0% at 95% 0%);
    visibility: hidden;
    pointer-events: none;
    will-change: clip-path;
}

.blog-construction {
    background-color: #F4EFE6;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.025' numOctaves='4' result='n'/%3E%3CfeDiffuseLighting in='n' lighting-color='%23fff' surfaceScale='1.2'%3E%3CfeDistantLight azimuth='60' elevation='50'/%3E%3C/feDiffuseLighting%3E%3CfeBlend mode='multiply' in2='SourceGraphic'/%3E%3C/filter%3E%3Crect width='256' height='256' fill='%23F4EFE6' filter='url(%23p)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    overflow: hidden;
    position: relative;
    width: 100vw;
    height: 100vh;
    margin: 0;
    color: #111;
}

/* Horizontal Infinite Scroll */
.horizontal-viewport {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden; /* Hide horizontal overflow, JS will translate the track */
    z-index: 1; /* Below the tape container */
    pointer-events: none; /* Let clicks pass through to underlying elements */
}

.horizontal-track {
    display: flex;
    height: 100vh;
    width: max-content;
    align-items: center;
    padding-left: 200px; /* Initial offset */
    pointer-events: auto; /* Enable interaction for scrolling */
}

.blog-placeholder {
    width: 600px;
    height: 60vh;
    margin-right: 150px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.blog-placeholder h2 {
    font-family: var(--font-mono);
    font-size: 3rem;
    margin-bottom: 20px;
    opacity: 0.3;
}

.wireframe-box {
    width: 100%;
    flex-grow: 1;
    border: 2px dashed rgba(0,0,0,0.2);
    border-radius: 10px;
}

.tape-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 5; /* Tapes overlay the scrolling content */
    pointer-events: none; /* Let clicks pass through to scroll track */
}

.tape {
    /* Hazard stripes + glossy gold gradient */
    background: 
        repeating-linear-gradient(
            -45deg,
            rgba(0,0,0,0.06),
            rgba(0,0,0,0.06) 20px,
            transparent 20px,
            transparent 40px
        ),
        linear-gradient(to bottom, rgba(255, 230, 0, 0.85) 0%, rgba(245, 200, 0, 0.9) 100%);
    mix-blend-mode: multiply; /* Adheres to the paper texture */
    color: rgba(15, 15, 15, 0.85); /* Slightly faded ink */
    font-weight: 800;
    font-size: 2.5rem;
    padding: 10px 0;
    position: absolute;
    width: 200vw;
    left: -50vw;
    border-top: 1px solid rgba(0,0,0,0.15);
    border-bottom: 2px solid rgba(0,0,0,0.25);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: 'Anton', sans-serif;
    transform-origin: center;
    pointer-events: none;
    transform: rotate(var(--angle)); 
    
    /* Make text completely unselectable */
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
}

/* Infinite Scrolling Marquee */
.tape-marquee {
    display: flex;
    width: max-content;
    animation: marqueeScroll 15s linear infinite;
}

@keyframes marqueeScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* Pseudo element for a slight plastic glare/crinkle overlay */
.tape::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.15) 5%, transparent 20%, transparent 80%, rgba(255,255,255,0.05) 95%);
    mix-blend-mode: screen;
}

@keyframes tapeLeftToRight {
    0% { 
        clip-path: inset(0 100% 0 0);
        transform: scaleY(1.4) rotate(var(--angle)); 
        filter: drop-shadow(0 15px 10px rgba(0,0,0,0.3));
    }
    100% { 
        clip-path: inset(-10% -10% -10% -10%);
        transform: scaleY(1) rotate(var(--angle));
        filter: drop-shadow(0px 2px 3px rgba(0,0,0,0.15));
    }
}

@keyframes tapeRightToLeft {
    0% { 
        clip-path: inset(0 0 0 100%);
        transform: scaleY(1.4) rotate(var(--angle)); 
        filter: drop-shadow(0 15px 10px rgba(0,0,0,0.3));
    }
    100% { 
        clip-path: inset(-10% -10% -10% -10%);
        transform: scaleY(1) rotate(var(--angle));
        filter: drop-shadow(0px 2px 3px rgba(0,0,0,0.15));
    }
}

/* Stagger them, alternate directions, and apply different marquee scroll speeds! */
.strip-1 { top: 15%; --angle: -5deg; z-index: 10; animation: tapeLeftToRight 0.4s cubic-bezier(0.7, 0, 0.2, 1.2) 0.3s both; }
.strip-1 .tape-marquee { animation-duration: 18s; }

.strip-2 { top: 45%; --angle: 12deg; z-index: 12; animation: tapeRightToLeft 0.4s cubic-bezier(0.7, 0, 0.2, 1.2) 0.6s both; }
.strip-2 .tape-marquee { animation-duration: 12s; animation-direction: reverse; }

.strip-3 { top: 75%; --angle: -8deg; z-index: 11; animation: tapeLeftToRight 0.4s cubic-bezier(0.7, 0, 0.2, 1.2) 0.9s both; }
.strip-3 .tape-marquee { animation-duration: 22s; }

.strip-4 { top: 25%; --angle: 35deg; z-index: 9; animation: tapeRightToLeft 0.4s cubic-bezier(0.7, 0, 0.2, 1.2) 1.2s both; }
.strip-4 .tape-marquee { animation-duration: 15s; animation-direction: reverse; }

.strip-5 { top: 60%; --angle: -25deg; z-index: 13; animation: tapeLeftToRight 0.4s cubic-bezier(0.7, 0, 0.2, 1.2) 1.5s both; }
.strip-5 .tape-marquee { animation-duration: 19s; }

/* Blog close button visibility on light background */
.blog-construction .close-btn {
    color: #111;
    background: rgba(255,255,255,0.6);
    border: 1px solid rgba(0,0,0,0.2);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    backdrop-filter: blur(4px);
    z-index: 100;
    opacity: 1;
}
.blog-construction .close-btn:hover {
    background: #111;
    color: #fff;
}



.peel-overlay.active {
    visibility: visible;
    pointer-events: all;
}
