/* ==========================================================================
   APEX // BRAKE LAB — Módulo 2 (modulo2.html)
   ========================================================================== */

:root {
    --bg-dark: #0a0a0d;
    --card-bg: #121217;
    --red-eva: #e60012;
    --orange-accent: #ff8c00;
    --yellow-eva: #ffc700;
    --green-eva: #10b981;
    --text-main: #f3f4f6;
    --text-muted: #a1a1aa;
    --font-head: 'Rajdhani', sans-serif;
}

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

[hidden] { display: none !important; }

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Roboto', sans-serif;
    line-height: 1.6;
    animation: pageIn 1.1s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: none; }
}

:focus-visible { outline: 2px solid var(--yellow-eva); outline-offset: 3px; }

/* ---------- Navbar, contenedor y footer ---------- */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 2rem;
    background-color: rgba(18, 18, 23, 0.95);
    border-bottom: 1px solid rgba(230, 0, 18, 0.5);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.logo {
    font-family: var(--font-head);
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-shadow: 0 0 8px rgba(230, 0, 18, 0.6);
}

.logo .accent { color: var(--red-eva); }

.nav-links a {
    position: relative;
    margin-left: 1.8rem;
    color: var(--text-main);
    text-decoration: none;
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 1.05rem;
    text-transform: uppercase;
    transition: all 0.25s ease;
}

.nav-links a:hover {
    color: var(--yellow-eva);
    text-shadow: 0 0 10px rgba(255, 199, 0, 0.8);
}

.container { max-width: 850px; margin: 4rem auto; padding: 0 1rem; }

.footer {
    padding: 2.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ---------- Botones ---------- */
.btn {
    display: inline-block;
    padding: 0.85rem 2.2rem;
    border: none;
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.15rem;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
    background: linear-gradient(135deg, var(--red-eva), #99000c);
    color: #fff;
    box-shadow: 0 0 18px rgba(230, 0, 18, 0.5);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--orange-accent), var(--yellow-eva));
    color: #000;
    transform: scale(1.04);
    filter: drop-shadow(0 0 14px rgba(255, 199, 0, 0.9));
}

.btn-action {
    flex: 1;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(230, 0, 18, 0.5);
    color: var(--text-main);
}

.btn-action:hover {
    background-color: var(--red-eva);
    color: #fff;
    box-shadow: 0 0 12px rgba(230, 0, 18, 0.6);
}

.btn-group { display: flex; gap: 1rem; }

/* ---------- Cabecera, estado y menú ---------- */
.sim-header { text-align: center; margin-bottom: 2rem; }

.sim-header h2 {
    font-family: var(--font-head);
    font-size: 2rem;
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
}

.sim-top-info {
    font-family: var(--font-head);
    font-size: 1.2rem;
    color: var(--yellow-eva);
}

.status-disconnected,
.status-connected,
.status-warning {
    display: inline-block;
    padding: 0.4rem 1rem;
    border-radius: 2px;
    font-family: var(--font-head);
    font-size: 1rem;
    letter-spacing: 1px;
}

.status-disconnected { background-color: rgba(230, 0, 18, 0.15); color: var(--red-eva); border: 1px dashed var(--red-eva); }
.status-connected { background-color: rgba(16, 185, 129, 0.15); color: var(--green-eva); border: 1px solid var(--green-eva); }
.status-warning { background-color: rgba(255, 199, 0, 0.12); color: var(--yellow-eva); border: 1px dashed var(--yellow-eva); }

.menu-note { margin-top: 0.8rem; font-size: 0.9rem; color: var(--text-muted); }
.menu-note a { color: var(--yellow-eva); }

.menu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2rem; }
.full-span { grid-column: span 2; }

.difficulty-card {
    --accent: var(--yellow-eva);
    padding: 2rem;
    background-color: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 15px, 100% 100%, 15px 100%, 0 calc(100% - 15px));
    transition: all 0.3s ease;
}

.difficulty-card[data-level="1"] { --accent: var(--green-eva); }
.difficulty-card[data-level="2"] { --accent: var(--yellow-eva); }
.difficulty-card[data-level="3"] { --accent: var(--red-eva); }

.difficulty-card:hover,
.difficulty-card:focus-visible {
    border-color: var(--accent);
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(255, 255, 255, 0.06);
}

.difficulty-card h3 { margin: 0.5rem 0 1rem; font-family: var(--font-head); font-size: 1.6rem; color: #fff; }
.difficulty-card p { margin-bottom: 1rem; color: var(--text-muted); font-size: 0.95rem; line-height: 1.5; }
.diff-tag, .card-action-hint { font-family: var(--font-head); letter-spacing: 1px; color: var(--accent); }
.diff-tag { font-size: 0.9rem; }
.card-action-hint { font-size: 0.9rem; }

.diff-meta {
    display: block;
    margin-bottom: 1rem;
    font-family: var(--font-head);
    font-size: 0.85rem;
    letter-spacing: 1px;
    opacity: 0.75;
}

.centered-card { grid-column: span 2; width: 100%; max-width: 600px; margin: 0 auto; }

/* ---------- Simulador ---------- */
#simulator-view:not([hidden]) { animation: expandIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }

@keyframes expandIn {
    from { opacity: 0; transform: scale(0.92) translateY(20px); }
    to { opacity: 1; transform: none; }
}

.telemetry-card {
    padding: 2rem;
    background-color: var(--card-bg);
    border: 1px solid var(--red-eva);
    clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 20px 100%, 0 calc(100% - 20px));
}

