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

:root {
    --color-active: #ffffff;
    --color-inactive: #a0a0a0;
    --font-menu: 'Univers', 'DIN Alternate', 'Segoe UI', sans-serif;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #000;
    /* Letterbox: center the viewport box */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* ══ GLOBAL APERTURE VIEWPORT — Letterbox container ══ */
/* Locks aspect ratio 1920/876 — black bars on top/bottom on wider screens */
#aperture-viewport {
    position: relative;
    width: 1920px;
    height: 876px;
    transform-origin: center center;
    overflow: hidden;
    flex-shrink: 0;
}


#app {
    width: 100%;
    height: 100%;
    position: relative;
}


#view-menu {
    position: relative;
    overflow: hidden;
}

.view {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: none;
    background: #000;
}

.view.active {
    display: block;
}

.bg-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

.main-menu {
    position: absolute;
    left: 10%;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.menu-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.menu-item {
    position: relative;
    display: flex;
    align-items: center;
    padding-left: 2rem;
}

.menu-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.menu-indicator {
    position: absolute;
    left: 0;
    width: 8px;
    height: 24px;
    background: var(--color-active);
    opacity: 0;
    transform: translateX(-10px);
}

.menu-label {
    font-family: var(--font-menu);
    font-size: 2rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-inactive);
    transition: none;
    user-select: none;
}

/* ============================================
   EDUCATION SECTION - CHAMBER 01
   ============================================ */

#view-education {
    position: relative;
    overflow: hidden;
    background: #000;
}

/* Scene wrapper for zooming entire scene */
.edu-scene-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: center center;
    will-change: transform;
}

/* Layer 1: Background (Z-Index: 1) - Overscan for parallax */
.edu-bg-layer {
    position: absolute;
    top: -131px;
    left: -288px;
    width: 2496px;
    height: 1139px;
    z-index: 1;
    will-change: transform;
}

.edu-bg-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Layer 2: UI Screen (Z-Index: 2) - Fitted to wall niche under Aperture logo */
.edu-screen-wrapper {
    position: absolute;
    z-index: 2;
    top: 58%;
    left: 51%;
    transform: translate(-50%, -50%);
    width: 52vmin;
    max-width: 520px;
    aspect-ratio: 3/4;
}

.edu-screen-layer {
    width: 100%;
    height: 100%;
    will-change: transform;
    position: relative;
    z-index: 2;
}

/* Glow behind screen - flickers with screen */
.edu-screen-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 160%;
    height: 160%;
    background: radial-gradient(ellipse at center, rgba(100, 180, 220, 0.4) 0%, rgba(80, 160, 200, 0.25) 25%, rgba(60, 140, 180, 0.1) 50%, transparent 70%);
    filter: blur(60px);
    z-index: 1;
    animation: glowFlicker 8s infinite;
    pointer-events: none;
    mix-blend-mode: soft-light;
}

/* Extra ambient glow for wall integration */
.edu-screen-wrapper::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 180%;
    height: 140%;
    background: radial-gradient(ellipse at center, rgba(120, 140, 150, 0.2) 0%, rgba(100, 120, 130, 0.1) 40%, transparent 65%);
    filter: blur(80px);
    z-index: 0;
    animation: glowFlicker 8s infinite;
    pointer-events: none;
}

.edu-screen-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    animation: flicker 8s infinite;
}

/* Glow Flicker Animation - synced with screen but slightly different */
@keyframes glowFlicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
        opacity: 0.7;
    }
    20%, 24%, 55% {
        opacity: 0.4;
    }
    22% {
        opacity: 0.25;
    }
    52%, 58%, 96% {
        opacity: 0.6;
    }
    94% {
        opacity: 0.55;
    }
}

/* Flicker Animation for damaged lab effect */
@keyframes flicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
        opacity: 1;
        filter: brightness(1);
    }
    20%, 24%, 55% {
        opacity: 0.85;
        filter: brightness(0.9);
    }
    22% {
        opacity: 0.7;
        filter: brightness(0.85);
    }
    52%, 58%, 96% {
        opacity: 0.95;
        filter: brightness(0.95);
    }
    94% {
        opacity: 0.9;
        filter: brightness(0.92);
    }
}

