/* ==========================================================================
   LUNORIA ACADEMY — CORE DESIGN SYSTEM
   A premium, dark + gold visual language. Inspired by block-game progression,
   built like a serious education product. No gradients-as-decoration,
   no glassmorphism, no rounded-card-soup. Edges are fine, spacing does the work.
   ========================================================================== */

:root{
  /* ---- Surface ---- */
  --bg:            #080808;
  --bg-alt:        #101010;
  --panel:         #151515;
  --panel-raised:  #1b1b1b;
  --border:        #292929;
  --border-soft:   #1f1f1f;

  /* ---- Gold ---- */
  --gold:          #D4AF37;
  --gold-bright:   #F1D76A;
  --gold-muted:    #9F8128;
  --gold-10:       rgba(212,175,55,0.10);
  --gold-20:       rgba(212,175,55,0.20);

  /* ---- Text ---- */
  --text:          #F5F5F5;
  --text-dim:      #A6A6A6;
  --text-faint:    #6E6E6E;

  /* ---- Signal (muted, not neon) ---- */
  --good:          #7FAE83;
  --good-bg:       rgba(127,174,131,0.12);
  --bad:           #B5615F;
  --bad-bg:        rgba(181,97,95,0.12);

  /* ---- Rarity (inventory-inspired, used sparingly) ---- */
  --rarity-common:    #8a8a8a;
  --rarity-uncommon:  #6fae7f;
  --rarity-rare:      #5c92c4;
  --rarity-epic:      #9b6fc4;
  --rarity-legendary: var(--gold);

  /* ---- Type ---- */
  --font-display: "Cormorant Garamond", "Georgia", serif;
  --font-body:    "Inter", -apple-system, "Segoe UI", sans-serif;

  /* ---- Geometry ---- */
  --radius-sm: 3px;
  --radius-md: 6px;
  --sidebar-w: 248px;
  --content-max: 1180px;

  /* ---- Motion ---- */
  --ease: cubic-bezier(.22,.8,.3,1);
  --dur-fast: 150ms;
  --dur-med: 320ms;
  --dur-slow: 650ms;
}

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

html[data-reduced-motion="true"] *{
  animation-duration: 0.001ms !important;
  transition-duration: 0.001ms !important;
}

*,*::before,*::after{ box-sizing: border-box; }

html{ scroll-behavior: smooth; }

body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

html[data-text-size="large"] body{ font-size: 17px; }

h1,h2,h3,h4{
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.2px;
  margin: 0 0 .5em;
  color: var(--text);
}
h1{ font-size: clamp(2.1rem, 3vw + 1rem, 3.4rem); line-height: 1.08; }
h2{ font-size: clamp(1.5rem, 1.6vw + 1rem, 2.1rem); line-height: 1.15; }
h3{ font-size: 1.3rem; }
h4{ font-size: 1.05rem; font-family: var(--font-body); font-weight: 600; }

p{ color: var(--text-dim); max-width: 62ch; }
a{ color: inherit; text-decoration: none; }

.gold{ color: var(--gold); }
.text-dim{ color: var(--text-dim); }
.text-faint{ color: var(--text-faint); }

.serif{ font-family: var(--font-display); }

