﻿/* ================================================================
   PracticeMath - Stylesheet
   Calculator-inspired dark training interface
   ================================================================ */

/* -- Custom Properties -- */
:root {
    --bg-dark: #0e1015;
    --bg-panel: #161920;
    --bg-card: #1c1f2a;
    --bg-input: #232736;
    --bg-key: #272b3a;
    --bg-key-hover: #323750;
    --bg-key-press: #3b4160;
    --bg-submit: #3b82f6;
    --bg-submit-hover: #2563eb;
    --bg-correct: #16a34a;
    --bg-wrong: #dc2626;
    --border: #2a2e3d;
    --border-focus: #4a5070;
    --text: #eaecf4;
    --text-mid: #b0b5cc;
    --text-dim: #6b7194;
    --accent: #f59e42;
    --accent-dim: rgba(245,158,66,0.12);
    --blue: #3b82f6;
    --blue-dim: rgba(59,130,246,0.12);
    --green: #22c55e;
    --red: #ef4444;
    --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Consolas', 'SF Mono', 'Menlo', 'Liberation Mono', monospace;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --transition: 0.15s ease;
}

/* -- Reset -- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    background: var(--bg-dark);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
img { display: block; max-width: 100%; }

/* -- Scrollbar -- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ================================================================
   SITE HEADER
   ================================================================ */
.site-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.site-hdr__logo {
    display: flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    color: var(--text);
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.03em;
    flex-shrink: 0;
    z-index: 102;
}
.site-hdr__logo:hover { text-decoration: none; }
.site-hdr__logo img { width: 28px; height: 28px; }
.site-hdr__logo .hl { color: var(--accent); }

/* Nav */
.site-hdr__nav {
    display: flex;
    gap: 20px;
    align-items: center;
}
.site-hdr__nav a {
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: color var(--transition);
}
.site-hdr__nav a:hover { color: var(--text); text-decoration: none; }

/* Hamburger toggle (hidden on desktop) */
.site-hdr__toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-mid);
    font-size: 1.3rem;
    cursor: pointer;
    z-index: 102;
    transition: border-color var(--transition);
}
.site-hdr__toggle:hover { border-color: var(--border-focus); color: var(--text); }

/* ================================================================
   LAYOUT
   ================================================================ */
.page-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ================================================================
   TRAINER + HISTORY WRAPPER
   ================================================================ */
.trainer-wrap {
    display: flex;
    flex-direction: column;
    max-width: 520px;
    margin: 40px auto;
    padding: 0 20px;
    align-items: stretch;
}

/* ================================================================
   TRAINER PANEL
   ================================================================ */
.trainer {
    min-width: 0;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    overflow: hidden;
}

/* -- setup bar -- */
.trainer__setup {
    display: flex;
    gap: 8px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.trainer__select {
    flex: 1;
    min-width: 110px;
    padding: 9px 32px 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7194'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
.trainer__select:focus { outline: none; border-color: var(--blue); }
.trainer__select option { background: var(--bg-panel); }
.trainer__go {
    padding: 9px 22px;
    background: var(--bg-submit);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition);
}
.trainer__go:hover { background: var(--bg-submit-hover); }

/* -- stats bar -- */
.trainer__stats {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.trainer__stat {
    flex: 1;
    text-align: center;
    padding: 10px 6px;
    border-right: 1px solid var(--border);
}
.trainer__stat:last-child { border-right: none; }
.stat__label {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 2px;
}
.stat__value {
    display: block;
    font-size: 1.15rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text);
}
.stat__value--correct { color: var(--green); }
.stat__value--wrong { color: var(--red); }
.stat__value--streak { color: var(--accent); }

/* -- question display -- */
.trainer__question {
    padding: 28px 22px 14px;
    text-align: center;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.q-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    margin-bottom: 10px;
}
.q-text {
    font-size: 2rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--text);
    letter-spacing: 0.02em;
    word-break: break-word;
    line-height: 1.3;
}

/* -- answer display -- */
.trainer__answer-display {
    margin: 0 18px;
    padding: 14px 18px;
    background: var(--bg-dark);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    font-family: var(--font-mono);
    font-size: 1.7rem;
    font-weight: 700;
    text-align: right;
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    color: var(--text);
    transition: border-color var(--transition), color var(--transition);
    overflow: hidden;
    word-break: break-all;
}
.trainer__answer-display--correct {
    border-color: var(--green);
    color: var(--green);
}
.trainer__answer-display--wrong {
    border-color: var(--red);
    color: var(--red);
}
.answer-cursor {
    display: inline-block;
    width: 2px;
    height: 1.3em;
    background: var(--blue);
    margin-left: 2px;
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}
@keyframes blink { 50% { opacity: 0; } }

