/* ============================================================
   CHANNELS REALTY — Co-Own Program
   Design system: tokens, themes, base, shell, components
   ============================================================ */

/* ---------- Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700;800&family=Manrope:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Manrope', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
::selection { background: var(--orange-200); color: var(--orange-700); }

/* ---------- Tokens ---------- */
:root {
  /* Brand */
  --teal-950: #152e38;
  --teal-900: #1b3a46;
  --teal-800: #224a59;
  --teal-700: #2b5666;   /* brand primary */
  --teal-600: #356678;
  --teal-500: #3f7c91;
  --teal-400: #5b97aa;
  --teal-200: #b7d2da;
  --teal-100: #dceaee;
  --teal-50:  #eef5f7;

  --orange-700: #b0561c;
  --orange-600: #c4631f;
  --orange-500: #d9742e;  /* brand accent */
  --orange-400: #e68a4d;
  --orange-300: #f0a878;
  --orange-200: #f8d8bf;
  --orange-100: #fbe9da;
  --orange-50:  #fdf4ec;

  /* Warm neutrals */
  --ink:    #1c2429;
  --ink-2:  #3a444b;
  --muted:  #6a747b;
  --faint:  #9aa3a9;
  --line:   #e7e3dd;
  --line-2: #efece7;
  --paper:  #ffffff;
  --bg:     #f5f2ee;
  --bg-2:   #efeae3;

  /* Semantic */
  --green-600: #2f8f5b;
  --green-500: #36a368;
  --green-50:  #e8f5ee;
  --red-500:   #d1483b;
  --red-50:    #fbeae8;
  --gold:      #d9a23e;

  /* Surfaces (themeable) */
  --surface:        var(--paper);
  --surface-2:      #fbfaf8;
  --surface-sunk:   var(--bg-2);
  --on-surface:     var(--ink);
  --on-surface-mut: var(--muted);
  --hairline:       var(--line);
  --app-bg:         var(--bg);

  /* Accent roles */
  --accent:       var(--orange-500);
  --accent-ink:   #ffffff;
  --primary:      var(--teal-700);
  --primary-ink:  #ffffff;

  /* Radii */
  --r-xs: 8px; --r-sm: 12px; --r-md: 16px; --r-lg: 22px; --r-xl: 28px; --r-pill: 999px;

  /* Shadows */
  --sh-xs: 0 1px 2px rgba(28,36,41,.06);
  --sh-sm: 0 2px 8px rgba(28,36,41,.06), 0 1px 2px rgba(28,36,41,.04);
  --sh-md: 0 8px 24px rgba(28,36,41,.08), 0 2px 6px rgba(28,36,41,.05);
  --sh-lg: 0 24px 60px rgba(28,36,41,.14), 0 6px 16px rgba(28,36,41,.06);
  --sh-teal: 0 16px 40px rgba(43,86,102,.28);
  --sh-orange: 0 14px 30px rgba(217,116,46,.32);

  --maxw: 1180px;
  --sidebar-w: 250px;
  --ease: cubic-bezier(.4,0,.2,1);
  --ease-out: cubic-bezier(.16,1,.3,1);
  --spring: cubic-bezier(.34,1.56,.64,1);
}

/* ---------- Theme: Midnight (dark teal) ---------- */
[data-theme="midnight"] {
  --surface:        #1d3f4c;
  --surface-2:      #234a59;
  --surface-sunk:   #15323d;
  --on-surface:     #eaf2f3;
  --on-surface-mut: #9fb9c0;
  --hairline:       rgba(255,255,255,.09);
  --app-bg:         #122a33;
  --ink:    #eaf2f3;
  --ink-2:  #cfe0e3;
  --muted:  #9fb9c0;
  --faint:  #7896a0;
  --line:   rgba(255,255,255,.09);
  --line-2: rgba(255,255,255,.06);
  --primary:     var(--orange-500);
  --primary-ink: #fff;
}

/* ---------- Theme: Canvas (warm editorial) ---------- */
[data-theme="canvas"] {
  --surface:        #fffdfa;
  --surface-2:      #fbf5ec;
  --surface-sunk:   #f3ead9;
  --app-bg:         #f4ecdd;
  --hairline:       #ece0cd;
  --line:           #ece0cd;
  --line-2:         #f2e9da;
  --primary:        var(--teal-800);
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
.font-display { font-family: 'Sora', sans-serif; }
.font-mono { font-family: 'JetBrains Mono', monospace; }
h1,h2,h3,h4 { font-family: 'Sora', sans-serif; margin: 0; line-height: 1.08; letter-spacing: -.02em; color: var(--on-surface); }
.eyebrow {
  font-size: 11.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); font-family: 'Manrope', sans-serif;
}
.num { font-family: 'JetBrains Mono', monospace; font-feature-settings: "tnum"; letter-spacing: -.02em; }
.naira { font-family: 'JetBrains Mono', monospace; }

