/* ============================================================
   Component styles — Grimoire
   ============================================================ */

/* Hide browser number-input spinners globally (Stepper uses its own +/- buttons) */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* ===== CARD ===== */
.card {
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  position: relative;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(244, 236, 214, 0.03), transparent 40%);
  pointer-events: none;
}
.card-soft {
  background: var(--bg-2);
  border: 1px solid var(--line-0);
  border-radius: var(--radius);
}
.card-bare { background: transparent; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--line-1);
  position: relative;
}
.card-head .card-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-0);
  display: flex; align-items: center; gap: 8px;
}
.card-head .card-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}
.card-body { padding: 14px 16px 16px; }
.card-body.tight { padding: 10px 14px; }

/* Decorative gold rule under titles (filigree style) */
.card-head::after {
  content: '';
  position: absolute;
  left: 16px; right: 16px; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%, var(--gold-2) 8%, var(--gold-0) 50%, var(--gold-2) 92%, transparent 100%);
  opacity: 0.5;
  pointer-events: none;
}
.card-head.plain::after { display: none; }

/* ===== BUTTON ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  color: var(--ink-0);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
  position: relative;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-4); border-color: var(--gold-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: 0.4; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(180deg, var(--gold-0), var(--gold-2));
  border-color: var(--gold-1);
  color: var(--bg-0);
  box-shadow: 0 1px 0 var(--gold-1) inset, 0 4px 12px rgba(0,0,0,0.4);
}
.btn.primary:hover {
  background: linear-gradient(180deg, var(--gold-1), var(--gold-0));
  border-color: var(--gold-1);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line-1);
  color: var(--ink-2);
}
.btn.ghost:hover { color: var(--gold-1); border-color: var(--gold-2); }

.btn.danger {
  border-color: var(--crimson);
  color: var(--crimson-1);
  background: var(--crimson-soft);
}
.btn.danger:hover { background: rgba(196, 61, 61, 0.28); }

.btn.heal {
  border-color: var(--emerald);
  color: var(--emerald-1);
  background: var(--emerald-soft);
}
.btn.heal:hover { background: rgba(91, 156, 94, 0.28); }

.btn.sm { padding: 4px 8px; font-size: 10px; gap: 5px; }
.btn.lg { padding: 11px 18px; font-size: 13px; }
.btn.icon-only { padding: 6px; }

/* Icon-button (e.g. delete row) */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink-3);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-icon:hover { color: var(--gold-1); border-color: var(--line-1); background: var(--bg-2); }
.btn-icon.danger:hover { color: var(--crimson-1); border-color: var(--crimson); background: var(--crimson-soft); }

/* ===== CHIP ===== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: 999px;
  color: var(--ink-1);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.chip:hover { border-color: var(--gold-2); color: var(--gold-1); }
.chip.active {
  background: var(--gold-soft);
  border-color: var(--gold-0);
  color: var(--gold-1);
  box-shadow: 0 0 0 1px var(--gold-soft);
}
.chip.fill {
  background: var(--gold-0);
  border-color: var(--gold-1);
  color: var(--bg-0);
}
.chip.fill.crimson  { background: var(--crimson);  border-color: var(--crimson-1);  color: white; }
.chip.fill.emerald  { background: var(--emerald);  border-color: var(--emerald-1);  color: white; }
.chip.fill.azure    { background: var(--azure);    border-color: var(--azure-1);    color: white; }
.chip.fill.violet   { background: var(--violet);   border-color: var(--violet-1);   color: white; }
.chip.muted { color: var(--ink-3); border-style: dashed; }
.chip.sm { font-size: 8.5px; padding: 2px 7px; }
.chip.lg { font-size: 11px; padding: 5px 14px; }

/* ===== INPUT ===== */
.input, .select, .textarea {
  width: 100%;
  height: 34px;
  padding: 0 12px;
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--radius);
  color: var(--ink-0);
  font-family: var(--font-ui);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-2); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--gold-2); background: var(--bg-1); }
.input::placeholder { color: var(--ink-3); }
.textarea { padding: 8px 12px; resize: vertical; min-height: 70px; height: auto; }

