/* ═══════════════════════════════════════════════════
   Keyboard Tester — styles
   ═══════════════════════════════════════════════════ */

.keyboard-tester {
    padding: 60px 0;
    background: #f8f9fa;
}

.keyboard-tester-header h2 {
    color: #333;
    margin-bottom: 15px;
}

.keyboard-tester-header .lead {
    color: #666;
    font-size: 1.1rem;
}

.keyboard-instructions {
    border-left: 4px solid #007bff;
}

/* ── Controls bar ─────────────────────────────────── */
.keyboard-controls {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .1);
}

/* ── Stats cards ──────────────────────────────────── */
.pressed-keys-display {
    min-height: 40px;
    padding: 8px 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    word-break: break-all;
    line-height: 1.6;
}

/* ── Keyboard outer wrapper ──────────────────────── */
.keyboard-container {
    background: white;
    padding: 24px 20px 20px;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .1);
    overflow-x: auto;
    /* horizontal scroll on small screens */
    text-align: center;
    /* centres the inline-flex kb-wrapper */
}

/* Flex row: main | nav | numpad */
.kb-wrapper {
    display: inline-flex;
    /* shrink-wrap to content */
    gap: 16px;
    align-items: flex-start;
    font-family: 'Courier New', monospace;
    user-select: none;
    min-width: max-content;
    /* prevents wrapping keys */
}

