/* ANIMUS — shared app shell (nav, mobile, tokens, toast) */

:root {
  --bg: #080808;
  --surface: #0f0f0f;
  --surface2: #141414;
  --border: #1e1e1e;
  --border2: #2a2a2a;
  --text: #e2e2e2;
  --muted: #555;
  --muted2: #888;
  --gold: #c8a96e;
  --gold2: #8a6f3e;
  --gold3: #f0d090;
  --white: #f0ece4;
  --green: #27ae60;
  --green2: #2d6b47;
  --red: #c0392b;
  --compare-mode-h: 44px;
  --nav-h: 56px;
  --mbn-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body.light-mode {
  --bg: #f4f1ec;
  --surface: #fff;
  --surface2: #f8f5f0;
  --border: #e0dbd4;
  --border2: #cdc7bf;
  --text: #1a1714;
  --muted: #9a9189;
  --muted2: #6b6259;
  --white: #1a1714;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: rgba(200, 169, 110, 0.15);
}

img, video, svg {
  max-width: 100%;
}

/* Unified app page containment — prevents horizontal bleed on mobile */
.app-page {
  width: 100%;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: clip;
}

.app-page--wide {
  max-width: 920px;
}

.app-section,
.app-section-mount {
  margin-bottom: 32px;
  min-width: 0;
  max-width: 100%;
}

.app-section-mount:empty {
  display: none;
}

/* Navbar */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  background: rgba(8, 8, 8, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding-top: 0;
  z-index: 200;
  gap: 0;
}

body.light-mode .navbar {
  background: rgba(244, 241, 236, 0.95);
}

.nav-logo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 0.1em;
  color: var(--white);
  text-decoration: none;
  margin-right: 24px;
  flex-shrink: 0;
}

.nav-logo span {
  color: var(--gold);
}

.nav-items {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  min-height: 40px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted2);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
  border-radius: 2px;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface);
}

.nav-item.active {
  color: var(--gold);
  background: rgba(200, 169, 110, 0.06);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.nav-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 14px;
  color: var(--gold);
  text-decoration: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.nav-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  color: var(--text);
  align-items: center;
  justify-content: center;
}

.nav-mobile-menu {
  display: none;
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  background: rgba(8, 8, 8, 0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 199;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  max-height: calc(100vh - var(--nav-h));
  overflow-y: auto;
}

body.light-mode .nav-mobile-menu {
  background: rgba(244, 241, 236, 0.98);
}

.nav-mobile-menu.open {
  display: block;
}

.nav-mobile-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  min-height: 48px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted2);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.nav-mobile-item:hover,
.nav-mobile-item.active {
  color: var(--gold);
  background: rgba(200, 169, 110, 0.04);
}

.theme-toggle-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  background: none;
  border: 1px solid var(--border2);
  color: var(--muted2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
  border-radius: 2px;
}

.theme-toggle-btn:hover {
  border-color: var(--gold2);
  color: var(--gold);
}

.nav-item-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  min-height: 40px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted2);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, background 0.15s;
  border-radius: 2px;
}

.nav-item-btn:hover {
  color: var(--text);
  background: var(--surface);
}

.notif-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--muted2);
  cursor: pointer;
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
  border-radius: 2px;
}

.notif-btn:hover {
  color: var(--text);
  background: var(--surface);
}

.nav-item-notif {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.nav-item-notif:hover {
  color: var(--text);
  background: var(--surface);
}

.nav-item-notif.active {
  color: var(--gold);
  background: rgba(200, 169, 110, 0.06);
}

.nav-item-notif .notif-badge {
  top: 10px;
  right: 10px;
}

.notif-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  background: var(--gold);
  border-radius: 50%;
  border: 1px solid var(--bg);
  display: none;
}

.notif-dropdown {
  display: none;
  position: fixed;
  top: calc(var(--nav-h) + 6px);
  right: max(12px, env(safe-area-inset-right));
  width: min(360px, calc(100vw - 24px));
  max-height: min(420px, calc(100vh - var(--nav-h) - 24px));
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border2);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  z-index: 250;
  padding: 12px 0;
}

.notif-dropdown.open {
  display: block;
}