/* Dynamic Chamber Status Mask over baked-in screen.png text */
.screen-status-header {
    position: absolute;
    top: 24%;
    left: 10%;
    width: 80%;
    height: 31%;
    z-index: 5;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    padding: 6px 12px;
}

.status-bg-mask {
    position: absolute;
    inset: 0;
    background: transparent;
    z-index: 1;
}

.status-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.status-title {
    font-family: 'Rajdhani', 'Orbitron', sans-serif;
    font-size: 1.45rem;
    font-weight: 500;
    color: rgba(210, 235, 255, 0.9);
    letter-spacing: 1px;
    margin-bottom: 4px;
    text-shadow: 0 0 12px rgba(100, 200, 255, 0.5);
    text-transform: uppercase;
    white-space: nowrap;
}

.status-line-sep {
    width: 100%;
    height: 1px;
    background: rgba(160, 210, 255, 0.4);
    box-shadow: 0 0 6px rgba(100, 200, 255, 0.5);
    margin-bottom: 6px;
}

.chamber-number {
    font-family: 'Orbitron', sans-serif;
    font-size: 5.2rem;
    font-weight: 700;
    color: #c8e6ff;
    line-height: 0.85;
    letter-spacing: -2px;
    text-shadow: 0 0 25px rgba(150, 210, 255, 0.7);
    transition: opacity 0.3s ease;
}

/* Layer 3: Grid (Z-Index: 3) - 3x2 Layout inside screen panel */
.edu-grid {
    position: absolute;
    z-index: 3;
    top: 45%;
    left: 5%;
    width: 90%;
    height: 30%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    column-gap: 2%;
    row-gap: 4%;
    align-items: end;
    pointer-events: none;
}

.edu-grid .grid-item {
    pointer-events: auto;
    height: 100%;
}

.grid-item {
    width: 100%;
    background: rgba(100, 150, 255, 0.1);
    border: 1px solid rgba(100, 150, 255, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    filter: drop-shadow(0 0 8px rgba(100, 180, 220, 0.35));
}

.grid-icon {
    width: 32px;
    height: 32px;
    color: rgba(150, 200, 255, 0.6);
    transition: all 0.3s ease;
    stroke-width: 1.5;
    position: relative;
    z-index: 2;
    pointer-events: none;
    filter: drop-shadow(0 0 5px rgba(100, 200, 255, 0.5));
}

.grid-label {
    color: rgba(200, 240, 255, 0.9);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    transition: all 0.3s ease;
    text-align: center;
    opacity: 0;
    transform: translateY(15px);
    position: absolute;
    bottom: 15%;
    pointer-events: none;
    filter: drop-shadow(0 0 6px rgba(120, 200, 255, 0.5));
}

.grid-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.8);
    filter: drop-shadow(0 0 15px rgba(100, 200, 255, 0.6)) brightness(1.1);
}

.grid-item:hover .grid-icon {
    color: rgba(220, 245, 255, 1);
    filter: drop-shadow(0 0 10px rgba(150, 220, 255, 0.85));
    transform: translateY(-10px);
}

.grid-item:hover .grid-label {
    opacity: 1;
    transform: translateY(0);
    filter: drop-shadow(0 0 10px rgba(150, 220, 255, 0.85));
}

/* Detail View Styles */
.detail-icon {
    width: 50px;
    height: 50px;
    color: rgba(150, 200, 255, 0.9);
    filter: drop-shadow(0 0 15px rgba(100, 200, 255, 0.6));
    margin-bottom: 10px;
}

#edu-detail-view {
    position: absolute;
    top: 28%;
    left: 8%;
    width: 84%;
    height: 55%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 10% 5% 5% 5%;
    z-index: 4;
    opacity: 0;
    pointer-events: none;
}

