/* ==========================================================================
   1. TOKENS DE DISEÑO SOBERANO (NEGRO ABSOLUTO OLED)
   ========================================================================== */
:root {
    color-scheme: dark;
    --bg: #000000;
    --text: #f5efe4;
    --muted: #8e867b;
    --quiet: rgba(255, 255, 255, 0.25);
    --line: rgba(255, 255, 255, 0.06);
    
    /* Tipografías Editoriales */
    --font-main: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-serif: Georgia, Cambria, "Times New Roman", Times, serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    /* ESTADO NEUTRO INICIAL: El sistema nace en el color hueso base */
    --acento: #f5efe4; 
    --acento-contrast: #000000;
}

/* Matriz de Acentos Cromáticos Sutiles */
:root[data-accent="blanco"]{
  --acento:#FFFFFF;
}

:root[data-accent="sangre"]{
  --acento:#C73A4A;
  --acento-contrast: #ffffff;
}

:root[data-accent="mostaza"]{
  --acento:#B78627;
  --acento-contrast: #ffffff;
}

:root[data-accent="tierra"]{
  --acento:#6D7C50;
  --acento-contrast: #ffffff;
}

:root[data-accent="cobre"]{
  --acento:#248692;
  --acento-contrast: #ffffff;
}

:root[data-accent="amatista"]{
  --acento:#7D5AA1;
  --acento-contrast: #ffffff;
}

/* ==========================================================================
   2. REGLAS BASE Y ALINEACIÓN AXIAL
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    background-color: var(--bg);
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 48px; /* Margen de seguridad para no tapar contenido con la barra fija */
}

/* --- BLOQUEO DE SCROLL NATIVO REFORZADO (MULTIDISPOSITIVO) --- */
html:has(dialog[open]),
body:has(dialog[open]) {
    overflow: hidden !important;
    height: 100vh !important;
    height: 100dvh !important; /* Dinámico para absorber barras de navegadores móviles */
    position: fixed;           /* Anclaje estructural absoluto */
    width: 100%;
    touch-action: none;        /* Desactiva el arrastre y scroll táctil por hardware */
}

/* 2. TRUCO DE SIMULACIÓN DE BACKDROP (Para pruebas sin JavaScript)
   Inyectamos una capa absoluta sobre todo el viewport acoplada al body */
body:has(dialog[open])::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    
    /* CONTROL DE OPACIDAD ABSOLUTA: 
       Aumentamos a 0.95 (95% negro) para extinguir casi por completo el contenido trasero */
    background: rgba(0, 0, 0, 0.950) !important; 
    
    /* Blur removido: la capa ya es opaca, el blur duplicado generaba una costura de renderizado GPU en el borde redondeado */
    z-index: 99998 !important; /* Se posiciona inmediatamente debajo del dialog (z-index: 100) */
}

.shell {
    width: min(960px, calc(100% - 48px));
    margin: 0 auto;
}

