/* ==========================================================
 * LAYOUT — navbar, sound toggle, mobile drawer + overlay,
 * page shell (SPA fade), content sections, section heads, footer.
 * ========================================================== */

/* ---------------------------------------------------------
 * Navbar
 * --------------------------------------------------------- */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: var(--safe-top) calc(2rem + var(--safe-right)) 0 calc(2rem + var(--safe-left));
    height: calc(var(--navbar-height) + var(--safe-top));
    background-color: rgba(10, 10, 12, 0.7);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: var(--z-nav);
}
.nav-brand a { font-size: 1.5rem; font-weight: 700; color: var(--color-texto); }

.nav-links {
    display: flex;
    list-style: none;
    align-items: center;
    height: 100%;
}
.nav-links li {
    margin-left: 2rem;
    height: 100%;
    display: flex;
    align-items: center;
}
/* Nav items that are <button>: same look as <a> */
.nav-links button {
    -webkit-appearance: none;
    appearance: none;
    background: none;
    border: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
}
.nav-links a,
.nav-links button {
    position: relative;
    color: var(--color-texto-secundario);
    font-weight: 400;
    transition: color 0.3s ease;
    padding: 0 0.5rem;
    height: 100%;
    display: flex;
    align-items: center;
    white-space: nowrap;
}
.nav-links a:focus-visible,
.nav-links button:focus-visible { color: var(--color-primario); outline-offset: -4px; }
@media (hover: hover) and (pointer: fine) {
    .nav-links a:hover,
    .nav-links button:hover { color: var(--color-primario); }
    .page-work .nav-links a:hover,
    .page-work .nav-links button:hover { color: var(--color-work-accent); }
}
.page-work .nav-links a:focus-visible,
.page-work .nav-links button:focus-visible { color: var(--color-work-accent); }

/* Active item: accent colour + 2px underline indicator (no glow) */
.nav-links a.active,
.nav-links button.active {
    color: var(--color-primario);
    font-weight: 600;
}
.nav-links a.active::after,
.nav-links button.active::after {
    content: "";
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    bottom: 12px;
    height: 2px;
    background: currentColor;
}
.page-work .nav-links a.active,
.page-work .nav-links button.active { color: var(--color-work-accent); }

/* 7 items: tighter spacing on narrow desktops */
@media (max-width: 1100px) {
    .nav-links li { margin-left: 1.25rem; }
}
@media (max-width: 900px) {
    .nav-links li { margin-left: 0.75rem; }
    .nav-links a,
    .nav-links button { padding: 0 0.4rem; }
}

/* --- Right cluster: sound toggle + hamburger --- */
.nav-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
    z-index: 2; /* stays above the open drawer */
}
.nav-brand { position: relative; z-index: 2; }

.sound-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 36px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--color-borde);
    border-radius: 999px;
    padding: 0.42rem 0.9rem;
    color: var(--color-texto-secundario);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.3s ease, border-color 0.3s ease, background-color 0.3s ease;
}
.sound-toggle .icon { font-size: 1rem; }
.sound-toggle .icon-on,
.sound-toggle .sound-state-on { display: none; }
.sound-toggle[aria-pressed="true"] .icon-on,
.sound-toggle[aria-pressed="true"] .sound-state-on { display: inline; }
.sound-toggle[aria-pressed="true"] .icon-off,
.sound-toggle[aria-pressed="true"] .sound-state-off { display: none; }
.sound-toggle:focus-visible { border-color: rgba(0, 255, 255, 0.4); color: var(--color-texto); }
@media (hover: hover) and (pointer: fine) {
    .sound-toggle:hover { border-color: rgba(0, 255, 255, 0.4); color: var(--color-texto); }
}
.sound-toggle.sound-on,
.sound-toggle[aria-pressed="true"] {
    color: var(--color-primario);
    border-color: rgba(0, 255, 255, 0.5);
}
@media (pointer: coarse) {
    .sound-toggle { min-height: 44px; min-width: 44px; padding: 0.5rem 0.85rem; }
}

/* --- Hamburger (hidden on desktop) --- */
.hamburger-menu {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    width: 44px;
    height: 44px;
    padding: 9px;
    margin-right: -9px;
    color: var(--color-texto);
}
.hamburger-menu span {
    display: block;
    width: 26px;
    height: 2px;
    background-color: currentColor;
    margin: 6px 0;
    border-radius: 2px;
    transition: transform 0.3s var(--ease-out), opacity 0.2s ease;
}

/* ---------------------------------------------------------
 * Mobile drawer: phones, tablets and any touch screen < 1024px
 * --------------------------------------------------------- */
