/* ReCircuit v3 — Upgraded Editorial Architectural Design System (UN SDG 12) */
:root {
  --bg-paper: #F4F3EF;
  --bg-card: #FFFFFF;
  --bg-elevated: #FAF9F6;
  --ink: #111210;
  --ink-muted: #5C5B56;
  --obsidian: #121513;
  --obsidian-soft: #1B1F1C;
  --line: #DDDAD2;
  --line-subtle: #EAE7DF;
  --lime: #B8F25A;
  --forest: #164E3B;
  --vermilion: #D94326;
  --amber: #C26A0A;
  --glow-lime: rgba(184, 242, 90, 0.35);
  --glow-forest: rgba(22, 78, 59, 0.3);
}

/* ========= DARK MODE ========= */
[data-theme="dark"] {
  --bg-paper: #0D0F0E;
  --bg-card: #161A17;
  --bg-elevated: #1D221E;
  --ink: #EEEDE8;
  --ink-muted: #A6A39C;
  --line: #2A2F2C;
  --line-subtle: #1F2421;
  --forest: #34D399;
}

[data-theme="dark"] body {
  background-color: var(--bg-paper);
  color: var(--ink);
  background-image: radial-gradient(rgba(184, 242, 90, 0.03) 1px, transparent 0);
}

[data-theme="dark"] .glass-header {
  background-color: rgba(13, 15, 14, 0.90);
}

[data-theme="dark"] .item-card,
[data-theme="dark"] .bg-white {
  background-color: var(--bg-card) !important;
  border-color: var(--line) !important;
}

[data-theme="dark"] .bg-paper {
  background-color: var(--bg-elevated) !important;
}

[data-theme="dark"] .text-ink {
  color: var(--ink) !important;
}

[data-theme="dark"] .text-forest {
  color: #4ADE80 !important;
}

[data-theme="dark"] .text-neutral-700,
[data-theme="dark"] .text-neutral-600 {
  color: #B6B3AC !important;
}

[data-theme="dark"] .text-neutral-500,
[data-theme="dark"] .text-neutral-400 {
  color: #8C8982 !important;
}

[data-theme="dark"] .bg-rose-50,
[data-theme="dark"] .bg-rose-50\/70 {
  background-color: rgba(217, 67, 38, 0.14) !important;
  border-color: rgba(217, 67, 38, 0.35) !important;
}

[data-theme="dark"] .bg-amber-50 {
  background-color: rgba(217, 119, 6, 0.14) !important;
  border-color: rgba(217, 119, 6, 0.35) !important;
}

[data-theme="dark"] .text-amber-900,
[data-theme="dark"] .text-amber-950,
[data-theme="dark"] .text-amber-800 {
  color: #FCD34D !important;
}

[data-theme="dark"] .bg-emerald-50 {
  background-color: rgba(16, 185, 129, 0.15) !important;
}

[data-theme="dark"] .badge-household {
  background-color: #1F2421;
  color: #C7C4BC;
  border-color: #343A36;
}

[data-theme="dark"] .badge-appliance {
  background-color: rgba(52, 211, 153, 0.12);
  color: #6EE7B7;
  border-color: rgba(52, 211, 153, 0.3);
}

[data-theme="dark"] .badge-battery {
  background-color: rgba(245, 158, 11, 0.14);
  color: #FBBF24;
  border-color: rgba(245, 158, 11, 0.32);
}

[data-theme="dark"] .badge-hazard {
  background-color: rgba(239, 68, 68, 0.16);
  color: #FCA5A5;
  border-color: rgba(239, 68, 68, 0.35);
}

[data-theme="dark"] footer {
  background-color: var(--bg-card) !important;
  border-color: var(--line) !important;
}

[data-theme="dark"] .nav-link {
  color: var(--ink-muted);
}

[data-theme="dark"] .nav-link:hover,
[data-theme="dark"] .nav-link.active {
  color: var(--ink);
  background-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] input,
[data-theme="dark"] select {
  background-color: var(--bg-elevated);
  color: var(--ink);
  border-color: var(--line);
}

