/* ═══════════════════════════════════════════════════════════════
   THE ARCANE ARCHIVES — MEMBER PORTAL DESIGN SYSTEM
   arcane-portal.css  |  v4.0
   Mirrors the landing page (index.html): Inter Tight + Inter + JetBrains
   Mono, violet/lavender/gold on #0B0A10, flat surfaces, hairline borders.
   Link this on every portal page, then add page-specific styles.
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg-primary:   #0B0A10;
  --bg-secondary: #0E0C14;
  --bg-card:      #141218;
  --bg-elevated:  #1A1724;
  --bg-hover:     #201C2C;

  --purple:       #9B7BF7;
  --purple-light: #C9B8FF;
  --purple-dark:  #6C4CE6;
  --purple-glow:  rgba(108, 76, 230, 0.35);

  --gold:         #F2C94C;
  --gold-light:   #F7DB85;

  --blue:         #60A5FA;
  --green:        #4ADE80;
  --red:          #F87171;

  --text:           #ffffff;
  --text-secondary: #C9C4D6;
  --text-muted:     #9D97AE;

  --border:       rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);

  --sidebar-w: 248px;
  --nav-h: 64px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --display: 'Inter Tight', 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; outline: none; background: none; font-family: inherit; }
svg { display: block; }
img { display: block; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.16); }

/* ── Ambient background ── */
.bg-gradient {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: var(--bg-primary);
}
.grid-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.5;
  background-image:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 30%, black 40%, transparent 100%);
}

/* ════════ SIDEBAR ════════ */
.arcane-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w); z-index: 1100;
  background: rgba(8,8,10,0.92);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.85rem 1.5rem;
  display: flex; flex-direction: column; gap: 0.15rem;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.4rem 0.6rem 1.1rem; margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand img { width: 34px; height: 34px; object-fit: contain; }
.sidebar-brand .brand-text {
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.04em; line-height: 1.25; text-transform: uppercase;
  background: linear-gradient(135deg, #fff, var(--purple-light));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.sidebar-section-label {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-muted); padding: 0.9rem 0.7rem 0.45rem;
}
.sidebar-nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.7rem; border-radius: 10px;
  color: var(--text-secondary); font-size: 0.86rem; font-weight: 600;
  transition: all 0.18s ease; position: relative;
}
.sidebar-nav-item .sidebar-nav-icon { width: 18px; height: 18px; flex-shrink: 0; color: currentColor; }
.sidebar-nav-item .sidebar-nav-icon svg { width: 18px; height: 18px; }
.sidebar-nav-item:hover { color: var(--text); background: var(--bg-elevated); }
.sidebar-nav-item.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(139,92,246,0.18), rgba(139,92,246,0.05));
  border: 1px solid rgba(139,92,246,0.28);
}
.sidebar-nav-item.active::before {
  content: ''; position: absolute; left: -0.85rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 4px; background: var(--purple);
}
.sidebar-nav-item.admin-item { color: var(--gold); }
.sidebar-divider { height: 1px; background: var(--border); margin: 0.6rem 0.3rem; }
.sidebar-overlay {
  position: fixed; inset: 0; z-index: 1050;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(2px);
  opacity: 0; visibility: hidden; transition: opacity 0.25s;
}
.sidebar-overlay.open { opacity: 1; visibility: visible; }