h1, h2, h3, h4 {
    font-family: var(--font-serif);
    font-weight: normal;
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

/* ==========================================================================
   3. CABECERA DEL SITIO (SITE HEADER)
   ========================================================================== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
}

.header-layout {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 32px;
    min-height: 64px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark svg {
    width: 48px;
    height: 48px;
    display: block;
    stroke: var(--acento);
    stroke-width: 1.5px;
}

.brand-copy {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.brand-tagline {
    color: var(--muted);
    font-size: 0.72rem;
    font-family: var(--font-mono);
}

.main-nav {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-right: 16px;
}

.nav-link {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    padding: 6px 12px;
    border-radius: 4px;
    transition: color 140ms ease;
}

.nav-link:hover { color: var(--text); }
.nav-link.is-active { color: var(--acento); font-weight: 700; }

.controls-group { display: flex; align-items: center; }

/* ==========================================================================
   4. HERO PLANO Y CONTROLADO
   ========================================================================== */
.hero-section {
    border-bottom: 1px solid var(--line);
    padding: 48px 0 40px; 
}

.hero-layout {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.daily-briefing {
    background: transparent !important;
    padding: 0 !important;
    min-height: auto !important;
    border: none !important;
    max-width: 760px;
}

.eyebrow {
    color: var(--acento);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.daily-briefing h1 {
    font-size: 2.4rem;
    line-height: 1.15;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

.briefing-dek {
    color: var(--muted);
    font-size: 0.98rem;
    line-height: 1.6;
    margin-bottom: 20px;
}

.briefing-meta {
    display: flex;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

.briefing-meta span {
    border: 1px solid var(--line);
    padding: 2px 8px;
    border-radius: 3px;
    color: var(--muted);
}

.method-panel {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 20px 0 0 0 !important;
    border-top: 1px dashed var(--line) !important;
    max-width: 500px;
}

.method-panel h2 {
    font-size: 1rem;
    font-family: var(--font-main);
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 8px;
}

.method-panel ol {
    list-style: none;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--quiet);
    background: transparent !important;
}

.method-panel ol li {
    background: transparent !important;
    margin-bottom: 4px;
    display: flex;
    gap: 8px;
}

.method-panel ol li::before {
    content: "0" counter(my-counter) ".";
    counter-increment: my-counter;
    color: var(--acento);
    font-weight: 700;
}
.method-panel ol { counter-reset: my-counter; }

/* ==========================================================================
   5. ARCHIVO EDITORIAL SIMÉTRICO (CORREGIDO)
   ========================================================================== */
.briefings-section {
    padding: 48px 0;
    border-bottom: 1px solid var(--line);
}

.section-heading { margin-bottom: 32px; }
.section-heading h2 { font-size: 1.5rem; margin-top: 4px; }

.briefing-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 32px;
}

.briefing-card {
    background: transparent !important;
    border: none !important;
    border-top: 1px solid var(--line) !important;
    padding: 20px 12px 12px 12px !important; /* Cojín interno para el resalte */
    display: flex;
    flex-direction: column;
    position: relative; /* Anclaje para la expansión del enlace */
    transition: background-color 180ms ease, border-top-color 180ms ease;
    cursor: pointer;
    margin: 0 -12px; /* Alineación axial exacta */
}

/* ESTADO DE RESALTE: Forzamos la mutación rompiendo la inmutabilidad base */
.briefing-card:hover {
    background-color: rgba(255, 255, 255, 0.02) !important;
    border-top-color: var(--acento) !important;
}

.briefing-card h3 { font-size: 1.25rem; line-height: 1.2; margin: 8px 0; }
.briefing-card h3 a:hover { color: var(--acento); }

/* Corregimos el contraste del texto para que no sea estático */
.briefing-card p:not(.card-axis) { 
    color: var(--muted); 
    font-size: 0.88rem; 
    line-height: 1.5; 
    margin-bottom: 16px; 
    transition: color 180ms ease;
}

.briefing-card:hover p:not(.card-axis) {
    color: var(--text); /* El texto se ilumina sutilmente al entrar en la tarjeta */
}

/* EL TRUCO MAESTRO: Expansión absoluta de la superficie interactiva */
.briefing-card h3 a::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1; /* Cubre el lienzo de la tarjeta por completo */
}

.card-meta {
    margin-top: auto;
    display: flex;
    gap: 12px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--quiet);
    border: none !important;
    padding: 0;
}

/* ==========================================================================
   6. SECCIÓN ACERCA DE / INTERNAS
   ========================================================================== */
.about-section {
    padding: 48px 0;
    border: none !important;
    max-width: 640px;
}
.about-section h2 { font-size: 1.5rem; margin: 6px 0 12px; }
.about-section p { color: var(--muted); font-size: 0.9rem; }

.empty-state {
    border: 1px solid var(--line);
    color: var(--muted);
    padding: 24px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

/* ==========================================================================
   7. RESPONSIVE DESIGN & ANIMACIÓN EN EQUIS (X) MATEMÁTICA
   ========================================================================== */
@media (max-width: 920px) {
    .menu-toggle {
        display: flex;
        position: relative;
        width: 36px;
        height: 36px;
        background: transparent;
        border: 1px solid var(--line);
        border-radius: 4px;
        cursor: pointer;
        align-items: center;
        justify-content: center;
    }

    .hamburger-line {
        position: absolute;
        width: 16px;
        height: 1px;
        background-color: var(--text);
        transition: transform 180ms cubic-bezier(0.4, 0, 0.2, 1);
    }

    .hamburger-line:nth-child(1) { transform: translateY(-3px); }
    .hamburger-line:nth-child(2) { transform: translateY(3px); }

    .menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(1) {
        transform: translateY(0) rotate(45deg);
    }
    .menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(2) {
        transform: translateY(0) rotate(-45deg);
    }

    .header-layout { grid-template-columns: 1fr auto; }
    
    .main-nav {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        height: calc(100vh - 74px);
        background: #000000;

        flex-direction: column;
        justify-content: flex-start !important;
        align-items: flex-end;   /* Cambiado de flex-start a flex-end para empujar los bloques a la derecha */
        text-align: right;        /* Asegura que el texto interno de los links se justifique a la derecha */
        
        padding: 24px;
        gap: 12px;

        opacity: 0;
        transform: translateY(-10px);
        pointer-events: none;
        transition: opacity 150ms ease, transform 150ms ease;
        border-bottom: 1px solid var(--line);
    }
    
    .menu-toggle[aria-expanded="true"] ~ .main-nav,
    .main-nav.is-open {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }

    /* Si tus enlaces tienen subtextos o iconos internos, esto asegura que todo el contenedor se estructure simétricamente */
    .nav-link {
        text-align: right;
        width: 100%;
    }
}

/* Blindaje absoluto contra filtraciones visuales y elementos vacíos */
[hidden], .menu-toggle { 
    display: none !important; 
}

@media (max-width: 920px) {
    .menu-toggle { 
        display: flex !important; 
    }
}

/* ==========================================================================
   8. SISTEMA DE TELEMETRÍA INFERIOR SOBERANO
   ========================================================================== */
.sys-telemetry {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #000000;
    border-top: 1px solid var(--line);
    z-index: 200;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    height: 32px;
    display: flex;
    align-items: center;
}

.telemetry-layout {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sys-status {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
}

.status-indicator {
    width: 6px;
    height: 6px;
    background-color: var(--acento);
    border-radius: 50%;
    display: inline-block;
}

.mono-text {
    letter-spacing: 0.02em;
}

.settings-root {
    position: relative;
    display: flex;
    align-items: center;
}

.settings-menu-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    cursor: pointer;
    padding: 0 4px;
    transition: color 140ms ease;
}

.settings-menu-btn:hover {
    color: var(--text);
}

.settings-submenu {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: #0a0a0a;
    border: 1px solid var(--line);
    padding: 6px 8px;
    border-radius: 4px;
    gap: 8px;
    
    /* Control de renderizado por estado puro */
    display: none; 
    visibility: hidden;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 140ms ease, transform 140ms ease;
}

.settings-submenu[data-state="open"] {
    display: flex;
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================================================
   INTERRUPTOR DE TELEMETRÍA (CON ICONO VECTORIAL)
   ========================================================================== */
.settings-toggle-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 6px 8px;
    transition: color 150ms ease;

    /* COMPOSICIÓN AXIAL: Centrado perfecto del vector y el texto */
    display: inline-flex;
    align-items: center;
    gap: 6px; /* Separación matemática entre el icono y el corchete */
}

/* Modificador dinámico heredado del ecosistema de la plaza */
.settings-toggle-btn:hover {
    color: var(--acento);
}

/* Restricción dimensional estricta para el SVG */
.icon-settings {
    width: 14px;  /* Proporción áurea respecto al tamaño de la fuente mono */
    height: 14px;
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Micro-animación cinética: El engranaje rota levemente al posar el cursor */
.settings-toggle-btn:hover .icon-settings {
    transform: rotate(45deg);
}

.accent-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    padding: 0;
    transition: transform 100ms ease;
}
.accent-dot:hover { border-color: var(--text); transform: scale(1.1); }
.accent-dot.is-active { border-color: var(--text); transform: scale(1.15); }
.accent-dot[data-accent="blanco"]  { background: #ffffff; }
.accent-dot[data-accent="sangre"]  { background: #C73A4A; }
.accent-dot[data-accent="mostaza"] { background: #B78627; }
.accent-dot[data-accent="tierra"]  { background: #6D7C50; }
.accent-dot[data-accent="cobre"]   { background: #248692; }
.accent-dot[data-accent="amatista"] { background: #7D5AA1; }

/* ==========================================================================
   9. PORTAL SOBERANO & TELEMETRÍA
   ========================================================================== */

.portal-setup {
    margin: 12px 0 12px 0;
    padding-top: 16px;
    border-top: 1px dashed var(--line);
    text-align: center;
}

/* Portal Modal Estricto (Cero Desplazamiento) */
.portal-gate {
    background: #050505 !important;
    color: var(--text);
    border: 1px solid var(--line);
    padding: 32px 40px; /* Reducción sutil para maximizar el área útil */
    border-radius: 13px;

    width: 90%;
    max-width: 580px;
    min-height: 420px;
    height: auto;
    max-height: 90vh;
    
    overflow: hidden !important; /* SOLUClÓN: Capa de contención absoluta contra scrollbars */
    box-shadow: 0 20px 50px rgba(0,0,0,0.9);

    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 99999;
}

/* Clausura del anillo de enfoque nativo del navegador (Focus Reset) */
#portalGate:focus,
#portalGate:focus-visible {
    outline: none !important;
}

.portal-gate button:focus {
    outline: none !important;
    box-shadow: none !important;
}

.setup-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--muted);
    letter-spacing: 1.5px;
    margin-bottom: 12px;
    text-transform: uppercase;
}

/* Grupo de Acentos (Alineación compacta de las burbujas cromáticas) */
.portal-accent-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 4px;
}

/* Forzar simetría interactiva en los círculos dentro del portal */
.portal-accent-group .accent-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

/* El cambio a 'activo' es instantáneo: evita un frame residual visible al cambiar de slide a medio camino de una transición de escala */
.portal-accent-group .accent-dot.is-active {
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

/* Feedback visual instantáneo cuando una opción es la activa en el sistema */
.portal-accent-group .accent-dot.is-active {
    border-color: var(--text) !important;
    transform: scale(1.25);
    box-shadow: 0 0 12px var(--acento);
}

/* --- DIFUMINADO DEL ENTORNO (BACKDROP) --- */
.portal-gate::backdrop {
    background: rgba(0, 0, 0, 0.867) !important; /* Capa oscura traslúcida */
    backdrop-filter: blur(8px) !important;       /* Difuminado cinético por hardware */
    transition: backdrop-filter 0.3s ease;
}

.portal-title {
    font-size: clamp(2.2rem, 5vw, 3rem);
    font-family: var(--font-serif);
    margin: 12px 0 10px 0;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.portal-text {
    font-size: 1rem;
    color: var(--muted);
    line-height: 1.65;
    max-width: 420px;
}



.portal-body p {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--muted);
    margin-bottom: 16px;
}

.portal-actions {
    justify-content: center;
    margin-top: 18px;
    text-align: center;
}

.portal-btn {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
    padding: 10px 20px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 150ms ease;
}

.portal-btn:hover {
    border-color: var(--acento);
    background: rgba(255, 255, 255, 0.02);
}

/* Botón de Ejecución Definitivo (Sólido y Reactivo al Acento) */
.portal-btn-execute {
    background: var(--acento) !important;
    color: var(--acento-contrast) !important;
    border: 12px solid var(--acento) !important;
    padding: 40px 24px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    border-radius: 4px;
    
    /* Animación de feedback cinético al posar el cursor */
    transition: opacity 250ms ease, transform 150ms ease, box-shadow 150ms ease;

    padding-bottom: 0;
    padding-top: 0;
    height: auto;
    line-height: 1.5;

    vertical-align: baseline;
}

/* ==========================================================================
   SISTEMA DE BARRIDO CINEMÁTICO DIRECCIONAL BIFÁSICO
   ========================================================================== */

/* --- AVANCE (Paso 2 → Paso 3) --- */
/* 1. CONTINUAR se borra hacia la derecha disolviéndose en el eje axial */
dialog[data-current-step="3"][data-direction="forward"] #nextStep {
    animation: barrerSalidaHaciaDerecha 220ms cubic-bezier(0.4, 0, 1, 1) forwards;
}
/* 2. ENTRAR emerge de derecha a izquierda tras una ventana de 120ms de vacío */
dialog[data-current-step="3"][data-direction="forward"] #acceptManifesto {
    animation: barrerEntradaDesdeDerecha 340ms cubic-bezier(0.16, 1, 0.3, 1) 120ms both;
}

/* --- RETROCESO ANALÓGICO (Paso 3 → Paso 2) --- */
/* 1. ENTRAR se contrae y repliega hacia el extremo derecho */
dialog[data-current-step="2"][data-direction="backward"] #acceptManifesto {
    animation: barrerSalidaHaciaDerecha 220ms cubic-bezier(0.4, 0, 1, 1) forwards;
    opacity: 1; /* Forzado de render dinámico durante la salida */
}
/* 2. CONTINUAR vuelve a florecer desde el eje axial hacia la izquierda */
dialog[data-current-step="2"][data-direction="backward"] #nextStep {
    animation: barrerEntradaDesdeDerecha 340ms cubic-bezier(0.16, 1, 0.3, 1) 120ms both;
}

/* --- MATRICES DE TRANSFORMACIÓN GEOMÉTRICA DE CLIP-PATH --- */
@keyframes barrerSalidaHaciaDerecha {
    0% {
        clip-path: inset(0 0 0 0);
        opacity: 1;
    }
    100% {
        clip-path: inset(0 0 0 100%); /* Desplazamiento del umbral izquierdo al límite derecho */
        opacity: 0;
    }
}

@keyframes barrerEntradaDesdeDerecha {
    0% {
        clip-path: inset(0 0 0 100%);
        opacity: 0;
    }
    100% {
        clip-path: inset(0 0 0 0); /* Apertura absoluta del lienzo */
        opacity: 1;
    }
}

.portal-btn-execute:hover {
    box-shadow: 0 0 16px var(--acento); /* Brillo cuántico del color seleccionado */
}

.portal-btn-execute:active {
    box-shadow: 0 0 10px var(--acento);
}

/* Adaptación responsiva básica */
@media (max-width: 768px) {
    .portal-gate { 
        width: calc(100% - 32px); 
        padding: 24px 20px;
        overflow: hidden !important;
    }
}

/* BARRA DE PROGRESO SUTIL */
.portal-progress-bar {
    width: 100%;
    height: 2px;
    background: var(--line);
    position: absolute;
    top: 0;
    left: 0;
}
.progress-indicator {
    height: 100%;
    background: var(--acento);
    width: 33.33%; /* Cambia dinámicamente vía JS (33% -> 66% -> 100%) */
    transition: width 200ms ease, background-color 150ms ease;
}

/* TRATAMIENTO DE SLIDES */
.portal-content-wrapper {
    padding-bottom: 96px; /* Reserva espacio para nav absoluta ahora que el alto es fluido */
}

.portal-slide {
    display: none; /* Por defecto ocultos */
    animation: fadeIn 250ms ease forwards;
}

/* Controladores de visibilidad pura basados en el estado del diálogo */
dialog[data-current-step="1"] [data-slide="1"] { display: block; }
dialog[data-current-step="2"] [data-slide="2"] { display: block; }
dialog[data-current-step="3"] [data-slide="3"] { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* CONTENEDOR DE BOTONES INFERIORES */
.portal-navigation {
    position: absolute;
    bottom: 55px;
    left: 40px;
    right: 40px;
    height: 32px;

    /* Nueva arquitectura de alineación */
    display: flex;
    align-items: center; /* Centrado vertical */
    justify-content: space-between;

}

/* Pila Grid: ambos botones de avance comparten una sola celda */
.portal-action-stack {
    display: grid;
    grid-template-areas: "stack";
    align-items: center;
    justify-items: end;
    min-width: 140px; /* Ancho del botón sólido más grande, evita resize del clip-path */
}

#nextStep, #acceptManifesto {
    grid-area: stack;
    margin: 0 !important;
    transition: transform 150ms ease, box-shadow 150ms ease;
}

/* Modificadores adaptativos para preservar tu feedback activo en el botón sólido */
#acceptManifesto:hover {
    box-shadow: 0 0 18px var(--acento) !important;
}
#acceptManifesto:active {
    box-shadow: 0 0 10px var(--acento) !important;
}

