/* Navegación global. Todos los colores y fuentes provienen de Tatamias. */

.app-page {
    display: contents;
}

.app-menu-toggle {
    position: fixed;
    z-index: 80;
    right: 3.3vw;
    top: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg);
    color: var(--paper);
    box-shadow: 0 4px 18px color-mix(in srgb, var(--paper) 12%, transparent);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
}

    .app-menu-toggle svg {
        width: 18px;
        height: 18px;
        color: var(--orange);
    }

    .app-menu-toggle:hover {
        border-color: var(--orange);
    }

    .app-menu-toggle svg,
    .app-sidebar-close svg,
    .app-sidebar-link svg {
        fill: none;
        stroke: currentColor;
        stroke-width: 1.7;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

.app-sidebar-layer {
    position: fixed;
    z-index: 120;
    inset: 0;
    isolation: isolate;
}

    .app-sidebar-layer[hidden] {
        display: none;
    }

html:has(.app-sidebar-layer[data-open="true"]),
body:has(.app-sidebar-layer[data-open="true"]) {
    overflow: hidden;
    overscroll-behavior: none;
}

.app-sidebar-backdrop {
    position: absolute;
    z-index: 0;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    backdrop-filter: blur(5px);
    cursor: pointer;
}

.app-sidebar-panel {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 28px;
    width: min(360px, calc(100vw - 32px));
    height: 100%;
    padding: 30px 24px max(24px, env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    overscroll-behavior: contain;
    border-right: 1px solid var(--line);
    background: var(--bg);
    color: var(--paper);
    box-shadow: 12px 0 40px color-mix(in srgb, var(--paper) 10%, transparent);
    font-family: 'DM Sans', Arial, sans-serif;
    animation: app-sidebar-enter 0.22s ease-out;
}

.app-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.app-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -1px;
    white-space: nowrap;
}

    .app-sidebar-brand img {
        display: block;
        width: 40px;
        height: 40px;
        object-fit: contain;
        flex-shrink: 0;
    }

.app-sidebar-period {
    color: var(--orange);
}

.app-sidebar-close {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 8px;
    flex-shrink: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

    .app-sidebar-close:hover {
        border-color: var(--orange);
        color: var(--orange);
    }

    .app-sidebar-close svg {
        width: 20px;
        height: 20px;
    }

.app-sidebar-navigation {
    display: grid;
    align-content: start;
    gap: 8px;
}

.app-sidebar-caption,
.app-sidebar-signature {
    margin: 0;
    color: var(--muted);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 1.5px;
    line-height: 1.8;
}

.app-sidebar-caption {
    margin: 0 14px 12px;
}

.app-sidebar-link {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 54px;
    padding: 14px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    text-decoration: none;
    transition: background-color 0.16s, border-color 0.16s, color 0.16s;
}

    .app-sidebar-link svg {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }

    .app-sidebar-link:hover {
        background: color-mix(in srgb, var(--paper) 5%, transparent);
        color: var(--paper);
    }

    .app-sidebar-link.is-active {
        border-color: color-mix(in srgb, var(--orange) 24%, transparent);
        background: color-mix(in srgb, var(--orange) 8%, transparent);
        color: var(--orange);
        box-shadow: inset 3px 0 0 var(--orange);
        font-weight: 600;
    }

.app-sidebar-footer {
    display: grid;
    gap: 18px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.app-sidebar-access {
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.app-sidebar-preferences {
    display: grid;
    justify-items: start;
    gap: 12px;
    padding: 0 14px;
}

    .app-sidebar-preferences .app-sidebar-caption {
        margin: 0;
    }

.app-sidebar-footer .theme-switch {
    position: static;
    inset: auto;
    z-index: auto;
    width: fit-content;
}

.app-sidebar-signature {
    padding-left: 14px;
}

.app-menu-toggle:focus-visible,
.app-sidebar-close:focus-visible,
.app-sidebar-link:focus-visible,
.app-sidebar-theme button:focus-visible {
    outline: 2px solid var(--orange);
    outline-offset: 4px;
}

.app-visually-hidden,
.app-focus-guard {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

@keyframes app-sidebar-enter {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

@media (min-width: 2000px) {
    .app-menu-toggle {
        top: 42px;
    }
}

@media (max-width: 600px) {
    .app-menu-toggle {
        top: 22px;
        right: 6%;
    }

    .app-sidebar-panel {
        width: min(340px, calc(100vw - 28px));
        padding: 24px 20px max(24px, env(safe-area-inset-bottom, 0px));
        gap: 24px;
    }
}

@media (max-width: 400px) {
    .app-menu-toggle {
        width: 44px;
        padding: 10px;
    }

        .app-menu-toggle span {
            display: none;
        }
}

@media (prefers-reduced-motion: reduce) {
    .app-sidebar-panel {
        animation: none;
    }

    .app-sidebar-link {
        transition: none;
    }
}

/* Separación discreta entre páginas públicas y mantención. */
.app-sidebar-admin { margin-top: 16px; padding-top: 20px; border-top: 1px solid var(--line); }
.app-sidebar-admin .app-sidebar-caption { margin-bottom: 8px; }
.app-api-status { display: flex; align-items: flex-start; gap: 9px; padding: 14px 14px 0; border-top: 1px solid var(--line); }
.app-api-status p { margin: 0; color: var(--muted); font: 500 11px/1.6 'DM Sans', Arial, sans-serif; }
.app-api-status div > span { color: var(--muted); font: 9px/1.6 'IBM Plex Mono', monospace; }
.app-api-dot { width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.app-api-status[data-state="connected"] .app-api-dot { background: #4d946b; }
.app-api-status[data-state="unavailable"] .app-api-dot,
.app-api-status[data-state="connectionproblem"] .app-api-dot { background: var(--orange); }

@media (max-height: 800px) {
    .app-sidebar-panel { gap: 16px; padding-block: 20px; }
    .app-sidebar-navigation { gap: 4px; }
    .app-sidebar-link { min-height: 44px; padding: 10px 14px; }
    .app-sidebar-caption { margin-bottom: 8px; }
    .app-sidebar-admin { margin-top: 8px; padding-top: 12px; }
    .app-sidebar-footer { gap: 10px; padding-top: 12px; }
    .app-sidebar-access { padding-bottom: 12px; }
    .app-sidebar-preferences { gap: 8px; }
    .app-api-status { padding-top: 10px; }
}

/* Franja de país en páginas públicas: misma posición y escala del HERO. */
.app-page { position:relative; }
.tm-public-chile { --chile-width:clamp(20px,3.1vw,60px); inset-block:auto; top:max(96.2px,13svh); right:0; height:clamp(99px,15.75vw,468px); box-sizing:border-box; z-index:2; pointer-events:none; }
@media(min-width:601px) and (max-width:1000px) { .tm-public-chile { top:max(133.2px,18svh); height:16.2vw; } }
@media(max-width:600px) { .tm-public-chile { top:130px; height:16.74vw; } }
