/**
 * Tippgeschwindigkeits-Test
 *
 * Identisch gepflegt in Blocksy-Child und im MVC
 * (tempteria-mvc/public/assets/css/tools/typing-test.css).
 * Aenderungen bitte immer in beide Dateien uebertragen.
 *
 * Farbquelle: erst Blocksy-Palette, dann MVC-Brandvariablen, dann Hex-Fallback.
 */

.ttt {
    --tt-accent: var(--theme-palette-color-1, var(--brand-blue, #2872fa));
    --tt-error: var(--danger, #d63637);
    --tt-ink: var(--theme-headings-color, var(--ink, #1f1f1f));
    --tt-text: var(--theme-text-color, var(--muted, #5a5a5a));
    --tt-surface: var(--surface, #fff);
    --tt-surface-2: var(--surface-2, #f4f6fb);
    --tt-line: var(--border, #e5e7ea);
    --tt-radius: 16px;
    --tt-radius-sm: 10px;

    margin: 2.5rem 0;
    color: var(--tt-text);
    container-type: inline-size;
}

html[data-theme="dark"] .ttt {
    --tt-surface: var(--surface, #111a2e);
    --tt-surface-2: var(--surface-2, #162038);
    --tt-line: var(--border, #1e2942);
    --tt-ink: var(--ink, #e8ecf4);
    --tt-text: var(--muted, #9aa7bd);
}

.ttt *,
.ttt *::before,
.ttt *::after {
    box-sizing: border-box;
}

.ttt__box {
    background: var(--tt-surface);
    border: 1px solid var(--tt-line);
    border-radius: var(--tt-radius);
    padding: 1.4rem;
}

/* --------------------------------------------------------------- Einstellung */

.ttt__setup {
    display: flex;
    flex-wrap: wrap;
    gap: 1.4rem;
    margin-bottom: 1.3rem;
    padding-bottom: 1.2rem;
    border-bottom: 1px solid var(--tt-line);
}

.ttt__group {
    display: grid;
    gap: 0.45rem;
    min-width: 0;
}

.ttt__label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--tt-accent);
}

.ttt__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.ttt__chip {
    padding: 0.4rem 0.7rem;
    font: inherit;
    font-size: 0.83rem;
    line-height: 1.2;
    color: var(--tt-ink);
    background: var(--tt-surface-2);
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ttt__chip:hover {
    border-color: var(--tt-accent);
}

.ttt__chip[aria-pressed="true"] {
    background: var(--tt-accent);
    border-color: var(--tt-accent);
    color: #fff;
}

.ttt__chip:focus-visible,
.ttt__restart:focus-visible,
.ttt__stage:focus-visible {
    outline: 2px solid var(--tt-accent);
    outline-offset: 2px;
}

/* ------------------------------------------------------------- Live-Anzeige */

.ttt__live {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.ttt__stat {
    padding: 0.7rem 0.85rem;
    background: var(--tt-surface-2);
    border-radius: var(--tt-radius-sm);
}

.ttt__stat dt {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.7;
}

.ttt__stat dd {
    margin: 0.2rem 0 0;
    font-family: var(--font-head, inherit);
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--tt-ink);
    font-variant-numeric: tabular-nums;
}

.ttt__stat--time dd {
    color: var(--tt-accent);
}

/* -------------------------------------------------------------- Tippfläche */

.ttt__stage {
    position: relative;
    padding: 1.2rem 1.3rem;
    background: var(--tt-surface-2);
    border-radius: var(--tt-radius-sm);
    cursor: text;
}

.ttt__text {
    margin: 0;
    font-size: clamp(1.05rem, 2.6cqi, 1.3rem);
    line-height: 1.9;
    letter-spacing: 0.01em;
    color: var(--tt-text);
    overflow-wrap: break-word;
    /* Leerzeichen muessen erhalten bleiben, sonst verrutscht die Markierung. */
    white-space: pre-wrap;
    /* Buchstabenbreiten duerfen beim Tippen nicht springen. */
    font-variant-ligatures: none;
}

.ttt__char {
    transition: color 0.05s;
}

.ttt__char--done {
    color: var(--tt-ink);
}

.ttt__char--wrong {
    color: var(--tt-error);
    background: color-mix(in srgb, var(--tt-error) 12%, transparent);
    border-radius: 3px;
}

/* Leerzeichen-Fehler waeren sonst unsichtbar. */
.ttt__char--wrong.ttt__char--space {
    background: color-mix(in srgb, var(--tt-error) 30%, transparent);
}

.ttt__char--next {
    border-radius: 2px;
    box-shadow: -2px 0 0 var(--tt-accent);
}

.ttt__capture {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: transparent;
    caret-color: transparent;
    resize: none;
    outline: none;
    opacity: 0;
}

.ttt__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--tt-ink);
    background: color-mix(in srgb, var(--tt-surface-2) 82%, transparent);
    backdrop-filter: blur(2px);
    border-radius: var(--tt-radius-sm);
}

.ttt__overlay[hidden] {
    display: none;
}

.ttt__hint {
    margin: 0.7rem 0 0;
    font-size: 0.78rem;
    line-height: 1.45;
    opacity: 0.75;
}

.ttt__restart {
    margin-top: 1.1rem;
    padding: 0.7rem 1.3rem;
    font: inherit;
    font-weight: 700;
    color: #fff;
    background: var(--tt-accent);
    border: 0;
    border-radius: var(--tt-radius-sm);
    cursor: pointer;
    transition: filter 0.15s;
}

.ttt__restart:hover {
    filter: brightness(0.92);
}

/* ------------------------------------------------------------------ Ergebnis */

.ttt__result[hidden] {
    display: none;
}

.ttt__result {
    margin-top: 1.3rem;
    padding-top: 1.3rem;
    border-top: 1px solid var(--tt-line);
}

.ttt__headline {
    margin: 0 0 1.1rem;
}

.ttt__headline-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--tt-text);
}

.ttt__headline-value {
    display: block;
    margin-top: 0.1rem;
    font-family: var(--font-head, inherit);
    font-size: clamp(2.4rem, 7cqi, 3.2rem);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.03em;
    color: var(--tt-ink);
    font-variant-numeric: tabular-nums;
}

.ttt__headline-sub {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.85rem;
}

.ttt__cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
    margin: 0 0 1.3rem;
}

@container (max-width: 560px) {
    .ttt__cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .ttt__live {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.ttt__card {
    padding: 0.8rem;
    background: var(--tt-surface-2);
    border-radius: var(--tt-radius-sm);
}

.ttt__card dt {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.7;
}

.ttt__card dd {
    margin: 0.25rem 0 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--tt-ink);
    font-variant-numeric: tabular-nums;
}

.ttt__card-note {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.76rem;
    font-weight: 500;
    opacity: 0.7;
}

/* ---------------------------------------- Signature: Verlauf über die Zeit */

.ttt__chart-title {
    margin: 0 0 0.15rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--tt-ink);
}

.ttt__chart-note {
    margin: 0 0 0.7rem;
    font-size: 0.75rem;
    opacity: 0.75;
}

.ttt__chart {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.ttt__grid-line {
    stroke: currentColor;
    stroke-width: 0.5;
    opacity: 0.18;
}

.ttt__avg-line {
    stroke: currentColor;
    stroke-width: 0.6;
    stroke-dasharray: 3 3;
    opacity: 0.4;
}

.ttt__area {
    fill: var(--tt-accent);
    opacity: 0.1;
}

.ttt__line {
    fill: none;
    stroke: var(--tt-accent);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.ttt__error-dot {
    fill: var(--tt-error);
    stroke: var(--tt-surface);
    stroke-width: 1.5;
}

.ttt__hover-dot {
    fill: var(--tt-accent);
    stroke: var(--tt-surface);
    stroke-width: 1.5;
}

.ttt__axis-label {
    fill: currentColor;
    font-size: 6px;
    opacity: 0.65;
}

.ttt__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 1.1rem;
    margin: 0.6rem 0 0;
    font-size: 0.75rem;
}

.ttt__legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.ttt__key {
    width: 0.85rem;
    height: 0.2rem;
    border-radius: 999px;
    background: var(--tt-accent);
    flex: none;
}

.ttt__key--error {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--tt-error);
}

.ttt__best {
    margin: 1.1rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--tt-line);
    font-size: 0.8rem;
}

.ttt__best b {
    color: var(--tt-ink);
}

@supports not (color: color-mix(in srgb, red 50%, blue)) {
    .ttt__char--wrong {
        background: #fdeaea;
    }
    .ttt__overlay {
        background: rgba(244, 246, 251, 0.9);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ttt *,
    .ttt *::before,
    .ttt *::after {
        transition-duration: 0.01ms !important;
    }
}

/* =========================================================================
   Beitragsinhalt (.tt-prose)
   Gleiche Struktur wie bei den anderen Werkzeugen.
   ========================================================================= */

.tt-prose {
    --tt-accent: var(--theme-palette-color-1, var(--brand-blue, #2872fa));
    --tt-mark: var(--brand-yellow, #ffd800);
    --tt-ink: var(--theme-headings-color, var(--ink, #1f1f1f));
    --tt-text: var(--theme-text-color, var(--muted, #5a5a5a));
    --tt-surface-2: var(--surface-2, #f7f8fb);
    --tt-line: var(--border, #e5e7ea);
    --tt-soft: var(--soft-blue, #eaf1ff);

    max-width: none;
    color: var(--tt-text);
}

html[data-theme="dark"] .tt-prose {
    --tt-surface-2: var(--surface-2, #162038);
    --tt-line: var(--border, #1e2942);
    --tt-ink: var(--ink, #e8ecf4);
    --tt-text: var(--muted, #9aa7bd);
    --tt-soft: var(--soft-blue, #14213f);
}

.tt-prose p {
    margin: 0 0 16px;
    line-height: 1.72;
    color: var(--tt-text);
}

.tt-prose h3 {
    margin: 0 0 8px;
    font-size: 17px;
    color: var(--tt-ink);
}

.tt-prose b,
.tt-prose strong {
    color: var(--tt-ink);
}

.tt-prose .tt-callout {
    margin: 26px 0;
    padding: 18px 22px;
    background: var(--tt-soft);
    border-left: 4px solid var(--tt-accent);
    border-radius: 0 12px 12px 0;
}

.tt-prose .tt-table-wrap {
    overflow-x: auto;
    margin: 0 0 8px;
}

.tt-prose .tt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.tt-prose .tt-table th {
    padding: 12px 14px;
    text-align: left;
    font-size: 12.5px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--tt-text);
    border-bottom: 1px solid var(--tt-line);
}

.tt-prose .tt-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--tt-line);
    color: var(--tt-text);
}

.tt-prose .tt-table td:first-child {
    font-weight: 700;
    color: var(--tt-ink);
    white-space: nowrap;
}

.tt-prose .tt-table th:not(:first-child),
.tt-prose .tt-table td:not(:first-child) {
    text-align: right;
}

.tt-prose .tt-table tr:last-child td {
    border-bottom: 0;
}

.tt-prose .tt-table tr.is-marked td:first-child {
    box-shadow: inset 3px 0 0 var(--tt-mark);
    padding-left: 18px;
}

.tt-prose .tt-compare {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin: 24px 0 8px;
}

.tt-prose .tt-compare-card {
    padding: 22px;
    background: var(--tt-surface-2);
    border: 1px solid var(--tt-line);
    border-radius: 15px;
}

.tt-prose .tt-compare-card p:last-child {
    margin: 0;
    font-size: 14.5px;
}

.tt-prose .tt-figure {
    margin-bottom: 12px !important;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--tt-accent) !important;
}

.tt-prose .tt-faq details {
    border-bottom: 1px solid var(--tt-line);
}

.tt-prose .tt-faq summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 0;
    font-weight: 700;
    color: var(--tt-ink);
    cursor: pointer;
    list-style: none;
}

.tt-prose .tt-faq summary::-webkit-details-marker {
    display: none;
}

.tt-prose .tt-faq summary::after {
    content: "+";
    flex: 0 0 auto;
    font-size: 22px;
    font-weight: 400;
    color: var(--tt-accent);
    transition: transform 0.2s;
}

.tt-prose .tt-faq details[open] summary::after {
    transform: rotate(45deg);
}

.tt-prose .tt-faq details p {
    margin: 0 0 18px;
    padding-right: 36px;
}

@media (prefers-reduced-motion: reduce) {
    .tt-prose .tt-faq summary::after {
        transition: none;
    }
}
