/* HomeHub — warm & cozy design system */

:root {
  /* Warm earth tone palette */
  --hh-bg: #F5EDE3;           /* warm cream */
  --hh-bg-alt: #EDE1D1;       /* slightly deeper cream */
  --hh-surface: #FFFBF4;      /* near-white warm */
  --hh-surface-2: #FAF3E7;
  --hh-ink: #2A211A;          /* warm near-black */
  --hh-ink-soft: #5C4A3C;     /* warm brown */
  --hh-ink-mute: #8B7763;     /* muted brown */
  --hh-line: #E4D5C2;
  --hh-line-soft: #EFE4D4;

  /* Accents — share chroma ~0.09, lightness ~0.68 */
  --hh-accent: #C9562E;        /* terracotta (default) */
  --hh-accent-soft: #F0C9B8;
  --hh-accent-tint: #FBEADF;

  --hh-sage: #6E8662;
  --hh-sage-soft: #CBDABB;
  --hh-mustard: #C99A2E;
  --hh-mustard-soft: #F0DCA8;
  --hh-clay: #B26749;
  --hh-plum: #7A4F6B;
  --hh-sky: #5F7E91;
  --hh-sky-soft: #C5D5DE;

  /* Semantic */
  --hh-good: #6E8662;
  --hh-warn: #C99A2E;
  --hh-bad: #B23B2A;

  --hh-r-sm: 10px;
  --hh-r-md: 16px;
  --hh-r-lg: 22px;
  --hh-r-xl: 28px;

  --hh-shadow-sm: 0 1px 2px rgba(42, 33, 26, 0.06);
  --hh-shadow: 0 2px 10px rgba(42, 33, 26, 0.06), 0 1px 2px rgba(42, 33, 26, 0.04);
  --hh-shadow-lg: 0 8px 24px rgba(42, 33, 26, 0.10), 0 2px 6px rgba(42, 33, 26, 0.04);

  --hh-font: "Fraunces-fallback", "Cooper BT", "Cooper Std", Georgia, serif;
  --hh-sans: "Geist", "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --hh-mono: "JetBrains Mono", "Geist Mono", ui-monospace, Menlo, monospace;

  /* Density */
  --hh-pad: 16px;
  --hh-gap: 12px;
  --hh-row: 56px;
}

[data-density="compact"] {
  --hh-pad: 12px;
  --hh-gap: 8px;
  --hh-row: 46px;
}

