:root {
    --bg-color: #0c0c0c;
    --rect-border: #ffffff;
    --rect-fill: rgba(255, 255, 255, 0.03);
    --text-color: #e0e0e0;
    --dim-line-color: #333333;
    --accent-color: #ffffff;
}

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

body {
    font-family: 'Space Grotesk', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* Glitch Marquee Header */
.glitch-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 10px 0;
    background: rgba(12, 12, 12, 0.8);
    backdrop-filter: blur(10px);
    z-index: 100;
    overflow: hidden;
}

.marquee-track {
    display: flex;
    width: max-content;
    animation: marquee-left-to-right 12s linear infinite;
    will-change: transform;
}

.marquee-item {
    display: flex;
    align-items: center;
}

.marquee-spacer {
    width: 40vw; /* Exact 40% spacing */
    flex-shrink: 0;
}

.glitch-text {
    position: relative;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    white-space: nowrap;
    flex-shrink: 0;
}

@keyframes marquee-left-to-right {
    0% { transform: translateX(-50%); } 
    100% { transform: translateX(0); }  
}

.container {
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Move from center to top */
    width: 100%;
    height: 100%;
    padding-top: 20px; /* Reverted to 20px */
}

.dimension-wrapper {
    position: relative;
    padding: 10px 20px; /* Reduced top/bottom padding */
}

.rectangle-box {
    /* Scale target: 1m = 40px */
    width: 392px;   
    height: 722.4px; 
    
    /* Responsive Containment */
    max-width: 90vw;
    max-height: 80vh;
    width: min(392px, 90vw);
    height: auto;
    aspect-ratio: 9.8 / 18.06;

    background-color: var(--rect-fill);
    position: relative;
    
    /* Borders except left */
    border-top: 1px solid var(--rect-border);
    border-right: 1px solid var(--rect-border);
    border-bottom: 1px solid var(--rect-border);
}

/* Partial Left Border */
.rectangle-box::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50px; /* 1.25m gap */
    bottom: 50px; /* 1.25m gap */
    background-color: var(--rect-border);
}

/* Sala Sections Sequence */
#sala-sections {
    position: absolute;
    top: 50%;
    left: 10%;
    right: 10%;
    transform: translateY(-50%);
    height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    pointer-events: none;
}

#section-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    scroll-behavior: smooth;
    scroll-snap-type: y mandatory; /* Added snap */
    pointer-events: auto;
    padding: 85px 0; /* Adjusted for better centering */
    mask-image: linear-gradient(to bottom, transparent, black 30%, black 70%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 30%, black 70%, transparent);
}

#section-list::-webkit-scrollbar {
    display: none;
}

.section-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 5px;
    flex-shrink: 0;
    transition: all 0.4s ease;
    scroll-snap-align: center; /* Added snap align */
}

.section {
    transition: all 0.3s ease;
    text-align: center;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
    font-weight: 400;
    cursor: pointer;
    font-size: 0.8rem;
    opacity: 0.2;
}

/* Style for the visually focused section (at the center) */
.section-item.visual-active .section {
    font-size: 1.15rem;
    font-weight: 700;
    opacity: 1;
}

.section-item.active .section {
    /* If synced, we might want a special indicator here, 
       but for now we let visual-active handle the size */
}

.section-item.completed .section {
    /* Subtle hint it was done */
}

.status-text {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.5;
    color: var(--text-color);
}

.resync-btn {
    position: absolute;
    bottom: -40px;
    background: var(--rect-border);
    color: var(--bg-color);
    border: none;
    padding: 8px 24px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    transform: translateY(10px);
    touch-action: manipulation; /* Eliminate iOS click delay */
    z-index: 1000;
}

.resync-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.active-section-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 5px; /* Progress bar very close to text */
}

.section {
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
    font-weight: 400;
    pointer-events: auto; /* Make sections clickable */
    cursor: pointer;
}

.section.active {
    font-size: 1.2rem;
    font-weight: 700;
    opacity: 1;
    transform: scale(1);
}

.section.prev-1, .section.next-1 {
    font-size: 0.9rem;
    opacity: 0.5;
    transform: scale(0.9);
}

.section.prev-2, .section.next-2 {
    font-size: 0.7rem;
    opacity: 0.2;
    transform: scale(0.8);
}

.progress-container {
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 1px;
    overflow: hidden;
    max-width: 180px;
}

#section-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--rect-border);
    transition: width 0.1s linear;
}

.exit-icon {
    position: absolute;
    width: 14px;
    height: 14px;
    color: var(--text-color);
}

.top-left {
    top: 10px;
    left: 10px;
    transform: rotate(180deg); /* Pointing to the left exit */
}

.bottom-left {
    bottom: 10px;
    left: 10px;
    transform: rotate(180deg); /* Pointing to the left exit */
}

/* Spots */
.spot {
    position: absolute;
    width: 32px;
    height: 42px;
    background-color: var(--rect-fill);
    border: 2px solid var(--rect-border);
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    z-index: 10;
}