.notif-dropdown-head {
  font-size: 10px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold2);
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.notif-empty {
  padding: 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.notif-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
  margin-top: 6px;
}

.notif-text {
  font-size: 12px;
  color: var(--muted2);
  line-height: 1.6;
}

.notif-text strong {
  color: var(--text);
  font-weight: 500;
}

.btn-add-small {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 6px 10px;
  border: 1px solid var(--border2);
  background: none;
  color: var(--muted2);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-add-small:hover {
  border-color: var(--gold2);
  color: var(--gold);
}

.btn-add-small--accept {
  border-color: var(--green);
  color: var(--green);
}

.btn-add-small--accept:hover {
  border-color: var(--green);
  color: var(--green);
  filter: brightness(1.15);
}

/* Mobile bottom nav */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--mbn-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(8, 8, 8, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  z-index: 300;
  justify-content: space-around;
  align-items: center;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

body.light-mode .mobile-bottom-nav {
  background: rgba(244, 241, 236, 0.98);
}

.mbn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  min-width: 0;
  flex: 1;
  max-width: 80px;
  min-height: 48px;
  color: var(--muted);
  text-decoration: none;
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 0.2s;
  position: relative;
  text-align: center;
  line-height: 1.2;
}

.mbn-item.active {
  color: var(--gold);
  font-weight: 500;
}

.mbn-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  border-radius: 0 0 2px 2px;
}

.mbn-item.active::after {
  content: '';
  position: absolute;
  bottom: calc(4px + var(--safe-bottom, 0px) * 0);
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0.9;
}

.mbn-item svg {
  opacity: 0.55;
  transition: opacity 0.2s ease, transform 0.2s ease, filter 0.2s ease;
}

.mbn-item.active svg {
  opacity: 1;
  transform: translateY(-1px);
  filter: drop-shadow(0 0 6px rgba(200, 169, 110, 0.35));
}

.mbn-badge {
  position: absolute;
  top: 6px;
  right: 10px;
  width: 8px;
  height: 8px;
  background: var(--gold);
  border-radius: 50%;
  border: 1px solid var(--bg);
  display: none;
}

.mbn-badge.visible {
  display: block;
}

/* Toast */
body:has(.mobile-bottom-nav) .toast {
  bottom: calc(var(--mbn-h) + var(--safe-bottom) + 12px);
}

.toast {
  position: fixed;
  bottom: calc(28px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  border: 1px solid var(--gold2);
  color: var(--text);
  padding: 12px 24px;
  font-size: 12px;
  z-index: 600;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  letter-spacing: 0.05em;
  max-width: min(92vw, 420px);
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* App page offset below fixed nav */
.has-app-nav {
  padding-top: var(--nav-h);
}

.profile-tabs {
  position: sticky;
  top: var(--nav-h);
  z-index: 100;
}

@media (max-width: 768px) {
  .nav-items {
    display: none !important;
  }

  .nav-hamburger {
    display: flex !important;
  }

  .nav-right .nav-avatar {
    display: flex !important;
    flex-shrink: 0;
  }

  .mobile-bottom-nav {
    display: flex;
  }

  body:has(.mobile-bottom-nav) {
    padding-bottom: calc(var(--mbn-h) + var(--safe-bottom));
  }

  .mbn-item {
    font-size: 7px;
    letter-spacing: 0.06em;
    padding: 8px 2px;
  }

  .nav-logo {
    margin-right: auto;
  }
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 1000;
  padding: 12px 20px;
  background: var(--gold);
  color: #000;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
}

.skip-link:focus {
  left: max(12px, env(safe-area-inset-left));
  top: max(12px, env(safe-area-inset-top));
  width: auto;
  height: auto;
  overflow: visible;
}

/* Premium typography rhythm */
h1, h2, h3, .home-greeting, .shop-title, .friends-page-title {
  text-wrap: balance;
}

p, .shop-sub, .friends-page-sub {
  text-wrap: pretty;
}

/* Nav polish */
.navbar {
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.nav-item,
.nav-mobile-item,
.mbn-item {
  -webkit-tap-highlight-color: transparent;
}

.nav-item:active,
.mbn-item:active {
  transform: scale(0.98);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .nav-item:active,
  .mbn-item:active {
    transform: none;
  }
}