[data-theme="dark"] .cat-pill:not(.bg-obsidian),
[data-theme="dark"] .stream-pill:not(.bg-obsidian),
[data-theme="dark"] .reg-pill:not(.bg-obsidian) {
  color: var(--ink-muted);
  background-color: var(--bg-elevated) !important;
}

[data-theme="dark"] kbd {
  background-color: var(--bg-elevated);
  border-color: var(--line);
  color: var(--ink-muted);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-image: radial-gradient(rgba(17, 18, 16, 0.03) 1px, transparent 0);
  background-size: 24px 24px;
  transition: background-color 0.35s ease, color 0.35s ease;
}

.font-editorial {
  font-family: 'Fraunces', Georgia, serif;
  letter-spacing: -0.025em;
}

.font-code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.hairline {
  border-color: var(--line);
}

/* ========= GLASS HEADER ========= */
.glass-header {
  background-color: rgba(244, 243, 239, 0.88);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  transition: background-color 0.3s ease;
}

/* ========= NAVIGATION ========= */
.nav-link {
  position: relative;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #5C5B56;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  transition: color 0.18s ease, background-color 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--ink);
  background-color: rgba(17, 18, 16, 0.045);
}

.nav-link.active {
  color: var(--ink);
  font-weight: 600;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: -2px;
  height: 2px;
  background-color: var(--ink);
  border-radius: 99px;
}

