/* DL2CC Morse Trainer — web client styles */

:root {
    --bg: #0f1419;
    --panel: #1a212b;
    --panel-2: #232c38;
    --border: #2f3a48;
    --text: #e6edf3;
    --muted: #8b98a8;
    --accent: #2f81f7;
    --accent-hover: #4a93f8;
    --green: #3fb950;
    --red: #f85149;
    --yellow: #d9a441;
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

.app { max-width: 1100px; margin: 0 auto; padding: 16px; }

.app-header {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
    border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 16px;
}
.app-header h1 { font-size: 1.25rem; margin: 0; flex: 0 0 auto; }
.app-nav { display: flex; gap: 4px; flex: 1 1 auto; flex-wrap: wrap; }
.nav-btn {
    background: transparent; color: var(--muted); border: 1px solid transparent;
    padding: 6px 12px; border-radius: var(--radius); cursor: pointer; font-size: .9rem;
}
.nav-btn:hover { color: var(--text); background: var(--panel); }
.nav-btn.active { color: var(--text); background: var(--panel-2); border-color: var(--border); }

/* Cross-link to the sibling trainer app (separate deployment at
   /morsetrainer-advanced/). Deliberately NOT a .nav-btn so the in-app
   view router ignores the click — it is a real navigation link. */
.nav-switch {
    margin-left: auto;
    align-self: center;
    color: var(--muted);
    padding: 6px 8px;
    font-size: .9rem;
    text-decoration: none;
    white-space: nowrap;
}
.nav-switch:hover { color: var(--text); text-decoration: underline; }

.box-status { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); }
.box-status.connected #box-status-text { color: var(--green); }