.target-text {
    min-height: 2.6rem;
    margin-bottom: 1rem;
    text-align: center;
    font-family: var(--font-head);
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--yellow-eva);
}

.change-timer { max-width: 420px; margin: 0 auto 1.5rem; text-align: center; font-family: var(--font-head); color: var(--text-muted); }

.timer-bar {
    height: 8px;
    margin-top: 0.3rem;
    overflow: hidden;
    background-color: #08080a;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.timer-fill { width: 100%; height: 100%; background-color: var(--green-eva); }
.timer-fill.low { background-color: var(--red-eva); }

/* Barra vertical del pedal */
.stage {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.2rem;
    margin: 1rem 0 2rem;
}

.scale { position: relative; width: 2.4rem; height: 340px; font-family: var(--font-head); font-size: 0.85rem; color: var(--text-muted); }
.scale span { position: absolute; right: 0; transform: translateY(50%); }

.bar-wrap {
    position: relative;
    width: 160px;
    height: 340px;
    background-color: #08080a;
    border: 3px solid rgba(255, 255, 255, 0.7);
}

.bar-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background-color: var(--red-eva); }

.target-band {
    position: absolute;
    left: -10px;
    right: -10px;
    border: 3px solid var(--yellow-eva);
    background-color: rgba(255, 199, 0, 0.12);
    pointer-events: none;
}

.readout { min-width: 7rem; text-align: left; }
.percent { display: block; font-family: var(--font-head); font-size: 3.2rem; font-weight: 700; line-height: 1; }

.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
.metric-box { padding: 1.2rem; text-align: center; background-color: rgba(0, 0, 0, 0.4); border: 1px solid rgba(255, 255, 255, 0.1); }
.metric-label { display: block; margin-bottom: 0.3rem; font-family: var(--font-head); font-size: 0.9rem; color: var(--text-muted); }
.metric-value { font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; }
.status-ok { color: var(--yellow-eva); }

/* ---------- Resumen ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1000;
}

.modal-card {
    width: 100%;
    max-width: 500px;
    max-height: 94vh;
    overflow-y: auto;
    padding: 2rem;
    text-align: center;
    background-color: var(--card-bg);
    border: 2px solid var(--yellow-eva);
    clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 20px 100%, 0 calc(100% - 20px));
    animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: none; }
}

.modal-card h3 { margin-bottom: 0.3rem; font-family: var(--font-head); font-size: 1.8rem; color: #fff; }
.modal-subtitle { margin-bottom: 1.2rem; font-family: var(--font-head); font-size: 0.95rem; color: var(--text-muted); }
.modal-score-box { margin-bottom: 1rem; padding: 1.2rem; background-color: rgba(0, 0, 0, 0.5); border: 1px solid rgba(255, 255, 255, 0.1); }
.modal-score-label { display: block; margin-bottom: 0.4rem; font-family: var(--font-head); font-size: 0.9rem; color: var(--text-muted); }
.modal-score-value { font-family: var(--font-head); font-size: 2.5rem; font-weight: 700; color: var(--yellow-eva); }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.8rem; margin-bottom: 1rem; }
.stats-row div { padding: 0.7rem 0.3rem; background-color: rgba(0, 0, 0, 0.4); border: 1px solid rgba(255, 255, 255, 0.1); }
.stats-row strong { font-family: var(--font-head); font-size: 1.4rem; }

.modal-feedback { margin-bottom: 1rem; }

.rounds-table { max-height: 200px; margin-bottom: 1.2rem; overflow-y: auto; font-family: var(--font-head); font-size: 0.95rem; text-align: left; }
.round-row { display: grid; grid-template-columns: 2.2rem 1fr 1fr 1fr 3rem; gap: 0.4rem; padding: 0.25rem 0.5rem; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.round-row.head { color: var(--text-muted); position: sticky; top: 0; background-color: var(--card-bg); }
.round-row.miss { color: var(--red-eva); }

/* ---------- Móvil y accesibilidad ---------- */
@media (max-width: 640px) {
    .navbar { padding: 1rem; }
    .logo { font-size: 1.25rem; }
    .container { margin: 2rem auto; }
    .menu-grid { grid-template-columns: 1fr; gap: 1.2rem; }
    .full-span, .centered-card { grid-column: span 1; }
    .sim-header h2 { font-size: 1.5rem; }
    .telemetry-card { padding: 1.2rem; }
    .target-text { font-size: 1.4rem; }
    .scale, .bar-wrap { height: 260px; }
    .bar-wrap { width: 120px; }
    .percent { font-size: 2.4rem; }
    .readout { min-width: 5rem; }
    .metrics-grid { grid-template-columns: 1fr; gap: 0.8rem; }
    .btn-group { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