/* ════════ TOP NAV ════════ */
.arcane-nav {
  position: fixed; top: 0; right: 0; left: var(--sidebar-w); z-index: 1000;
  height: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(3,3,3,0.78);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { display: flex; align-items: center; height: var(--nav-h); padding: 0 1.5rem; gap: 1rem; }
.sidebar-toggle { display: none; width: 40px; height: 40px; border-radius: 10px; color: var(--text-secondary); align-items: center; justify-content: center; }
.sidebar-toggle svg { width: 22px; height: 22px; }
.sidebar-toggle:hover { background: var(--bg-elevated); color: var(--text); }
.nav-left { display: none; align-items: center; gap: 0.6rem; }
.nav-logo { width: 30px; height: 30px; object-fit: contain; }
.nav-brand { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text); }
.nav-center { flex: 1; display: flex; align-items: center; gap: 1rem; min-width: 0; }
.nav-store-btn {
  flex-shrink: 0; padding: 0.5rem 1.1rem; border-radius: 9px;
  background: linear-gradient(135deg, var(--gold), #d99e1f);
  color: #1a1206; font-size: 0.74rem; font-weight: 800; letter-spacing: 0.03em;
  transition: transform 0.2s, box-shadow 0.2s; box-shadow: 0 2px 14px rgba(251,191,36,0.22);
}
.nav-store-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(251,191,36,0.3); }
.nav-ticker-wrap { flex: 1; overflow: hidden; min-width: 0; position: relative; mask-image: linear-gradient(90deg, transparent, black 5%, black 95%, transparent); }
.nav-ticker-track { display: flex; width: max-content; animation: ticker-scroll 48s linear infinite; }
.nav-ticker-track:hover { animation-play-state: paused; }
.nav-ticker-item {
  display: inline-flex; align-items: center; gap: 0.45rem; padding: 0 1.15rem; white-space: nowrap; cursor: default;
  font-family: var(--mono); font-size: 0.7rem; border-right: 1px solid var(--border);
}
.t-sym   { color: var(--text-muted); font-weight: 500; }
.t-price { color: var(--text-secondary); font-weight: 700; }
.t-chg   { font-weight: 700; }
.t-chg.up { color: var(--green); }
.t-chg.down { color: var(--red); }
.t-chg.flat { color: var(--text-muted); }
@keyframes ticker-scroll { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }
.nav-right { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.nav-balance {
  font-family: var(--mono); font-size: 0.78rem; font-weight: 700; color: var(--gold);
  padding: 0.4rem 0.7rem; border-radius: 9px;
  border: 1px solid rgba(251,191,36,0.22); background: rgba(251,191,36,0.06); white-space: nowrap;
}
.nav-online { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); flex-shrink: 0; animation: pulse-dot 2s ease-in-out infinite; }
.nav-online.offline { background: var(--red); box-shadow: 0 0 8px var(--red); animation: none; }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }
.nav-btn {
  width: 38px; height: 38px; border-radius: 10px; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text-secondary); transition: all 0.18s;
}
.nav-btn:hover { border-color: var(--border-hover); color: var(--text); background: var(--bg-hover); }
.nav-avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--purple); cursor: pointer; flex-shrink: 0; transition: border-color 0.2s, box-shadow 0.2s;
}
.nav-avatar:hover { border-color: var(--purple-light); box-shadow: 0 0 0 4px rgba(139,92,246,0.18); }

/* ════════ PAGE LAYOUT ════════ */
.page-wrap {
  position: relative; z-index: 2;
  margin-left: var(--sidebar-w);
  padding: calc(var(--nav-h) + env(safe-area-inset-top, 0px) + 2rem) 2rem 4rem;
  max-width: 1320px;
}

/* ── Section heading ── */
.section-header { display: flex; align-items: center; gap: 0.85rem; margin: 2.75rem 0 1.4rem; }
.section-title { font-family: var(--display); font-size: 1.2rem; font-weight: 700; letter-spacing: -0.015em; }
.section-header .section-sub { color: var(--text-muted); font-size: 0.84rem; margin-left: auto; }

/* ── Page header (title block) ── */
.page-head { margin-bottom: 0.5rem; }
.page-head h1 { font-family: var(--display); font-size: clamp(1.9rem, 4vw, 2.75rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1.05; }
.page-head h1 span { color: var(--purple-light); }
.page-head p { color: var(--text-secondary); margin-top: 0.5rem; max-width: 640px; }

/* ── Badges ── */
.badge-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.7rem; border-radius: 999px;
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
}
.badge-pill.purple { background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.3); color: var(--purple-light); }
.badge-pill.gold   { background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,0.3); color: var(--gold); }
.badge-pill.red    { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.badge-pill.green  { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }
.badge-pill.live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1.5s ease-in-out infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.2; } }

