/* ===== FUENTES ===== */
@font-face {
    font-family: 'Gill Sans MT Light';
    src: url('./data/fonts/gill-sans-mt-light.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Fidelma';
    src: url('./data/fonts/Fidelma.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ===== RESET Y BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Gill Sans MT Light', 'Gill Sans', 'Gill Sans MT', sans-serif;
    overflow-x: hidden;
    background: #000;
    color: #fff;
    min-height: 100vh;
}

/* ===== PAGE TRANSITIONS ===== */
body.page-exit {
    animation: pageExit 0.3s ease both;
    pointer-events: none;
}

@keyframes pageExit {
    to {
        opacity: 0;
        transform: scale(0.98);
    }
}

/* Menu close */
.menu-overlay.closing {
    animation: menuOverlayOut 0.2s ease both;
}

.menu-overlay.closing .menu-modal {
    animation: menuModalOut 0.2s ease both;
}

@keyframes menuOverlayOut {
    to { opacity: 0; }
}

@keyframes menuModalOut {
    to {
        opacity: 0;
        transform: translateY(10px) scale(0.97);
    }
}

/* ===== FONDO DINAMICO ===== */
#background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 0.8s ease-in-out;
}


/* ===== TRANSICION IRIS RADIAL (SWITCH DE MODO) ===== */
#mode-iris-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
}

/* ===== CONTENEDOR PRINCIPAL - GRID WINDOWS 10 ===== */
#projects-container {
    width: 100dvw;
    height: 100dvh;
    display: grid;
    grid-template-columns: repeat(var(--grid-cols, 6), var(--tile-size, 120px));
    grid-template-rows: repeat(var(--grid-rows, 6), var(--tile-size, 120px));
    gap: 3px;
    justify-content: center;
    align-content: center;
    overflow: hidden;
}

/* ===== ANIMACION ENTRADA TILES ===== */
@keyframes tileIn {
    from {
        opacity: 0;
        transform: scale(0.85);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== TILES DE PROYECTO (GLASSMORPHISM) ===== */
.project-card {
    position: relative;
    border-radius: 0;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease, background 0.2s ease;
    animation: tileIn 0.3s ease both;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.project-card:hover {
    transform: scale(1.04);
    filter: brightness(1.15);
    z-index: 2;
    background: rgba(var(--tile-rgb), 0.75) !important;
}

.project-card:active {
    transform: scale(0.97);
}

/* Thumbnail de fondo del tile */
.project-thumb {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    opacity: 0.35;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.project-card:hover .project-thumb {
    opacity: 0.5;
}

.project-card-inner {
    width: 100%;
    height: 100%;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    position: relative;
    z-index: 1;
}

.project-icon {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 24px;
    height: 24px;
    filter: invert(1) brightness(2);
    opacity: 0.7;
}

.project-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== TILES ESPECIALES (SWITCH, IDIOMA) — misma estructura que project-card ===== */
.special-tile {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease, background 0.2s ease;
    animation: tileIn 0.3s ease both;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    color: #fff;
    font-family: 'Gill Sans MT Light', 'Gill Sans', 'Gill Sans MT', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: lowercase;
    letter-spacing: 0.03em;
}

.special-tile-inner {
    width: 100%;
    height: 100%;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    position: relative;
    z-index: 1;
}

img.special-tile-icon {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 24px;
    height: 24px;
    opacity: 0.7;
}

span.special-tile-icon.lang-icon {
    position: absolute;
    top: 8px;
    left: 10px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    opacity: 0.8;
}

.special-tile:hover {
    transform: scale(1.04);
    filter: brightness(1.15);
    background: rgba(var(--tile-rgb), 0.75) !important;
}

.special-tile:active {
    transform: scale(0.97);
}


/* ===== REPRODUCTOR DE AUDIO (CUADRADO AMBIENCE) ===== */
#audio-player {
    display: block !important; /* evitar que .hidden generico lo oculte con display:none */
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    width: 260px;
    height: 260px;
    z-index: 200;
    transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s ease;
    cursor: grab;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #000;
}

#audio-player:active {
    cursor: grabbing;
}

#audio-player.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
    visibility: hidden;
}

#audio-player:not(.hidden) {
    visibility: visible;
}

#player-canvas,
#player-canvas-webgl {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

#player-canvas-webgl {
    display: none; /* visible solo cuando Butterchurn esta activo */
}

/* ===== OVERLAY: OCULTO POR DEFECTO, VISIBLE EN HOVER O CLASE ===== */
.player-overlay {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

/* Mostrar en hover (desktop) o con clase controls-visible (movil tap) */
#audio-player:hover .player-overlay,
#audio-player.controls-visible .player-overlay {
    opacity: 1;
    pointer-events: auto;
}

.player-drag-handle {
    display: flex;
    justify-content: space-between;
    padding: 6px 8px;
    cursor: grab;
    min-height: 28px;
}

.player-drag-handle:active {
    cursor: grabbing;
}

.player-fullscreen {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 2px 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
    line-height: 1;
}

.player-fullscreen:hover {
    color: #fff;
}