/* ── Sections ────────────────────────────────────── */
.kb-main,
.kb-nav,
.kb-numpad {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* ── Rows ────────────────────────────────────────── */
.kb-row {
    display: flex;
    gap: 5px;
    align-items: stretch;
}

.kb-row-fn {
    margin-bottom: 8px;
    /* extra gap below fn row */
}

.kb-row-spacer {
    height: 14px;
    /* gap between nav groups */
}

/* ── Base key ────────────────────────────────────── */
.key {
    background: #f1f3f4;
    border: 1.5px solid #c8cbcf;
    border-bottom: 3px solid #b0b4ba;
    border-radius: 6px;
    padding: 0;
    min-width: 38px;
    height: 38px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #333;
    cursor: default;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.15;
    white-space: nowrap;
    flex-shrink: 0;
}

.key:hover {
    background: #e8eaed;
}

/* Permanent "tested / ever-pressed" state */
.key.tested {
    background: #28a745;
    border-color: #1e7e34;
    border-bottom-color: #155724;
    color: #fff;
}

/* Momentary "active / held" animation */
.key.active {
    transform: translateY(2px);
    border-bottom-width: 1.5px;
    background: #218838;
    color: #fff;
}

/* Spacer between keys that don't exist */
.key-spacer {
    min-width: 12px;
    height: 38px;
    flex-shrink: 0;
}

.key-cell-empty {
    min-width: 38px;
    height: 38px;
    flex-shrink: 0;
}

/* ── Width variants (main keyboard) ──────────────── */
.w-backspace {
    min-width: 82px;
}

.w-tab {
    min-width: 62px;
}

.w-backslash {
    min-width: 56px;
}

.w-caps {
    min-width: 78px;
}

.w-enter {
    min-width: 88px;
}

.w-shift-l {
    min-width: 100px;
}

.w-shift-r {
    min-width: 116px;
}

.w-ctrl,
.w-alt,
.w-meta,
.w-menu {
    min-width: 52px;
}

.w-space {
    min-width: 260px;
}

/* ── Navigation block — CSS grid ─────────────────── */
/* 7 rows: system | gap | ins/home/pgup | del/end/pgdn | gap | arrow-up | arrows */
.kb-nav-grid {
    display: grid;
    grid-template-columns: repeat(3, 44px);
    grid-template-rows:
        38px
        /* 1: PrtSc / ScrLk / Pause */
        14px
        /* 2: gap */
        38px
        /* 3: Ins / Home / PgUp */
        38px
        /* 4: Del / End / PgDn */
        14px
        /* 5: gap */
        38px
        /* 6: ↑ */
        38px;
    /* 7: ← ↓ → */
    gap: 5px 5px;
}

.nav-key {
    min-width: unset;
    /* size is managed by grid */
    height: unset;
    font-size: 10px;
}

/* Arrow keys larger icon */
.arrow-key {
    font-size: 14px;
}

/* ── Numpad — CSS grid for proper rowspan ─────────── */
.kb-numpad-grid {
    display: grid;
    grid-template-columns: repeat(4, 44px);
    grid-template-rows: repeat(5, 38px);
    gap: 5px;
}

.num-key {
    /* sizing handled by grid */
    min-width: unset;
    height: unset;
}

/* Numpad 0 spans 2 columns; + and Enter span 2 rows.
   Dimensions are set via inline grid-column / grid-row styles in JS. */

/* ── Limitations alert ───────────────────────────── */
.keyboard-limitations {
    border-left: 4px solid #ffc107;
}

/* ── SEO Content ─────────────────────────────────── */
.seo-content {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 30px;
}

.seo-content h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.seo-content h3 {
    color: #007bff;
    margin-top: 25px;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.seo-content p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 15px;
}

.seo-content ul {
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
}

.seo-content li {
    margin-bottom: 8px;
}

.seo-content strong {
    color: #495057;
    font-size: 16px;
}

/* ── @1280px: laptop / 1024px viewport ───────────── */
/* At 1024px the Bootstrap container is ~960px.
   Scale keys 38→33px and wide keys ~87% so total width ≈ 890px */
@media (max-width: 1280px) {
    .keyboard-container {
        padding: 16px 12px;
    }

    .kb-wrapper {
        gap: 12px;
    }

    .kb-main {
        gap: 4px;
    }

    .kb-row {
        gap: 4px;
    }

    .kb-row-fn {
        margin-bottom: 6px;
    }

    .key {
        min-width: 33px;
        height: 33px;
        font-size: 10px;
        border-radius: 5px;
    }

    .key-spacer,
    .key-cell-empty {
        min-width: 10px;
        height: 33px;
    }

    /* Wide keys — scaled ×0.87 relative to base */
    .w-backspace {
        min-width: 72px;
    }

    .w-tab {
        min-width: 54px;
    }

    .w-backslash {
        min-width: 48px;
    }

    .w-caps {
        min-width: 68px;
    }

    .w-enter {
        min-width: 76px;
    }

    .w-shift-l {
        min-width: 88px;
    }

    .w-shift-r {
        min-width: 100px;
    }

    .w-ctrl,
    .w-alt,
    .w-meta,
    .w-menu {
        min-width: 45px;
    }

    .w-space {
        min-width: 226px;
    }

    /* Navigation grid */
    .kb-nav-grid {
        grid-template-columns: repeat(3, 40px);
        grid-template-rows: 33px 12px 33px 33px 12px 33px 33px;
        gap: 4px 4px;
    }

    .nav-key {
        font-size: 9px;
    }

    .arrow-key {
        font-size: 13px;
    }

    /* Numpad grid */
    .kb-numpad-grid {
        grid-template-columns: repeat(4, 40px);
        grid-template-rows: repeat(5, 33px);
        gap: 4px;
    }
}


@media (max-width: 768px) {
    .keyboard-container {
        padding: 12px 8px;
    }

    .key {
        min-width: 28px;
        height: 30px;
        font-size: 9px;
    }

    .key-spacer,
    .key-cell-empty {
        min-width: 28px;
        height: 30px;
    }

    .w-space {
        min-width: 160px;
    }

    .w-backspace {
        min-width: 60px;
    }

    .w-tab {
        min-width: 46px;
    }

    .w-backslash {
        min-width: 42px;
    }

    .w-caps {
        min-width: 60px;
    }

    .w-enter {
        min-width: 66px;
    }

    .w-shift-l {
        min-width: 76px;
    }

    .w-shift-r {
        min-width: 88px;
    }

    .w-ctrl,
    .w-alt,
    .w-meta,
    .w-menu {
        min-width: 40px;
    }

    .nav-key {
        font-size: 8px;
    }

    .kb-nav-grid {
        grid-template-columns: repeat(3, 34px);
        grid-template-rows:
            30px 12px 30px 30px 12px 30px 30px;
        gap: 4px 4px;
    }

    .kb-numpad-grid {
        grid-template-columns: repeat(4, 34px);
        grid-template-rows: repeat(5, 30px);
        gap: 4px;
    }

    .kb-wrapper {
        gap: 10px;
    }

    .kb-main {
        gap: 4px;
    }

    .kb-row {
        gap: 4px;
    }
}