/* ── Buttons ── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.75rem 1.5rem; border-radius: 11px;
  background: var(--purple-dark); color: #fff;
  font-weight: 700; font-size: 0.88rem; box-shadow: none;
  transition: background 0.2s;
}
.btn-primary:hover { background: #7A5CF0; }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.7rem 1.3rem; border-radius: 11px;
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text);
  font-weight: 700; font-size: 0.85rem; transition: all 0.2s;
}
.btn-ghost:hover { border-color: var(--purple); background: rgba(139,92,246,0.1); }

/* ── Generic tile cards ── */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.free-card {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.1rem 1.2rem; border-radius: 14px;
  background: var(--bg-card); border: 1px solid var(--border);
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}
.free-card:hover { transform: translateY(-2px); border-color: var(--border-hover); background: var(--bg-elevated); box-shadow: none; }
.free-icon {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px; font-size: 1.25rem;
  display: flex; align-items: center; justify-content: center;
  background: rgba(155,123,247,0.1); border: 1px solid rgba(155,123,247,0.22); color: var(--purple-light);
}
.free-icon svg { width: 20px; height: 20px; }
.free-info { flex: 1; min-width: 0; }
.free-title { font-weight: 700; font-size: 0.95rem; }
.free-desc { color: var(--text-muted); font-size: 0.8rem; }
.free-arrow, .free-badge { color: var(--text-muted); font-size: 1.05rem; transition: transform 0.25s, color 0.25s; }
.free-card:hover .free-arrow { color: var(--purple-light); transform: translateX(3px); }

/* ── Footer ── */
.dash-footer {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem;
  margin-top: 3.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
}
.version-tag { font-family: var(--mono); font-size: 0.7rem; color: var(--text-muted); letter-spacing: 0.04em; }
.logout-btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 1.2rem; border-radius: 10px;
  border: 1px solid rgba(239,68,68,0.25); background: rgba(239,68,68,0.06); color: #fca5a5;
  font-weight: 700; font-size: 0.82rem; transition: all 0.2s;
}
.logout-btn:hover { background: rgba(239,68,68,0.14); border-color: rgba(239,68,68,0.4); color: #fff; }

/* ════════ SHELL-INJECTED PAGES (portal-shell.js) ════════ */
/* Pages that inject the chrome via JS use body padding instead of .page-wrap */
body.has-portal-shell { padding-left: var(--sidebar-w); padding-top: calc(var(--nav-h) + env(safe-area-inset-top, 0px)); }
body.has-portal-shell .back-btn { display: none !important; }
/* Common centered content wrapper used by reskinned pages */
.portal-page { position: relative; z-index: 2; max-width: 1100px; margin: 0 auto; padding: 2.25rem 2rem 4rem; }
@media (max-width: 640px) { .portal-page { padding: 1.5rem 1.1rem 3rem; } }

/* ════════ RESPONSIVE ════════ */
@media (max-width: 1024px) {
  body.has-portal-shell { padding-left: 0; }
  .arcane-sidebar { transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.4,0,0.2,1); }
  .arcane-sidebar.open { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,0.7); }
  .arcane-nav { left: 0; }
  .page-wrap { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .nav-left { display: flex; }
}
@media (max-width: 640px) {
  :root { --nav-h: 58px; }
  .nav-inner { padding: 0 1rem; gap: 0.6rem; }
  .nav-brand { display: none; }
  .nav-balance { display: none; }
  .nav-ticker-wrap { display: none; }
  .page-wrap { padding: calc(var(--nav-h) + env(safe-area-inset-top, 0px) + 1.25rem) 1.1rem 3rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