[data-theme="dark"] {
  --hh-bg: #1B1612;
  --hh-bg-alt: #221B16;
  --hh-surface: #2A221B;
  --hh-surface-2: #332920;
  --hh-ink: #F5EDE3;
  --hh-ink-soft: #D7C6B2;
  --hh-ink-mute: #A08872;
  --hh-line: #3E3229;
  --hh-line-soft: #2F251E;
  --hh-accent-tint: #3A2418;
  --hh-accent-soft: #5E3624;
  --hh-shadow: 0 2px 10px rgba(0,0,0,0.35);
  --hh-shadow-lg: 0 10px 30px rgba(0,0,0,0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overscroll-behavior: none;
  background: #E8DDCC;
  font-family: var(--hh-sans);
  color: var(--hh-ink);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01","cv11";
}

/* Typography helpers */
.hh-serif { font-family: var(--hh-font); letter-spacing: -0.01em; }
.hh-mono { font-family: var(--hh-mono); }

/* Scrollbars hidden globally */
*::-webkit-scrollbar { display: none; width: 0; height: 0; }
* { scrollbar-width: none; -ms-overflow-style: none; }

.hh-scroll::-webkit-scrollbar { display: none; }
.hh-scroll { scrollbar-width: none; }

/* Ensure vertical scroll areas clear the fixed tab bar */
.hh-screen[data-tabbar="true"] .hh-scroll:not(.hh-hscroll) {
  padding-bottom: calc(var(--hh-tabbar-h) + env(safe-area-inset-bottom)) !important;
}

/* iOS safe-area: push content below the translucent status bar */
.hh-screen {
  padding-top: env(safe-area-inset-top);
}
/* Map screen: the map must fill the safe area (extend behind status bar),
   so compensate on the overlay controls instead */
.hh-screen .hh-map-topchrome-safe {
  padding-top: calc(14px + env(safe-area-inset-top));
}

/* Focus */
button, input, textarea, select { font-family: inherit; color: inherit; }
input, textarea, select { font-size: 16px !important; } /* prevent iOS zoom on focus */
button { cursor: pointer; border: none; background: none; padding: 0; }

/* Phone screen canvas */
.hh-screen {
  flex: 1; min-height: 0;
  background: var(--hh-bg);
  color: var(--hh-ink);
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
  height: 100%;
  width: 100%;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

/* Bottom tab bar (shared) */
.hh-tabbar {
  position: fixed;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  width: min(calc(100vw - 16px), calc(var(--hh-shell-width) + 48px));
  z-index: 10000;
  display: flex; align-items: flex-end; justify-content: center; gap: 10px;
  padding: 0 8px;
  background: none;
  pointer-events: none;
}

.hh-tabbar,
.hh-tabbar * {
  pointer-events: auto;
}

.hh-tabbar-main {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  min-height: 72px;
  padding: 10px 10px max(10px, env(safe-area-inset-bottom));
  background: color-mix(in oklab, var(--hh-surface) 90%, transparent);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
  border: 1px solid var(--hh-line-soft);
  border-radius: 24px;
  box-shadow: 0 18px 32px rgba(25, 18, 11, 0.16);
}

.hh-tabbar-bell {
  width: 54px;
  height: 54px;
  margin-bottom: 12px;
  border-radius: 18px;
  background: color-mix(in oklab, var(--hh-surface) 92%, transparent);
  border: 1px solid var(--hh-line-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 18px 32px rgba(25, 18, 11, 0.16);
}

[data-theme="dark"] .hh-tabbar-bell {
  background: color-mix(in oklab, var(--hh-surface) 96%, transparent);
}

.leaflet-container {
  z-index: 1;
}

.mapboxgl-map,
.mapboxgl-canvas {
  z-index: 1;
}
.hh-tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  color: var(--hh-ink-mute); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.02em;
  min-width: 0;
  padding: 6px 4px; border-radius: 16px;
  transition: color .15s ease, background .15s ease, transform .15s ease;
}
.hh-tab[data-active="true"] {
  color: var(--hh-accent);
  background: color-mix(in oklab, var(--hh-accent-tint) 84%, transparent);
}
.hh-tab svg { width: 22px; height: 22px; }

/* Card */
.hh-card {
  background: var(--hh-surface);
  border-radius: var(--hh-r-lg);
  box-shadow: var(--hh-shadow);
  border: 1px solid var(--hh-line-soft);
}

/* Buttons */
.hh-btn {
  height: 44px; padding: 0 18px; border-radius: 999px;
  background: var(--hh-ink); color: var(--hh-bg);
  font-weight: 600; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.hh-btn.ghost { background: transparent; color: var(--hh-ink); border: 1px solid var(--hh-line); }
.hh-btn.accent { background: var(--hh-accent); color: #fff; }
.hh-btn.tint { background: var(--hh-accent-tint); color: var(--hh-accent); }

/* Pill */
.hh-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; font-size: 12px;
  background: var(--hh-surface-2); color: var(--hh-ink-soft);
  border: 1px solid var(--hh-line-soft);
  font-weight: 500;
}

/* Section header */
.hh-section-h {
  font-family: var(--hh-font);
  font-size: 13px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--hh-ink-mute);
  padding: 16px 20px 8px;
}

/* Number / hero numerics */
.hh-numeric {
  font-family: var(--hh-font);
  font-weight: 400;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: -0.02em;
}

/* Toggle */
.hh-toggle {
  width: 44px; height: 26px; border-radius: 999px;
  background: var(--hh-line); position: relative;
  transition: background .2s ease;
}
.hh-toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.15);
  transition: transform .22s cubic-bezier(.4,1.3,.5,1);
}
.hh-toggle[data-on="true"] { background: var(--hh-accent); }
.hh-toggle[data-on="true"]::after { transform: translateX(18px); }

/* Placeholder stripe */
.hh-placeholder {
  background: repeating-linear-gradient(
    -45deg,
    var(--hh-surface-2) 0 10px,
    var(--hh-bg-alt) 10px 20px
  );
  color: var(--hh-ink-mute);
  font-family: var(--hh-mono);
  font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--hh-r-md);
  text-transform: uppercase; letter-spacing: 0.1em;
}

/* ── Login Screen ──────────────────────────────────────────────────────────── */

.hh-auth-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--hh-line);
  border-top-color: var(--hh-accent);
  border-radius: 50%;
  animation: hh-spin 0.8s linear infinite;
}
@keyframes hh-spin { to { transform: rotate(360deg); } }

.hh-login-screen {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 20px;
  background: radial-gradient(ellipse at 50% 0%, rgba(201,86,46,0.12) 0%, transparent 60%), var(--hh-bg);
}

.hh-login-card {
  width: 100%; max-width: 360px;
  background: var(--hh-surface);
  border: 1px solid var(--hh-line);
  border-radius: var(--hh-r-xl);
  padding: 40px 28px 36px;
  box-shadow: var(--hh-shadow-lg);
  text-align: center;
}

.hh-login-title {
  font-family: var(--hh-font);
  font-size: 32px; font-weight: 600;
  color: var(--hh-ink);
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}

.hh-login-sub {
  font-family: var(--hh-sans);
  font-size: 14px;
  color: var(--hh-ink-mute);
  margin: 0 0 28px;
}