/* ---- Layout shell ---- */
.app-shell{
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar{
  background: var(--bg-alt);
  border-right: 1px solid var(--border-soft);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
}
.brand-mark{
  width: 30px; height: 30px;
  border: 1px solid var(--gold);
  display: grid; place-items: center;
  color: var(--gold);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}
.brand-name{
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: .3px;
  color: var(--text);
}
.brand-name span{ color: var(--gold); }

.nav-group{ display:flex; flex-direction:column; gap: 2px; }
.nav-label{
  font-size: .68rem;
  letter-spacing: 1.4px;
  color: var(--text-faint);
  padding: 10px 12px 6px;
}
.nav-link{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: .92rem;
  border-left: 2px solid transparent;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.nav-link:hover{ color: var(--text); background: var(--panel); }
.nav-link.active{
  color: var(--gold-bright);
  background: var(--gold-10);
  border-left-color: var(--gold);
}
.nav-icon{ width: 16px; height: 16px; flex-shrink: 0; opacity: .85; }

.sidebar-footer{
  margin-top: auto;
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
  font-size: .78rem;
  color: var(--text-faint);
}

.main{
  padding: 36px 44px 90px;
  max-width: var(--content-max);
}

.topbar{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
}

.eyebrow{
  font-size: .72rem;
  letter-spacing: 2px;
  color: var(--gold-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
  display: block;
}

/* ---- Buttons ---- */
.btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  font-family: var(--font-body);
  font-size: .88rem;
  font-weight: 600;
  letter-spacing: .3px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  position: relative;
  overflow: hidden;
}
.btn:focus-visible{ outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.btn:active{ transform: translateY(1px); }

.btn-gold{
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #1a1400;
}
.btn-gold::after{
  content:"";
  position:absolute; inset:0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.45) 50%, transparent 70%);
  transform: translateX(-120%);
}
.btn-gold:hover::after{ transform: translateX(120%); transition: transform .7s var(--ease); }
.btn-gold:hover{ box-shadow: 0 4px 18px rgba(212,175,55,.25); }

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

.btn-discord{
  background: var(--panel-raised);
  border-color: var(--gold-muted);
  color: var(--gold-bright);
}
.btn-discord:hover{ border-color: var(--gold); background: var(--gold-10); }

.btn-sm{ padding: 7px 14px; font-size: .78rem; }
.btn-block{ width: 100%; }
.btn:disabled{ opacity: .4; cursor: not-allowed; }

/* ---- Panels / Cards ---- */
.panel{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
}
.panel-raised{ background: var(--panel-raised); }
.panel-tight{ padding: 16px; }

.hairline{ border: none; border-top: 1px solid var(--border); margin: 24px 0; }

.grid{ display:grid; gap: 18px; }
.grid-2{ grid-template-columns: repeat(2, 1fr); }
.grid-3{ grid-template-columns: repeat(3, 1fr); }
.grid-4{ grid-template-columns: repeat(4, 1fr); }

/* ---- Slot / inventory-style card ---- */
.slot{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  cursor: pointer;
}
.slot:hover{ border-color: var(--gold-muted); transform: translateY(-2px); }
.slot.selected{ border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.slot.locked{ opacity: .45; cursor: not-allowed; }
.slot.locked:hover{ transform: none; border-color: var(--border); }

.rarity-bar{ height: 2px; width: 100%; margin-bottom: 12px; }
.rarity-common .rarity-bar{ background: var(--rarity-common); }
.rarity-uncommon .rarity-bar{ background: var(--rarity-uncommon); }
.rarity-rare .rarity-bar{ background: var(--rarity-rare); }
.rarity-epic .rarity-bar{ background: var(--rarity-epic); }
.rarity-legendary .rarity-bar{ background: var(--gold); }

/* ---- XP bar ---- */
.xp-track{
  width: 100%;
  height: 8px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.xp-fill{
  height: 100%;
  background: linear-gradient(90deg, var(--gold-muted), var(--gold-bright));
  width: 0%;
  transition: width 900ms var(--ease);
  position: relative;
}
.xp-fill::after{
  content:"";
  position:absolute; inset:0;
  background: linear-gradient(110deg, transparent 40%, rgba(255,255,255,.5) 50%, transparent 60%);
  transform: translateX(-100%);
  animation: xpshine 2.2s var(--ease) infinite;
}
@keyframes xpshine{
  0%{ transform: translateX(-100%); }
  60%,100%{ transform: translateX(220%); }
}

/* ---- Badges / tags ---- */
.tag{
  display:inline-flex; align-items:center; gap:6px;
  font-size: .72rem; letter-spacing: .5px;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.tag-gold{ border-color: var(--gold-muted); color: var(--gold-bright); background: var(--gold-10); }

/* ---- Forms ---- */
input[type="text"], input[type="number"], select, textarea{
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: .9rem;
  width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible{
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}
label{ font-size: .82rem; color: var(--text-dim); display:block; margin-bottom: 6px; }

.toggle{
  width: 42px; height: 24px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle::after{
  content:"";
  position:absolute; top:2px; left:2px;
  width: 18px; height: 18px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: all var(--dur-fast) var(--ease);
}
.toggle.on{ border-color: var(--gold-muted); background: var(--gold-10); }
.toggle.on::after{ left: 20px; background: var(--gold-bright); }

/* ---- Mobile nav ---- */
.mobile-topbar{ display:none; }
.mobile-nav{ display:none; }

@media (max-width: 920px){
  .app-shell{ grid-template-columns: 1fr; }
  .sidebar{ display:none; }
  .main{ padding: 20px 18px 100px; }
  .mobile-topbar{
    display:flex; align-items:center; justify-content:space-between;
    padding: 14px 18px; background: var(--bg-alt); border-bottom: 1px solid var(--border-soft);
    position: sticky; top:0; z-index: 20;
  }
  .mobile-nav{
    display:flex; justify-content: space-around;
    position: fixed; bottom:0; left:0; right:0;
    background: var(--bg-alt); border-top: 1px solid var(--border-soft);
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
    z-index: 20;
  }
  .mobile-nav a{ display:flex; flex-direction:column; align-items:center; gap:3px; font-size:.62rem; color: var(--text-faint); padding: 4px 8px; }
  .mobile-nav a.active{ color: var(--gold-bright); }
  .mobile-nav .nav-icon{ width: 18px; height: 18px; }
  .grid-2,.grid-3,.grid-4{ grid-template-columns: 1fr; }
}

@media (max-width: 600px){
  .main{ padding: 16px 14px 100px; }
  h1{ font-size: 1.9rem; }
}

/* ---- High contrast ---- */
html[data-contrast="high"]{
  --bg:#000; --bg-alt:#000; --panel:#0a0a0a; --border:#555;
  --text:#fff; --text-dim:#ddd; --gold: #FFD24A; --gold-bright:#FFE98C;
}

.sr-only{
  position:absolute; width:1px;height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
}

.skip-link{
  position:absolute; left:-999px; top:0;
  background: var(--gold); color:#1a1400; padding: 10px 16px; z-index: 100;
}
.skip-link:focus{ left: 10px; top: 10px; }
