/* =============================================================
   VELOUR — Shared UI System  (v2 redesign)
   Loaded AFTER style.css on every redesigned page.
   Owns: animated background, top nav, bottom nav, buttons,
   cards, sections, modals, toasts, fields, chips, skeletons.
   Each page should only define its own page-specific layout.
   ============================================================= */

:root {
  /* Unified font roles */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-ui:      'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body:    'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Spacing scale */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;  --sp-3: 0.75rem;
  --sp-4: 1rem;     --sp-5: 1.25rem; --sp-6: 1.5rem;
  --sp-8: 2rem;     --sp-10: 2.5rem; --sp-12: 3rem;

  /* Container */
  --page-max: 760px;
  --page-wide: 1180px;

  /* Background texture (dark) */
  --v-dot:     rgba(201, 169, 110, 0.085);
  --v-glow-a:  rgba(201, 169, 110, 0.10);
  --v-glow-b:  rgba(201, 169, 110, 0.055);

  /* Glass */
  --glass-bg:     rgba(255, 255, 255, 0.045);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-bg-2:   rgba(20, 20, 20, 0.72);
}

[data-theme="light"] {
  --v-dot:     rgba(150, 116, 56, 0.16);
  --v-glow-a:  rgba(184, 146, 74, 0.12);
  --v-glow-b:  rgba(184, 146, 74, 0.07);
  --glass-bg:     rgba(255, 255, 255, 0.55);
  --glass-border: rgba(120, 95, 50, 0.14);
  --glass-bg-2:   rgba(255, 255, 255, 0.82);
}

/* ── Animated background: dot grid + breathing glows ──────── */
body { position: relative; }

body::before {
  content: '';
  position: fixed;
  inset: -10% -10% -10% -10%;
  z-index: -2;
  pointer-events: none;
  background-image: radial-gradient(circle, var(--v-dot) 1px, transparent 1.5px);
  background-size: 26px 26px;
  /* fade the grid toward the edges so it reads as texture, not wallpaper */
  -webkit-mask-image: radial-gradient(130% 110% at 50% 0%, #000 45%, transparent 92%);
          mask-image: radial-gradient(130% 110% at 50% 0%, #000 45%, transparent 92%);
  animation: vGridDrift 60s linear infinite;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(42% 38% at 16% 8%,  var(--v-glow-a), transparent 72%),
    radial-gradient(48% 42% at 88% 86%, var(--v-glow-b), transparent 74%);
  animation: vGlowBreathe 16s ease-in-out infinite alternate;
}

@keyframes vGridDrift {
  from { background-position: 0 0; }
  to   { background-position: 26px 52px; }
}
@keyframes vGlowBreathe {
  0%   { opacity: 0.65; transform: scale(1)    translateY(0); }
  100% { opacity: 1;    transform: scale(1.08) translateY(-1.5%); }
}

@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none !important; }
}

/* ── Top navigation ──────────────────────────────────────── */
.topnav {
  position: sticky; top: 0; z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: blur(22px) saturate(170%);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  border-bottom: 1px solid var(--border-soft);
  padding: calc(var(--safe-top) + 0.7rem) 1rem 0.7rem;
  display: flex; align-items: center; gap: 0.6rem;
}
@media (min-width: 768px) {
  .topnav { padding: calc(var(--safe-top) + 0.85rem) 1.5rem 0.85rem; gap: 0.75rem; }
}
.topnav-brand {
  font-family: var(--font-ui); font-size: 1.25rem;
  letter-spacing: 0.22em; color: var(--gold); font-weight: 700;
  cursor: pointer; user-select: none;
}
.topnav-brand .dot { color: var(--cream); }
.topnav-sub {
  font-family: var(--font-display); font-style: italic;
  color: var(--muted); font-size: 0.92rem; margin-left: 0.1rem;
}
.topnav-spacer { flex: 1; }
.topnav-icon {
  width: 40px; height: 40px; min-width: 40px; min-height: 40px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--border-soft);
  display: grid; place-items: center;
  color: var(--cream); cursor: pointer;
  transition: all var(--transition); position: relative;
}
.topnav-icon:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-faint); }
.topnav-icon:active { transform: scale(0.94); }
.topnav-icon .badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--gold); color: #1a1408;
  font-size: 10px; font-weight: 700; border-radius: 9px;
  display: grid; place-items: center;
  font-family: var(--font-ui); border: 2px solid var(--bg); line-height: 1;
}

/* ── Page container ──────────────────────────────────────── */
.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: calc(var(--safe-top) + 1.25rem) 1.25rem
           calc(var(--bottom-nav-h) + var(--safe-bottom) + 4.5rem);
}
@media (min-width: 768px) {
  .page { padding-left: 1.5rem; padding-right: 1.5rem; }
}

