/* BrainTreat shared stylesheet
 * <link rel="stylesheet" href="../shared/shared.css">
 *
 * Page types:   <body>               light site page (themes recolor page + header)
 *               <body class="bt-dark">  dark game page (themes recolor header only)
 * Themes:       <html data-theme="default | halloween | winter">
 * Everything is prefixed bt- so it can't collide with a game's own CSS.
 */

/* ============ 1. TOKENS ============ */
:root {
    --bt-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    --bt-header-bg: #E97462;
    --bt-logo-accent: #88C9C3;
    --bt-page-bg: #f7f8fa;
    --bt-page-text: #1f2933;
    --bt-surface: #ffffff;
    --bt-surface-text: #1f2933;
    --bt-border: rgba(0, 0, 0, 0.08);
    --bt-footer-bg: #ffffff;
    --bt-footer-border: #e2e8f0;
    --bt-footer-text: #64748b;

    --bt-primary: #E97462;
    --bt-secondary: #6366f1;
    --bt-gold: #f59e0b;
    --bt-success: #22c55e;
    --bt-danger: #ef4444;
    --bt-play-bg: #0f172a;

    --bt-radius-sm: 10px;
    --bt-radius: 16px;
    --bt-radius-lg: 20px;
    --bt-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --bt-content-width: 900px;
}

/* Themes: header + (on light pages) page and card colors */
html[data-theme="halloween"] {
    --bt-header-bg: #A35E44;
    --bt-page-bg: #1f2933;
    --bt-page-text: #f7fafc;
    --bt-surface: #2d3748;
    --bt-surface-text: #f7fafc;
    --bt-border: rgba(255, 255, 255, 0.1);
    --bt-footer-bg: #111111;
    --bt-footer-border: #222222;
}
html[data-theme="winter"] {
    --bt-header-bg: #86A8E7;
    --bt-page-bg: #D9EFFF;
    --bt-surface: #ffffff;
    --bt-surface-text: #0c4a6e;
}

/* Dark game pages: keep their own dark palette whatever the theme */
body.bt-dark {
    --bt-page-bg: #020617;
    --bt-page-text: #f8fafc;
    --bt-surface: #0f172a;
    --bt-surface-text: #f8fafc;
    --bt-border: #1e293b;
    --bt-footer-bg: #0f172a;
    --bt-footer-border: #1e293b;
}

/* ============ 2. BASE ============ */
*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}
body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--bt-font);
    background: var(--bt-page-bg);
    color: var(--bt-page-text);
    overflow-x: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}
button { font-family: inherit; }
:focus-visible { outline: 3px solid var(--bt-gold); outline-offset: 2px; }

/* ============ 3. HEADER ============ */
.bt-header {
    background: var(--bt-header-bg);
    min-height: 70px;
    display: flex;
    align-items: center;
    transition: background 0.3s ease;
}
.bt-header__inner {
    width: 100%;
    padding: 0 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.bt-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}
.bt-logo__icon { font-size: 24px; }
.bt-logo__text { margin: 0; font-size: 28px; font-weight: 800; color: #fff; }
.bt-logo__accent { color: var(--bt-logo-accent); }
.bt-nav { display: flex; align-items: center; gap: 15px; }

.bt-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 16px;
    background: #fff;
    color: #000;
    border: 3px solid #000;
    border-radius: 50px;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
    white-space: nowrap;
    text-decoration: none;
    transition: transform 0.1s ease;
}
a.bt-pill:hover { transform: scale(1.05); }

