/* Navigation */
.ptf-nav {
    position: fixed; top: 0; left: 0; width: 100%;
    padding: 30px 60px; 
    z-index: 100;
    transition: padding 0.3s ease; /* Smooth transition for resizing */
}

.ptf-nav .container {
    max-width: 100%; 
    padding: 0; 
    margin: 0;
}

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

.logo {
    color: white; text-decoration: none;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8); 
}

.nav-links a {
    color: white; text-decoration: none;
    margin-left: 40px; opacity: 0.8; transition: opacity 0.3s;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8); 
}
.nav-links a:hover { opacity: 1; }

/* Return Link (Topic Page) */
#navReturn {
    color: white; text-decoration: none;
    opacity: 0.8; transition: opacity 0.3s;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}
#navReturn:hover { opacity: 1; }

/* Mobile Navigation (Max-width: 768px) */
@media (max-width: 768px) {
    .ptf-nav {
        padding: 20px 20px;
        background: linear-gradient(to bottom, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0) 100%); /* Add contrast for readability */
    }

    .ptf-nav .flex-between {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .nav-links {
        display: flex;
        gap: 20px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-links a {
        margin-left: 0; /* Remove left margin in favor of gap */
        font-size: 0.8rem; /* Slightly smaller text */
    }
    
    .logo {
        display: none; /* Hide logo text on mobile as requested */
    }

    /* Position Return link correctly on mobile */
    #navReturn {
        font-size: 0.8rem;
    }
}

/* Footer */
.ptf-footer {
    text-align: center; /* Ensure global centering */
    padding: 40px 0;
    opacity: 0.6;
}

/* Parallax Background Layer */
.ptf-hero-bg {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100vh;
    background-image: url('../img/hero-bg.webp');
    background-size: cover;
    background-position: center;
    z-index: 0; 
    will-change: transform, opacity;
}

/* Hero Section */
.ptf-hero {
    height: 100vh; display: flex; align-items: center; justify-content: center;
    border-top: none;
    position: relative;
    overflow: hidden;
    background: transparent; 
    z-index: 1; 
}

/* Dark overlay */
.ptf-hero::before {
    content: '';
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: -1; 
}

/* Ensure subsequent sections have background to cover the fixed hero bg on scroll */
.ptf-section, .ptf-archive {
    position: relative;
    background-color: var(--bg); 
    z-index: 2; 
}

/* Hero Content */
.hero-inner {
    position: relative;
    z-index: 2;
    width: 100%; height: 100%;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
}

.hero-quote-wrapper {
    display: flex; flex-direction: column; align-items: center;
    transform: translateY(-20px);
}

.hero-chapter-label {
    font-family: var(--font-mono);
    font-size: 1.2rem; 
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 40px; 
    opacity: 0.8;
}

.hero-quote {
    font-family: var(--font-head);
    font-size: clamp(2rem, 4.5vw, 6rem); 
    line-height: 1.1;
    text-align: center; 
    margin-bottom: 50px;
    max-width: 95vw; 
    white-space: nowrap; 
    letter-spacing: -0.01em;
    text-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

@media (max-width: 768px) {
    .hero-quote {
        white-space: normal;
        font-size: 3rem;
        line-height: 1.2;
        width: 100%; /* Ensure it fits container */
        max-width: 100%; /* Prevent overflow */
        padding: 0 20px; /* Add safety padding */
    }
    
    .hero-chapter-label {
        letter-spacing: 0.2em; /* Reduced from 0.4em for mobile */
        font-size: 1rem;
    }
    
    .hero-quote-wrapper {
        width: 100%; /* Ensure wrapper doesn't overflow */
        transform: translateY(0); /* Reset transform just in case */
    }
}

.ptf-btn-primary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    color: var(--text); 
    padding: 18px 48px;
    font-family: var(--font-mono); 
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.2em; 
    cursor: pointer;
    transition: all 0.4s var(--ease-cinematic);
    border-radius: 2px;
}