/* -- keypad -- */
.trainer__keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 12px 18px 18px;
}
.key {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 8px;
    background: var(--bg-key);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), transform 0.08s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.key:hover { background: var(--bg-key-hover); border-color: var(--border-focus); }
.key:active { background: var(--bg-key-press); transform: scale(0.96); }
.key--submit {
    background: var(--bg-submit);
    border-color: var(--bg-submit);
    color: #fff;
    grid-row: span 2;
}
.key--submit:hover { background: var(--bg-submit-hover); border-color: var(--bg-submit-hover); }
.key--zero { grid-column: span 3; }
.key--action {
    font-size: 0.85rem;
    font-family: var(--font);
    font-weight: 600;
    color: var(--text-mid);
}

/* -- session controls -- */
.trainer__controls {
    display: flex;
    gap: 8px;
    padding: 0 18px 16px;
}
.ctrl-btn {
    flex: 1;
    padding: 9px 10px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.ctrl-btn:hover {
    border-color: var(--border-focus);
    color: var(--text-mid);
}

/* ================================================================
   HISTORY STRIP (below calculator, exactly 5 items)
   ================================================================ */
.history {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    overflow: hidden;
}
.history__list {
    display: flex;
    flex-direction: column;
}
.history__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 16px;
    font-size: 0.82rem;
    font-family: var(--font-mono);
    border-top: 1px solid var(--border);
}
.history__item--correct { background: rgba(34, 197, 94, 0.06); }
.history__item--wrong   { background: rgba(239, 68, 68, 0.06); }
.history__q {
    color: var(--text-mid);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
}
.history__a {
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}
.history__item--correct .history__a { color: var(--green); }
.history__item--wrong .history__a { color: var(--red); }

/* ================================================================
   HOMEPAGE SECTIONS
   ================================================================ */
.hero {
    text-align: center;
    padding: 56px 20px 20px;
    max-width: 640px;
    margin: 0 auto;
}
.hero__title {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
    margin-bottom: 14px;
}
.hero__title .hl, .hl { color: var(--accent); }
.hero__sub {
    color: var(--text-mid);
    font-size: 1rem;
    line-height: 1.6;
    max-width: 500px;
    margin: 0 auto;
}

/* -- categories grid -- */
.cats {
    padding: 48px 20px 20px;
    max-width: 820px;
    margin: 0 auto;
}
.cats__title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
    color: var(--text);
}
.cats__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.cat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 22px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--text);
    transition: border-color var(--transition), background var(--transition);
}
.cat-card:hover {
    border-color: var(--border-focus);
    background: var(--bg-input);
    text-decoration: none;
}
.cat-card__icon { font-size: 1.8rem; margin-bottom: 8px; }
.cat-card__name { font-size: 0.92rem; font-weight: 700; }
.cat-card__desc {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 4px;
    text-align: center;
    line-height: 1.4;
}

/* -- how it works -- */
.how {
    padding: 48px 20px;
    max-width: 700px;
    margin: 0 auto;
}
.how__title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
}
.how__steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}
.how__step { text-align: center; padding: 18px 10px; }
.how__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.95rem;
    margin-bottom: 10px;
}
.how__step-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 5px; }
.how__step-desc { font-size: 0.82rem; color: var(--text-dim); line-height: 1.5; }

/* -- benefits -- */
.benefits {
    padding: 30px 20px 48px;
    max-width: 700px;
    margin: 0 auto;
}
.benefits__title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 18px;
    text-align: center;
}
.benefits__list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    list-style: none;
}
.benefits__list li {
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.88rem;
    color: var(--text-mid);
    line-height: 1.5;
}
.benefits__list li strong {
    color: var(--text);
    display: block;
    margin-bottom: 3px;
}

