/* Ritter-Systems.de — Morse-Trainer (style.css) */
/* Design wie Hauptsseite: dunkel-indigo, Inter, Karten rgba(255,255,255,.05) */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --accent: #06b6d4;
    --bg-dark: #0f172a;
    --bg-card: rgba(255, 255, 255, 0.05);
    --text-light: #f1f5f9;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --ok: #34d399;
    --bad: #f87171;
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1e1b4b 50%, #312e81 100%);
    color: var(--text-light);
    line-height: 1.7;
    font-size: 16px;
    min-height: 100vh;
}

.mt-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
}

.mt-hero {
    text-align: center;
    padding: 2.5rem 0 2rem;
}
.mt-hero-icon {
    font-size: 3.5rem;
    margin-bottom: .5rem;
    filter: drop-shadow(0 0 18px rgba(99, 102, 241, 0.6));
}
.mt-hero h1 {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 2.6rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a5b4fc 0%, #67e8f9 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.mt-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-top: .4rem;
}

.mt-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.6rem 1.8rem;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
}
.mt-card h2 {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 1.35rem;
    margin-bottom: .35rem;
}
.mt-hint {
    color: var(--text-muted);
    font-size: .95rem;
    margin-bottom: 1.1rem;
}

/* ---- Morse-Tabelle ---- */
.morse-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
    gap: .55rem;
}
.morse-cell {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .55rem .3rem;
    color: var(--text-light);
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    text-align: center;
    transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.morse-cell:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(165, 180, 252, 0.5);
    transform: translateY(-2px);
}
.morse-cell.playing {
    background: rgba(6, 182, 212, 0.35);
    border-color: var(--accent);
    box-shadow: 0 0 22px rgba(6, 182, 212, 0.45);
}
.mc-char {
    display: block;
    font-size: 1.35rem;
    font-weight: 700;
}
.mc-morse {
    display: block;
    font-size: .95rem;
    color: #c7d2fe;
    letter-spacing: .1em;
    white-space: nowrap;
    text-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
}

/* ---- Einstellungen ---- */
.mt-settings {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
    margin-bottom: 1.1rem;
}
.mt-settings label {
    display: flex;
    align-items: center;
    gap: .55rem;
    font-size: .92rem;
    color: var(--text-muted);
    min-width: 260px;
    flex: 1;
}
.mt-settings input[type="range"] {
    flex: 1;
    min-width: 130px;
    accent-color: var(--primary);
}
.mt-settings output {
    color: var(--text-light);
    font-weight: 600;
    min-width: 2.6em;
    text-align: right;
}

/* ---- Keyer ---- */
.key-btn {
    display: block;
    width: 100%;
    padding: 1.6rem 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    color: #fff;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    user-select: none;
    touch-action: none;
    transition: transform .08s ease, box-shadow .12s ease, filter .12s ease;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.35);
}
.key-btn:hover { filter: brightness(1.08); }
.key-btn.pressed {
    transform: scale(.985);
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    box-shadow: 0 0 40px rgba(6, 182, 212, 0.6);
}
.mt-live {
    min-height: 2rem;
    text-align: center;
    font-family: 'Space Grotesk', monospace;
    font-size: 1.15rem;
    color: #67e8f9;
    letter-spacing: .2em;
    margin: .5rem 0 .3rem;
}

.mt-output-row label {
    display: block;
    font-size: .85rem;
    color: var(--text-muted);
    margin-bottom: .3rem;
}
.mt-output-row textarea {
    width: 100%;
    background: rgba(15, 23, 42, 0.7);
    color: var(--text-light);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .7rem .9rem;
    font-family: 'Space Grotesk', 'Courier New', monospace;
    font-size: 1.15rem;
    letter-spacing: .12em;
    resize: vertical;
}
.mt-output-row textarea:focus {
    outline: none;
    border-color: rgba(165, 180, 252, 0.5);
}

/* ---- Buttons ---- */
.mt-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: .7rem;
    margin-top: .9rem;
}
.btn {
    padding: .6rem 1.2rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-family: 'Inter', sans-serif;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter .12s ease, transform .08s ease;
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.08);
}
.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn.primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: transparent;
}
.btn.danger {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}
.btn.ghost { background: rgba(255, 255, 255, 0.06); }

/* ---- Mikrofon ---- */
.mt-meter-wrap {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin: .8rem 0 .2rem;
}
.mt-meter-label {
    font-size: .82rem;
    color: var(--text-muted);
    min-width: 3.6em;
}
.mt-meter {
    flex: 1;
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    overflow: hidden;
}
.mt-meter > div {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent) 0%, var(--primary) 100%);
    border-radius: 6px;
    transition: width .06s linear;
}
.mt-msg { color: var(--bad); font-size: .9rem; min-height: 1.2em; margin: .3rem 0; }