.ptf-btn-primary:hover {
    background: var(--text); 
    color: var(--bg);
    border-color: var(--text);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

/* Video Layer */
.hero-video-layer {
    position: absolute; inset: 0; z-index: 1;
    background: var(--bg);
    opacity: 0; pointer-events: none;
    transition: opacity 1.2s var(--ease-cinematic);
    
    /* Flex Center for Wrapper */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Wrapper to constrain video and hold HUD */
.hero-player-wrapper {
    position: relative;
    width: 100%;
    height: auto;
    
    /* Constrain to screen size while keeping 16:9 */
    max-width: 100vw;
    max-height: 100vh;
    aspect-ratio: 16 / 9;
    
    background: black; /* Placeholder if video loads slow */
}

/* Ensure HUD stays inside wrapper */
.hero-player-wrapper .hero-progress-area {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1002;
}

#heroVideoPlayer {
    width: 100%; height: 100%;
    position: absolute; top: 0; left: 0;
}

body.is-playing .hero-video-layer { opacity: 1; pointer-events: auto; z-index: 1; }
body.is-playing .hero-inner { opacity: 0; pointer-events: none; transition: opacity 0.8s var(--ease-cinematic); }

.hero-close-btn {
    position: absolute; top: 120px; right: 40px;
    background: transparent; border: none; color: white;
    font-size: 2rem; cursor: pointer; z-index: 1002;
    opacity: 0; pointer-events: none;
    transition: opacity 0.5s;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

body.is-playing .hero-close-btn { opacity: 0.5; pointer-events: auto; }
body.is-playing .hero-close-btn:hover { opacity: 1; }

/* --- HERO HUD CONTROLS (Ghost UI) --- */

/* Center State Indicator (Play/Pause Icon) */
.hero-center-state {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 80px; height: 80px;
    z-index: 1001;
    pointer-events: none; /* Let clicks pass through to container */
    
    display: flex; align-items: center; justify-content: center;
    
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Only show when paused (or explicitly active) */
.hero-video-layer.paused .hero-center-state {
    opacity: 1;
}

.state-icon {
    width: 0; height: 0;
    opacity: 0.8;
    filter: drop-shadow(0 0 20px rgba(0,0,0,0.5));
}

/* CSS Play Triangle */
.state-icon.play {
    border-style: solid;
    border-width: 25px 0 25px 45px;
    border-color: transparent transparent transparent white;
    transform: translateX(5px); /* Visual correction */
}

/* Ghost Progress Bar Area */
.hero-progress-area {
    position: absolute;
    bottom: 0; left: 0; width: 100%;
    height: 60px; /* Hit area height */
    z-index: 1001;
    cursor: pointer;
    
    display: flex; align-items: flex-end; /* Align bar to bottom */
    
    opacity: 0; /* Hidden by default */
    transition: opacity 0.3s ease;
}

/* Reveal on hover */
.hero-progress-area:hover {
    opacity: 1;
}

.hero-progress-bar {
    width: 100%;
    height: 4px; /* Visible line height */
    background: rgba(255, 255, 255, 0.2);
    position: relative;
    margin-bottom: 0; /* Flush to bottom */
}

.hero-progress-fill {
    position: absolute; top: 0; left: 0; bottom: 0;
    width: 0%; /* Dynamic */
    background: var(--accent);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    transition: width 0.1s linear; /* Smooth fill */
}

/* Mission Grid */
.section-title {
    font-size: clamp(1.5rem, 3vw, 3rem); /* Smaller, responsive */
    margin-bottom: 100px;
    font-family: var(--font-head);
    white-space: nowrap; /* Force single line */
    letter-spacing: -0.01em;
    text-align: center; /* Centered for better balance */
}

.mission-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 100px;
    align-items: start;
}

/* Offset the "Nothing more" side for narrative contrast */
.mission-more {
    margin-top: 150px;
}

@media (max-width: 900px) {
    .mission-grid {
        display: flex;
        flex-direction: column;
        gap: 60px;
        width: 100%;
        margin: 0;
        padding: 0;
    }
    
    .mission-group, 
    .project-grid {
        width: 100%;
        margin: 0;
        padding: 0;
        display: block;
    }
    
    .project-card {
        width: 100% !important;
        margin: 0 0 80px 0 !important; /* Force left align and bottom spacing */
        padding: 0;
        display: block;
    }
    
    .project-info {
        margin-top: 20px;
        padding: 0; /* Ensure no padding on info */
        width: 100%;
    }

    .mission-more {
        margin-top: 60px;
    }

    .section-title {
        white-space: normal;
        margin-bottom: 60px;
    }
}

.group-label {
    display: block; margin-bottom: 40px; 
    opacity: 0.4; font-size: 0.7rem;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
}

.project-card {
    margin-bottom: 80px; text-decoration: none; color: inherit;
    display: block;
}

.project-media {
    width: 100%; aspect-ratio: 2.35 / 1;
    overflow: hidden; background: #151515; /* Placeholder background */
    position: relative;
    min-height: 200px; /* Force height even if empty */
}

.play-indicator {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 60px; height: 60px;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 1.2rem;
    opacity: 0; transition: all 0.4s var(--ease-cinematic);
}

.project-card:hover .play-indicator {
    opacity: 1; transform: translate(-50%, -50%) scale(1);
}

.project-card img {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform 0.8s var(--ease-cinematic);
}

.project-card:hover img { transform: scale(1.03); }

.project-info { margin-top: 20px; }
.project-info h3 { font-size: 1.5rem; margin-bottom: 5px; }

/* Dream Gallery */
.dream-gallery {
    display: grid; grid-template-columns: 1fr; gap: 120px;
}

@media (max-width: 900px) {
    .dream-gallery {
        display: flex;
        flex-direction: column;
        gap: 60px;
        width: 100%;
        margin: 0;
        padding: 0;
    }
    
    .dream-item, .project-card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 0 60px 0 !important;
        padding: 0;
    }
}

.dream-item {
    width: 100%; max-width: 1000px; margin: 0 auto;
}

/* Magic (AI Artifact) */
.magic-entry {
    max-width: 900px;
    margin: 0 auto; /* Center the container */
}

@media (max-width: 900px) {
    .magic-entry {
        width: 100%;
        margin: 0;
        padding: 0;
    }
    
    .artifact-card {
        width: 100%;
        margin: 0;
        padding: 20px; /* Keep internal padding */
    }
}

.artifact-card {
    padding: 30px; 
    border: 1px solid var(--line);
    background: var(--surface); 
    transition: all 0.4s var(--ease-cinematic);
    text-decoration: none; 
    color: inherit; 
    display: block;
}

.artifact-card h3 {
    font-family: var(--font-head);
    font-weight: 300;
}

.artifact-card:hover { border-color: var(--accent); }

/* Archive Exit */
.ptf-archive { padding: 200px 0; border-top: 1px solid var(--line); }
.archive-link {
    display: inline-flex; align-items: center; gap: 20px;
    text-decoration: none; color: var(--text); font-size: 2.5rem;
    font-family: var(--font-head);
}
.archive-link svg { transition: transform 0.4s var(--ease-cinematic); }
.archive-link:hover svg { transform: translateX(10px); }

/* Global Video Overlay */
.video-overlay {
    position: fixed; inset: 0; z-index: 2000;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    visibility: hidden;
    transition: opacity 0.4s var(--ease-cinematic), visibility 0.4s;
    perspective: 1000px;
}

.video-overlay.active { 
    opacity: 1; 
    pointer-events: auto; 
    visibility: visible;
}

.overlay-bg {
    position: absolute; inset: 0;
    /* Cinema Black: Very subtle radial gradient for vignette effect */
    background: radial-gradient(
        circle at center, 
        hsl(0, 0%, 4%) 0%, 
        hsl(0, 0%, 0%) 100%
    );
    z-index: 0;
}

/* Film Grain Texture - Pure CSS via SVG Data URI */
.overlay-bg::after {
    content: '';
    position: absolute; inset: 0;
    /* 
       Noise SVG: Base frequency 0.65 for fine grain, low opacity.
       Data URI avoids external requests.
    */
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.04'/%3E%3C/svg%3E");
    background-repeat: repeat;
    /* Blend mode helps it sit 'in' the black rather than on top */
    mix-blend-mode: overlay; 
    opacity: 0.6; /* Adjust for 1-2% perceptual visibility */
    pointer-events: none;
    z-index: 1;
}

.overlay-playlist-container {
    position: relative; z-index: 2001;
    width: 90%; max-width: 1000px;
    height: 80vh;
    display: flex; flex-direction: column; 
    align-items: center; justify-content: center;
}

/* Base Playlist Item */
.playlist-item {
    position: absolute;
    width: 100%;
    transition: all 0.6s var(--ease-cinematic);
}

/* Active State (Center) */
.playlist-item.is-active {
    z-index: 20;
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Prev/Next States (Anchored Closer to Video) */
.playlist-item.is-prev, 
.playlist-item.is-next {
    z-index: 15;
    opacity: 0.5; 
    cursor: pointer;
    height: auto; 
    width: 300px;
    left: 50%; 
    right: auto;
    
    position: absolute; 
    display: flex; align-items: center; 
    flex-direction: row; 
    justify-content: center;
    overflow: visible; 
    
    background: transparent; 
    border: none;
    padding: 0;
    transition: all 0.4s var(--ease-cinematic);
}

/* Specific Vertical Positions - Brought Inward */
.playlist-item.is-prev {
    top: 12%; 
    bottom: auto;
    margin-top: 0;
    transform: translateX(-50%);
}

.playlist-item.is-next {
    top: auto;
    bottom: 12%; 
    margin-bottom: 0;
    transform: translateX(-50%); 
}

/* Info Container Layout */
.playlist-item .item-info {
    text-align: left; 
    display: flex; 
    flex-direction: column;
    justify-content: center;
    margin-left: 20px; 
    position: static; 
}

/* Detached Label Styling - Moved to Left */
.playlist-item .item-type {
    position: absolute;
    left: -80px; /* Hang to the left */
    top: 50%;
    transform: translateY(-50%);
    
    font-size: 0.7rem; 
    letter-spacing: 0.3em; 
    opacity: 0.6; 
    white-space: nowrap;
    color: var(--accent); 
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    font-weight: 600;
    text-align: right;
    width: 60px; /* Fixed width for alignment */
}

/* No specific top/bottom for type anymore, just centered left */
.playlist-item.is-prev .item-type,
.playlist-item.is-next .item-type {
    top: 50%;
    bottom: auto;
}

/* Prompt Mode */
.overlay-playlist-container.prompt-mode .playlist-item.is-prev,
.overlay-playlist-container.prompt-mode .playlist-item.is-next {
    opacity: 0.8; 
}

/* Hover: Fully Active & Scaled */
.playlist-item.is-prev:hover,
.playlist-item.is-next:hover {
    opacity: 1 !important; 
    transform: translateX(-50%) scale(1.1); 
    z-index: 20; 
}

.playlist-item .item-title {
    font-size: 1rem; 
    font-weight: 400;
    margin: 0;
    line-height: 1.2;
    color: white;
}

.playlist-item .item-visual {
    width: 100px; 
    aspect-ratio: 16/9;
    background: #222; background-size: cover; background-position: center;
    border-radius: 2px;
    flex-shrink: 0;
    opacity: 0.9;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5); 
}

/* Active Video Player Styles */
.video-wrapper {
    width: 100%; height: auto; /* Allow video to dictate height */
    max-height: 80vh; /* Prevent overflow on tall screens */
    background: transparent; /* KEY: No black box behind video */
    box-shadow: 0 30px 80px rgba(0,0,0,0.8);
    position: relative;
    outline: 1px solid rgba(255,255,255,0.1);
    outline-offset: 15px;
    display: flex; align-items: center; justify-content: center;
}

#overlayPlayer { width: 100%; height: 100%; }

/* Decoration Layer for Corners Only */
.video-frame-deco {
    position: absolute;
    inset: -10px; 
    pointer-events: none;
    z-index: 10;
}

/* Four Corners */
.video-frame-deco::before,
.video-frame-deco::after {
    content: '';
    position: absolute;
    width: 100%; height: 100%;
    /* Gradient borders for corners */
    background: 
        linear-gradient(to right, white 2px, transparent 2px) 0 0,
        linear-gradient(to bottom, white 2px, transparent 2px) 0 0,
        linear-gradient(to left, white 2px, transparent 2px) 100% 0,
        linear-gradient(to bottom, white 2px, transparent 2px) 100% 0,
        linear-gradient(to right, white 2px, transparent 2px) 0 100%,
        linear-gradient(to top, white 2px, transparent 2px) 0 100%,
        linear-gradient(to left, white 2px, transparent 2px) 100% 100%,
        linear-gradient(to top, white 2px, transparent 2px) 100% 100%;
    background-size: 40px 40px;
    background-repeat: no-repeat;
    opacity: 0.8;
}

/* Independent Vertical Track */
.overlay-track {
    position: absolute;
    right: -80px; 
    top: 15%; bottom: 15%; 
    width: 40px; 
    
    background: repeating-linear-gradient(
        to bottom,
        rgba(255,255,255,0.4) 0,
        rgba(255,255,255,0.4) 2px, 
        transparent 2px,
        transparent 40px 
    );
    background-size: 20px 100%; 
    background-position: center;
    background-repeat: no-repeat;
    
    border-right: 1px solid rgba(255,255,255,0.1);
    mask-image: linear-gradient(to bottom, transparent, black 10%, black 90%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 10%, black 90%, transparent);
    pointer-events: none;
}

.overlay-meta {
    margin-top: 50px; 
    text-align: center;
    font-family: var(--font-mono); 
    color: var(--text-muted);
    font-size: 1rem; 
}

.overlay-tag {
    position: absolute;
    left: 60px; 
    top: 50%;
    transform: translateY(-50%); 
    font-size: 1.2rem; 
    letter-spacing: 0.15em;
    color: rgba(255, 255, 255, 0.4); 
    white-space: nowrap;
    z-index: 2002;
    pointer-events: none;
    transition: opacity 0.4s;
    
    border-left: 2px solid var(--accent);
    padding-left: 20px;
}

.overlay-counter {
    position: absolute;
    right: 60px;
    bottom: 60px;
    font-size: 4rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.15); 
    pointer-events: none;
    z-index: 2010; 
}

