/* ==========================================================================
   APEX // BRAKE LAB — Módulo 1 (modulo1.html)
   Un solo archivo: base, menú, simulador, resumen y calibración.
   ========================================================================== */

: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;
}

canvas {
    display: block;
    width: 100%;
    height: auto;
}

/* ---------- Navbar 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::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -4px;
    width: 0;
    height: 2px;
    background-color: var(--green-eva);
    transition: width 0.25s ease;
}

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

.nav-links a:hover::after {
    width: 100%;
}

.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 (corte biselado) ---------- */
.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:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.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:not(:disabled) {
    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 de conexión 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 {
    margin-top: 0.3rem;
    text-align: center;
    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-tools {
    margin-top: 1rem;
}

.menu-tools .btn {
    flex: none;
    padding: 0.5rem 1.4rem;
    letter-spacing: 1px;
}

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

.full-span {
    grid-column: span 2;
}

.difficulty-card {
    --accent: var(--yellow-eva);
    position: relative;
    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 0;
    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 {
    font-family: var(--font-head);
    font-size: 0.9rem;
    letter-spacing: 1px;
    color: var(--accent);
}

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

.card-action-hint {
    font-family: var(--font-head);
    font-size: 0.9rem;
    letter-spacing: 1px;
    color: var(--accent);
}

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

/* ---------- Simulador ---------- */
.simulator-wrapper: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-info {
    min-height: 1.8em;
    margin-bottom: 1.5rem;
    text-align: center;
    font-family: var(--font-head);
    font-size: 1.15rem;
    color: var(--text-muted);
}

.canvas-wrapper {
    margin-bottom: 2rem;
    background-color: #08080a;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.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.5rem;
    font-weight: 700;
}

.status-ok {
    color: var(--yellow-eva);
}

/* ---------- Ventanas modales ---------- */
.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: 450px;
    padding: 2.5rem;
    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.5rem;
    font-family: var(--font-head);
    font-size: 0.95rem;
    color: var(--text-muted);
}

.modal-score-box {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    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.5rem;
    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);
}

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

/* ---------- Calibración ---------- */
.cal-card {
    max-width: 620px;
    max-height: 92vh;
    overflow-y: auto;
    text-align: left;
}

.cal-card h3,
.cal-card .modal-subtitle {
    text-align: center;
}

.cal-card > .btn-primary {
    display: block;
    margin: 0 auto;
}

.cal-label {
    display: block;
    margin-bottom: 0.3rem;
    font-family: var(--font-head);
    font-size: 0.9rem;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.cal-select {
    width: 100%;
    margin-bottom: 1.2rem;
    padding: 0.6rem 0.8rem;
    background-color: #08080a;
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-family: var(--font-head);
    font-size: 1rem;
}

.cal-select:disabled {
    opacity: 0.6;
}

.cal-instruction {
    min-height: 3.2em;
    margin-bottom: 0.8rem;
    padding: 0.8rem 1rem;
    background-color: rgba(0, 0, 0, 0.4);
    border-left: 3px solid var(--yellow-eva);
    font-size: 0.98rem;
    line-height: 1.45;
}

.cal-instruction.ok { border-left-color: var(--green-eva); }
.cal-instruction.error { border-left-color: var(--red-eva); }

.cal-progress,
.cal-bar {
    width: 100%;
    height: 10px;
    overflow: hidden;
    background-color: #08080a;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.cal-progress {
    margin-bottom: 1.4rem;
}

.cal-progress-fill,
.cal-bar-fill {
    width: 0;
    height: 100%;
}

.cal-progress-fill { background-color: var(--yellow-eva); }
.cal-bar-fill { background-color: var(--red-eva); }

.cal-live {
    margin-bottom: 1.4rem;
    text-align: center;
}

.cal-live .metric-label {
    margin-bottom: 0.5rem;
}

.cal-live .cal-bar {
    height: 18px;
    margin-bottom: 0.4rem;
}

.cal-actions {
    margin-bottom: 1.2rem;
}

.cal-diagnostic {
    margin-bottom: 1.5rem;
    padding: 0.6rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.cal-diagnostic summary {
    cursor: pointer;
    font-family: var(--font-head);
    letter-spacing: 1px;
    color: var(--text-muted);
}

.cal-hint {
    margin: 0.8rem 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.cal-channels {
    max-height: 220px;
    overflow-y: auto;
}

.cal-channel {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    align-items: center;
    gap: 0.8rem;
    padding: 0.35rem 0.4rem;
    border-left: 3px solid transparent;
}

.cal-channel.selected {
    border-left-color: var(--yellow-eva);
    background-color: rgba(255, 199, 0, 0.06);
}

.cal-channel-name {
    font-family: var(--font-head);
    font-size: 0.9rem;
}

.cal-bar.small {
    height: 8px;
}

.cal-channel-btn {
    padding: 0.25rem 0.6rem;
    background: transparent;
    border: 1px solid rgba(230, 0, 18, 0.5);
    color: var(--text-main);
    font-family: var(--font-head);
    font-size: 0.75rem;
    letter-spacing: 1px;
    cursor: pointer;
}

.cal-channel-btn:hover {
    background-color: var(--red-eva);
}

/* ---------- Móvil y accesibilidad ---------- */
@media (max-width: 640px) {
    .navbar { padding: 1rem; }
    .logo { font-size: 1.25rem; }
    .nav-links a { margin-left: 0; font-size: 0.95rem; }
    .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; }
    .metrics-grid { grid-template-columns: 1fr; gap: 0.8rem; }
    .btn-group { flex-direction: column; }
    .modal-card { padding: 1.5rem; }
}

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