/* ============================================================
   FAMER RPG  –  Global Dark Fantasy Stylesheet
   Colour system:  black-gold + arcane glows
   ============================================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@400;700;900&family=Cinzel:wght@400;600;700&family=Crimson+Text:ital,wght@0,400;0,600;1,400&display=swap');

/* ── CSS Variables ── */
:root {
  --bg-void:        #050508;
  --bg-deep:        #0a0a0f;
  --bg-panel:       #0f0f1a;
  --bg-card:        #141420;
  --bg-hover:       #1c1c2e;

  --gold-bright:    #ffd700;
  --gold-mid:       #c9a84c;
  --gold-dim:       #7a6230;
  --gold-dark:      #3d2f10;

  --text-primary:   #f0e6c8;
  --text-secondary: #a89060;
  --text-muted:     #5a4a30;

  --red-hp:         #c0392b;
  --red-hp-bg:      #2d0a0a;
  --blue-mana:      #2980b9;
  --blue-mana-bg:   #0a1a2d;
  --green-exp:      #27ae60;
  --green-exp-bg:   #0a1f12;

  --rarity-common:    #9e9e9e;
  --rarity-rare:      #2196f3;
  --rarity-epic:      #9c27b0;
  --rarity-legendary: #ff9800;
  --rarity-holy:      #fff9c4;

  --border-gold:    1px solid var(--gold-dim);
  --radius-sm:      4px;
  --radius-md:      8px;
  --radius-lg:      16px;

  --shadow-gold:    0 0 18px rgba(201,168,76,.35);
  --shadow-deep:    0 8px 32px rgba(0,0,0,.8);

  --font-title:     'Cinzel Decorative', serif;
  --font-heading:   'Cinzel', serif;
  --font-body:      'Crimson Text', serif;
}

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

html { scroll-behavior: smooth; }

body {
  background-color: var(--bg-void);
  background-image:
    radial-gradient(ellipse 120% 60% at 50% 0%, rgba(60,40,10,.55) 0%, transparent 70%),
    url("../img/noise.png");   /* subtle noise texture — optional */
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Custom Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-mid); }

/* ── Typography ── */
h1, h2, h3 { font-family: var(--font-heading); color: var(--gold-bright); }
h1 { font-size: clamp(1.6rem, 4vw, 2.8rem); letter-spacing: .05em; }
h2 { font-size: clamp(1.2rem, 3vw, 2rem); }
h3 { font-size: 1.1rem; color: var(--gold-mid); }
a  { color: var(--gold-mid); text-decoration: none; transition: color .2s; outline: none; }
a:hover { color: var(--gold-bright); text-shadow: 0 0 8px var(--gold-bright); }
a:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; border-radius: var(--radius-sm); }

/* ── Layout ── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.2rem; }
.page-wrap  { min-height: 100vh; display: flex; flex-direction: column; }
.main-content { flex: 1; padding: 2rem 0; }

/* ── Panels & Cards ── */
.panel {
  background: var(--bg-panel);
  border: var(--border-gold);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-gold), var(--shadow-deep);
  position: relative;
}
.panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(201,168,76,.06) 0%, transparent 60%);
  pointer-events: none;
}
.panel-title {
  font-family: var(--font-heading);
  color: var(--gold-bright);
  font-size: 1.1rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-bottom: var(--border-gold);
  padding-bottom: .5rem;
  margin-bottom: 1rem;
}

/* Glass variant */
.panel-glass {
  background: rgba(15,15,26,.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .6rem 1.4rem;
  font-family: var(--font-heading);
  font-size: .88rem;
  letter-spacing: .08em;
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .25s;
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  outline: none;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.06) 0%, transparent 100%);
  opacity: 0;
  transition: opacity .25s;
}
.btn:hover::after { opacity: 1; }
.btn:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 3px; }