.overlay-close {
    position: absolute; top: 40px; right: 40px;
    background: none; border: none; color: white;
    font-size: 2rem; cursor: pointer; z-index: 2005;
    transition: transform 0.3s;
}
.overlay-close:hover { transform: scale(1.1); color: var(--error); }

/* Mobile Overlay Adjustments */
@media (max-width: 768px) {
    .overlay-tag, 
    .overlay-counter,
    .overlay-track,
    .playlist-item.is-prev,
    .playlist-item.is-next {
        display: none !important; /* Hide distractions */
    }

    .overlay-playlist-container {
        width: 100%;
        height: 100vh;
        justify-content: center;
    }

    .video-wrapper {
        width: 100%;
        max-height: 60vh; /* Allow more space for video on mobile */
        box-shadow: none;
        outline: none;
    }

    .video-frame-deco {
        display: none !important; /* Hide corner decorations on mobile */
    }

    .overlay-close {
        top: auto;
        bottom: 30px;
        right: 50%;
        transform: translateX(50%);
        background: rgba(0,0,0,0.5);
        width: 50px; height: 50px;
        border-radius: 50%;
        display: flex; align-items: center; justify-content: center;
        border: 1px solid rgba(255,255,255,0.2);
    }
    
    .overlay-chapter-exit {
        width: 100%;
        bottom: 100px; /* Above the close button */
    }
}