/* ---- Hoeuebung ---- */
.quiz-controls { margin-top: .8rem; }
.quiz-target-row {
    display: flex;
    align-items: center;
    gap: .8rem;
    margin-bottom: .7rem;
}
.quiz-target-label { color: var(--text-muted); font-size: .95rem; }
.quiz-target {
    font-family: 'Space Grotesk', monospace;
    font-size: 1.9rem;
    font-weight: 700;
    color: #67e8f9;
    background: rgba(6, 182, 212, 0.12);
    border: 1px solid rgba(6, 182, 212, 0.35);
    border-radius: 10px;
    padding: .15rem 1rem;
    min-width: 3.2rem;
    text-align: center;
}
.quiz-feedback {
    min-height: 1.6em;
    font-size: 1.05rem;
    font-weight: 600;
    margin-top: .5rem;
}
.quiz-feedback.ok { color: var(--ok); }
.quiz-feedback.bad { color: var(--bad); }
.quiz-score {
    color: var(--text-muted);
    font-size: .9rem;
    min-height: 1.5em;
    margin-top: .25rem;
}

/* ---- Lektionen ---- */
.lesson-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .55rem;
}
.lesson-cell {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .6rem .5rem;
    color: var(--text-light);
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    text-align: center;
    transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.lesson-cell:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(165, 180, 252, 0.5);
    transform: translateY(-2px);
}
.lc-id {
    display: block;
    font-size: .78rem;
    color: var(--accent);
    font-weight: 700;
    letter-spacing: .08em;
}
.lc-text {
    display: block;
    font-family: 'Space Grotesk', monospace;
    font-size: 1.02rem;
    font-weight: 600;
    margin: .15rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lc-meta {
    display: block;
    font-size: .72rem;
    color: var(--text-muted);
}
.lc-best {
    display: block;
    font-size: .74rem;
    color: #fbbf24;
    min-height: 1.1em;
}
.lesson-run {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.lesson-head {
    display: flex;
    align-items: center;
    gap: .8rem;
    flex-wrap: wrap;
    margin-bottom: .7rem;
}
.lesson-title {
    font-family: 'Space Grotesk', monospace;
    font-weight: 700;
    color: var(--accent);
    font-size: 1.1rem;
}
.lesson-meta { color: var(--text-muted); font-size: .85rem; flex: 1; }
.lesson-target {
    font-family: 'Space Grotesk', monospace;
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    margin-bottom: .7rem;
}
.ls-char {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: .3rem .55rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    font-size: 1.3rem;
    font-weight: 700;
    min-width: 2.2rem;
}
.ls-char em {
    font-style: normal;
    font-size: .72rem;
    color: #c7d2fe;
    letter-spacing: .08em;
}
.ls-char.done { opacity: .45; border-color: rgba(52, 211, 153, 0.4); }
.ls-char.cur {
    background: rgba(6, 182, 212, 0.18);
    border-color: var(--accent);
    box-shadow: 0 0 16px rgba(6, 182, 212, 0.35);
}
.ls-gap {
    align-self: center;
    color: var(--text-muted);
    font-size: .8rem;
    padding: 0 .2rem;
}
.lesson-status {
    color: var(--text-muted);
    font-size: .92rem;
    margin-bottom: .6rem;
}
.lesson-hint-warn { color: var(--bad); }
.lesson-result {
    background: rgba(52, 211, 153, 0.08);
    border: 1px solid rgba(52, 211, 153, 0.35);
    border-radius: 10px;
    padding: .8rem 1rem;
    margin-bottom: .6rem;
}
.lesson-result-row {
    display: flex;
    justify-content: space-between;
    max-width: 320px;
    font-size: .98rem;
}
.lesson-result-row span { color: var(--text-muted); }
.lesson-save { font-size: .92rem; margin-top: .4rem; color: var(--text-muted); }
.lesson-save.ok { color: var(--ok); }
.lesson-save.warn { color: var(--warning, #fbbf24); }

/* ---- Hiscores ---- */
.hs-tabs {
    display: flex;
    gap: .5rem;
    margin-bottom: .9rem;
}
.hs-tab {
    padding: .45rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
}
.hs-tab.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    border-color: transparent;
}
.hs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}
.hs-table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    font-size: .8rem;
    padding: .35rem .5rem;
    border-bottom: 1px solid var(--border);
}
.hs-table td {
    padding: .4rem .5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.hs-table tr:first-child td { color: #fbbf24; font-weight: 600; }
.hs-empty {
    color: var(--text-muted);
    font-size: .9rem;
    padding: .6rem 0;
}

.mt-info p { color: var(--text-muted); font-size: .95rem; }

.mt-footer {
    text-align: center;
    padding: 1.5rem 1rem 2rem;
    font-size: .85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.6);
}
.mt-footer a { color: #a5b4fc; text-decoration: none; }
.mt-footer a:hover { text-decoration: underline; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .mt-wrap { padding: 1.25rem .9rem 2rem; }
    .mt-card { padding: 1.2rem 1rem; }
    .morse-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
    .mt-hero h1 { font-size: 2rem; }
    .key-btn { font-size: 1.05rem; padding: 1.3rem .8rem; }
}
/* ---- Hörübung: Muster-Grafik (Punkt/Strich-Chips) ---- */
.qm-pattern {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    vertical-align: middle;
    margin: 0 .35rem;
    padding: .25rem .45rem;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
}
.qm-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: currentColor;
}
.qm-dash {
    display: inline-block;
    width: 26px;
    height: 9px;
    border-radius: 5px;
    background: currentColor;
}

/* ---- Morse-Baum ---- */
.tree-scroll {
    overflow-x: auto;
    padding-bottom: .4rem;
}
.tree-scroll svg { display: block; }
.tree-root-glyph { font-size: 20px; fill: var(--text-muted); }
.tree-edge {
    stroke: rgba(255, 255, 255, 0.22);
    stroke-width: 2;
    fill: none;
    transition: stroke .15s ease, stroke-width .15s ease;
}
.tree-edge.on-path {
    stroke: var(--accent);
    stroke-width: 3.5;
    filter: drop-shadow(0 0 6px rgba(6, 182, 212, 0.6));
}
.tree-node circle {
    fill: rgba(255, 255, 255, 0.06);
    stroke: var(--border);
    stroke-width: 1.5;
    transition: fill .12s ease, stroke .12s ease;
}
.tree-node.has-letter { cursor: pointer; }
.tree-node.has-letter circle {
    fill: rgba(99, 102, 241, 0.22);
    stroke: rgba(165, 180, 252, 0.55);
}
.tree-node.has-letter:hover circle {
    fill: rgba(99, 102, 241, 0.45);
    stroke: #a5b4fc;
}
.tree-node.has-letter circle.playing {
    fill: rgba(6, 182, 212, 0.5);
    stroke: var(--accent);
}
.tree-node.current circle {
    fill: rgba(6, 182, 212, 0.3);
    stroke: var(--accent);
    stroke-width: 3;
    filter: drop-shadow(0 0 10px rgba(6, 182, 212, 0.7));
}
.tree-letter {
    fill: var(--text-light);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 700;
    pointer-events: none;
}
.tree-current-row {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin: .6rem 0 .2rem;
    font-size: .95rem;
}
.tree-current-label { color: var(--text-muted); }
.tree-current {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-family: 'Space Grotesk', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: #67e8f9;
}
.tree-seq {
    font-size: .85rem;
    color: var(--text-muted);
    letter-spacing: .15em;
}

/* ============ Mobile Morse-Taste (Daumenzone, fixed unten) ============ */
.mkey-bar { display: none; }

@media (hover: none) and (pointer: coarse), (max-width: 700px) {
    body {
        padding-bottom: calc(7.6rem + env(safe-area-inset-bottom, 0px));
    }
    .mkey-bar {
        display: flex;
        align-items: center;
        gap: 1rem;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 900;
        padding: .7rem 1rem calc(.7rem + env(safe-area-inset-bottom, 0px));
        background: rgba(15, 23, 42, 0.94);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
        border-top: 1px solid rgba(148, 163, 184, 0.18);
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.35);
        touch-action: manipulation;
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
        -webkit-tap-highlight-color: transparent;
    }
    .mkey-info {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: .35rem;
    }
    .mkey-live {
        min-height: 1.7rem;
        max-width: 100%;
        font-family: 'Space Grotesk', monospace;
        font-size: 1.3rem;
        font-weight: 700;
        letter-spacing: .25em;
        color: #67e8f9;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .mkey-clear {
        border: 1px solid rgba(148, 163, 184, 0.35);
        background: transparent;
        color: var(--text-muted);
        font-size: .8rem;
        padding: .28rem .8rem;
        border-radius: 999px;
        cursor: pointer;
        touch-action: manipulation;
    }
    .mkey-btn {
        flex: 0 0 auto;
        width: 96px;
        height: 96px;
        border-radius: 50%;
        border: 3px solid rgba(148, 163, 184, 0.35);
        background: radial-gradient(circle at 30% 30%, #818cf8 0%, var(--primary) 45%, var(--primary-dark) 100%);
        color: #fff;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: .1rem;
        cursor: pointer;
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
        touch-action: none;
        -webkit-tap-highlight-color: transparent;
        transition: transform .08s ease, box-shadow .12s ease;
        box-shadow: 0 10px 30px rgba(99, 102, 241, 0.45);
    }
    .mkey-btn-label {
        font-weight: 800;
        font-family: 'Space Grotesk', sans-serif;
        font-size: 1rem;
        letter-spacing: .08em;
    }
    .mkey-btn-hint { font-size: .62rem; opacity: .85; }
    .mkey-btn.pressed {
        transform: scale(.95);
        background: radial-gradient(circle at 30% 30%, #22d3ee 0%, #06b6d4 45%, #0891b2 100%);
        box-shadow: 0 0 40px rgba(6, 182, 212, 0.65);
    }
}
