/* ── 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;
}

/* Same shape as .btn-primary, muted color (e.g. "use server version"). */
.btn-secondary {
    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: #e2e8f0;
    color: #1e293b;
    border: none;
    transition: background-color 0.15s;
}

.btn-secondary:hover {
    background-color: #cbd5e1;
}

/* ── 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;
}

.glitch::after {
    content: "😵";
}

.success {
    color: #34d399;
}

.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;
}

/* ── thaw AutoComplete/Combobox positioning fix ─────────────────
   thaw 0.5.0-beta's Binder positions its `.thaw-binder-follower`
   popup container with `position: absolute` relative to the
   document, but computes the popup's offset from viewport-relative
   getBoundingClientRect() values and applies it via a CSS
   `transform: translate(...)`. As soon as the page is scrolled,
   the popup lands at `documentTop - scrollY`, off-screen above the
   viewport — e.g. autocomplete dropdowns for weapon/spell fields
   deep in a long character sheet render invisibly.
   Forcing `position: fixed` makes the popup's own layout position
   viewport-relative (unaffected by scroll), matching the assumption
   baked into the transform calculation. No newer thaw release fixes
   this as of 0.5.0-beta (latest on crates.io). Remove this override
   if/when upstream fixes the Binder positioning. */
.thaw-binder-follower {
    position: fixed !important;
}

/* thaw 0.5.0-beta hardcodes `.thaw-auto-complete > .thaw-input { min-width:
   250px }`, which is too wide for the compact skill-name fields used for
   spoken/written languages, weapon/trained/hereditary skills (the `Skill`
   component in character_view.rs, marked with `.skill-name-field`). Scoped
   to that component only — spell/weapon name AutoComplete fields elsewhere
   keep the default width since their names tend to be longer. */
.skill-name-field .thaw-auto-complete > .thaw-input {
    min-width: 120px;
}

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

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