.field {
  display: flex; flex-direction: column; gap: 5px;
}
.field-label {
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* ===== DOT / SWITCH ===== */
.dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--ink-3);
  cursor: pointer;
  transition: all 0.15s;
  vertical-align: middle;
}
.dot:hover { border-color: var(--gold-1); }
.dot.on { background: var(--gold-0); border-color: var(--gold-0); box-shadow: 0 0 8px var(--gold-glow); }
.dot.expert { background: var(--violet); border-color: var(--violet); box-shadow: 0 0 8px var(--violet-soft); }
.dot.crimson.on { background: var(--crimson); border-color: var(--crimson); box-shadow: 0 0 8px var(--crimson-soft); }
.dot.emerald.on { background: var(--emerald); border-color: var(--emerald); box-shadow: 0 0 8px var(--emerald-soft); }
.dot.lg { width: 16px; height: 16px; }
.dot.sm { width: 8px; height: 8px; border-width: 1px; }

/* ===== BAR ===== */
.bar {
  height: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line-0);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.bar > .bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--gold-2), var(--gold-0));
  transition: width 0.35s cubic-bezier(.2,.7,.3,1);
}
.bar.crimson > .bar-fill { background: linear-gradient(90deg, #8a2424, var(--crimson-1)); }
.bar.emerald > .bar-fill { background: linear-gradient(90deg, #3a6e3c, var(--emerald-1)); }
.bar.azure   > .bar-fill { background: linear-gradient(90deg, #2c4d80, var(--azure-1)); }
.bar.lg { height: 12px; }
.bar.thin { height: 4px; }

/* ===== DIVIDER ===== */
.divider {
  height: 1px;
  background: var(--line-1);
  margin: 12px 0;
}
.divider.gold {
  background: linear-gradient(90deg,
    transparent, var(--gold-2) 30%, var(--gold-0) 50%, var(--gold-2) 70%, transparent);
  opacity: 0.4;
  height: 1px;
}

/* ===== STAT BLOCK (ability score) ===== */
.stat {
  position: relative;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line-1);
  border-radius: var(--radius);
  padding: 12px 8px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s;
  overflow: hidden;
}
.stat::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid var(--line-0);
  border-radius: calc(var(--radius) - 2px);
  pointer-events: none;
}
.stat:hover { border-color: var(--gold-2); box-shadow: var(--shadow-gold); }
.stat:hover::before { border-color: var(--gold-soft); }
.stat .stat-k {
  font-family: var(--font-display);
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 4px;
  position: relative;
}
.stat .stat-v {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink-0);
  position: relative;
}
.stat .stat-m {
  display: inline-block;
  margin-top: 8px;
  padding: 1px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--gold-1);
  border: 1px solid var(--gold-2);
  border-radius: 999px;
  background: var(--gold-soft);
  position: relative;
}
.stat:hover .stat-m {
  border-color: var(--gold-0);
  color: var(--bg-0);
  background: var(--gold-0);
}

/* Save-prof badge in upper-right corner of stat */
.stat .stat-save {
  position: absolute;
  top: 6px; right: 6px;
  z-index: 1;
}

/* ===== SHIELD STAT (AC etc) ===== */
.shield-stat {
  position: relative;
  width: 56px;
  height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.shield-stat svg.shield-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}
.shield-stat .ss-v {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink-0);
  line-height: 1;
  position: relative;
  z-index: 1;
}
.shield-stat .ss-k {
  font-family: var(--font-display);
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-0);
  position: relative;
  z-index: 1;
  margin-top: 2px;
}

/* ===== SLOT (spell slot) — diamond gem ===== */
.slot {
  width: 18px;
  height: 18px;
  transform: rotate(45deg);
  border: 1.5px solid var(--violet);
  background: transparent;
  position: relative;
  cursor: pointer;
  transition: all 0.15s;
}
.slot::after {
  content: '';
  position: absolute;
  inset: 2px;
  background: transparent;
  transition: background 0.15s;
}
.slot.full {
  border-color: var(--violet);
  background: var(--violet);
  box-shadow: 0 0 10px var(--violet-soft);
}
.slot.full::after {
  background: linear-gradient(135deg, var(--violet-1) 0%, var(--violet) 60%);
}
.slot:hover { border-color: var(--violet-1); }
.slot.used { opacity: 0.35; }

/* ===== ROW / TABLE ===== */
.row {
  display: grid;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-0);
  transition: background 0.12s;
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--bg-2); }
.row.head {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line-2);
  padding-bottom: 6px;
  padding-top: 6px;
}
.row.head:hover { background: transparent; }

