/* ============================================================
   tastatur.css — Alle Styles für die Bildschirmtastatur
   NEU: Klarer Druck-Effekt für alle Tasten:
        - 1px nach unten (translateY)
        - Innen-Schatten oben (wie eingedrückt)
        - Hintergrund dunkler
        Gleich stark auf iPhone und Desktop.
        Smart-Chips: 0.5px + Innen-Schatten
        Tabs: 1px + Innen-Schatten (auch aktive Tabs)
   ============================================================ */

:root {
    --kb-hoehe:       clamp(240px, 42dvh, 360px);
    --kb-gap:         3px;
    --kb-padding:     3px;
    --kb-tab-hoehe:   26px;
    --kb-strip-hoehe: 30px;
    --kb-safe-bottom: env(safe-area-inset-bottom, 0px);

    /* NEU: Farben für den Druck-Effekt */
    --taste-gedrueckt:      #dde3ea;   /* Standardtaste gedrückt */
    --taste-aktion-gedrueckt: #b8c4d4; /* Aktions-Taste gedrückt */
    --schatten-innen:       inset 0 1px 2px rgba(0, 0, 0, 0.12);
    --schatten-innen-stark: inset 0 1px 2px rgba(0, 0, 0, 0.18);
}

#tastatur-wrapper {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    height: var(--kb-hoehe);
    background: #f1f5f9;
    border-top: 1px solid #cbd5e1;
    padding: var(--kb-padding);
    padding-bottom: calc(var(--kb-padding) + var(--kb-safe-bottom));
    gap: var(--kb-gap);
    transition: height 0.25s ease-in-out;
}

#tastatur-wrapper.kb-geschlossen {
    height: calc(
        var(--kb-tab-hoehe)
        + 2 * var(--kb-padding)
        + var(--kb-safe-bottom)
        + 2px
    );
}

#tastatur-wrapper.kb-geschlossen #tastatur-text,
#tastatur-wrapper.kb-geschlossen #tastatur-math,
#tastatur-wrapper.kb-geschlossen #tastatur-erweitert,
#tastatur-wrapper.kb-geschlossen #smart-strip {
    display: none !important;
}

/* ============================================================
   SMART-STRIP
   ============================================================ */
#smart-strip {
    flex-shrink: 0;
    display: flex;
    flex-wrap: nowrap;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    height: var(--kb-strip-hoehe);
    padding: 0 1px;
}

#smart-strip-links {
    display: flex;
    flex-wrap: nowrap;
    flex-direction: row;
    align-items: center;
    gap: 3px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#smart-strip-links::-webkit-scrollbar { display: none; }

#smart-strip-rechts {
    display: flex;
    flex-wrap: nowrap;
    flex-direction: row;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
    border-left: 1px solid #cbd5e1;
    padding-left: 6px;
}

/* Smart-Chip */
.smart-chip {
    flex-shrink: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    min-width: 34px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    -webkit-tap-highlight-color: transparent;
    transition: background 0.1s, transform 0.1s, box-shadow 0.1s;
    font-family: inherit;
}

/* NEU: Druck-Effekt für Chips (0.5px + Innen-Schatten + scale) */
.smart-chip:active {
    background: var(--taste-gedrueckt);
    transform: translateY(0.5px) scale(0.96);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.12);
}

/* Feste Buttons rechts */
.smart-chip.fix {
    background: #f8fafc;
    color: #475569;
    border-color: #cbd5e1;
}

/* ============================================================
   TABS + TOGGLE
   ============================================================ */
#tastatur-tabs {
    flex-shrink: 0;
    display: flex;
    gap: var(--kb-gap);
    height: var(--kb-tab-hoehe);
    width: 100%;
}

#tastatur-tabs .tab {
    flex: 1;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
    transition: background 0.1s, transform 0.1s, box-shadow 0.1s;
}

/* NEU: Druck-Effekt für Tabs (auch inaktiv) */
#tastatur-tabs .tab:active {
    background: var(--taste-gedrueckt);
    transform: translateY(1px);
    box-shadow: var(--schatten-innen);
}