/* ============================================================
   SHELL — responsive (mobile bottom-nav  ↔  desktop sidebar)
   ============================================================ */
#root { min-height: 100vh; }
.app-bg { background: var(--app-bg); min-height: 100vh; transition: background .4s var(--ease); }

/* App authenticated shell */
.shell { display: flex; min-height: 100vh; background: var(--app-bg); }

/* Sidebar (desktop) */
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  position: sticky; top: 0; height: 100vh;
  background: var(--surface); border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column; padding: 22px 16px;
  z-index: 30;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
.side-nav { display: flex; flex-direction: column; gap: 3px; }
.side-link {
  display: flex; align-items: center; gap: 13px; padding: 11px 13px; border-radius: var(--r-sm);
  color: var(--on-surface-mut); font-weight: 600; font-size: 14.5px;
  transition: all .18s var(--ease); position: relative;
}
.side-link svg { width: 20px; height: 20px; flex: 0 0 20px; }
.side-link:hover { background: var(--surface-sunk); color: var(--on-surface); }
.side-link.active { background: var(--primary); color: var(--primary-ink); box-shadow: var(--sh-sm); }
[data-theme="midnight"] .side-link.active { color:#fff; }
.side-link .side-badge { margin-left: auto; font-size: 11px; font-weight: 800; background: var(--accent); color:#fff; border-radius: var(--r-pill); padding: 1px 7px; }
.side-link.active .side-badge { background: rgba(255,255,255,.25); }

/* Main column */
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.main-inner { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 26px 30px 60px; }

/* Topbar (desktop) */
.topbar {
  position: sticky; top: 0; z-index: 25;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 30px; background: color-mix(in srgb, var(--app-bg) 86%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--hairline);
}

/* Bottom nav (mobile) */
.bottom-nav { display: none; }

/* Mobile header */
.m-header { display: none; }

/* ---------- Responsive switch ---------- */
@media (max-width: 1023px) {
  .sidebar { display: none; }
  .topbar { display: none; }
  .main-inner { padding: 0 16px 120px; max-width: 560px; }

  .m-header {
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 40;
    padding: 14px 16px 12px;
    background: color-mix(in srgb, var(--app-bg) 90%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--hairline);
  }
  .m-header .mh-spacer { flex: 1; }

  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid var(--hairline);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .bn-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    color: var(--faint); font-size: 10.5px; font-weight: 700; flex: 1; padding: 4px 2px;
    transition: color .18s var(--ease); position: relative;
  }
  .bn-item svg { width: 23px; height: 23px; }
  .bn-item.active { color: var(--accent); }
  .bn-item.active::before {
    content:''; position: absolute; top: -8px; width: 26px; height: 3px; border-radius: 3px;
    background: var(--accent);
  }
}
@media (min-width: 1024px) { .m-only { display: none !important; } }
@media (max-width: 1023px) { .d-only { display: none !important; } }

/* ---- Mobile overflow hardening ---- */
@media (max-width: 1023px) {
  html, body { overflow-x: hidden; max-width: 100vw; }
  .shell, .main, .main-inner { min-width: 0; max-width: 100%; overflow-x: clip; }
  /* Any inline 2-col grid that wasn't tagged still collapses safely */
  .grid { gap: 13px; }
  /* Keep wide media elements inside the frame */
  .card, .reveal > * { max-width: 100%; }
  img, svg, canvas { max-width: 100%; }
  /* Long mono strings (ref links, account numbers) must wrap, not push width */
  .font-mono { overflow-wrap: anywhere; word-break: break-word; }
  /* Sticky desktop offsets shouldn't apply on mobile */
  .main-inner [style*="position: sticky"] { position: static !important; }
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* Card */
.card {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.card-pad { padding: 20px; }
.card-hover { transition: transform .22s var(--ease-out), box-shadow .22s var(--ease-out); }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--sh-md); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-weight: 700; font-size: 15px; border-radius: var(--r-pill); padding: 13px 22px;
  transition: transform .14s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease), filter .2s;
  white-space: nowrap; line-height: 1;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--sh-orange); }
.btn-primary:hover { filter: brightness(1.05); box-shadow: 0 18px 38px rgba(217,116,46,.4); }
.btn-teal { background: var(--primary); color: var(--primary-ink); box-shadow: var(--sh-teal); }
.btn-teal:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface-sunk); color: var(--on-surface); }
.btn-ghost:hover { background: color-mix(in srgb, var(--surface-sunk) 80%, var(--ink)); }
.btn-outline { background: transparent; border: 1.5px solid var(--hairline); color: var(--on-surface); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 15px; font-size: 13.5px; }
.btn-lg { padding: 16px 28px; font-size: 16.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* Chips / pills */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700; padding: 6px 12px; border-radius: var(--r-pill);
  background: var(--surface-sunk); color: var(--on-surface-mut);
}
.chip-accent { background: var(--orange-100); color: var(--orange-700); }
.chip-teal { background: var(--teal-100); color: var(--teal-800); }
.chip-green { background: var(--green-50); color: var(--green-600); }
.chip-gold  { background: #f8efd6; color: #9a6f15; }
[data-theme="midnight"] .chip-accent { background: rgba(217,116,46,.18); color: var(--orange-300); }
[data-theme="midnight"] .chip-teal { background: rgba(91,151,170,.18); color: var(--teal-200); }

/* Progress */
.progress { height: 9px; border-radius: 999px; background: var(--surface-sunk); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--orange-400), var(--orange-600));
  transition: width 1s var(--ease-out); }