/* Pointer / Peak at the bottom */
.spot::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px 6px 0;
    border-style: solid;
    border-color: var(--rect-border) transparent transparent transparent;
}

.spot.has-image {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Inside placement */
.spot-1 { top: 15px; left: calc(50% - 16px); }
.spot-2 { top: calc(15% - 21px); right: 15px; }
.spot-3 { top: calc(50% - 21px); right: 15px; }
.spot-4 { top: calc(85% - 21px); right: 15px; }
.spot-5 { bottom: 15px; left: calc(50% - 16px); }
.spot-6 { top: calc(85% - 21px); left: 15px; }
.spot-7 { top: calc(50% - 21px); left: 15px; }
.spot-8 { top: calc(15% - 21px); left: 15px; }

/* FOH Area */
.foh-box {
    position: absolute;
    top: 32.5%;
    left: 15px; /* Aligned with the left edge of profiles */
    transform: translateY(-50%);
    width: 30px;
    height: 80px;
    border: 1px solid var(--rect-border);
    background-color: rgba(255, 255, 255, 0.05); /* Slight fill */
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    z-index: 5;
    writing-mode: vertical-rl;
    text-orientation: upright;
}

@media (max-width: 500px) {
    .rectangle-box {
        max-width: 85vw;
        max-height: 70vh;
    }
    .rectangle-box::before {
        top: 37.5px; /* Adjust gap for mobile scale (30px/m) */
        bottom: 37.5px;
    }
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-card {
    background: var(--bg-color);
    border: 2px solid var(--rect-border);
    border-radius: 16px;
    width: 90%;
    max-width: 460px;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
    margin-top: 30px; /* space so image isn't cut on small screens */
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-color);
    cursor: pointer;
    z-index: 20;
    transition: transform 0.2s, color 0.2s;
}

.close-modal:hover {
    color: var(--rect-border);
    transform: scale(1.1);
}

.modal-content-wrapper {
    padding: 20px 30px 25px;
    position: relative;
}

.modal-image {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    border: 3px solid var(--rect-border);
    background-size: cover;
    background-position: center;
    background-color: var(--bg-color);
    margin-top: -80px; /* Adjust slightly for the smaller padding */
    margin-bottom: 15px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    display: none; /* Hidden by default */
}

.modal-content {
    color: var(--text-color);
}

.modal-content h2 {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 15px;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.modal-content h2 .profession {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: var(--rect-border);
    color: var(--bg-color);
    padding: 6px 12px;
    border-radius: 20px;
    display: inline-block;
}

.cv-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--rect-border);
    opacity: 0.6;
    letter-spacing: 0.15em;
    margin-bottom: 12px;
}

.modal-content p {
    font-size: 0.95rem;
    line-height: 1.6;
    opacity: 0.85;
    text-align: justify;
}

/* CAROUSEL CONTROLS */
.carousel-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed var(--rect-border);
    width: 100%;
}

.arrow-btn {
    background: transparent;
    border: none;
    color: var(--rect-border);
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    padding: 2px 10px;
    opacity: 0.8;
}

.arrow-btn:hover {
    transform: scale(1.2);
    opacity: 1;
}

.carousel-dots {
    display: flex;
    gap: 8px;
}

.carousel-dots .dot {
    width: 8px;
    height: 8px;
    background-color: var(--rect-border);
    border-radius: 50%;
    opacity: 0.2;
    transition: opacity 0.3s, transform 0.3s;
}

.carousel-dots .dot.active {
    opacity: 1;
    transform: scale(1.3);
}

.spot { cursor: pointer; transition: transform 0.2s; }
.spot:hover { transform: scale(1.1); z-index: 20; }
.foh-box { cursor: pointer; transition: transform 0.2s; }
.foh-box:hover { transform: scale(1.05); z-index: 20; }

/* TOP NAVIGATION BUTTONS */
.top-nav {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 70px 0 -15px 0; /* Pushed even further down */
    z-index: 100;
}

.custom-nav-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--rect-border);
    color: var(--text-color);
    padding: 6px 14px; /* Smaller padding */
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.75rem; /* Smaller font size */
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.custom-nav-btn:hover {
    background: var(--rect-border);
    color: var(--bg-color);
    box-shadow: 0 0 20px var(--rect-border);
    transform: translateY(-2px);
}

.custom-nav-btn:active {
    transform: translateY(0);
}

/* SLIDE ANIMATIONS */
.slide-out-left { animation: slide-out-left 0.15s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.slide-in-right { animation: slide-in-right 0.15s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.slide-out-right { animation: slide-out-right 0.15s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.slide-in-left { animation: slide-in-left 0.15s cubic-bezier(0.4, 0, 0.2, 1) forwards; }

@keyframes slide-out-left {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(-20px); opacity: 0; }
}
@keyframes slide-in-right {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slide-out-right {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(20px); opacity: 0; }
}
@keyframes slide-in-left {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