/* --- ESTADOS NEUTROS BASE (Evitan filtraciones visuales previas) --- */
dialog[data-current-step="1"] #acceptManifesto,
dialog[data-current-step="2"] #acceptManifesto {
    opacity: 0;
    pointer-events: none;
}

dialog[data-current-step="3"] #nextStep {
    opacity: 0;
    pointer-events: none;
}

.portal-nav-btn {
    background: none;
    border: none;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    cursor: pointer;
    letter-spacing: 1px;
}
.portal-nav-btn:hover { color: var(--text); }
#prevStep  { left: 0; line-height: 1}
/* REMOCIÓN DE DIRECCIONAMIENTO INERTE (Flexbox ya maneja el empuje a la derecha) */
#acceptManifesto {
    right: 0; 
}

#nextStep {
    padding-right: 36px; /* 24px padding + 12px border de #acceptManifesto: ancla la flecha a la misma coordenada */
}

.portal-version {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--muted);
    opacity: 0.35;
    letter-spacing: 0.08em;
    pointer-events: none;
}

/* ==========================================================================
   INTERVENCIÓN DE DISEÑO: ARQUITECTURA GEOMÉTRICA DE LA SLIDE 3
   ========================================================================== */

/* Contenedor general de sub-bloques de configuración (Acentos y Datos) */
.portal-config-block {
    margin-top: 28px;
    margin-bottom: 32px;
    border-left: 1px solid var(--line);
    padding-left: 16px;
    text-align: left; /* Garantiza la alineación axial izquierda */
}