.bt-theme-switcher { gap: 10px; }
.bt-theme-btn {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 2px solid #000;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s ease;
}
.bt-theme-btn:hover { transform: scale(1.1); }
.bt-theme-btn--default   { background: linear-gradient(135deg, #7FA8A3, #4E5E65); }
.bt-theme-btn--halloween { background: linear-gradient(135deg, #A35E44, #3B1E42); }
.bt-theme-btn--winter    { background: linear-gradient(135deg, #D9EFFF, #86A8E7); }

/* ============ 4. PAGE LAYOUT ============ */
.bt-main {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 30px;
}
.bt-game-shell {
    width: 100%;
    max-width: var(--bt-content-width);
    margin: 0 auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    flex: 1;
}
.bt-game-shell--wide { max-width: none; padding: 30px; }

/* Arena where the game happens */
.bt-play-area {
    position: relative;
    width: 100%;
    flex-grow: 1;
    min-height: 380px;
    overflow: hidden;
    background: var(--bt-play-bg);
    border: 4px solid var(--bt-secondary);
    border-radius: var(--bt-radius-lg);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.bt-play-area--boss { border-color: var(--bt-danger); box-shadow: 0 0 25px rgba(239, 68, 68, 0.5); }

/* ============ 5. HUD ============ */
.bt-hud {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 14px;
    font-weight: 800;
}
.bt-hud__group--full { order: 3; width: 100%; }
.bt-hud__group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.bt-hud__stat  { min-width: 90px; }
.bt-hud__stat--end { text-align: right; }

/* Stat bar for light pages (Fruit Math style) */
.bt-stats {
    width: 100%;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px;
    border-radius: var(--bt-radius-sm);
    background: rgba(255, 255, 255, 0.85);
    color: #2c3e50;
    font-size: 1.2rem;
    font-weight: 700;
}

.bt-streak { display: flex; justify-content: center; gap: 8px; }
.bt-streak__dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #1e293b;
    border: 2px solid #334155;
    transition: 0.3s;
}
.bt-streak__dot.is-active {
    background: var(--bt-gold);
    border-color: #fff;
    box-shadow: 0 0 10px var(--bt-gold);
}

/* ============ 6. BUTTONS ============ */
.bt-btn {
    border: none;
    border-radius: 999px;
    padding: 10px 18px;
    font-weight: 800;
    font-size: 1rem;
    white-space: nowrap;
    cursor: pointer;
    color: #fff;
    background: var(--bt-secondary);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.25);
    transition: transform 0.1s ease, filter 0.15s ease;
}
.bt-btn:hover  { transform: translateY(-1px); filter: brightness(1.08); }
.bt-btn:active { transform: scale(0.97); }
.bt-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.bt-btn--block   { width: 100%; }
.bt-btn--primary { background: var(--bt-primary); box-shadow: 0 4px 10px rgba(233, 116, 98, 0.3); }
.bt-btn--gold    { background: var(--bt-gold); color: #000; box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4); }
.bt-btn--success { background: var(--bt-success); box-shadow: none; }
.bt-btn--muted   { background: #64748b; box-shadow: none; }
.bt-btn--ghost   { background: #334155; box-shadow: none; }
.bt-btn--sm      { padding: 6px 14px; font-size: 12px; }

/* ============ 7. OVERLAYS + CARDS ============ */
.bt-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(2, 6, 23, 0.92);
    backdrop-filter: blur(6px);
}
.bt-overlay.is-open { display: flex; }
.bt-overlay--light { background: rgba(255, 255, 255, 0.95); backdrop-filter: none; }

.bt-card {
    width: 90%;
    max-width: 320px;
    padding: 20px 24px;
    text-align: center;
    border-radius: 18px;
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    color: #0f172a;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
}
.bt-card h3 { margin: 0 0 8px; font-size: 1.2rem; }
.bt-card p  { margin: 0 0 14px; font-size: 0.95rem; line-height: 1.5; opacity: 0.85; }
.bt-card__icon { font-size: 2.5rem; margin-bottom: 5px; }
.bt-card--dark {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: #fff;
    border: 3px solid var(--bt-secondary);
}
.bt-card--gold { border-color: var(--bt-gold); }
.bt-card--gold h3 { color: var(--bt-gold); }
.bt-card--wide { max-width: 340px; }

.bt-consent {
    max-width: 260px;
    margin-top: 15px;
    font-size: 11px;
    line-height: 1.4;
    text-align: center;
    color: #fff;
}
.bt-consent a { color: #a5b4fc; text-decoration: underline; font-weight: 700; }

/* Content card (About / How to play) */
.bt-info-card {
    width: 95%;
    max-width: var(--bt-content-width);
    margin: 15px auto 0;
    padding: 25px 30px;
    background: var(--bt-surface);
    color: var(--bt-surface-text);
    border: 1px solid var(--bt-border);
    border-radius: var(--bt-radius-lg);
    box-shadow: var(--bt-shadow);
    transition: background 0.3s ease, color 0.3s ease;
}
.bt-info-card h2 { margin: 0 0 12px; font-size: 1.4rem; font-weight: 800; }
.bt-info-card p  { margin: 0 0 12px; font-size: 0.95rem; line-height: 1.6; opacity: 0.9; }
.bt-info-card p:last-child { margin-bottom: 0; }

/* Ad slots reserve space and stay hidden until filled */
.bt-ad { width: 95%; max-width: var(--bt-content-width); margin: 10px auto; min-height: 0; }

/* ============ 8. FEEDBACK / MOTION ============ */
.bt-float {
    position: absolute;
    left: 50%;
    top: 45%;
    z-index: 999;
    white-space: nowrap;
    font-weight: 900;
    pointer-events: none;
    text-shadow: 0 0 16px rgba(0, 0, 0, 0.9);
    animation: bt-float-up 0.7s ease-out forwards;
}
@keyframes bt-float-up {
    from { transform: translate(-50%, -50%) scale(0.6); opacity: 1; }
    to   { transform: translate(-50%, -110%) scale(1.35); opacity: 0; }
}
.bt-shake { animation: bt-shake 0.25s ease-in-out; }
@keyframes bt-shake {
    0%   { transform: translate(0, 0); }
    20%  { transform: translate(-6px, 4px); }
    40%  { transform: translate(6px, -4px); }
    60%  { transform: translate(-4px, -2px); }
    80%  { transform: translate(4px, 2px); }
    100% { transform: translate(0, 0); }
}
.bt-pop { animation: bt-pop 0.35s ease-out; }
@keyframes bt-pop {
    0%   { transform: scale(0.85); }
    60%  { transform: scale(1.08); }
    100% { transform: scale(1); }
}

/* ============ 9. FOOTER ============ */
.bt-footer {
    width: 100%;
    margin-top: auto;
    flex-shrink: 0;
    background: var(--bt-footer-bg);
    border-top: 1px solid var(--bt-footer-border);
    color: var(--bt-footer-text);
    font-size: 0.9rem;
}
.bt-footer a { color: inherit; }

/* ============ 10. RESPONSIVE ============ */
@media (max-width: 600px) {
    .bt-header { min-height: auto; padding: 12px 0; }
    .bt-header__inner { flex-direction: column; gap: 12px; padding: 0 15px; }
    .bt-logo__text { font-size: 24px; }
    .bt-nav { width: 100%; justify-content: center; gap: 10px; }
    .bt-pill { padding: 5px 12px; }

    .bt-game-shell { padding: 12px; gap: 12px; }
    .bt-game-shell--wide { padding: 15px; }
    .bt-hud { font-size: 12px; }
    .bt-hud__stat { min-width: 60px; }
    .bt-stats { font-size: 0.9rem; padding: 8px; }
    .bt-info-card { padding: 20px; }
}

/* ============ 11. ACCESSIBILITY ============ */
@media (prefers-reduced-motion: reduce) {
    .bt-shake, .bt-pop { animation: none; }
    .bt-float { animation-duration: 0.01s; }
    * { transition-duration: 0.01ms !important; }
}
