/**
 * oma-games — Shared CSS for all games.
 *
 * Provides ONLY:
 *   - Minimal reset
 *   - Theme token defaults (each game overrides visual identity)
 *   - Common UI primitives (difficulty group, count stepper, panel, key cap)
 *
 * Each game's own <style> defines its unique look. This file is intentionally
 * visual-identity-neutral so games can be military HUD, neon arcade, retro
 * terminal, etc., without fighting shared styles.
 *
 * Usage: <link rel="stylesheet" href="../shared/oma-games.css">
 */

/* ===== Reset ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary, #0a0a0a);
    color: var(--text-primary, #f9fafb);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.25s ease, color 0.25s ease;
}

button,
input {
    font: inherit;
    color: inherit;
}

button {
    background: none;
    border: none;
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ===== Theme tokens (defaults; games override freely) ===== */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-card: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-dim: #9ca3af;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --accent: #8b5cf6;
    --accent-strong: #7c3aed;
    --accent-contrast: #ffffff;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
}

[data-theme='dark'] {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-card: #181818;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-dim: #6b7280;
    --border: #1f1f1f;
    --border-strong: #2a2a2a;
    --accent: #a78bfa;
    --accent-strong: #8b5cf6;
    --accent-contrast: #0a0a0a;
    --danger: #f87171;
    --success: #34d399;
    --warning: #fbbf24;
}

/* ===== Layout primitives ===== */
.oma-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== Common UI: difficulty button group =====
 * Used by every game's config panel.
 * Visual variant can be overridden per-game via CSS variables.
 */
.oma-diff-group {
    display: flex;
}

.oma-diff-btn {
    flex: 1;
    padding: 9px 0;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 12px;
    letter-spacing: 1px;
    transition: all 0.2s;
}

.oma-diff-btn:first-child {
    border-radius: 4px 0 0 4px;
}

.oma-diff-btn:last-child {
    border-radius: 0 4px 4px 0;
}

.oma-diff-btn + .oma-diff-btn {
    border-left: none;
}

.oma-diff-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.oma-diff-btn.active {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: var(--accent);
}

/* ===== Common UI: count stepper (− input +) ===== */
.oma-count {
    display: flex;
}

.oma-count-btn {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 18px;
    transition: all 0.15s;
}

.oma-count-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.oma-count-btn:first-child {
    border-radius: 4px 0 0 4px;
}

.oma-count-btn:last-child {
    border-radius: 0 4px 4px 0;
}

.oma-count-input {
    width: 64px;
    height: 38px;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-left: none;
    border-right: none;
    color: var(--accent);
    -moz-appearance: textfield;
}

.oma-count-input::-webkit-outer-spin-button,
.oma-count-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ===== Common UI: panel (config / sidebar) ===== */
.oma-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 20px;
}

.oma-panel-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.oma-field {
    margin-bottom: 16px;
}

.oma-field:last-child {
    margin-bottom: 0;
}

.oma-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.oma-hint {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 6px;
}

/* ===== Common UI: primary action button ===== */
.oma-btn-primary {
    display: inline-block;
    width: 100%;
    padding: 14px 20px;
    background: var(--accent);
    color: var(--accent-contrast);
    border: 1px solid var(--accent);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    transition: all 0.2s;
}

.oma-btn-primary:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

.oma-btn-primary:active {
    transform: scale(0.98);
}

.oma-btn-primary:disabled {
    background: var(--bg-secondary);
    color: var(--text-dim);
    border-color: var(--border);
    cursor: not-allowed;
}

/* ===== Common UI: keyboard key cap (used in controls help) ===== */
.oma-key {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 11px;
    color: var(--text-primary);
    min-width: 22px;
    text-align: center;
}

/* ===== Common UI: header with theme/lang toggle =====
 * Reusable top bar for games that need global controls.
 */
.oma-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.oma-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--text-primary);
}

.oma-icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: 8px;
    transition: all 0.15s;
}

.oma-icon-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.oma-header-controls {
    display: flex;
    gap: 8px;
}

/* ===== Common UI: unified game header (in-game top bar) =====
 * Renders via OmaGames.ui.header({ back, mount }).
 * Uses currentColor inheritance so each game's body `color` drives the look.
 * Override these vars per-game if needed:
 *   --oma-header-bg     (default: rgba(0,0,0,0.45))
 *   --oma-header-fg     (default: currentColor — i.e. body color)
 *   --oma-header-border (default: currentColor)
 *   --oma-header-hover-bg (default: currentColor; hover swaps fg/bg)
 */
.oma-game-header {
    position: fixed;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    font-family: inherit;
}

.oma-game-header > * {
    pointer-events: auto;
}

.oma-game-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--oma-header-border, currentColor);
    background: var(--oma-header-bg, rgba(0, 0, 0, 0.45));
    color: var(--oma-header-fg, currentColor);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-size: 12px;
    letter-spacing: 1px;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.oma-game-back:hover {
    background: var(--oma-header-hover-bg, currentColor);
    color: var(--oma-header-hover-fg, var(--bg-primary, #000));
    box-shadow: 0 0 16px var(--oma-header-glow, transparent);
}

.oma-game-back-arrow {
    font-size: 10px;
    opacity: 0.7;
}

.oma-game-controls {
    display: flex;
    gap: 8px;
}

.oma-game-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--oma-header-border, currentColor);
    background: var(--oma-header-bg, rgba(0, 0, 0, 0.45));
    color: var(--oma-header-fg, currentColor);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    letter-spacing: 1px;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.oma-game-btn:hover {
    background: var(--oma-header-hover-bg, currentColor);
    color: var(--oma-header-hover-fg, var(--bg-primary, #000));
    box-shadow: 0 0 16px var(--oma-header-glow, transparent);
}

@media (max-width: 600px) {
    .oma-game-back-text {
        display: none;
    }
    .oma-game-back {
        padding: 6px 10px;
    }
}
