/* ── Visibility helpers ─────────────────────────────────────── */
.modal-hidden {
    visibility: hidden;
}

.modal-visible {
    visibility: visible;
}

/* ── Base ───────────────────────────────────────────────────── */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: #f8fafc;
    color: #1e293b;
    min-height: 100vh;
}

/* ── Typography ─────────────────────────────────────────────── */
h4.section-heading {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #64748b;
    border-bottom: 2px solid #ddd6fe;
    padding: 0.5rem 0.5rem 0.25rem;
    margin-bottom: 0.5rem;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card-accent {
    background: #faf5ff;
    border: 1px solid #c4b5fd;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* ── Inputs ─────────────────────────────────────────────────── */
input[type="text"],
input[type="number"],
textarea {
    border: 1px solid #cbd5e1;
    border-radius: 0.25rem;
    padding: 0.125rem 0.375rem;
    background: white;
    font-size: inherit;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus {
    outline: none;
    border-color: #a78bfa;
    box-shadow: 0 0 0 2px rgba(167,139,250,0.2);
}

select {
    border: 1px solid #cbd5e1;
    border-radius: 0.25rem;
    padding: 0.125rem 0.25rem;
    background: white;
    font-size: inherit;
    font-family: inherit;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 1rem;
    line-height: 1;
    transition: background-color 0.15s;
    border: none;
    background: transparent;
}

.btn-icon:hover {
    background-color: rgba(0,0,0,0.07);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    background-color: #7c3aed;
    color: white;
    border: none;
    transition: background-color 0.15s;
}

.btn-primary:hover {
    background-color: #6d28d9;
}

/* ── Header ─────────────────────────────────────────────────── */
#character-header {
    background: #1e293b;
    color: white;
    position: sticky;
    top: 0;
    z-index: 20;
}

#character-header input {
    background: transparent;
    color: white;
    border-color: rgba(255,255,255,0.3);
}

#character-header input:focus {
    border-color: #a78bfa;
    box-shadow: 0 0 0 2px rgba(167,139,250,0.25);
}

/* ── Dice roll states ───────────────────────────────────────── */
.glitch {
    color: #fb923c;
}

.success {
    color: #60a5fa;
}

.critical {
    color: #34d399;
}

.critical::before {
    content: "✨";
}

.critical::after {
    content: "✨";
}

/* ── Weight progress bar ────────────────────────────────────── */
progress[value] {
    --w: calc(min(50vw, 300px));
    --red-limit: calc(0.33 * var(--w));
    --orange-limit: calc(0.67 * var(--w));
    --b:
        linear-gradient(#fff8, #fff0),
        repeating-linear-gradient(135deg, #0003 0 10px, #0000 0 20px),
        linear-gradient(red 0 0) 0 / calc(var(--red-limit) - 100%) 1px,
        linear-gradient(orange 0 0) 0 / calc(var(--orange-limit) - 100%) 1px,
        green;
    width: var(--w);
    height: 18px;
    background-color: #e2e8f0;
    border-radius: 50px;
    align-self: end;
}

progress[value]::-webkit-progress-bar {
    background-color: #e2e8f0;
    border-radius: 50px;
}

progress[value]::-webkit-progress-value {
    border-radius: 50px;
    background: var(--b);
}

progress[value]::-moz-progress-bar {
    border-radius: 50px;
    background: var(--b);
}

/* ── Stat grid (2-col attribute/property tables) ────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 0.5rem;
    row-gap: 0.125rem;
    padding: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

/* ── Print ──────────────────────────────────────────────────── */
@media print {
    body {
        background: white;
    }

    #character-header {
        position: static;
        background: white;
        color: #1e293b;
    }
}