/* ========= ENHANCED CARDS ========= */
.item-card {
  background-color: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 0.875rem;
  transition: border-color 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

.item-card:hover {
  border-color: var(--ink);
  transform: translateY(-3px);
  box-shadow: 0 20px 40px -16px rgba(17, 18, 16, 0.18),
              0 0 0 1px rgba(17, 18, 16, 0.04);
}

[data-theme="dark"] .item-card:hover {
  border-color: var(--lime);
  box-shadow: 0 20px 40px -16px rgba(0, 0, 0, 0.55),
              0 0 0 1px rgba(184, 242, 90, 0.25);
}

.item-card:hover .card-arrow {
  transform: translateX(5px);
}

.card-arrow {
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ========= OBSIDIAN PANELS ========= */
.obsidian-grid {
  background-color: var(--obsidian);
  background-image:
    radial-gradient(circle at 88% 12%, rgba(184, 242, 90, 0.14), transparent 45%),
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 100% 100%, 28px 28px, 28px 28px;
}

.obsidian-red {
  background-color: #161111;
  background-image:
    radial-gradient(circle at 85% 15%, rgba(217, 67, 38, 0.2), transparent 48%),
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 100% 100%, 28px 28px, 28px 28px;
}

/* ========= SCROLL REVEAL ANIMATIONS ========= */
.reveal, .reveal-left, .reveal-right, .reveal-scale {
  transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal:not(.revealed) { opacity: 0; transform: translateY(22px); }
.reveal-left:not(.revealed) { opacity: 0; transform: translateX(-24px); }
.reveal-right:not(.revealed) { opacity: 0; transform: translateX(24px); }
.reveal-scale:not(.revealed) { opacity: 0; transform: scale(0.94); }

.revealed {
  opacity: 1 !important;
  transform: none !important;
}

.stagger-children > * {
  transition: opacity 0.48s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.48s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.25s ease,
              box-shadow 0.25s ease;
}

.stagger-children:not(.revealed) > * {
  opacity: 0;
  transform: translateY(16px);
}

.stagger-children.revealed > *:nth-child(1) { transition-delay: 0.04s; }
.stagger-children.revealed > *:nth-child(2) { transition-delay: 0.08s; }
.stagger-children.revealed > *:nth-child(3) { transition-delay: 0.12s; }
.stagger-children.revealed > *:nth-child(4) { transition-delay: 0.16s; }
.stagger-children.revealed > *:nth-child(5) { transition-delay: 0.20s; }
.stagger-children.revealed > *:nth-child(6) { transition-delay: 0.24s; }

.stagger-children.revealed > * {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal-left, .reveal-right, .reveal-scale, .stagger-children > * {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .particle-container, .ticker-track { animation: none !important; }
}

/* ========= ANIMATED COUNTER ========= */
.counter-animated {
  font-variant-numeric: tabular-nums;
  display: inline-block;
}

/* ========= SLIDE-OVER DRAWER ========= */
.drawer-backdrop {
  background-color: rgba(17, 18, 16, 0.52);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.drawer-panel {
  animation: slideInRight 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideInRight {
  from { transform: translateX(28px); opacity: 0.85; }
  to { transform: translateX(0); opacity: 1; }
}

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

.animate-fade-up {
  animation: fadeUp 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ========= AMBIENT PULSE ========= */
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 var(--glow-lime); }
  50% { box-shadow: 0 0 24px 4px var(--glow-lime); }
}

.pulse-lime {
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.4); }
}

.pulse-dot {
  animation: pulse-dot 2s ease-in-out infinite;
}

/* ========= GRADIENT SHIMMER ========= */
@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.text-gradient-forest {
  background: linear-gradient(135deg, #164E3B, #1D7A58, #6FB827, #164E3B);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-shift 6s ease-in-out infinite;
}

[data-theme="dark"] .text-gradient-forest {
  background: linear-gradient(135deg, #4ADE80, #B8F25A, #6EE7B7, #4ADE80);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ========= FLOATING PARTICLES ========= */
@keyframes float-up {
  0% { transform: translateY(100vh) scale(0); opacity: 0; }
  10% { opacity: 0.45; }
  90% { opacity: 0.25; }
  100% { transform: translateY(-10vh) scale(1); opacity: 0; }
}

.particle-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--lime);
  opacity: 0;
  animation: float-up linear infinite;
}

.particle:nth-child(1) { left: 10%; animation-duration: 18s; animation-delay: 0s; }
.particle:nth-child(2) { left: 25%; animation-duration: 22s; animation-delay: 3s; width: 3px; height: 3px; }
.particle:nth-child(3) { left: 40%; animation-duration: 16s; animation-delay: 6s; }
.particle:nth-child(4) { left: 55%; animation-duration: 20s; animation-delay: 2s; width: 5px; height: 5px; }
.particle:nth-child(5) { left: 70%; animation-duration: 24s; animation-delay: 5s; width: 3px; height: 3px; }
.particle:nth-child(6) { left: 85%; animation-duration: 19s; animation-delay: 8s; }
.particle:nth-child(7) { left: 15%; animation-duration: 21s; animation-delay: 10s; width: 2px; height: 2px; }
.particle:nth-child(8) { left: 60%; animation-duration: 17s; animation-delay: 1s; width: 2px; height: 2px; }

/* ========= LIVE TICKER ========= */
@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker-track {
  display: flex;
  animation: ticker-scroll 42s linear infinite;
  width: max-content;
}

.ticker-track:hover {
  animation-play-state: paused;
}

/* ========= PROGRESS RING ========= */
.progress-ring-circle {
  transition: stroke-dashoffset 1.2s cubic-bezier(0.16, 1, 0.3, 1);
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

/* ========= GLASSMORPHISM CARDS ========= */
.glass-card {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid var(--line);
}

[data-theme="dark"] .glass-card {
  background: rgba(22, 26, 23, 0.76);
  border-color: var(--line);
}

/* ========= STATUS BADGES ========= */
.badge-ewaste {
  background-color: #121513;
  color: #B8F25A;
  border: 1px solid #262C28;
}

.badge-hazard {
  background-color: rgba(217, 67, 38, 0.1);
  color: #B8321A;
  border: 1px solid rgba(217, 67, 38, 0.28);
}

.badge-battery {
  background-color: rgba(194, 106, 10, 0.1);
  color: #9A5006;
  border: 1px solid rgba(194, 106, 10, 0.28);
}

.badge-appliance {
  background-color: rgba(22, 78, 59, 0.09);
  color: #164E3B;
  border: 1px solid rgba(22, 78, 59, 0.25);
}

.badge-household {
  background-color: #F4F3EF;
  color: #44433E;
  border: 1px solid #D5D2C8;
}

/* ========= CUSTOM RANGE SLIDERS ========= */
input[type="range"].rc-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: #DDDAD2;
  outline: none;
}

input[type="range"].rc-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #121513;
  border: 2px solid #B8F25A;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

input[type="range"].rc-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ========= CUSTOM SCROLLBAR ========= */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg-paper); }
::-webkit-scrollbar-thumb { background: #CFCBC1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9E9B92; }

/* ========= DARK MODE TOGGLE ========= */
.theme-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: #DDDAD2;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.3s ease;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5px;
  font-size: 10px;
}

.theme-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .theme-toggle {
  background: #164E3B;
  border-color: #1A6B4E;
}

[data-theme="dark"] .theme-toggle::after {
  transform: translateX(20px);
  background: #B8F25A;
}

/* ========= IMPACT BADGE ========= */
@keyframes badge-pop {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}

.badge-pop {
  animation: badge-pop 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ========= BACK TO TOP BUTTON ========= */
.back-to-top {
  position: fixed;
  bottom: 4.5rem;
  left: 1.5rem;
  z-index: 40;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--obsidian);
  color: var(--lime);
  border: 1px solid rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

@media (min-width: 1024px) {
  .back-to-top { bottom: 1.75rem; left: 1.75rem; }
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  box-shadow: 0 8px 24px rgba(184, 242, 90, 0.28);
}

/* ========= MOBILE BOTTOM DOCK ========= */
.mobile-dock {
  background-color: rgba(244, 243, 239, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

[data-theme="dark"] .mobile-dock {
  background-color: rgba(13, 15, 14, 0.94);
}

/* ========= PRINT ARCHITECTURE ========= */
.only-print {
  display: none !important;
}

@media print {
  @page {
    margin: 8mm 10mm;
    size: auto;
  }

  *, *::before, *::after {
    box-shadow: none !important;
    text-shadow: none !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body {
    background: #FFFFFF !important;
    background-image: none !important;
    color: #111210 !important;
    font-size: 10pt !important;
    line-height: 1.35 !important;
  }

  main {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  .no-print,
  header,
  footer,
  nav,
  #cmd-palette,
  #toast-container,
  #mobile-menu,
  .no-print-section,
  .particle-container,
  .back-to-top,
  .ticker-bar,
  .mobile-dock,
  #achievements-modal {
    display: none !important;
  }

  .only-print {
    display: block !important;
  }

  .print-slip {
    display: block !important;
    border: 2px solid #111210 !important;
    border-radius: 6px !important;
    padding: 16px !important;
    background: #FFFFFF !important;
    color: #111210 !important;
    page-break-inside: avoid;
  }

  .print-slip table {
    border-collapse: collapse !important;
    width: 100% !important;
  }

  .print-slip th, .print-slip td {
    border: 1px solid #111210 !important;
    padding: 4px 6px !important;
  }

  #red-box-emergency {
    background: #FFFFFF !important;
    background-image: none !important;
    color: #111210 !important;
    border: 3px solid #D94326 !important;
    border-radius: 8px !important;
    padding: 16px !important;
    page-break-inside: avoid;
    box-shadow: none !important;
  }

  #red-box-emergency * {
    color: #111210 !important;
  }

  #red-box-emergency h2,
  #red-box-emergency h3 {
    color: #D94326 !important;
  }

  #red-box-emergency .print-step-box {
    border: 1.5px solid #D94326 !important;
    background: #FFFBFB !important;
    padding: 10px !important;
    border-radius: 6px !important;
  }

  #red-box-emergency .print-emergency-badge {
    background: #D94326 !important;
    color: #FFFFFF !important;
    padding: 2px 8px !important;
    border-radius: 4px !important;
    font-weight: bold !important;
    display: inline-block !important;
  }

  .item-card {
    border: 1px solid #DDDAD2 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }

  .reveal, .reveal-left, .reveal-right, .reveal-scale, .stagger-children > * {
    opacity: 1 !important;
    transform: none !important;
  }
}