/* ===== Section header inside body ===== */
.section-h {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-1);
  position: relative;
}
.section-h h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-0);
}
.section-h .section-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
}
.section-h::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 60px;
  height: 1px;
  background: var(--gold-0);
}

/* ===== TOAST ===== */
.toast-wrap {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-elv);
  border: 1px solid var(--gold-2);
  border-radius: var(--radius);
  padding: 10px 18px;
  box-shadow: var(--shadow-2);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-0);
  display: flex; align-items: center; gap: 12px;
  animation: toast-in 0.35s cubic-bezier(.2,.8,.2,1.2);
  pointer-events: auto;
}
.toast.crit { border-color: var(--gold-1); box-shadow: 0 0 24px var(--gold-glow), var(--shadow-2); }
.toast .toast-val {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--gold-1);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Flexbox utils ===== */
.flex { display: flex; }
.icol { display: flex; flex-direction: column; }
.icenter { display: flex; align-items: center; justify-content: center; }
.iwrap { flex-wrap: wrap; }
.igrow { flex: 1 1 0; min-width: 0; }
.ica { align-items: center; }
.iba { align-items: baseline; }
.ija { justify-content: space-between; }
.ig-4 { gap: 4px; }
.ig-6 { gap: 6px; }
.ig-8 { gap: 8px; }
.ig-10 { gap: 10px; }
.ig-12 { gap: 12px; }
.ig-14 { gap: 14px; }
.ig-16 { gap: 16px; }
.ig-20 { gap: 20px; }
.ig-24 { gap: 24px; }
.mb-4 { margin-bottom: 4px; }
.mb-6 { margin-bottom: 6px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }

/* Animations */
.fade-in { animation: fade-in 0.3s ease-out; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.pulse-gold { animation: pulse-gold 1.6s ease-in-out infinite; }
@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 0 0 var(--gold-glow); }
  50% { box-shadow: 0 0 16px 2px var(--gold-glow); }
}

/* ============================================================
   ILLUMINATED FRAME — corner ornaments
   ============================================================ */
.ornamented {
  position: relative;
}
.ornamented .orn {
  position: absolute;
  z-index: 3;
  color: var(--gold-0);
  opacity: 0.9;
  pointer-events: none;
  transition: opacity 0.25s;
  filter: drop-shadow(0 0 4px var(--gold-glow));
}
[data-ornaments="off"] .ornamented .orn { display: none; }
.ornamented .orn-tl { top: -8px;    left: -8px; }
.ornamented .orn-tr { top: -8px;    right: -8px; }
.ornamented .orn-br { bottom: -8px; right: -8px; }
.ornamented .orn-bl { bottom: -8px; left: -8px; }

/* ============================================================
   PORTRAIT DROP — for character portrait upload
   ============================================================ */
.portrait-drop {
  position: relative;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--bg-3), var(--bg-1) 80%);
  border: 2px solid var(--gold-0);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 0 0 4px var(--bg-2), 0 0 24px var(--gold-glow);
  transition: all 0.25s;
}
.portrait-drop:hover { box-shadow: 0 0 0 4px var(--bg-2), 0 0 36px var(--gold-glow); }
.portrait-drop.drag {
  box-shadow: 0 0 0 4px var(--gold-soft), 0 0 36px var(--gold-glow);
  border-color: var(--gold-1);
}
.portrait-drop img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.portrait-drop .portrait-monogram {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--gold-1);
  text-shadow: 0 0 16px var(--gold-glow);
}
.portrait-drop .portrait-rim {
  position: absolute;
  inset: 6px;
  border: 1px solid var(--gold-2);
  border-radius: 50%;
  pointer-events: none;
}
.portrait-drop .portrait-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 9, 7, 0.7);
  color: var(--gold-1);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.portrait-drop:hover .portrait-overlay { opacity: 1; }
.portrait-drop.drag .portrait-overlay { opacity: 1; background: rgba(10, 9, 7, 0.85); }
.portrait-drop .portrait-clear {
  position: absolute;
  top: 6px; right: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
}
.portrait-drop:hover .portrait-clear { display: flex; }
.portrait-drop .portrait-clear:hover { color: var(--crimson-1); border-color: var(--crimson); }