/* ── Page header (editorial) ─────────────────────────────── */
.v-head { margin-bottom: 1.5rem; }
.v-eyebrow {
  font-family: var(--font-ui); font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold);
  display: inline-flex; align-items: center; gap: 0.45rem; margin-bottom: 0.5rem;
}
.v-title {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.9rem, 6vw, 2.6rem); line-height: 1.05;
  color: var(--cream); letter-spacing: -0.015em;
}
.v-title .it { font-style: italic; color: var(--gold); }
.v-subtitle { color: var(--muted); font-size: 0.95rem; margin-top: 0.5rem; max-width: 46ch; }

/* ── Cards & sections ────────────────────────────────────── */
.v-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 34px rgba(0,0,0,0.16);
}
[data-theme="light"] .v-card { box-shadow: 0 10px 34px rgba(90,70,30,0.08); }

.v-section { margin-bottom: 1.5rem; }
.v-section-head {
  display: flex; align-items: center; gap: 0.6rem;
  margin: 0 0.15rem 0.85rem;
}
.v-section-title {
  font-family: var(--font-display); font-size: 1.15rem;
  color: var(--cream); font-weight: 600; letter-spacing: -0.01em;
}
.v-section-ico { color: var(--gold); font-size: 1rem; }
.v-section-spacer { flex: 1; }
.v-section-link {
  font-family: var(--font-ui); font-size: 0.78rem; font-weight: 600;
  color: var(--gold); cursor: pointer; letter-spacing: 0.02em;
}
.v-section-link:hover { color: var(--gold-light); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-ui); font-size: 0.92rem; font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0.8rem 1.2rem; min-height: 46px;
  border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer;
  transition: all var(--transition);
  -webkit-user-select: none; user-select: none;
}
.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-gold {
  background: var(--gold); color: #1a1408; border-color: var(--gold);
  box-shadow: 0 6px 20px rgba(201,169,110,0.22);
}
.btn-gold:hover:not(:disabled) { background: var(--gold-light); transform: translateY(-1px); box-shadow: 0 10px 26px rgba(201,169,110,0.34); }
.btn-ghost {
  background: var(--glass-bg); color: var(--cream); border-color: var(--glass-border);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); background: var(--gold-faint); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(217,75,75,0.3); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 0.5rem 0.9rem; font-size: 0.82rem; }
.btn-pill { border-radius: var(--radius-pill); }

/* ── Chips ───────────────────────────────────────────────── */
.cat-chip, .chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 0.95rem;
  font-family: var(--font-ui); font-size: 0.82rem; font-weight: 500;
  color: var(--muted);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  cursor: pointer; white-space: nowrap;
  transition: all var(--transition);
}
.cat-chip:hover, .chip:hover { color: var(--cream); border-color: var(--gold-dim); }
.cat-chip.active, .chip.active {
  color: #1a1408; background: var(--gold); border-color: var(--gold); font-weight: 600;
}

/* ── Fields ──────────────────────────────────────────────── */
.field { margin-bottom: 1rem; }
.field label {
  display: block; font-family: var(--font-ui);
  font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 0.45rem; font-weight: 600;
}
.field input, .field select, .field textarea,
.v-input {
  width: 100%; padding: 0.8rem 0.95rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--cream); font-family: var(--font-ui); font-size: 0.92rem;
  transition: all var(--transition); min-height: 46px;
}
.field textarea { min-height: auto; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: var(--muted-dim); }
.field input:focus, .field select:focus, .field textarea:focus, .v-input:focus {
  border-color: var(--gold); outline: none;
  box-shadow: 0 0 0 3px var(--gold-faint);
}

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--bg-3); border: 1px solid var(--border); border-radius: 99px; transition: var(--transition); cursor: pointer; }
.toggle-slider::before { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; background: var(--muted); border-radius: 50%; transition: var(--transition); }
.toggle input:checked + .toggle-slider { background: var(--gold-dim); border-color: var(--gold); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); background: var(--gold); }