/* -- faq -- */
.faq {
    padding: 30px 20px 56px;
    max-width: 700px;
    margin: 0 auto;
}
.faq__title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 18px;
    text-align: center;
}
.faq__item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    background: var(--bg-card);
}
.faq__item summary {
    padding: 14px 18px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.faq__item summary::-webkit-details-marker { display: none; }
.faq__item summary::after {
    content: '+';
    font-size: 1.15rem;
    color: var(--text-dim);
    flex-shrink: 0;
    margin-left: 12px;
}
.faq__item[open] summary::after { content: '\2212'; }
.faq__item p, .faq__item div {
    padding: 0 18px 14px;
    font-size: 0.88rem;
    color: var(--text-mid);
    line-height: 1.65;
}

/* -- category page intro -- */
.cat-intro {
    max-width: 640px;
    margin: 0 auto;
    padding: 44px 20px 10px;
    text-align: center;
}
.cat-intro__title {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
    line-height: 1.25;
}
.cat-intro__desc {
    color: var(--text-mid);
    font-size: 0.95rem;
    line-height: 1.65;
    max-width: 520px;
    margin: 0 auto;
}

/* -- cross links -- */
.cross-links {
    max-width: 700px;
    margin: 0 auto;
    padding: 30px 20px 50px;
    text-align: center;
}
.cross-links__title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--text);
}
.cross-links__list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
.cross-links__list a {
    padding: 7px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-mid);
    font-size: 0.84rem;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition);
}
.cross-links__list a:hover {
    border-color: var(--border-focus);
    color: var(--text);
    text-decoration: none;
}

/* ================================================================
   LEGAL PAGES
   ================================================================ */
.legal {
    max-width: 680px;
    margin: 0 auto;
    padding: 44px 20px 80px;
}
.legal h1 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 6px;
}
.legal h2 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-top: 26px;
    margin-bottom: 8px;
    color: var(--accent);
}
.legal h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-top: 18px;
    margin-bottom: 6px;
}
.legal p, .legal li {
    color: var(--text-mid);
    font-size: 0.9rem;
    line-height: 1.7;
    margin-bottom: 10px;
}
.legal ul { padding-left: 18px; }
.legal li { margin-bottom: 5px; }
.legal a { color: var(--blue); }

/* -- contact card -- */
.contact-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 26px;
    margin: 20px 0;
}
.contact-card h2 { margin-top: 0; }
.contact-btns {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 16px 0;
}
.contact-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition);
    border: none;
    cursor: pointer;
}
.contact-btn--primary {
    background: var(--bg-submit);
    color: #fff !important;
}
.contact-btn--primary:hover { background: var(--bg-submit-hover); text-decoration: none; }
.contact-btn--secondary {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-mid);
}
.contact-btn--secondary:hover { border-color: var(--border-focus); color: var(--text); text-decoration: none; }

/* ================================================================
   FOOTER
   ================================================================ */
.site-ftr {
    border-top: 1px solid var(--border);
    padding: 28px 20px;
}
.ftr-links {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    margin-bottom: 12px;
}
.ftr-links a {
    color: var(--text-dim);
    font-size: 0.8rem;
    text-decoration: none;
    transition: color var(--transition);
}
.ftr-links a:hover { color: var(--text-mid); }
.ftr-copy {
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-dim);
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 700px) {
    /* hamburger nav */
    .site-hdr__toggle { display: flex; }
    .site-hdr__nav {
        display: none;
        position: fixed;
        top: 56px;
        left: 0; right: 0;
        background: var(--bg-panel);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: 12px 24px 16px;
        gap: 6px;
        z-index: 101;
    }
    .site-hdr__nav.open { display: flex; }
    .site-hdr__nav a { font-size: 0.95rem; padding: 8px 0; }

    .hero { padding-top: 36px; }
    .hero__title { font-size: 1.55rem; }
    .how__steps { grid-template-columns: 1fr; gap: 10px; }
    .benefits__list { grid-template-columns: 1fr; }
    .cats__grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }

    .trainer-wrap {
        margin: 24px auto;
        padding: 0 12px;
    }

    .q-text { font-size: 1.5rem; }
    .trainer__answer-display { font-size: 1.35rem; padding: 12px 14px; }
    .key { padding: 14px 6px; font-size: 1.15rem; }
}

@media (max-width: 440px) {
    .site-hdr { padding: 0 14px; }
    .trainer__setup { padding: 12px 12px; }
    .trainer__question { padding: 20px 14px 10px; }
    .trainer__answer-display { margin: 0 12px; font-size: 1.2rem; }
    .trainer__keypad { padding: 10px 12px 14px; gap: 5px; }
    .key { padding: 13px 4px; font-size: 1.05rem; }
    .trainer__controls { padding: 0 12px 12px; }
    .cat-intro__title { font-size: 1.3rem; }
}

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