button {
    background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
    padding: 8px 14px; border-radius: var(--radius); cursor: pointer; font-size: .9rem;
}
button:hover:not(:disabled) { background: var(--panel); border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.danger { border-color: var(--red); color: var(--red); }

.view { display: none; }
.view.active { display: block; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; align-items: center; }

/* Training */
.training-grid { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
@media (max-width: 760px) { .training-grid { grid-template-columns: 1fr; } }

.side-panel, .train-main {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
}
.side-panel h3 { margin-top: 0; }
.lesson-chars { font-size: 1.1rem; color: var(--text); font-weight: 700; margin: 0 0 6px; letter-spacing: .04em; }
.new-char-hint { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.nch-label { color: var(--muted); font-size: .9rem; }
.nch-items { display: inline-flex; align-items: center; gap: 18px; }
.nch-group { display: inline-flex; align-items: center; gap: 8px; }
.nch-char { font-size: 1.3rem; font-weight: 700; color: var(--text); }
.nch-pattern { display: inline-flex; align-items: center; gap: 4px; height: 14px; }
.nch-el { background: #1565c0; height: 14px; border-radius: 1px; }
.nch-el.dit { width: 6px; }
.nch-el.dah { width: 18px; }
.speed-row { display: flex; gap: 10px; margin: 12px 0; }
.speed-row label, .toggle { display: flex; flex-direction: column; font-size: .82rem; color: var(--muted); gap: 4px; }
.toggle { flex-direction: row; align-items: center; gap: 8px; margin: 8px 0; color: var(--text); }
input[type=number], input[type=text], select {
    background: var(--bg); color: var(--text); border: 1px solid var(--border);
    border-radius: 6px; padding: 6px 8px; font-size: .9rem; width: 100%;
}
.conn-status { font-size: .8rem; color: var(--muted); margin-top: 10px; white-space: pre-line; }

.landing-info { color: var(--muted); line-height: 1.6; }
.prompt-area { text-align: center; margin: 8px 0 16px; }
.lbl-prompt { font-size: 3rem; font-weight: 700; min-height: 3.4rem; letter-spacing: .15em; }
.lbl-feedback { font-size: 1.3rem; min-height: 1.8rem; font-weight: 600; }
.lbl-feedback.ok { color: var(--green); }
.lbl-feedback.err { color: var(--red); }
.lbl-feedback.info { color: var(--accent); }
.lbl-keying { font-size: .85rem; color: var(--muted); min-height: 1.1rem; }
.input-instruction { color: var(--muted); margin: 10px 0 4px; }
.txt-input {
    font-size: 1.6rem; text-align: center; max-width: 220px; margin: 0 auto;
    text-transform: uppercase; letter-spacing: .2em;
}
.session-stats { color: var(--muted); font-size: .85rem; margin-top: 12px; }
.txt-history {
    background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
    padding: 10px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    min-height: 48px; max-height: 140px; overflow-y: auto; font-size: .95rem; line-height: 1.7;
}
.session-complete {
    margin-top: 16px; background: var(--panel-2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
}
.session-complete pre { font-family: inherit; white-space: pre-wrap; margin: 0 0 8px; }

/* Lessons */
.lessons-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.lessons-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.lessons-table th, .lessons-table td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.lessons-table th { background: var(--panel-2); position: sticky; top: 0; }
.lessons-table tr.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.lessons-table tr.mastered td:first-child { border-left: 3px solid var(--green); }
.lessons-table tr.inprogress td:first-child { border-left: 3px solid var(--yellow); }
.lessons-table tr.locked { color: var(--muted); }
.lessons-table tr { cursor: pointer; }

/* Progress */
.overall-stats { display: flex; gap: 20px; flex-wrap: wrap; margin: 12px 0; color: var(--muted); }
.overall-stats strong { color: var(--text); font-size: 1.1rem; }
.progress-bars { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 8px; }
.pbar { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 8px; }
.pbar .ch { font-weight: 700; font-size: 1.1rem; }
.pbar .ch.new { color: var(--accent); }
.pbar .track { background: var(--bg); border-radius: 4px; height: 8px; margin: 6px 0 2px; overflow: hidden; }
.pbar .fill { height: 100%; background: var(--green); }
.pbar small { color: var(--muted); }
.confusion-list { color: var(--muted); }
.session-history { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; color: var(--muted); max-height: 220px; overflow-y: auto; }

/* Alphabet */
.alphabet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px,1fr)); gap: 8px; }
.alpha-cell { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 10px; text-align: center; }
.alpha-cell .a-ch { font-size: 1.4rem; font-weight: 700; }
.alpha-cell .a-pat { color: var(--accent); font-family: ui-monospace, Consolas, monospace; letter-spacing: .1em; }

/* Game */
.game-area {
    position: relative; height: 420px; background: var(--panel);
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-top: 12px;
}
.balloon {
    position: absolute; width: 54px; height: 64px; border-radius: 50% 50% 48% 48%;
    background: var(--accent); color: #fff; display: flex; align-items: center;
    justify-content: center; font-weight: 700; font-size: 1.3rem;
}
.game-score { color: var(--muted); }
/* Visually hidden but still focusable — must NOT use display/visibility:none
   or opacity-collapsed sizing, or iOS Safari won't open the soft keyboard. */
.game-hidden-input {
    position: absolute; left: -9999px; width: 1px; height: 1px;
    opacity: 0; border: 0; padding: 0; margin: 0;
}

/* Settings */
.settings-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 12px; }
.settings-form label { display: flex; flex-direction: column; font-size: .82rem; color: var(--muted); gap: 4px; }
.settings-form .btn-row { grid-column: 1 / -1; }
.file-btn { display: inline-block; background: var(--panel-2); border: 1px solid var(--border); padding: 8px 14px; border-radius: var(--radius); cursor: pointer; font-size: .9rem; }
.muted { color: var(--muted); font-size: .85rem; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }

.audio-overlay {
    position: fixed; inset: 0; width: 100%; height: 100%;
    background: rgba(15,20,25,.96); color: var(--text); font-size: 1.2rem;
    border: none; z-index: 999;
}

/* ── Legal footer ────────────────────────────────────────────────
   Links to the shared bilingual legal pages. This app's UI is
   English-only, so the links carry no ?lang= — the legal page
   auto-detects the browser language and still offers an EN/DE
   toggle, so a German visitor can read it in German. */
.legal-footer {
    max-width: 1100px;
    margin: 32px auto 0;
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
    font-size: .8rem; color: var(--muted);
}
.legal-footer a, .legal-footer a:visited { color: inherit; text-decoration: none; }
.legal-footer a:hover { text-decoration: underline; }
.legal-footer .sep { color: var(--border); }
.legal-footer .copy { margin-left: auto; }
@media (max-width: 600px) {
    .legal-footer .copy { margin-left: 0; flex-basis: 100%; }
}
