/* Campfire Arcade — shared design tokens and base components.
   Every page links this first, then its own game stylesheet.
   Games set --accent / --accent-deep / --accent-tint on :root. */

@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("/assets/fonts/inter-medium.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("/assets/fonts/inter-semibold.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("/assets/fonts/inter-bold.woff2") format("woff2"); }

:root {
    --bg: #f4f1ea;
    --surface: #ffffff;
    --surface-2: #faf8f4;
    --ink: #1c1a17;
    --muted: #77716a;
    --line: #e6e1d7;
    --danger: #c8473a;
    --success: #2f9a5d;

    --accent: #1c1a17;
    --accent-deep: #1c1a17;
    --accent-tint: #ece8df;

    --red: #e06a55;
    --red-deep: #a63a28;
    --blue: #4f7fd0;
    --blue-deep: #2b559e;

    --radius-lg: clamp(18px, 1.6vw, 28px);
    --radius: 14px;
    --radius-sm: 10px;
    --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-weight: 500;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

p { margin: 0; }

a { color: var(--accent-deep); }

[hidden] { display: none !important; }

/* ---------- Buttons ---------- */
button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45em;
    min-height: 2.75rem;
    padding: 0.6em 1.15em;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--accent-deep);
    color: #fff;
    font: 600 1rem/1.2 var(--font);
    letter-spacing: -0.01em;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
}

button:hover,
.btn:hover { background: color-mix(in srgb, var(--accent-deep) 86%, #000); }

button:active,
.btn:active { transform: translateY(1px); }

button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
    outline-offset: 2px;
}

button:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

button.secondary,
.btn.secondary {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
}

button.secondary:hover,
.btn.secondary:hover { border-color: var(--ink); background: var(--surface); }

button.ghost,
.btn.ghost {
    background: transparent;
    color: var(--ink);
}

button.ghost:hover,
.btn.ghost:hover { background: rgba(28, 26, 23, 0.06); }

button.danger,
.btn.danger { background: var(--danger); }

button.danger:hover,
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }

button.large,
.btn.large {
    min-height: 3.4rem;
    padding: 0.8em 1.6em;
    font-size: 1.1rem;
    border-radius: 16px;
}

/* ---------- Form fields ---------- */
input,
select,
textarea {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.6em 0.85em;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font: 500 1rem/1.3 var(--font);
}

input::placeholder,
textarea::placeholder { color: #a9a39a; }

input[type="color"] {
    width: 3rem;
    padding: 0.25rem;
    cursor: pointer;
}

input[type="range"] {
    padding: 0;
    min-height: 0;
    border: 0;
    background: none;
    accent-color: var(--accent-deep);
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    min-height: 0;
    accent-color: var(--accent-deep);
}

label {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.field {
    display: grid;
    gap: 0.4rem;
}

/* ---------- Surfaces ---------- */
.panel {
    padding: clamp(1rem, 1.6vw, 1.6rem);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.eyebrow {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.3em 0.75em;
    border-radius: 999px;
    background: var(--accent-tint);
    color: var(--accent-deep);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.muted { color: var(--muted); }

/* ---------- App bar with "back to arcade" ---------- */
.appbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: clamp(0.75rem, 1.4vw, 1.25rem) clamp(1rem, 2.4vw, 2.5rem);
}

.appbar h1 {
    font-size: clamp(1.25rem, 1.8vw, 1.75rem);
    color: var(--accent-deep);
}

.appbar .spacer { flex: 1; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.7rem 0.4rem 0.5rem;
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.back-link:hover { background: rgba(28, 26, 23, 0.06); color: var(--ink); }

.back-link svg { width: 1rem; height: 1rem; }

/* ---------- Modal ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    place-items: center;
    padding: 1rem;
    background: rgba(28, 26, 23, 0.42);
    backdrop-filter: blur(4px);
}

.modal[style*="block"],
.modal.open { display: grid !important; }

.modal-content {
    position: relative;
    display: grid;
    gap: 1rem;
    width: min(440px, 100%);
    max-height: calc(100vh - 2rem);
    overflow: auto;
    padding: clamp(1.25rem, 2vw, 2rem);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: 0 30px 80px rgba(28, 26, 23, 0.25);
}

.modal-content h2 { font-size: 1.4rem; padding-right: 2rem; }

.close-button {
    position: absolute;
    top: 0.9rem;
    right: 0.9rem;
    display: grid;
    place-items: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    color: var(--muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.close-button:hover { background: rgba(28, 26, 23, 0.06); color: var(--ink); }

/* ---------- Toast ---------- */
.toast-stack {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    z-index: 200;
    display: grid;
    gap: 0.5rem;
    transform: translateX(-50%);
    pointer-events: none;
}

.toast {
    padding: 0.75rem 1.1rem;
    border-radius: var(--radius);
    background: var(--ink);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 12px 30px rgba(28, 26, 23, 0.25);
    animation: toast-in 0.2s ease;
}

.toast.error { background: var(--danger); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
}

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