/* =========================================================
   AIS Collision Avoidance Simulator — Styles
   SkipperCheck.net · Real-MKD radar aesthetic
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=VT323&display=swap');

/* Page header (reuse VHF class names for consistency) */
.vhf-page-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1a3a5c;
    margin-top: 32px;
    margin-bottom: 4px;
}
.vhf-page-subtitle {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 28px;
}

/* Section headers between scenario groups */
.ais-section-header {
    color: #1a3a5c;
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 18px 0 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid #e0e8f0;
}
.ais-section-header:first-of-type { margin-top: 0; }

/* Scenario grid (shared look with VHF) */
.scenario-selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
    margin-bottom: 32px;
}
.scenario-card {
    border: 2px solid #e0e8f0;
    border-radius: 10px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.18s ease;
    background: #fff;
    position: relative;
}
.scenario-card:hover {
    border-color: #0d6efd;
    background: #f0f6ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(13,110,253,0.12);
}
.scenario-card.active { border-color: #0d6efd; background: #e8f0ff; }
.scenario-card .badge-type {
    font-size: 10px; font-weight: 700;
    padding: 3px 9px; border-radius: 12px;
    display: inline-block; margin-bottom: 8px;
    text-transform: uppercase; letter-spacing: 0.8px;
}
.badge-distress  { background: #fde8e8; color: #c0392b; }
.badge-urgency   { background: #fef3cd; color: #a05000; }
.badge-safety    { background: #d4edda; color: #155724; }
.badge-routine   { background: #d1ecf1; color: #0c5460; }
.badge-dsc       { background: #ede0ff; color: #5b0070; }
.badge-receive   { background: #d6eaff; color: #004085; }
.badge-explore   { background: #e8e0ff; color: #3a006f; }
.scenario-card h6 { margin: 0 0 5px; font-size: 14px; font-weight: 700; color: #1a2a3a; }
.scenario-card p  { margin: 0; font-size: 12px; color: #666; line-height: 1.4; }

/* Completed scenario */
.scenario-card.is-completed {
    border-color: #28a745;
    background: #f3fbf4;
}
.scenario-card.is-completed:hover { background: #e6f5ea; border-color: #28a745; box-shadow: 0 4px 16px rgba(40,167,69,0.15); }
.scenario-card.is-completed::after {
    content: "✓";
    position: absolute; top: 8px; right: 8px;
    width: 24px; height: 24px; border-radius: 50%;
    background: #28a745; color: #fff; font-weight: 700; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

#ais-markdone-btn.is-done { background: #28a745 !important; border-color: #28a745 !important; color: #fff !important; cursor: default; }

/* Signed-in wrapper: keep simulator usable inside 9-col content */
.ais-signed-in-wrap { max-width: 100%; }

/* Progress bar */
.ais-progress-wrap {
    background: #fff; border: 1px solid #e0e8f0; border-radius: 10px;
    padding: 14px 18px; margin-bottom: 18px;
}
.ais-progress-head {
    display: flex; justify-content: space-between; align-items: baseline;
    font-size: 13px; color: #333; margin-bottom: 8px;
}
.ais-progress-head strong { color: #0b2540; font-size: 14px; }
.ais-progress-head span { color: #6c757d; font-size: 12px; }
.ais-progress-bar {
    background: #eef2f6; border-radius: 20px; height: 10px; overflow: hidden;
}
.ais-progress-bar-fill {
    background: linear-gradient(90deg, #28a745 0%, #5bd675 100%);
    height: 100%; transition: width .4s ease;
}

/* ── Layout ── */
.ais-layout {
    display: grid;
    grid-template-columns: 620px 1fr;
    gap: 24px;
    align-items: start;
}
@media (max-width: 1200px) {
    .ais-layout { grid-template-columns: 1fr; }
}

.ais-radar-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ============================================================
   AIS MKD — real radar display
   ============================================================ */
.ais-mkd {
    background: linear-gradient(180deg, #232528 0%, #141516 100%);
    border: 1px solid #000;
    border-radius: 6px;
    padding: 10px;
    box-shadow:
        0 10px 28px rgba(0,0,0,0.6),
        inset 0 1px 0 rgba(255,255,255,0.08);
    user-select: none;
    -webkit-user-select: none;
}

.mkd-top-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px 6px;
    border-bottom: 1px solid #333;
    margin-bottom: 8px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    letter-spacing: 1.5px;
}
.mkd-brand { color: #f39100; font-weight: bold; letter-spacing: 2px; }
.mkd-mode { color: #888; font-size: 10px; }

.mkd-main {
    position: relative;
    background: #000;
    border: 1px solid #111;
    border-radius: 4px;
    overflow: hidden;
}
#ais-radar {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    background: #000;
    cursor: crosshair;
}

/* HUD overlays on PPI corners */
.mkd-hud-tl, .mkd-hud-tr, .mkd-hud-bl, .mkd-hud-br {
    position: absolute;
    font-family: 'Share Tech Mono', monospace;
    color: #f0c040;
    font-size: 11px;
    line-height: 1.3;
    pointer-events: none;
    text-shadow: 0 0 3px rgba(240,192,64,0.5);
}
.mkd-hud-tl { top: 8px; left: 10px; }
.mkd-hud-tr { top: 8px; right: 10px; text-align: right; }
.mkd-hud-bl { bottom: 8px; left: 10px; }
.mkd-hud-br { bottom: 8px; right: 10px; text-align: right; }
.hud-label { color: #6a7a80; font-size: 9px; letter-spacing: 1px; }
.hud-val   { color: #f0c040; font-size: 13px; font-weight: bold; }

.mkd-alert {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(180,0,0,0.85);
    color: #fff;
    padding: 6px 18px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 13px;
    letter-spacing: 3px;
    font-weight: bold;
    border: 2px solid #ff3030;
    border-radius: 3px;
    animation: mkd-blink 0.7s step-end infinite;
    pointer-events: none;
}
@keyframes mkd-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}

/* Control strip */
.mkd-ctl-strip {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    margin-top: 8px;
}
.mkd-btn {
    background: linear-gradient(180deg, #3f4145 0%, #242528 100%);
    color: #e8e8e8;
    border: 1px solid #050505;
    border-radius: 3px;
    padding: 8px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.18),
        inset 0 -2px 3px rgba(0,0,0,0.45),
        0 1px 1px rgba(0,0,0,0.5);
    font-family: Arial, sans-serif;
    transition: background 0.1s;
}
.mkd-btn:hover { background: linear-gradient(180deg, #4a4c50 0%, #2c2d30 100%); }
.mkd-btn:active, .mkd-btn.active {
    background: #16171a;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.65);
    color: #f0c040;
}

/* ── Own-ship control panel ── */
.ais-ctl-panel {
    background: linear-gradient(180deg, #2a2c30 0%, #1a1b1d 100%);
    border: 1px solid #000;
    border-radius: 6px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.ctl-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.ctl-label {
    color: #888;
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    min-width: 110px;
}
.ctl-buttons {
    display: flex;
    gap: 4px;
    align-items: center;
}
/* COG + SOG row attached directly under the MKD button strip */
.mkd-ship-row {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    padding: 6px 8px;
    background: linear-gradient(180deg, #2a2c30 0%, #1a1b1d 100%);
    border: 1px solid #000;
    border-radius: 4px;
    flex-wrap: wrap;
}
.mkd-ship-row .ctl-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 1 auto;
    min-width: 0;
}
.mkd-ship-row .ctl-label {
    min-width: 30px;
    font-size: 10px;
    letter-spacing: 1px;
}
.mkd-ship-row .ctl-value {
    font-size: 16px;
    min-width: 44px;
    padding: 0 3px;
    text-align: center;
}
.mkd-ship-row .rbtn {
    padding: 4px 5px;
    font-size: 9px;
    letter-spacing: 0;
    min-width: 0;
    flex: 0 0 auto;
}
.mkd-ship-row .ctl-group { gap: 4px; min-width: 0; }
.mkd-ship-row .ctl-label { min-width: 28px; font-size: 10px; }

/* COG + SOG side-by-side row */
.ctl-row-combined {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}
.ctl-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 320px;
}
.ctl-row-combined .ctl-label {
    min-width: 40px;
}

/* Full-screen tweaks — canvas on the left, controls stacked on the right */
#ais-panel-sim:fullscreen { background: #000; padding: 8px; overflow: auto; }
#ais-panel-sim:fullscreen .scenario-panel { display: none; }
#ais-panel-sim:fullscreen .ais-layout { display: block; }
#ais-panel-sim:fullscreen .ais-radar-stack { width: 100%; max-width: none; }

#ais-panel-sim:fullscreen .ais-mkd {
    display: grid;
    grid-template-columns: min(90vh, calc(100vw - 260px)) 1fr;
    grid-template-areas:
        "top  top"
        "main ctl"
        "main ship";
    gap: 8px;
    align-items: start;
}
#ais-panel-sim:fullscreen .mkd-top-strip { grid-area: top; }
#ais-panel-sim:fullscreen .mkd-main      { grid-area: main; }
#ais-panel-sim:fullscreen .mkd-ctl-strip {
    grid-area: ctl;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px;
}
#ais-panel-sim:fullscreen .mkd-ctl-strip .mkd-btn { width: 100%; padding: 10px 8px; font-size: 12px; }
#ais-panel-sim:fullscreen .mkd-ship-row {
    grid-area: ship;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 6px;
}
#ais-panel-sim:fullscreen .mkd-ship-row .ctl-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    min-width: 0;
}
#ais-panel-sim:fullscreen #ais-radar {
    width: 100%;
    height: auto;
    aspect-ratio: 1/1;
    max-width: none;
}
#ais-panel-sim:-webkit-full-screen .scenario-panel { display: none; }
.ctl-value {
    color: #f0c040;
    font-family: 'VT323', monospace;
    font-size: 26px;
    min-width: 70px;
    text-align: center;
    text-shadow: 0 0 5px rgba(240,192,64,0.5);
    line-height: 1;
    background: #000;
    border: 1px solid #222;
    padding: 2px 8px;
    border-radius: 3px;
}
.rbtn {
    background: linear-gradient(180deg, #3f4145 0%, #242528 100%);
    color: #e8e8e8;
    border: 1px solid #050505;
    border-radius: 3px;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.18),
        inset 0 -2px 3px rgba(0,0,0,0.45),
        0 1px 1px rgba(0,0,0,0.5);
    font-family: Arial, sans-serif;
    transition: background 0.1s;
    min-width: 44px;
}
.rbtn:hover { background: linear-gradient(180deg, #4a4c50 0%, #2c2d30 100%); }
.rbtn:active { background: #16171a; box-shadow: inset 0 2px 5px rgba(0,0,0,0.65); }
.rbtn.wide  { width: 100%; padding: 10px; font-size: 13px; letter-spacing: 2px; color: #ff9040; }
.rbtn:disabled { opacity: 0.35; cursor: not-allowed; }
.rbtn.rbtn-emerg {
    background: linear-gradient(180deg, #b32c1e 0%, #7a1d12 100%);
    color: #fff7e0;
    border-color: #601208;
    font-weight: bold;
    letter-spacing: 1px;
}
.rbtn.rbtn-emerg:hover  { background: linear-gradient(180deg, #d8361f 0%, #961e10 100%); }
.rbtn.rbtn-emerg:active { background: #4a0c05; box-shadow: inset 0 2px 5px rgba(0,0,0,0.75); }

/* ── Target info panel ── */
.ais-target-panel {
    background: #0b0d10;
    border: 1px solid #1a2230;
    border-radius: 6px;
    padding: 12px 14px;
    color: #cfe0ff;
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
}
.tgt-header {
    color: #f0c040;
    font-size: 11px;
    letter-spacing: 2.5px;
    border-bottom: 1px solid #1a2230;
    padding-bottom: 6px;
    margin-bottom: 8px;
    font-weight: bold;
}
.tgt-empty { color: #556; font-style: italic; padding: 6px 0; }
.tgt-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px dotted #1a2230;
}
.tgt-row:last-child { border-bottom: none; }
.tgt-row span:first-child { color: #6a7a95; letter-spacing: 1.5px; }
.tgt-row span:last-child  { color: #cfe0ff; font-weight: bold; }
.tgt-row.tgt-critical span:last-child { color: #ff6040; text-shadow: 0 0 4px rgba(255,96,64,0.5); }

/* ============================================================
   Scenario Panel (reused styling, aligned with VHF)
   ============================================================ */
.scenario-panel {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    overflow: hidden;
    min-height: 480px;
    display: flex;
    flex-direction: column;
}
.scenario-panel-header {
    background: linear-gradient(135deg, #1a4a8a, #0d3060);
    color: #fff;
    padding: 18px 22px;
}
.header-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.scenario-panel-header .step-label {
    font-size: 10px; opacity: 0.6;
    letter-spacing: 2px; text-transform: uppercase;
    margin-bottom: 4px;
}
.scenario-panel-header h4 { margin: 0; font-size: 18px; font-weight: 700; }
.btn-header-continue {
    flex-shrink: 0;
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.6);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 16px;
    border-radius: 6px;
    white-space: nowrap;
    transition: background 0.15s;
}
.btn-header-continue:hover { background: rgba(255,255,255,0.28); border-color: #fff; color: #fff; }

.ais-rule-pills {
    display: flex; gap: 5px; flex-wrap: wrap; margin-top: 10px;
}
.ais-rule-pill {
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.4);
    color: #fff;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.scenario-panel-body {
    padding: 22px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.instr-box {
    border-left: 4px solid #0d6efd;
    background: #f0f6ff;
    border-radius: 0 8px 8px 0;
    padding: 13px 16px;
    font-size: 14px;
    line-height: 1.55;
    color: #1a2a3a;
    white-space: pre-wrap;
}
.instr-box.warn { border-color: #f39c12; background: #fffbf0; }
.instr-box.ok   { border-color: #27ae60; background: #f0fff6; }
.instr-box.err  { border-color: #e74c3c; background: #fff5f5; }

.feedback-box {
    border-radius: 8px;
    padding: 11px 14px;
    font-size: 13px;
    display: none;
    line-height: 1.55;
}
.feedback-box.show { display: block; }
.feedback-box.correct   { background: #f0fff6; border: 1px solid #27ae60; color: #155724; }
.feedback-box.incorrect { background: #fff5f5; border: 1px solid #e74c3c; color: #7a1010; }
.feedback-box.partial   { background: #fffbf0; border: 1px solid #f39c12; color: #7a5010; }
.feedback-box ul { margin: 6px 0 0 18px; padding: 0; }
.feedback-box li { margin: 3px 0; }

.action-btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}
.action-btn-row .btn,
.action-btn-row button {
    font-size: 1.05rem !important;
    padding: 11px 24px !important;
    min-height: 48px !important;
}

@media (max-width: 768px) {
    .ais-mkd { padding: 6px; }
    .ctl-buttons .rbtn { padding: 6px 8px; font-size: 11px; }
    .ctl-value { font-size: 22px; min-width: 60px; }
    .mkd-ctl-strip .mkd-btn { padding: 8px 2px; font-size: 10px; }
}

/* Night Recognition (lights_*) scenarios — hide irrelevant HUD overlays and
   ship controls; the canvas renders its own night scene + aspect badge. */
body.ais-lights-mode .mkd-hud-tl,
body.ais-lights-mode .mkd-hud-tr,
body.ais-lights-mode .mkd-hud-bl,
body.ais-lights-mode .mkd-hud-br,
body.ais-lights-mode .mkd-ctl-strip,
body.ais-lights-mode .mkd-ship-row,
body.ais-lights-mode #mkd-alert {
    display: none !important;
}