.btn-gold {
  background: linear-gradient(160deg, #3d2f10, #7a6230);
  color: var(--gold-bright);
  box-shadow: 0 0 12px rgba(201,168,76,.25);
}
.btn-gold:hover {
  border-color: var(--gold-bright);
  box-shadow: 0 0 22px rgba(255,215,0,.45);
  transform: translateY(-2px);
}

.btn-danger {
  background: linear-gradient(160deg, #4a0a0a, #8b1a1a);
  color: #ff6b6b;
  border-color: #8b1a1a;
}
.btn-danger:hover {
  border-color: #ff4444;
  box-shadow: 0 0 18px rgba(255,50,50,.4);
  transform: translateY(-2px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { color: var(--gold-bright); border-color: var(--gold-mid); }

.btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Forms ── */
.form-group { margin-bottom: 1.2rem; }
.form-label {
  display: block;
  font-family: var(--font-heading);
  font-size: .82rem;
  letter-spacing: .07em;
  color: var(--gold-mid);
  margin-bottom: .35rem;
  text-transform: uppercase;
}
.form-control {
  width: 100%;
  padding: .65rem 1rem;
  background: rgba(0,0,0,.5);
  border: 1px solid var(--gold-dark);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.form-control:focus {
  border-color: var(--gold-mid);
  box-shadow: 0 0 10px rgba(201,168,76,.25);
}
.form-control::placeholder { color: var(--text-muted); }

select.form-control option { background: var(--bg-panel); }

/* ── Navigation ── */
.navbar {
  background: rgba(5,5,8,.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gold-dark);
  padding: .75rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: relative;
}
.navbar-brand {
  font-family: var(--font-title);
  font-size: 1.3rem;
  color: var(--gold-bright);
  text-shadow: 0 0 16px var(--gold-bright);
  letter-spacing: .1em;
}

/* Mobile Toggle Button */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--gold-dark);
  color: var(--gold-bright);
  font-size: 1.5rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}
.nav-toggle:hover { border-color: var(--gold-mid); }
.nav-toggle:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }

.navbar-nav {
  display: flex;
  align-items: center;
  gap: .25rem;
  list-style: none;
}
.navbar-nav a {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .4rem .9rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: .8rem;
  letter-spacing: .07em;
  color: var(--text-secondary);
  text-transform: uppercase;
  transition: all .2s;
  border: 1px solid transparent;
}
.navbar-nav a:hover,
.navbar-nav a.active {
  color: var(--gold-bright);
  border-color: var(--gold-dim);
  background: rgba(201,168,76,.08);
  text-shadow: 0 0 8px var(--gold-bright);
}

/* ── Stat Bars ── */
.stat-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  margin-bottom: .6rem;
}
.stat-bar-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-heading);
  font-size: .75rem;
  letter-spacing: .06em;
  color: var(--text-secondary);
  text-transform: uppercase;
}
.stat-bar-track {
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(0,0,0,.6);
  border: 1px solid rgba(255,255,255,.06);
}
.stat-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .4s ease;
}
.bar-hp   { background: linear-gradient(90deg, #7b0000, var(--red-hp));  }
.bar-mana { background: linear-gradient(90deg, #001f5c, var(--blue-mana)); }
.bar-exp  { background: linear-gradient(90deg, #0a3d1a, var(--green-exp)); }

/* ── Character Profile ── */
.profile-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
  align-items: start;
}
.character-avatar {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg-card);
  border: 2px solid var(--gold-dim);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  box-shadow: var(--shadow-gold);
}
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: .4rem 0;
  border-bottom: 1px solid rgba(201,168,76,.1);
  font-size: .95rem;
}
.stat-key   { color: var(--text-secondary); font-family: var(--font-heading); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { color: var(--text-primary); font-weight: 600; }

/* ── Inventory ── */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: .6rem;
}
.inv-slot {
  aspect-ratio: 1;
  background: var(--bg-card);
  border: 1px solid var(--gold-dark);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  font-size: 1.8rem;
  cursor: pointer;
  transition: all .2s;
  position: relative;
  overflow: hidden;
  outline: none;
}
.inv-slot:hover {
  border-color: var(--gold-mid);
  transform: translateY(-3px);
  box-shadow: var(--shadow-gold);
}
.inv-slot:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.inv-slot.equipped { border-color: var(--gold-bright); box-shadow: 0 0 14px rgba(255,215,0,.4); }
.inv-slot-name { font-size: .6rem; font-family: var(--font-heading); text-align: center; line-height: 1.2; color: var(--text-secondary); text-transform: uppercase; }
.inv-slot-qty {
  position: absolute; bottom: 2px; right: 5px;
  font-size: .65rem; color: var(--gold-mid); font-family: var(--font-heading);
}

/* rarity border glow */
.rarity-common    { border-color: var(--rarity-common)    !important; }
.rarity-rare      { border-color: var(--rarity-rare)      !important; box-shadow: 0 0 10px rgba(33,150,243,.3); }
.rarity-epic      { border-color: var(--rarity-epic)      !important; box-shadow: 0 0 10px rgba(156,39,176,.4); }
.rarity-legendary { border-color: var(--rarity-legendary) !important; box-shadow: 0 0 14px rgba(255,152,0,.5); }
.rarity-holy      { border-color: var(--rarity-holy)      !important; box-shadow: 0 0 18px rgba(255,249,196,.6); animation: holyPulse 2s ease-in-out infinite; }

@keyframes holyPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(255,249,196,.5); }
  50%       { box-shadow: 0 0 28px rgba(255,249,196,.9); }
}

/* ── Combat ── */
.battle-arena {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: center;
  text-align: center;
}
.fighter-card {
  background: var(--bg-card);
  border: var(--border-gold);
  border-radius: var(--radius-md);
  padding: 1.2rem;
}
.fighter-icon { font-size: 4rem; display: block; margin-bottom: .5rem; }
.vs-badge {
  font-family: var(--font-title);
  font-size: 1.8rem;
  color: var(--gold-bright);
  text-shadow: 0 0 20px var(--gold-bright);
}
.combat-log {
  background: rgba(0,0,0,.6);
  border: 1px solid var(--gold-dark);
  border-radius: var(--radius-sm);
  padding: .8rem;
  height: 150px;
  overflow-y: auto;
  font-size: .9rem;
  line-height: 1.7;
}
.log-damage { color: #ff6b6b; }
.log-heal   { color: #51cf66; }
.log-info   { color: var(--text-secondary); }
.log-victory{ color: var(--gold-bright); font-family: var(--font-heading); }

/* ── Story Scene ── */
.story-box {
  background: rgba(0,0,0,.7);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  font-size: 1.1rem;
  line-height: 1.9;
  min-height: 120px;
  position: relative;
}
.story-box::before {
  content: '❝';
  font-size: 3rem;
  color: var(--gold-dark);
  position: absolute;
  top: -1rem;
  left: .8rem;
}
.choice-list { display: flex; flex-direction: column; gap: .6rem; margin-top: 1.2rem; }
.choice-btn {
  background: rgba(20,20,32,.8);
  border: 1px solid var(--gold-dark);
  border-radius: var(--radius-sm);
  padding: .75rem 1.2rem;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  cursor: pointer;
  text-align: left;
  transition: all .2s;
  outline: none;
}
.choice-btn:hover {
  border-color: var(--gold-mid);
  background: rgba(201,168,76,.1);
  padding-left: 1.6rem;
  color: var(--gold-bright);
}
.choice-btn:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: -2px;
}

/* ── Town Menu ── */
.town-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}
.town-card {
  background: var(--bg-card);
  border: var(--border-gold);
  border-radius: var(--radius-md);
  padding: 1.4rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all .25s;
  text-decoration: none;
  display: block;
  outline: none;
}
.town-card:hover {
  border-color: var(--gold-bright);
  background: var(--bg-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-gold);
}
.town-card:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.town-card-icon { font-size: 2.5rem; display: block; margin-bottom: .6rem; }
.town-card-name {
  font-family: var(--font-heading);
  font-size: .82rem;
  letter-spacing: .07em;
  color: var(--gold-mid);
  text-transform: uppercase;
}

/* ── Flash messages ── */
.flash {
  padding: .75rem 1.2rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-family: var(--font-heading);
  font-size: .88rem;
  letter-spacing: .05em;
}
.flash-success { background: rgba(39,174,96,.15); border: 1px solid #27ae60; color: #51cf66; }
.flash-error   { background: rgba(192,57,43,.15); border: 1px solid #c0392b; color: #ff6b6b; }

/* ── Utilities ── */
.text-gold   { color: var(--gold-bright); }
.text-muted  { color: var(--text-muted);  }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem;  }
.mt-2 { margin-top: 1rem;   }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem;  }
.mb-2 { margin-bottom: 1rem;   }
.mb-3 { margin-bottom: 1.5rem; }
.w-full { width: 100%; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .profile-grid   { grid-template-columns: 1fr; }
  .battle-arena   { grid-template-columns: 1fr; }
  .vs-badge       { display: none; }
  .town-grid      { grid-template-columns: repeat(2, 1fr); }
  .inventory-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  
  /* Mobile Navigation Setup */
  .nav-toggle { display: block; }
  .navbar-nav {
    display: none; /* Hide by default on mobile */
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-panel);
    border-bottom: var(--border-gold);
    padding: 1rem;
    box-shadow: var(--shadow-deep);
  }
  .navbar-nav.active {
    display: flex; /* Shown when toggled via JS */
  }
}