@media (max-width: 768px), (max-width: 1023px) and (pointer: coarse) {
    .navbar {
        z-index: var(--z-toast);
        padding-left: calc(1rem + var(--safe-left));
        padding-right: calc(1rem + var(--safe-right));
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: 0;
        width: min(420px, 100%);
        height: 100vh;
        height: 100dvh;
        background-color: var(--color-drawer);
        border-left: 1px solid var(--color-borde);
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        padding: calc(var(--navbar-height) + var(--safe-top) + 1.5rem) calc(1.5rem + var(--safe-right)) calc(2rem + var(--safe-bottom)) 1.5rem;
        overflow-y: auto;
        overscroll-behavior: contain;
        counter-reset: nav;
        transform: translateX(100%);
        visibility: hidden;
        transition: transform 0.4s var(--ease-out), visibility 0s linear 0.4s;
        z-index: 1;
    }
    .nav-links.active {
        transform: translateX(0);
        visibility: visible;
        transition: transform 0.4s var(--ease-out), visibility 0s;
    }

    .nav-links li {
        margin: 0;
        height: auto;
        width: 100%;
        counter-increment: nav;
        border-bottom: 1px solid var(--color-borde);
    }
    .nav-links a,
    .nav-links button {
        width: 100%;
        height: auto;
        min-height: 56px;
        padding: 0.85rem 0;
        justify-content: flex-start;
        align-items: baseline;
        gap: 1rem;
        font-family: var(--font-display);
        font-size: 1.5rem;
        font-weight: 500;
        letter-spacing: -0.01em;
        color: var(--color-texto);
    }
    .nav-links a::before,
    .nav-links button::before {
        content: counter(nav, decimal-leading-zero);
        font-family: var(--font-mono);
        font-size: 0.75rem;
        font-weight: 400;
        letter-spacing: 0.1em;
        color: var(--color-texto-secundario);
        min-width: 1.6rem;
    }
    .nav-links a.active::after,
    .nav-links button.active::after { display: none; }
    .nav-links a.active,
    .nav-links button.active { color: var(--color-primario); font-weight: 600; }
    .nav-links a:focus-visible,
    .nav-links button:focus-visible { outline-offset: 2px; }

    .hamburger-menu { display: block; }
    .hamburger-menu.active span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
    .hamburger-menu.active span:nth-child(2) { opacity: 0; }
    .hamburger-menu.active span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }
}
@media (max-width: 599px) {
    .nav-links { width: 100%; border-left: 0; }
}
@media (max-width: 1023px) and (max-height: 500px) and (orientation: landscape) {
    .nav-links { padding-top: calc(var(--navbar-height) + 0.5rem); }
    .nav-links a,
    .nav-links button { min-height: 44px; padding: 0.45rem 0; font-size: 1.2rem; }
}

/* --- Overlay behind the drawer (JS toggles .visible) --- */
.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: var(--z-overlay);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.4s ease, visibility 0s linear 0.4s;
}
.mobile-menu-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.4s ease, visibility 0s;
}
/* Opened by the universes' Projects list: stays a transparent click-catcher
   (closes the list on outside tap) so the constellation isn't dimmed */
.mobile-menu-overlay.for-playlist { background-color: transparent; }

/* ---------------------------------------------------------
 * Page shell
 * --------------------------------------------------------- */
#main-content-container { transition: opacity 0.3s var(--ease-standard); }
#main-content-container.page-fading-out { opacity: 0; }

/* ---------------------------------------------------------
 * Content sections
 * --------------------------------------------------------- */
.content-section {
    padding: 6rem 2rem;
    max-width: var(--section-max);
    margin: 0 auto;
    position: relative;
}
#works,
#music,
#reel { z-index: var(--z-content); }

/* Soft divider between sections, aligned with the content inset */
#reel::before, #works::before, #music::before, #about::before, #contact::before {
    content: "";
    position: absolute;
    top: 0;
    left: 2rem;
    right: 2rem;
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    pointer-events: none;
}

.section-head { text-align: center; max-width: 640px; margin: 0 auto 3rem; }
#music .section-head { margin-bottom: 1.1rem; }
.section-eyebrow {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--color-primario);
    margin-bottom: 0.9rem;
    text-wrap: balance;
}
.section-sub { color: var(--color-texto-secundario); font-size: 1.05rem; font-weight: 300; text-wrap: balance; }
.section-foot { text-align: center; margin-top: 2.5rem; }

@media (max-width: 768px) {
    .content-section { padding: 4rem 1rem; }
}
@media (max-width: 599px) {
    .content-section { padding: 4.5rem 1.25rem; }
    #reel::before, #works::before, #music::before, #about::before, #contact::before { left: 1.25rem; right: 1.25rem; }
}
@media (min-width: 600px) and (max-width: 768px) {
    #reel::before, #works::before, #music::before, #about::before, #contact::before { left: 1rem; right: 1rem; }
}

/* ---------------------------------------------------------
 * Footer
 * --------------------------------------------------------- */
footer {
    text-align: center;
    padding: 3.5rem 2rem calc(2.5rem + var(--safe-bottom));
    background: transparent;
    color: var(--color-texto-secundario);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    z-index: 0;
}
.footer-inner { max-width: var(--section-max); margin: 0 auto; text-align: center; }
.footer-brand { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; letter-spacing: -0.01em; }
.footer-line { color: var(--color-texto-secundario); font-weight: 300; font-size: 0.95rem; margin-top: 0.3rem; }
.footer-copy { font-size: 0.8rem; color: var(--color-texto-secundario); margin-top: 1.6rem; }
/* Room for the floating play button (compact FAB layouts) */
@media (max-width: 1023px), (pointer: coarse), (max-height: 500px) and (orientation: landscape) {
    footer { padding-bottom: calc(2.5rem + 48px + 1rem + var(--safe-bottom)); }
}
