/* =============================================================
   design-system.css — Fractured Veil CSS Custom Properties
   Parchment-Arcane aesthetic: import FIRST before all other styles
   ============================================================= */

:root {
  /* ── Core palette ─────────────────────────────────────────── */
  --parchment:      #F2E8D5;
  --surface:        #E8DCC8;
  --surface-deep:   #D9CCAC;
  --ink:            #3B2F1E;
  --ink-muted:      #6B5740;
  --blood:          #8B1A1A;
  --blood-dark:     #5C1010;
  --blood-glow:     rgba(139,26,26,0.12);
  --gold:           #C4922A;
  --gold-light:     #E8B84B;
  --gold-dark:      #8B6520;
  --done-green:     #2E6B3E;
  --archive-blue:   #1A4D6E;
  --spell-accent:   #4A7A9B;

  /* ── Token disposition (PROJECT_BRIEF_v4 §2) ─────────────────── */
  --disposition-friendly: #1D9E75;
  --disposition-neutral:  #C4922A;
  --disposition-hostile:  #8B1A1A;

  /* ── Legacy aliases (keep existing component refs working) ── */
  --color-bg:           #F2E8D5;
  --color-surface:      #E8DCC8;
  --color-surface-alt:  #D9CCAC;
  --color-border:       rgba(139,26,26,0.2);
  --color-border-dark:  rgba(139,26,26,0.3);
  --color-accent:       #8B1A1A;
  --color-accent-muted: #B85050;
  --color-text:         #3B2F1E;
  --color-text-muted:   #6B5740;
  --color-text-on-accent: #F2E8D5;
  --color-hp-high:      #2D6A2D;
  --color-hp-mid:       #B8860B;
  --color-hp-low:       #8B1A1A;
  --color-pip-none:       transparent;
  --color-pip-half:       #B8860B;
  --color-pip-proficient: #2D6A2D;
  --color-pip-expert:     #1A4A8B;

  /* ── Typography ───────────────────────────────────────────── */
  --font-display: 'Uncial Antiqua', serif;
  --font-body:    'Lato', -apple-system, sans-serif;
  --font-mono:    'Consolas', 'Fira Code', monospace;

  /* ── Shadows — warm candlelight, never cold gray ──────────── */
  --shadow-sm:           0 1px 3px  rgba(59,47,30,0.15);
  --shadow-md:           0 4px 12px rgba(59,47,30,0.22);
  --shadow-lg:           0 8px 32px rgba(59,47,30,0.30);
  --shadow-inset:        inset 0 2px 6px rgba(59,47,30,0.18);
  --shadow-glow-gold:    0 0 12px rgba(196,146,42,0.25);
  --shadow-glow-arcane:  0 0 12px rgba(100,140,200,0.25);

  /* ── Borders ──────────────────────────────────────────────── */
  --border-ornate: 1px solid rgba(139,26,26,0.3);
  --border-gold:   1px solid rgba(196,146,42,0.4);
  --border-arcane: 1px solid rgba(100,140,200,0.4);

  /* ── Textures ─────────────────────────────────────────────── */
  --tex-parchment: url('/assets/ui/parchment-texture.png');
  --tex-leather:   url('/assets/ui/dark-leather-texture.png');

  /* ── Card variants ────────────────────────────────────────── */
  --weapon-accent:      var(--blood);
  --weapon-accent-glow: var(--shadow-glow-gold);
  --spell-accent-glow:  var(--shadow-glow-arcane);

  /* ── Geometry — max 3px everywhere ───────────────────────── */
  --radius:    2px;
  --radius-lg: 3px;

  /* ── Spacing ──────────────────────────────────────────────── */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 40px;

  /* ── Transitions — warm and deliberate ───────────────────── */
  --transition-fast:  150ms ease;
  --transition:       250ms ease;
  --transition-panel: 300ms cubic-bezier(0.16,1,0.3,1);
}