.hh-user-picker {
  display: flex; gap: 10px; justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.hh-user-btn {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 14px 18px;
  background: var(--hh-bg);
  border: 1.5px solid var(--hh-line);
  border-radius: var(--hh-r-md);
  cursor: pointer;
  transition: all 0.18s;
  font-family: var(--hh-sans);
}
.hh-user-btn:hover { background: var(--hh-bg-alt, #EDE1D1); transform: translateY(-2px); box-shadow: var(--hh-shadow); }
.hh-user-btn.active {
  background: var(--hh-accent-tint);
  border-color: var(--hh-accent);
  box-shadow: 0 0 0 3px var(--hh-accent-soft);
}

.hh-user-avatar-wrap {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--hh-line-soft, #EFE4D4);
  overflow: hidden;
}

.hh-user-name {
  font-size: 12px; font-weight: 500;
  color: var(--hh-ink-soft);
  text-transform: capitalize;
}

.hh-pin-section {
  animation: hh-fade-up 0.25s ease;
}
@keyframes hh-fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.hh-pin-dots {
  display: flex; gap: 14px; justify-content: center;
  margin-bottom: 20px;
}

.hh-pin-dot {
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid var(--hh-line);
  transition: all 0.18s;
}
.hh-pin-dot.filled {
  background: var(--hh-accent);
  border-color: var(--hh-accent);
  box-shadow: 0 0 8px var(--hh-accent-soft);
}

.hh-pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  max-width: 280px; margin: 0 auto;
}

.hh-pin-key {
  padding: 16px 10px;
  font-family: var(--hh-sans);
  font-size: 22px; font-weight: 600;
  color: var(--hh-ink);
  background: var(--hh-bg);
  border: 1.5px solid var(--hh-line);
  border-radius: var(--hh-r-md);
  cursor: pointer;
  transition: all 0.12s;
  min-height: 64px;
}
.hh-pin-key:hover:not(:disabled) { background: var(--hh-line-soft, #EFE4D4); }
.hh-pin-key:active:not(:disabled) { transform: scale(0.94); background: var(--hh-accent-tint); border-color: var(--hh-accent); }
.hh-pin-key.invisible { visibility: hidden; }
.hh-pin-key:disabled { opacity: 0.5; cursor: default; }

.hh-pin-error {
  font-family: var(--hh-sans);
  font-size: 13px;
  color: var(--hh-bad);
  margin-top: 14px;
}

/* Device canvas surrounding */
.hh-stage {
  --hh-shell-width: 430px;
  --hh-tabbar-h: 86px;
  min-height: var(--hh-app-height, 100dvh); width: 100%;
  padding: 0;
  display: flex; flex-direction: column; gap: 30px;
  align-items: center;
  background: linear-gradient(180deg, #E8DDCC 0%, #DFD1BB 100%);
}

.hh-app-shell {
  /* Phone: constrained width */
  width: min(100%, var(--hh-shell-width));
  min-height: var(--hh-app-height, 100dvh);
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

/* Tablet / desktop: shell grows to fill width, side-by-side may come later */
@media (min-width: 700px) {
  .hh-stage {
    --hh-shell-width: 100vw;
    background: linear-gradient(180deg, #E8DDCC 0%, #DFD1BB 100%);
  }
  .hh-app-shell {
    width: 100%;
    max-width: none;
  }
}

.hh-app-shell .hh-screen {
  min-height: var(--hh-app-height, 100dvh);
  max-width: none;
  width: 100%;
}

/* Mapbox markers must sit above the canvas (which has z-index: 1) */
.mapboxgl-marker { z-index: 2 !important; }

.hh-map-pin-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hh-map-pin {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 2px solid #fff;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--hh-font);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
}

.hh-map-pin-tail {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #fff;
  margin-top: -1px;
}

[data-theme="dark"] .hh-stage {
  background: linear-gradient(180deg, #141010 0%, #0D0A08 100%);
}

/* Icon sets via mask — handled inline in JSX for flexibility */

/* Scroll snap for horizontal carousels */
.hh-hscroll {
  display: flex; gap: 10px; overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 4px 20px 6px;
}
.hh-hscroll > * { scroll-snap-align: start; flex-shrink: 0; }

/* Tweaks panel */
.hh-tweaks {
  position: fixed; bottom: 20px; right: 20px;
  width: 320px; max-height: 80vh; overflow: auto;
  background: #FFFBF4; color: #2A211A;
  border: 1px solid #E4D5C2; border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  z-index: 9999;
  font-family: var(--hh-sans);
}
.hh-tweaks header {
  padding: 14px 16px; border-bottom: 1px solid #E4D5C2;
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--hh-font); font-size: 16px;
}
.hh-tweaks section { padding: 12px 16px; border-bottom: 1px solid #EFE4D4; }
.hh-tweaks h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: #8B7763; font-weight: 600; }
.hh-tweaks .row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
.hh-tweaks .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hh-tweaks .chip {
  padding: 6px 10px; border-radius: 999px; font-size: 12px;
  background: #FAF3E7; border: 1px solid #E4D5C2; color: #5C4A3C;
}
.hh-tweaks .chip[data-on="true"] { background: #2A211A; color: #F5EDE3; border-color: #2A211A; }
.hh-tweaks .swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #E4D5C2; }
.hh-tweaks .swatch[data-on="true"] { box-shadow: 0 0 0 2px #2A211A; }

/* Ripple / press */
.press { transition: transform .12s ease, background .15s ease; }
.press:active { transform: scale(0.97); }

/* Toast slide-in animation */
@keyframes hh-toast-in {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}