/* ── Modals ──────────────────────────────────────────────── */
.modal-ov {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.62);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: none; align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal-ov.visible { display: flex; animation: vFade 0.2s ease; }
@media (min-width: 640px) { .modal-ov { align-items: center; padding: 1.5rem; } }
.modal {
  width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto;
  background: var(--glass-bg-2);
  backdrop-filter: blur(34px) saturate(180%);
  -webkit-backdrop-filter: blur(34px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -10px 60px rgba(0,0,0,0.5);
  animation: vSlideUp 0.32s cubic-bezier(0.16,1,0.3,1);
}
@media (min-width: 640px) {
  .modal { border-radius: var(--radius-lg); animation: vScaleIn 0.24s ease; box-shadow: var(--shadow-lg); }
}
.modal-hd {
  position: sticky; top: 0; z-index: 1;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 0.75rem;
  background: inherit;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.modal-ttl { font-family: var(--font-display); font-size: 1.2rem; flex: 1; color: var(--cream); font-weight: 600; }
.modal-x {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  color: var(--cream); cursor: pointer; font-size: 1.05rem;
  display: grid; place-items: center; transition: all var(--transition); flex-shrink: 0;
}
.modal-x:hover { background: var(--gold-faint); border-color: var(--gold); color: var(--gold); }
.modal-body { padding: 1.25rem; }

@keyframes vSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes vScaleIn { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes vFade { from { opacity: 0; } to { opacity: 1; } }

/* ── Bottom navigation (floating pill) ───────────────────── */
.bottom-nav {
  position: fixed; bottom: calc(var(--safe-bottom) + 1.1rem);
  left: 50%; transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; justify-content: center;
}
.bn-main {
  display: flex; align-items: center;
  background: rgba(28,28,30,0.55);
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 0.5rem 0.75rem; gap: 0.25rem;
  box-shadow: 0 14px 40px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.06);
}
[data-theme="light"] .bn-main {
  background: rgba(248,245,240,0.7);
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow: 0 14px 40px rgba(90,70,30,0.16), inset 0 1px 0 rgba(255,255,255,0.7);
}
.bn-item {
  display: grid; place-items: center; width: 42px; height: 42px;
  color: var(--muted); cursor: pointer; border-radius: 50%;
  transition: all var(--transition); position: relative;
}
.bn-item:hover { color: var(--cream); }
.bn-item.active { color: var(--gold); }
.bn-item.active::after {
  content: ''; position: absolute; bottom: 2px; left: 50%;
  width: 4px; height: 4px; border-radius: 50%; background: var(--gold);
  transform: translateX(-50%);
}
.bn-ico { font-size: 1.05rem; line-height: 1; }
.bn-plus {
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--gold); border: 3px solid rgba(28,28,30,0.7);
  color: #1a1408; display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 8px 24px rgba(201,169,110,0.4);
  transition: all var(--transition); margin: 0 0.25rem;
  position: relative; z-index: 1;
}
[data-theme="light"] .bn-plus { border-color: rgba(248,245,240,0.85); }
.bn-plus:hover { transform: scale(1.06) rotate(6deg); box-shadow: 0 12px 30px rgba(201,169,110,0.55); }
.bn-plus i { font-size: 1.1rem; }

/* ── Toasts ──────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 1.5rem);
  left: 50%; transform: translateX(-50%); z-index: 9999;
  display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none;
  width: max-content; max-width: 90vw;
}
.toast {
  padding: 0.85rem 1.2rem;
  background: var(--glass-bg-2);
  backdrop-filter: blur(22px) saturate(180%); -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: 0.88rem; color: var(--cream);
  animation: vToastIn 0.28s cubic-bezier(0.16,1,0.3,1);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes vToastIn { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Skeleton & spinner ──────────────────────────────────── */
.skel {
  background: linear-gradient(90deg, var(--bg-2), var(--bg-3), var(--bg-2));
  background-size: 200% 100%;
  animation: vShimmer 1.4s infinite;
  border-radius: var(--radius);
}
@keyframes vShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(201,169,110,0.3); border-top-color: var(--gold);
  border-radius: 50%; animation: vSpin 0.6s linear infinite; display: inline-block;
}
@keyframes vSpin { to { transform: rotate(360deg); } }

/* ── Empty states ────────────────────────────────────────── */
.v-empty { padding: 3.5rem 1.5rem; text-align: center; color: var(--muted); }
.v-empty-ico {
  width: 64px; height: 64px; margin: 0 auto 1rem;
  border-radius: 50%; display: grid; place-items: center;
  background: var(--gold-faint); color: var(--gold); font-size: 1.6rem;
  border: 1px solid var(--gold-dim);
}
.v-empty-title { font-family: var(--font-display); font-size: 1.25rem; color: var(--cream); margin-bottom: 0.35rem; }

/* ── Utilities ───────────────────────────────────────────── */
.v-row { display: flex; align-items: center; gap: 0.6rem; }
.v-grow { flex: 1; }
.v-mono-num { font-family: var(--font-ui); font-variant-numeric: tabular-nums; }

/* Desktop: keep the app feel but use the width */
@media (min-width: 1024px) {
  .page.page-wide { max-width: var(--page-wide); }
}
