/* ═══════════════════════════════════════════
   THE RITUAL — Base Styles
   Brand: Deep Navy · Stone · Muted Gold
═══════════════════════════════════════════ */

:root {
  --navy:        #0a0f18;
  --navy-darker: #060b12;
  --navy-card:   #0f1620;
  --navy-hover:  #151e2e;
  --gold:        #c4a46b;
  --gold-bright: #dbbf82;
  --gold-dim:    rgba(196, 164, 107, 0.15);
  --gold-line:   rgba(196, 164, 107, 0.3);
  --stone:       #d0bfaa;
  --stone-dim:   #8a9db5;
  --text:        #e8dfd2;
  --text-muted:  #7a8fa3;
  --success:     rgba(80, 160, 110, 0.9);
  --success-text: #6dba85;
  --success-bg:  rgba(80, 180, 100, 0.12);
  --danger-line: rgba(160, 80, 80, 0.4);
  --danger-text: rgba(220, 120, 120, 0.85);
  --danger-bg:   rgba(140, 60, 60, 0.15);

  --sidebar-width: 260px;
  --bottom-nav-height: 64px;
  --font-serif: 'Cormorant Garamond', serif;
  --font-sans:  'Jost', sans-serif;
}

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

html, body {
  width: 100%; min-height: 100vh;
  background: var(--navy);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

/* ── Grain texture overlay ── */
.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  opacity: 0.5;
}

/* ── Main content area ── */
.app-content {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 40px 32px 40px calc(var(--sidebar-width) + 48px);
  max-width: calc(var(--sidebar-width) + 1280px);
  transition: padding 0.3s ease;
}

@media (max-width: 1023px) {
  .app-content {
    padding: 72px 24px 32px;
  }
}

@media (max-width: 767px) {
  .app-content {
    /* Include iOS safe area inset so content clears the home indicator bar */
    padding: 24px 16px calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 24px) 16px;
  }
  .toast-container { right: 12px; left: 12px; }
  .toast { max-width: 100%; }
}

/* ── Shared elements ── */
.emblem {
  font-size: 40px;
  color: var(--gold);
  text-align: center;
  margin-bottom: 14px;
  opacity: 0.75;
  font-family: var(--font-serif);
  animation: breathe 4s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 0.9; }
}

.hidden { display: none !important; }

/* ── Shared page hero header (used across all views) ── */
.page-hero {
  text-align: center;
  padding: 40px 0 36px;
}

.page-hero-emblem {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  opacity: 0.75;
  animation: breathe 4s ease-in-out infinite;
  margin-bottom: 20px;
}

.page-hero-emblem svg {
  width: 48px;
  height: 48px;
}

.page-hero-title {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 44px;
  letter-spacing: 0.1em;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 10px;
}

.page-hero-sub {
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.75;
}

@media (max-width: 767px) {
  .page-hero { padding: 28px 0 24px; }
  .page-hero-title { font-size: 32px; }
  .page-hero-emblem { font-size: 30px; }
}

/* ── View transitions ── */
.view-enter {
  animation: viewEnter 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes viewEnter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.view-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(196,164,107,0.2);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(196,164,107,0.4); }

/* ── Focus ── */
input:focus, textarea:focus, select:focus { outline: none; }

/* ── Shared button ── */
.btn-primary {
  width: 100%;
  padding: 18px;
  background: var(--gold);
  border: none;
  border-radius: 8px;
  color: var(--navy);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 60%);
  pointer-events: none;
}

.btn-primary:disabled {
  background: rgba(196, 164, 107, 0.12);
  color: rgba(196,164,107,0.4);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary:not(:disabled):hover {
  background: var(--gold-bright);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(196, 164, 107, 0.35);
}

.btn-arrow {
  font-size: 15px;
  transition: transform 0.2s;
}
.btn-primary:not(:disabled):hover .btn-arrow { transform: translateX(4px); }

/* ── Card ── */
.card {
  background: var(--navy-card);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* ── Section title ── */
.section-label {
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 10px;
}

/* ── PnL colors ── */
.pnl-positive { color: #6dba85; }
.pnl-negative { color: #c97070; }

/* ── Toast container ── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--navy-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 14px 20px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: toastIn 0.3s ease both;
  max-width: 360px;
}

.toast.success   { border-color: rgba(80,180,100,0.3); }
.toast.error     { border-color: rgba(160,80,80,0.4); }
/* Rank-up — gold border with subtle glow */
.toast.rank-up  {
  border-color: rgba(196,164,107,0.6);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 20px rgba(196,164,107,0.15);
  font-family: var(--font-serif);
  font-size: 15px;
  letter-spacing: 0.08em;
}
/* Milestone — stone-toned, serif */
.toast.milestone {
  border-color: rgba(180,168,148,0.35);
  font-family: var(--font-serif);
  font-size: 15px;
  letter-spacing: 0.06em;
  font-style: italic;
}

.toast-exit {
  animation: toastOut 0.25s ease both;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

/* ═══════════════════════════════════════════
   Per-view account filter dropdown
═══════════════════════════════════════════ */

.acct-filter-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.acct-filter-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: rgba(255,255,255,0.04);
  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='M1 1l4 4 4-4' stroke='%237a8fa3' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 7px 30px 7px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
  min-width: 155px;
}
.acct-filter-select:hover {
  border-color: rgba(255,255,255,0.22);
  background-color: rgba(255,255,255,0.07);
}
.acct-filter-select:focus {
  outline: none;
  border-color: rgba(196,164,107,0.5);
}
.acct-filter-select option {
  background: #0f1620;
  color: #e8dfd2;
}

/* Per-view wrapper positioning helpers */
.view-acct-filter {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 18px;
}