.progress.teal > span { background: linear-gradient(90deg, var(--teal-500), var(--teal-700)); }
.progress.green > span { background: linear-gradient(90deg, var(--green-500), var(--green-600)); }
.progress.tall { height: 12px; }

/* Stat label */
.stat-label { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--on-surface-mut); }

/* Avatar */
.avatar { border-radius: 50%; object-fit: cover; background: var(--surface-sunk); }
.avatar-ring { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

/* Divider */
.hr { height: 1px; background: var(--hairline); border: 0; margin: 0; }

/* Section header */
.sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sec-head h3 { font-size: 19px; font-weight: 700; }

/* Grid helpers */
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
/* On mobile, force two-column app grids to a single column.
   !important is required so it beats inline gridTemplateColumns styles. */
@media (max-width: 1023px){ .d-grid-2 { grid-template-columns: 1fr !important; } }

/* Flex helpers */
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.wrap { flex-wrap: wrap; }

/* Tag for level dot */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Sheet / modal */
.overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(20,30,35,.5);
  backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center;
  animation: fade .25s var(--ease);
}
@media (min-width:700px){ .overlay { align-items: center; } }
.sheet {
  background: var(--surface); width: 100%; max-width: 460px;
  border-radius: var(--r-xl) var(--r-xl) 0 0; padding: 8px 22px calc(26px + env(safe-area-inset-bottom));
  box-shadow: var(--sh-lg); animation: sheetUp .38s var(--ease-out); max-height: 92vh; overflow-y: auto;
}
@media (min-width:700px){ .sheet { border-radius: var(--r-xl); animation: pop .34s var(--ease-out); margin: 20px; } }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--hairline); margin: 8px auto 14px; }

@keyframes fade { from { opacity: 0; } }
@keyframes sheetUp { from { transform: translateY(100%); } }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
@keyframes popIn { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes floatUp { from { transform: translateY(12px); } to { transform: translateY(0); } }
@keyframes fadeUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes spinIn { from { transform: rotate(-180deg) scale(.4); opacity: 0; } to { transform: rotate(0) scale(1); opacity: 1; } }
@keyframes shimmer { 100% { background-position: 200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes countPulse { 0%,100%{ transform: scale(1);} 50%{ transform: scale(1.04);} }
@keyframes ringPulse { 0% { box-shadow: 0 0 0 0 rgba(217,116,46,.4);} 70%{ box-shadow: 0 0 0 14px rgba(217,116,46,0);} 100%{ box-shadow:0 0 0 0 rgba(217,116,46,0);} }

/* Reveal on mount */
.reveal { animation: floatUp .5s var(--ease-out) both; }
.reveal-1 { animation-delay: .04s; } .reveal-2 { animation-delay: .1s; }
.reveal-3 { animation-delay: .16s; } .reveal-4 { animation-delay: .22s; }
.reveal-5 { animation-delay: .28s; } .reveal-6 { animation-delay: .34s; }

/* Skeleton shimmer (for value reveals) */
.shimmer-text { background: linear-gradient(90deg, var(--accent) 0%, var(--orange-300) 50%, var(--accent) 100%);
  background-size: 200% auto; -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Confetti pieces */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 300; overflow: hidden; }
.confetti i { position: absolute; width: 9px; height: 14px; top: -20px; opacity: .95;
  animation: confFall linear forwards; }
@keyframes confFall { to { transform: translateY(110vh) rotate(720deg); opacity: .9; } }

/* Toast */
.toast-wrap { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 8px; align-items: center; }
@media (min-width:1024px){ .toast-wrap { bottom: 28px; } }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 600; box-shadow: var(--sh-lg); display: flex; align-items: center; gap: 9px;
  animation: floatUp .3s var(--ease-out); }
[data-theme="midnight"] .toast { background: #0c1f26; border: 1px solid var(--hairline); }

/* Scrollbar */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* Misc */
/* Landing + auth responsive grids */
@media (min-width: 1024px) {
  .auth-wrap { grid-template-columns: 1.05fr 1fr !important; }
  .auth-brand { display: flex !important; }
}
@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr !important; }
}

.muted { color: var(--on-surface-mut); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.clickable { cursor: pointer; }
.hide-scroll::-webkit-scrollbar { display: none; }
.hide-scroll { scrollbar-width: none; }