.player-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.35);
    font-size: 1rem;
    cursor: pointer;
    padding: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
    line-height: 1;
}

.player-close:hover {
    color: #fff;
}

.player-center {
    padding: 0 14px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#audio-player .track-title {
    font-size: 0.8rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#audio-player .track-project {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.3);
}

.player-bottom {
    padding: 0 10px 10px;
}

.player-progress-mini {
    margin-bottom: 6px;
}

#progress-bar {
    width: 100%;
    height: 3px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    cursor: pointer;
}

#progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    cursor: pointer;
}

#progress-bar::-moz-range-thumb {
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.player-controls {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    column-gap: 4px;
    margin-bottom: 4px;
}

.player-controls-main {
    display: flex;
    gap: 4px;
    justify-content: center;
    align-items: center;
}

.control-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

#playlist-btn {
    justify-self: start;
}

.volume-control {
    position: relative;
    justify-self: end;
}

#volume-btn {
    justify-self: end;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.control-btn:active {
    background: rgba(255, 255, 255, 0.04);
}

#play-btn {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
}

.volume-popover {
    position: absolute;
    right: -6px;
    bottom: calc(100% + 6px);
    width: 40px;
    padding: 10px 6px 12px;
    background: rgba(12, 12, 18, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 3;
}

#volume-slider {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 28px;
    height: 92px;
    margin: 0;
    cursor: pointer;
    touch-action: none;
    accent-color: rgba(255, 255, 255, 0.7);
}

.player-time {
    text-align: center;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.25);
    font-variant-numeric: tabular-nums;
}

.time-sep {
    margin: 0 2px;
}

/* ===== FULLSCREEN ===== */
#audio-player.is-fullscreen {
    position: fixed;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0;
    z-index: 99999;
}

/* ===== PRESET NAV ===== */
.preset-nav {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
    padding: 6px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.35);
    text-transform: lowercase;
    background: rgba(10, 10, 15, 0.98);
    position: sticky;
    top: 0;
    z-index: 1;
}

.preset-nav-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    transition: color 0.15s ease;
}

.preset-nav-btn:hover {
    color: #fff;
}

.preset-cycle-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.68rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    transition: color 0.15s ease;
}

.preset-cycle-btn:hover {
    color: #fff;
}

.preset-nav-name {
    flex: 1;
    min-width: 0;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 8px 0 4px;
}

/* ===== PLAYLIST PANEL ===== */
.playlist-panel {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 100%;
    max-height: 240px;
    background: rgba(10, 10, 15, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: none;
    overflow-y: auto;
    z-index: 2;
}

#audio-player.is-fullscreen .playlist-panel {
    bottom: 0;
    max-height: min(64vh, 520px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.playlist-panel.hidden {
    display: none;
}

.playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.35);
    text-transform: lowercase;
    background: rgba(10, 10, 15, 0.98);
}

.playlist-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
}

.playlist-close:hover {
    color: #fff;
}

.playlist-items {
    padding: 2px 0;
}

.playlist-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    cursor: pointer;
    transition: background 0.1s ease;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.5);
}

.playlist-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.playlist-item.active {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
}

.pl-num {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.2);
    min-width: 16px;
    font-variant-numeric: tabular-nums;
}

.pl-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== TILE MENU (HOME) ===== */
.menu-tile .menu-tile-inner {
    align-items: flex-end;
    justify-content: flex-end;
}

/* ===== MENU OVERLAY (HOME) ===== */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: menuOverlayIn 0.3s ease both;
}

@keyframes menuOverlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.menu-modal {
    max-width: 540px;
    width: calc(100% - 16dvw);
    box-sizing: border-box;
    padding: 8dvh 2rem;
    border: 16px solid transparent;
    animation: menuModalIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: 0.05s;
}

@keyframes menuModalIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.menu-items {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
}

.menu-item {
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Fidelma', serif;
    font-size: 1.8rem;
    font-weight: normal;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 0.02em;
    transition: color 0.2s ease;
    text-align: center;
    line-height: 1.3;
}

.menu-item:hover {
    color: #fff;
}

/* ===== UTILIDADES ===== */
.hidden {
    display: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    #projects-container {
        gap: 2px;
        padding: 1rem;
    }

    .project-icon {
        width: 20px;
        height: 20px;
    }

    .project-title {
        font-size: 0.65rem;
    }

    #audio-player {
        width: 180px;
        height: 180px;
        bottom: 1rem;
        left: 1rem;
    }

    .control-btn {
        width: 26px;
        height: 26px;
        font-size: 0.65rem;
    }

    #volume-slider {
        height: 74px;
        width: 32px;
    }

    #play-btn {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }

    .menu-modal {
        width: calc(100% - 3rem);
        padding: 6dvh 1.5rem;
    }

    .menu-item {
        font-size: 1.4rem;
    }

    .menu-items {
        gap: 2rem;
    }
}

@media (max-width: 480px) {
    #projects-container {
        padding: 0.8rem;
    }

    .special-tile {
        font-size: 0.6rem;
    }

    .menu-modal {
        width: calc(100% - 5rem);
        padding: 5dvh 1.2rem;
    }
}