/* ── Global reset ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  background-color: var(--parchment);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  position: relative;
}

/* Subtle parchment grain overlay — CSS only, no image needed */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9900;
  opacity: 0.4;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(59,47,30,0.018) 3px,
      rgba(59,47,30,0.018) 4px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 4px,
      rgba(59,47,30,0.012) 4px,
      rgba(59,47,30,0.012) 5px
    ),
    repeating-linear-gradient(
      135deg,
      transparent,
      transparent 8px,
      rgba(196,146,42,0.04) 8px,
      rgba(196,146,42,0.04) 9px
    );
}

/* ── Global scrollbar styling ─────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface-deep); }
::-webkit-scrollbar-thumb { background: rgba(139,26,26,0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(139,26,26,0.5); }

/* ── Typography defaults ──────────────────────────────────────── */
a { color: var(--blood); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.2;
  margin-bottom: var(--spacing-sm);
  color: var(--blood);
}

h3 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Section dividers ─────────────────────────────────────────── */
hr, .section-rule {
  border: none;
  border-top: 1px solid rgba(139,26,26,0.2);
  margin: var(--spacing-md) 0;
}

th {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--ink-muted);
}

/* ── Global form input / select / textarea ────────────────────── */
input[type="text"],
input[type="number"],
input[type="search"],
input[type="email"],
input[type="password"],
select,
textarea {
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--ink);
  background: var(--parchment);
  border: var(--border-ornate);
  border-radius: 2px;
  padding: 5px 8px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
input[type="text"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(196,146,42,0.15);
}
input[type="text"]::placeholder,
input[type="number"]::placeholder,
input[type="search"]::placeholder,
input[type="email"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder {
  color: var(--ink-muted);
  opacity: 0.7;
}

/* Styled select chevron */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23C4922A'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 26px;
  cursor: pointer;
}

/* Hide number input spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* Checkbox / radio — minimal reset */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--blood);
  cursor: pointer;
}

/* ── .btn-metal — primary action button with metallic texture ─── */
.btn-metal {
  -webkit-appearance: none;
  appearance: none;
  font-family: var(--font-body);
  font-weight: 900;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.6rem 1.4rem;
  min-height: 40px;
  color: var(--parchment);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  background-image: url('/assets/ui/button-metallic.png');
  background-size: 100% 100%;
  background-color: transparent;
  border: none;
  box-shadow: 0 3px 10px rgba(0,0,0,0.5);
  cursor: pointer;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: filter var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}
.btn-metal:hover {
  filter: brightness(1.18) saturate(1.1);
  box-shadow: 0 0 16px rgba(196,146,42,0.55), 0 3px 10px rgba(0,0,0,0.5);
}
.btn-metal:active {
  transform: translateY(1px);
  filter: brightness(0.9);
}

/* Arcane variant for spell buttons */
.btn-metal.arcane {
  background-image: url('/assets/ui/button-arcane.png');
  color: #EEF3FF;
  text-shadow: 0 1px 4px rgba(80,40,160,0.9);
}
.btn-metal.arcane:hover {
  filter: brightness(1.2) saturate(1.15);
  box-shadow: 0 0 18px rgba(140,80,220,0.55), 0 3px 10px rgba(0,0,0,0.5);
}
.btn-metal:disabled,
.btn-metal[disabled] {
  filter: saturate(0.3) brightness(0.7);
  cursor: not-allowed;
}

/* ── .fv-tag — universal tag chip system ─────────────────────── */
.fv-tag {
  display: inline-block;
  font-size: 0.62rem;
  padding: 2px 7px;
  background: rgba(59,47,30,0.08);
  border: 1px solid rgba(139,26,26,0.2);
  border-radius: 2px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  white-space: nowrap;
  vertical-align: middle;
}

/* Arcane variant — spell tags, range, damage */
.fv-tag.arcane {
  background: rgba(74,122,155,0.10);
  border-color: rgba(74,122,155,0.35);
  color: var(--spell-accent);
}

/* Gold/martial variant — optional */
.fv-tag.martial {
  background: rgba(196,146,42,0.10);
  border-color: rgba(196,146,42,0.35);
  color: var(--gold-dark);
}
