/* ============ BASE STYLES ============ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font-body);
  color: var(--text-primary);
  background-color: var(--surface-warm);
  transition: background-color var(--transition-scene), color var(--transition-scene);
}

/* Dark-to-light scene transition (globe → city) */
body.city-active {
  background-color: var(--surface-cream);
  color: var(--text-dark);
}

/* Custom selection */
::selection {
  background: rgba(200, 146, 58, 0.3);
  color: var(--text-dark);
}

/* Grain overlay — subtle noise for texture */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 10000;
  transition: opacity 0.5s ease;
}

/* Vignette effect */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(
    ellipse 70% 70% at 50% 50%,
    transparent 0%,
    transparent 40%,
    rgba(10, 7, 5, 0.4) 70%,
    rgba(10, 7, 5, 0.75) 100%
  );
  pointer-events: none;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

/* Hide grain/vignette on city view */
body.city-active::before,
body.city-active::after { opacity: 0; }

/* === Views === */
.view {
  position: absolute;
  inset: 0;
}
.view.hidden { opacity: 0; pointer-events: none; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(44, 24, 16, 0.15); border-radius: 3px; }

/* Paper texture on light surfaces (city view + bottom sheet) */
#city-view::after,
.bottom-sheet::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)' opacity='0.02'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1;
  border-radius: inherit;
}

/* Focus visible for keyboard nav — warm glow */
:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 2px;
  box-shadow: var(--glow-warm);
}

/* Consistent warm glow on interactive element hover */
button:hover, a:hover, [role="button"]:hover {
  box-shadow: var(--glow-warm);
}

/* Reduced motion (REQ-8) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .bottom-sheet {
    transition: transform 200ms linear !important;
  }
}

/* Safe area handling (REQ-5) */
.view {
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* Touch-action on interactive elements */
button, a, [role="button"], .coffee-marker, .shop-list-card, .filter-pill {
  touch-action: manipulation;
}