/* --- NEW INDEPENDENT CHAPTER EXIT STYLES --- */
.overlay-chapter-exit {
    position: absolute;
    bottom: 60px; /* Aligned with .overlay-counter */
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    text-align: center;
    
    z-index: 2010;
    pointer-events: auto;
    
    opacity: 0; /* Base state (hidden until activated via JS logic) */
    transition: opacity 1.2s var(--ease-cinematic), transform 0.4s ease; 
}

/* Button style from user screenshot: White rectangle, black text */
.chapter-next-btn {
    background: #999999; /* Grey default */
    color: #000000;
    border: none;
    padding: 15px 75px; /* Reduced padding (approx 75%) */
    font-family: var(--font-mono);
    font-size: 1.125rem; /* Reduced font size (1.5 * 0.75) */
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.3s ease;
    display: inline-block;
    box-shadow: 0 0 20px rgba(0,0,0,0.6); /* Reduced shadow */
}

.chapter-next-btn:hover {
    background: #FFFFFF; /* White highlight on hover */
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(255,255,255,0.4);
}

/* Ensure container allows full visibility */
.overlay-chapter-exit.active {
    opacity: 1; /* Force visibility */
    bottom: 80px; /* Lift up slightly */
}

/* Prompt Active means user interaction is expected */
.overlay-chapter-exit.active.prompt-active {
    opacity: 1; 
}

.overlay-chapter-exit:hover {
    opacity: 1 !important;
}