#edu-detail-view > * {
    pointer-events: auto;
}

.detail-icon {
    width: 60px;
    height: 60px;
    background: rgba(100, 200, 255, 0.2);
    border: 2px solid rgba(100, 200, 255, 0.6);
    margin-bottom: 15px;
}

.detail-title {
    color: rgba(200, 230, 255, 0.95);
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 0 0 20px 0;
    text-align: center;
    text-shadow: 0 0 10px rgba(100, 200, 255, 0.5);
}

#typewriter-text {
    color: rgba(180, 220, 255, 0.9);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.75rem;
    line-height: 1.6;
    text-align: left;
    width: 100%;
    min-height: 100px;
    margin: 0 0 20px 0;
}

#typewriter-text::after {
    content: '_';
    animation: blink 0.8s infinite;
    color: rgba(100, 200, 255, 1);
}

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

#btn-return {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.8);
    color: rgba(255, 255, 255, 0.9);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    padding: 8px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: auto;
}

#btn-return:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(100, 200, 255, 1);
    color: rgba(100, 200, 255, 1);
    text-shadow: 0 0 10px rgba(100, 200, 255, 0.8);
}

/* GLaDOS 2.5D Component - locked to education background, hanging from ceiling */
#glados-container {
    position: absolute;
    top: -100px;
    right: 25%;
    z-index: 5;
    pointer-events: none;
    /* Skaluj wszystko razem */
    --glados-scale: 0.85;
    transform: scale(var(--glados-scale));
    transform-origin: top center;
    animation: glados-sway 6s ease-in-out infinite;
}

/* Cała GLaDOS lekko się kołysze */
@keyframes glados-sway {
    0%, 100% { transform: scale(var(--glados-scale)) rotate(-1deg); }
    50% { transform: scale(var(--glados-scale)) rotate(1deg); }
}

#glados-container > div {
    position: absolute;
    width: auto;
    height: auto;
    transition: transform 0.1s ease-out;
}

#glados-container > div img {
    width: auto;
    height: auto;
    max-width: none;
    display: block;
}

/* Base - przytwierdzona do sufitu (góra) */
.glados-base {
    z-index: 1;
    top: 0;
    left: 50px;
    transform-origin: center top;
}

/* Arm - joint połączony z bazą (joint w 75% wysokości bazy) */
.glados-base > .glados-arm {
    position: absolute;
    z-index: 2;
    top: 75%;
    left: 7%;
    transform: translateX(-50%) rotate(var(--parallax-rotate, 0deg));
    transform-origin: right top;
    animation: glados-arm-idle 4s ease-in-out infinite;
}

@keyframes glados-arm-idle {
    0%, 100% { transform: translateX(-50%) rotate(calc(var(--parallax-rotate, 0deg) + 0deg)); }
    50% { transform: translateX(-50%) rotate(calc(var(--parallax-rotate, 0deg) + 2deg)); }
}

/* Neck - joint połączony z ramieniem (podąża za głową z opóźnieniem) */
.glados-arm > .glados-neck {
    position: absolute;
    z-index: 3;
    top: 78%;
    left: 50%;
    transform: translateX(-50%) 
               translate(var(--neck-translate-x, 0px), var(--neck-translate-y, 0px))
               rotate(var(--neck-rotate, 0deg));
    transform-origin: right top;
    animation: glados-neck-idle 5s ease-in-out infinite;
}

/* Neck idle z translate */
@keyframes glados-neck-idle {
    0%, 100% { 
        transform: translateX(-50%) 
                   translate(var(--neck-translate-x, 0px), var(--neck-translate-y, 0px))
                   rotate(calc(var(--neck-rotate, 0deg) - 1deg)); 
    }
    50% { 
        transform: translateX(-50%) 
                   translate(var(--neck-translate-x, 0px), var(--neck-translate-y, 0px))
                   rotate(calc(var(--neck-rotate, 0deg) + 1.5deg)); 
    }
}