/* Aktiver Tab: blaues Design bleibt */
#tastatur-tabs .tab.aktiv {
    background: #0284c7;
    color: #fff;
    border-color: #0284c7;
}

/* NEU: Druck-Effekt für aktiven Tab (dunkleres Blau) */
#tastatur-tabs .tab.aktiv:active {
    background: #0369a1;
    transform: translateY(1px);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}

/* Ton- und Tastatur-Toggle (gemeinsam) */
#btn-kb-ton,
#btn-kb-toggle {
    flex: 0 0 38px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.1s, transform 0.1s, box-shadow 0.1s;
    font-family: inherit;
}

/* NEU: Druck-Effekt für Toggles */
#btn-kb-ton:active,
#btn-kb-toggle:active {
    background: var(--taste-gedrueckt);
    transform: translateY(1px);
    box-shadow: var(--schatten-innen);
}

/* Ton an: leicht bläulich */
#btn-kb-ton.ton-an {
    background: #e0f2fe;
    border-color: #7dd3fc;
    color: #0369a1;
}
#btn-kb-ton.ton-an:active {
    background: #bae6fd;
    transform: translateY(1px);
    box-shadow: var(--schatten-innen);
}

/* Ton aus: neutral grau */
#btn-kb-ton.ton-aus {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #94a3b8;
}
#btn-kb-ton.ton-aus:active {
    background: var(--taste-gedrueckt);
    transform: translateY(1px);
    box-shadow: var(--schatten-innen);
}

/* ============================================================
   EBENE 1-3
   ============================================================ */
#tastatur-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    gap: var(--kb-gap);
    width: 100%;
}
.q-row { display: flex; flex: 1; min-height: 0; gap: var(--kb-gap); }
.q-row .taste { flex: 1 1 0; min-width: 0; height: 100%; font-size: 17px; font-weight: 500; text-transform: lowercase; }
.q-row .taste.breit { flex: 1.5; }
.q-row .taste.space { flex: 5; }
.q-row .taste.aktiv { background: #bae6fd; }
#tastatur-text.upper .q-row .taste.txt { text-transform: uppercase; }

#tastatur-math {
    display: none; flex: 1; min-height: 0;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: var(--kb-gap); width: 100%;
}
#tastatur-math .taste { height: 100%; font-size: 15px; }

#tastatur-erweitert {
    display: none; flex: 1; min-height: 0;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: var(--kb-gap); width: 100%;
}
#tastatur-erweitert .taste { height: 100%; font-size: 13px; padding: 0 2px; }

/* ============================================================
   TASTEN — Standard
   ============================================================ */
.taste {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
    /* NEU: Übergänge für den Druck-Effekt */
    transition: background 0.08s, transform 0.08s, box-shadow 0.08s;
}

/* NEU: Druck-Effekt für alle Tasten */
.taste:active {
    background: var(--taste-gedrueckt);
    transform: translateY(1px);
    box-shadow: var(--schatten-innen);
}

/* Aktions-Tasten (Shift, Enter, ⌫) */
.taste.aktion {
    background: #cbd5e1;
}
.taste.aktion:active {
    background: var(--taste-aktion-gedrueckt);
    transform: translateY(1px);
    box-shadow: var(--schatten-innen-stark);
}

/* Kleine Tasten (Erweitert-Ebene, sin⁻¹ etc.) */
.taste.taste-klein {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

/* ============================================================
   DESKTOP (≥ 800 px) — Größen, aber gleicher Druck-Effekt
   ============================================================ */
@media (min-width: 800px) {
    :root {
        --kb-hoehe:      clamp(300px, 42dvh, 380px);
        --kb-tab-hoehe:  28px;
        --kb-strip-hoehe: 32px;
        --kb-gap:        3px;
        --kb-padding:    3px;
        /* Druck-Effekt bleibt identisch */
    }

    .taste { font-size: 15px; }
    #tastatur-erweitert .taste { font-size: 14px; }
    #tastatur-tabs .tab { font-size: 14px; }

    .smart-chip {
        height: 28px;
        font-size: 15px;
        padding: 3px 10px;
    }
}