.portal-config-block:last-of-type {
    margin-bottom: 8px; /* Restringe el empuje sobre los botones inferiores */
}

/* Etiquetas de control monospaciadas */
.config-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--muted);
    letter-spacing: 1px;
    margin-bottom: 14px;
    text-transform: uppercase;
}

.reader-block {
    padding: 32px 0;
    border-bottom: 1px solid var(--line);
    max-width: 680px;
}
.reader-block h3 {
    font-size: 1.15rem;
    margin-bottom: 12px;
}
.reader-block p {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.7;
}
.source-link {
    color: var(--acento);
}
.source-link:hover {
    text-decoration: underline;
}

/* TIPOS EDITORIALES */
:root[data-type="manifiesto"]    { --tipo-color: #000000; }
:root[data-type="investigacion"] { --tipo-color: #C73A4A; }
:root[data-type="analisis"]      { --tipo-color: #B78627; }
:root[data-type="cronica"]       { --tipo-color: #6D7C50; }
:root[data-type="reflexion"]     { --tipo-color: #248692; }
:root[data-type="memoria"]       { --tipo-color: #7D5AA1; }
:root[data-type="columna"]       { --tipo-color: #FFFFFF; }

.type-tag {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 2px;
    display: inline-block;
}

/* ==========================================================================
   HOME — SCROLL SNAP & LAYOUT
   ========================================================================== */

#mainScroll {
    height: calc(100dvh - 64px - 32px);
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

.home-section {
    height: 100%;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    padding: 32px 0 12px;
    border-bottom: 1px solid var(--line);
    overflow: hidden;
}

.home-layout {
    flex: 1;
    display: grid;
    grid-template-rows: 1fr auto;
    overflow: hidden;
}

/* HERO */
.home-hero {
    padding: 20px 0;
    border-top: 1px solid var(--line);
    overflow: hidden;
}

.briefing-card--hero {
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    position: relative;
}

.briefing-card--hero h2 {
    font-size: clamp(1.5rem, 4vw, 2.4rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin: 10px 0 12px;
}

.briefing-card--hero h2 a::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}

.briefing-card--hero .briefing-dek {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 12px;
}

/* ROW DE DOS */
.home-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    border-top: 1px solid var(--line);
    background: var(--line);
    margin: 0 -12px;
}

.briefing-card--small {
    background: var(--bg);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    position: relative;
    transition: background-color 150ms ease;
}

.briefing-card--small:hover {
    background: rgba(255,255,255,0.02);
}

.briefing-card--small h3 {
    font-size: 0.9rem;
    line-height: 1.3;
    margin: 4px 0;
}

.briefing-card--small h3 a::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* SCROLL HINT */
.scroll-hint {
    text-align: center;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 2px;
    padding: 10px 0 4px;
    flex-shrink: 0;
    animation: hintBounce 2s ease-in-out infinite;
}

@keyframes hintBounce {
    0%, 100% { opacity: 0.4; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(3px); }
}

/* ARCHIVO */
.archive-section {
    min-height: 100%;
    scroll-snap-align: start;
    padding: 48px 0;
}

@media (max-width: 480px) {
    .home-row {
        grid-template-columns: 1fr;
    }
}
 
/* CONTROLES DEL HEADER */
.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
 
/* BOTÓN CONFIG — solo desktop */
.config-btn {
    display: flex; /* Activación estructural en escritorio */
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--muted);
    cursor: pointer;
    padding: 6px 8px;
    transition: color 140ms ease, border-color 140ms ease;
    align-items: center;
}
 
.config-btn:hover { color: var(--text); border-color: var(--acento); }
.config-btn .icon-settings { width: 14px; height: 14px; }
.config-btn[aria-expanded="true"] .icon-settings { transform: rotate(45deg); }
 
/* Ocultar la X globalmente por defecto (Móvil no la renderiza) */
.nav-config-close {
    display: none;
}

/* NAV CONFIG — sección dentro del nav */
.nav-config {
    position: fixed; /* Posicionamiento absoluto respecto al Viewport global */
    z-index: 99999;
    background: #050505;
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 32px 40px;
    width: 400px;
    max-width: 90vw;
    height: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    gap: 24px;
    
    /* Estado Neutro Inicial: Oculto y permeable a clicks traseros */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-10px);
    transition: opacity 200ms ease, transform 200ms ease, visibility 200ms ease;
}

/* Mutación de Estado Activo inducido por JS */
.nav-config.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}
 
.nav-config-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}
 
.nav-accent-group {
    gap: 14px;
    align-items: right;
    flex-wrap: wrap;
    justify-content: flex-end;
}
 
.nav-accent-group .accent-dot {
    width: 20px;
    height: 20px;
}
 
.nav-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
 
.nav-toggle-label {
    font-size: 0.88rem;
    color: var(--text);
    align-items: right;
}
 
/* MÓVIL: config visible dentro del nav overlay abierto */
@media (max-width: 920px) {
    .config-btn { display: none !important; }
 
    .nav-config {
        position: static !important; /* Desanclaje del entorno flotante para integrarse al flujo */
        width: 100%;
        max-width: 100%;
        padding: 16px 0;
        box-shadow: none;
        border: none;
        border-top: 1px dashed var(--line);
        border-radius: 0;
        
        /* Visibilidad orgánica y fluida dentro del menú hamburguesa */
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        transform: none !important;
    }

    .main-nav{
        justify-content: space-between;
    }

    .main-nav.is-open .nav-config {
        display: flex;
        margin-top: auto;
        padding-bottom: 32px;
    }
}
 
/* ==========================================================================
   DESKTOP: Configuración optimizada ( styles.css )
   ========================================================================== */
@media (min-width: 921px) {
    .config-btn { display: flex; }

    /* Capa de oscurecimiento sutil de fondo */
    .nav-config.is-open::before {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.4); /* Un velo más sutil para no perder contexto */
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: -1;
    }

    .nav-config {
        /* Cambiamos de fixed absoluto centrado a posicionamiento dinámico por JS */
        position: fixed !important; 
        top: 0;
        left: 0;
        
        background: #050505;
        border: 1px solid var(--line);
        border-radius: 13px;
        padding: 40px;

        width: 420px;
        max-width: 90vw;
        height: auto;

        z-index: 99999;
        gap: 24px;
        box-shadow: 0 20px 50px rgba(0,0,0,0.9);
        flex-direction: column;
        
        /* Animación sobria de aparición suave (fade-in) */
        opacity: 0;
        transition: opacity 120ms ease;
    }

    .nav-config.is-open { 
        display: flex; 
        opacity: 1;
    }

    /* POSICIONAMIENTO MATEMÁTICO DE LA X */
    .nav-config-close {
        display: block !important;
        position: absolute !important;
        /* Fijamos la X a una distancia estándar y cómoda dentro de la tarjeta */
        top: 24px !important;
        right: 24px !important;
        background: transparent !important;
        border: none !important;
        color: var(--muted);
        font-family: var(--font-main);
        font-size: 1.1rem;
        cursor: pointer;
        transition: color 140ms ease;
        padding: 4px;
        z-index: 100000;
        width: 24px !important;  /* Forzamos un área cuadrada perfecta */
        height: 24px !important;
        line-height: 1 !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    .nav-config-close:hover {
        color: var(--text);
    }

    .nav-config-title {
        font-family: var(--font-serif);
        font-size: 1.4rem;
        color: var(--text);
        margin-bottom: 4px;
        letter-spacing: -0.01em;
    }

    .header-controls { position: relative; }
}
 
/* TOGGLE SWITCH */
.toggle-btn {
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: var(--line);
    border: 1px solid rgba(255,255,255,0.1);
    position: relative;
    cursor: pointer;
    transition: background 200ms ease;
    flex-shrink: 0;
}
 
.toggle-btn::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 200ms ease, background 200ms ease;
}
 
.toggle-btn[aria-checked="true"] {
    background: var(--acento);
    border-color: var(--acento);
}
 
.toggle-btn[aria-checked="true"]::after {
    transform: translateX(18px);
    background: var(--acento-contrast, #000);
}
 
/* MODO CLARO */
:root[data-theme="light"] {
    --bg: #F2EDE4;
    --text: #0A0A0A;
    --muted: #6B6560;
    --line: rgba(0,0,0,0.08);
    --quiet: rgba(0,0,0,0.25);
}
 
:root[data-theme="light"] .nav-config { background: #E8E3DA; }
:root[data-theme="light"] .sys-telemetry { background: #E8E3DA; }

#nextStep, #acceptManifesto { 
    line-height: 1;
}

.portal-gate .portal-accent-group .accent-dot.is-active {
    box-shadow: none;
}