/* Head - obrót wokół środka + przesunięcie żeby oko patrzyło (V2) */
.glados-neck > .glados-head {
    position: absolute;
    z-index: 4;
    top: 43%;
    left: -2%;
    transform: translateX(-50%) 
               translate(var(--head-translate-x, 0px), var(--head-translate-y, 0px)) 
               rotate(var(--head-rotate, 0deg));
    transform-origin: 100% 30%; /* punkt obrotu - prawy górny róg obrazka */
    animation: glados-head-idle 3s ease-in-out infinite;
    /* Bez cienia - usuwa się z szyi */
}

/* Głowa - mikroskopijny ruch idle (prawie niewidoczny) */
/* UWAGA: keyframes nadpisują transform! Muszą zawierać wszystkie wartości */
@keyframes glados-head-idle {
    0%, 100% { 
        transform: translateX(-50%) 
                   translate(var(--head-translate-x, 0px), var(--head-translate-y, 0px)) 
                   rotate(calc(var(--head-rotate, 0deg) - 1.5deg)); 
    }
    50% { 
        transform: translateX(-50%) 
                   translate(var(--head-translate-x, 0px), var(--head-translate-y, 0px)) 
                   rotate(calc(var(--head-rotate, 0deg) + 1.5deg)); 
    }
}

/* Responsive */
@media (max-width: 768px) {
    #glados-container {
        width: 250px;
        height: 300px;
        right: 2%;
    }
    
    .glados-base {
        width: 120px;
        top: 170px;
    }
    
    .glados-neck {
        width: 70px;
        top: 90px;
    }
    
    .glados-arm {
        width: 110px;
        top: 70px;
    }
    
    .glados-head {
        width: 85px;
    }
    
    .edu-side-nav {
        left: 2%;
        top: 25%;
    }
    
    .nav-btn {
        padding: 8px 12px;
    }
    
    .nav-label {
        font-size: 10px;
        letter-spacing: 1px;
    }
    
    .nav-icon {
        width: 18px;
        height: 18px;
    }
}

/* ============================================
   PORTAL 2 STYLE MENU - Locked to background
   ============================================ */

/* Kontener - PIKSELE od środka bg-layer */
.menu-container {
    position: absolute;
    left: 50%;
    top: 50%;
    /* TU USTAW OFFSET W PIKSELACH OD ŚRODKA: */
    transform: translate(calc(-50% + -700px), calc(-50%));
    z-index: 10;
    pointer-events: none;
}

/* Menu */
.portal-menu {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Portal 2 style nav item - WIĘKSZE NAPISY */
.portal-nav-item {
    position: relative;
    display: block;
    padding: 10px 0;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.6);
    font-family: 'Rajdhani', sans-serif;
    font-size: 18px;  /* <-- POWIĘKSZONE */
    font-weight: 400;
    letter-spacing: 4px;  /* <-- ZWIĘKSZONE */
    text-transform: uppercase;
    transition: all 0.3s ease;
}

/* White text */
.portal-text {
    display: inline-block;
    text-shadow: 0 0 0 transparent;
    transition: all 0.3s ease;
}

/* Underline for active */
.portal-underline {
    position: absolute;
    bottom: 4px;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Hover effect - brighten */
.portal-nav-item:hover {
    color: rgba(255, 255, 255, 0.9);
}

.portal-nav-item:hover .portal-text {
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
}

/* Active state - full white with glow */
.portal-nav-item.active {
    color: rgba(255, 255, 255, 1);
}

.portal-nav-item.active .portal-text {
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.6);
}

/* ============================================
   PAGE TRANSITION OVERLAY - Fade in/out
   ============================================ */

.page-transition-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.page-transition-overlay.fade-out {
    opacity: 1;
}

/* Initial page load - start with overlay visible */
body.page-loading .page-transition-overlay {
    opacity: 1;
}

body.page-loaded .page-transition-overlay {
    opacity: 0;
    transition: opacity 0.6s ease;
}
