/* ============================================================
   Foodmapme — Layout & larger components
   navbar · hero · map · modal · footer · tweaks
   ============================================================ */

/* ---- Brand mark ---- */
.brand { display: inline-flex; align-items: center; gap: 0.6em; font-weight: var(--fw-bold);
  font-size: 1.18rem; letter-spacing: -0.02em; }
.brand__pin { width: 30px; height: 30px; flex: none; display: grid; place-items: center;
  border-radius: 10px 10px 10px 3px; transform: rotate(-45deg);
  background: var(--brand); color: var(--on-brand);
  box-shadow: 0 4px 10px -3px color-mix(in oklab, var(--brand) 80%, transparent); }
.brand__pin span { transform: rotate(45deg); font-size: 1rem; }
.brand b { color: var(--brand-strong); }

/* ============================================================
   NAVBAR
   ============================================================ */
.nav {
  position: sticky; top: 0; z-index: 50; height: var(--header-h);
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(140%); backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.nav__inner { height: 100%; display: flex; align-items: center; gap: var(--sp-5); }
.nav__links { display: flex; align-items: center; gap: 0.3rem; }
.nav__links a { padding: 0.5em 0.85em; border-radius: var(--r-pill); font-size: var(--fs-sm);
  font-weight: var(--fw-medium); color: var(--ink-2); transition: all .16s var(--ease); }
.nav__links a:hover { background: var(--surface-2); color: var(--ink); }
.nav__links a.is-active { color: var(--brand-strong); background: var(--brand-soft); }
.nav__spacer { flex: 1; }
.nav__actions { display: flex; align-items: center; gap: var(--sp-3); }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%;
  background: transparent; border: 1px solid transparent; color: var(--ink-2); cursor: pointer;
  transition: all .16s var(--ease); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.nav__burger { display: none; }

/* theme toggle knob */
.theme-toggle { position: relative; }
.theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: block; }

/* burger always shown for logged-in users (sidebar nav) */
.nav__burger { display: grid; }

/* ---- sidebar (slide-in nav) ---- */
.sidebar-scrim { position: fixed; inset: 0; z-index: 60;
  background: color-mix(in oklab, var(--ink) 45%, transparent);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .22s var(--ease); }
.sidebar-scrim.is-open { opacity: 1; pointer-events: auto; }

.sidebar { position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
  width: min(320px, 86vw); display: flex; flex-direction: column;
  background: var(--bg); border-left: 1px solid var(--border); box-shadow: var(--shadow-xl);
  transform: translateX(100%); transition: transform .26s var(--ease); }
.sidebar.is-open { transform: none; }

.sidebar__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4) var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.sidebar__user { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.sidebar__user .avatar { font-size: 1.05rem; }
.sidebar__user-meta { display: flex; flex-direction: column; min-width: 0; }
.sidebar__user-meta strong { font-size: var(--fs-md); line-height: 1.25; }
.sidebar__user-meta span { font-size: var(--fs-sm); color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: var(--sp-3); display: flex; flex-direction: column; gap: 2px; }
.sidebar__nav a { display: flex; align-items: center; gap: var(--sp-3);
  padding: 0.7em 0.85em; border-radius: var(--r-md); font-size: var(--fs-md);
  font-weight: var(--fw-medium); color: var(--ink-2); transition: all .15s var(--ease); }
.sidebar__nav a svg { width: 20px; height: 20px; flex: none; color: var(--ink-3); }
.sidebar__nav a:hover { background: var(--surface-2); color: var(--ink); }
.sidebar__nav a.is-active { background: var(--brand-soft); color: var(--brand-strong); }
.sidebar__nav a.is-active svg { color: var(--brand-strong); }
/* หัวข้อคั่นกลุ่มเมนู */
.sidebar__group { font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--ink-3);
  letter-spacing: .03em; padding: 0.95em 0.85em 0.3em; }
.sidebar__group:first-child { padding-top: 0.2em; }

.sidebar__foot { padding: var(--sp-4); border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: var(--sp-2); }

/* ============================================================
   HERO
   ============================================================ */
.hero { position: relative; padding-block: clamp(2.5rem, 6vw, 5rem) clamp(3rem, 7vw, 5.5rem); overflow: hidden; }
.hero__glow { position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 55% at 78% 12%, color-mix(in oklab, var(--brand) 22%, transparent), transparent 70%),
    radial-gradient(50% 50% at 8% 92%, color-mix(in oklab, var(--brand) 12%, transparent), transparent 70%); }
.hero__grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: clamp(2rem, 5vw, 4rem); align-items: center; }
.hero h1 { font-size: var(--fs-display); margin-block: var(--sp-4) var(--sp-4); }
.hero h1 .hl { color: var(--brand-strong); position: relative; white-space: nowrap; }
.hero__lead { font-size: var(--fs-lg); color: var(--ink-2); max-width: 34ch; }
.hero__cta { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-6); }
.hero__proof { display: flex; align-items: center; gap: var(--sp-4); margin-top: var(--sp-6); color: var(--ink-3); font-size: var(--fs-sm); }
.hero__avatars { display: flex; }
.hero__avatars .avatar { width: 34px; height: 34px; border: 2px solid var(--bg); margin-left: -10px; }
.hero__avatars .avatar:first-child { margin-left: 0; }

/* hero collage */
.hero__art { position: relative; }
.hero__art .photo { border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-lg);
  border: 1px solid var(--border); aspect-ratio: 4/5; }
.hero__art .photo.p2 { position: absolute; width: 52%; aspect-ratio: 1; right: -6%; bottom: -8%;
  border: 4px solid var(--bg); border-radius: var(--r-lg); }
.hero__pin-tag { position: absolute; top: 8%; left: -7%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-md); padding: 0.6em 0.9em; display: flex; align-items: center;
  gap: 0.55em; font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.hero__pin-tag .ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--success-soft); color: var(--success); }
.hero__pin-tag .ic svg { width: 17px; height: 17px; }

/* ============================================================
   MAP VIEW
   ============================================================ */
.map { position: relative; border-radius: var(--r-xl); overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow-md); aspect-ratio: 16/10;
  min-height: 360px; background: var(--surface-2); }
/* faux realistic map drawn with CSS — swap for Mapbox/Google tiles in production */
.map__tiles { position: absolute; inset: 0;
  background-color: #e9e5dc;
  background-image:
    linear-gradient(0deg, rgba(120,170,140,.18) 0 100%),
    repeating-linear-gradient(0deg, transparent 0 78px, rgba(0,0,0,.04) 78px 80px),
    repeating-linear-gradient(90deg, transparent 0 96px, rgba(0,0,0,.04) 96px 98px); }
.map__tiles::before { content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(118deg, transparent 0 46%, #f7f4ee 46% 49.5%, #d9cfbf 49.5% 50%, transparent 50%),
    linear-gradient(28deg, transparent 0 62%, #f7f4ee 62% 65%, #d9cfbf 65% 65.4%, transparent 66%),
    radial-gradient(40% 30% at 76% 74%, rgba(120,175,210,.5), rgba(120,175,210,.5) 60%, transparent 62%); }
.map__tiles::after { content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(90deg, transparent 0 18%, #f3efe7 18% 20.5%, transparent 21%),
    linear-gradient(0deg, transparent 0 30%, #f3efe7 30% 32%, transparent 33%);
  opacity: .9; }
[data-theme="dark"] .map__tiles { background-color: #20242b;
  background-image:
    linear-gradient(0deg, rgba(60,90,75,.25) 0 100%),
    repeating-linear-gradient(0deg, transparent 0 78px, rgba(255,255,255,.03) 78px 80px),
    repeating-linear-gradient(90deg, transparent 0 96px, rgba(255,255,255,.03) 96px 98px); }
[data-theme="dark"] .map__tiles::before {
  background:
    linear-gradient(118deg, transparent 0 46%, #2c323b 46% 49.5%, #11151a 49.5% 50%, transparent 50%),
    linear-gradient(28deg, transparent 0 62%, #2c323b 62% 65%, #11151a 65% 65.4%, transparent 66%),
    radial-gradient(40% 30% at 76% 74%, rgba(60,100,130,.5), rgba(60,100,130,.5) 60%, transparent 62%); }
[data-theme="dark"] .map__tiles::after {
  background:
    linear-gradient(90deg, transparent 0 18%, #262c34 18% 20.5%, transparent 21%),
    linear-gradient(0deg, transparent 0 30%, #262c34 30% 32%, transparent 33%); }

/* map pins — circle head + pointed tail */
.pin { position: absolute; transform: translate(-50%, -100%); cursor: pointer; z-index: 2;
  border: none; background: none; padding: 0; -webkit-appearance: none; appearance: none;
  transition: transform .18s var(--ease); }
.pin:hover, .pin.is-active { transform: translate(-50%, -100%) scale(1.12); z-index: 5; }
.pin__body { position: relative; width: 38px; height: 38px; border-radius: 50%;
  background: var(--brand); color: var(--on-brand); display: grid; place-items: center;
  border: 3px solid var(--surface); box-shadow: 0 4px 8px rgba(0,0,0,.22); }
.pin__body::after { content: ""; position: absolute; z-index: -1; width: 14px; height: 14px;
  bottom: -3px; left: 50%; transform: translateX(-50%) rotate(45deg);
  background: var(--brand); border-radius: 0 0 3px 0; }
.pin__body svg { width: 18px; height: 18px; }
.pin.is-checkedin .pin__body { background: var(--success); color: var(--on-success); }
.pin.is-checkedin .pin__body::after { background: var(--success); }
.pin.is-want .pin__body { background: var(--surface); color: var(--brand); }
.pin.is-want .pin__body::after { background: var(--surface); }

/* z-index 1000+ so these float above Leaflet's internal panes (tiles 200 · markers 600 · popups 700) */
.map__panel { position: absolute; left: 16px; top: 16px; z-index: 1000; width: min(290px, 70%);
  background: color-mix(in oklab, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: var(--sp-4); }
.map__zoom { position: absolute; right: 16px; bottom: 16px; z-index: 1000; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-md); }
.map__zoom button { width: 40px; height: 40px; background: none; border: none; cursor: pointer; color: var(--ink-2); display:grid; place-items:center; }
.map__zoom button:hover { background: var(--surface-2); color: var(--ink); }
.map__zoom button + button { border-top: 1px solid var(--border); }
.map__note { position: absolute; right: 16px; top: 16px; z-index: 1000; font-family: var(--font-mono);
  font-size: 0.66rem; color: var(--ink-2); background: color-mix(in oklab, var(--surface) 85%, transparent);
  border: 1px solid var(--border); border-radius: var(--r-pill); padding: 0.4em 0.8em; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-scrim { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  padding: var(--sp-4); background: color-mix(in oklab, var(--ink) 45%, transparent);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity .2s var(--ease); }
.modal-scrim.is-open { opacity: 1; pointer-events: auto; }
.modal { width: min(520px, 100%); max-height: 90vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl); transform: translateY(14px) scale(.98); transition: transform .25s var(--ease); }
.modal-scrim.is-open .modal { transform: none; }
.modal__head { display: flex; align-items: start; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-5) var(--sp-3); }
.modal__title { font-size: var(--fs-h3); }
.modal__sub { color: var(--ink-3); font-size: var(--fs-sm); margin-top: 0.2em; }
.modal__body { padding: var(--sp-3) var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); }
.modal__foot { padding: var(--sp-4) var(--sp-5) var(--sp-5); display: flex; gap: var(--sp-3); justify-content: flex-end;
  border-top: 1px solid var(--border); margin-top: var(--sp-2); }

/* check-in rating buttons */
.rate { display: flex; gap: var(--sp-2); }
.rate button { flex: 1; aspect-ratio: 1; border: 1px solid var(--border); background: var(--surface-2);
  border-radius: var(--r-md); font-size: 1.5rem; cursor: pointer; transition: all .15s var(--ease); }
.rate button:hover { border-color: var(--brand); transform: translateY(-2px); }
.rate button.is-sel { background: var(--brand-soft); border-color: var(--brand); }

.checkin-hero { position: relative; aspect-ratio: 16/8; border-radius: var(--r-lg); overflow: hidden; }
.checkin-hero .badge { position: absolute; left: 12px; bottom: 12px; }

/* segmented control (used in forms) */
.seg { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-pill); }
.seg button { border: none; background: none; cursor: pointer; padding: 0.5em 1em; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--ink-2); transition: all .15s var(--ease); }
.seg button.is-sel { background: var(--surface); color: var(--brand-strong); box-shadow: var(--shadow-sm); }

/* ============================================================
   FOOTER
   ============================================================ */
.footer { background: var(--bg-tint); border-top: 1px solid var(--border); margin-top: var(--sp-9); }
.footer__grid { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: var(--sp-6);
  padding-block: clamp(2.5rem, 6vw, 4rem); }
.footer__about { max-width: 30ch; color: var(--ink-3); font-size: var(--fs-sm); margin-top: var(--sp-3); }
.footer__newsletter { display: flex; gap: var(--sp-2); margin-top: var(--sp-4); max-width: 320px; }
.footer h4 { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3);
  margin-bottom: var(--sp-3); font-weight: var(--fw-semibold); }
.footer__col ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.footer__col a { color: var(--ink-2); font-size: var(--fs-sm); }
.footer__col a:hover { color: var(--brand-strong); }
.footer__bar { border-top: 1px solid var(--border); padding-block: var(--sp-4); display: flex;
  align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap;
  color: var(--ink-3); font-size: var(--fs-sm); }
.footer__social { display: flex; gap: var(--sp-2); }

/* ============================================================
   TWEAKS PANEL (settings — accent / theme / radius)
   ============================================================ */
#tweaks { position: fixed; right: 16px; bottom: 16px; z-index: 2147483646; width: 260px;
  background: color-mix(in oklab, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(150%); backdrop-filter: blur(20px) saturate(150%);
  color: var(--ink); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-xl); font-size: 12px; overflow: hidden; display: none; }
#tweaks.is-open { display: block; }
#tweaks .tw-hd { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 12px 16px; }
#tweaks .tw-hd b { font-size: 13px; }
#tweaks .tw-x { width: 24px; height: 24px; border: none; background: none; color: var(--ink-3); cursor: pointer;
  border-radius: 6px; font-size: 15px; }
#tweaks .tw-x:hover { background: var(--surface-2); color: var(--ink); }
#tweaks .tw-body { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
#tweaks .tw-sect { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); }
#tweaks .tw-row { display: flex; flex-direction: column; gap: 7px; }
#tweaks .tw-row > span { font-weight: 600; color: var(--ink-2); }
.tw-swatches { display: flex; gap: 8px; }
.tw-sw { flex: 1; height: 34px; border-radius: 9px; border: 2px solid var(--border); cursor: pointer;
  position: relative; transition: transform .12s var(--ease); }
.tw-sw:hover { transform: translateY(-2px); }
.tw-sw.is-sel { border-color: var(--ink); }
.tw-seg2 { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: var(--r-pill); border: 1px solid var(--border); }
.tw-seg2 button { flex: 1; border: none; background: none; cursor: pointer; padding: 6px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; color: var(--ink-2); }
.tw-seg2 button.is-sel { background: var(--surface); color: var(--brand-strong); box-shadow: var(--shadow-sm); }

/* floating button to open the tweaks/settings panel */
.tweaks-fab { position: fixed; right: 16px; bottom: 16px; z-index: 2147483645;
  width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); cursor: pointer; transition: transform .14s var(--ease), color .14s var(--ease); }
.tweaks-fab:hover { transform: translateY(-2px) rotate(40deg); color: var(--brand); }
.tweaks-fab svg { width: 22px; height: 22px; }

/* ============================================================
   PAGE GRIDS (from landing assembly)
   ============================================================ */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: var(--sp-5); }
.profile-grid { display: grid; grid-template-columns: 320px 1fr; gap: var(--sp-5); align-items: start; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); }

/* ============================================================
   LEAFLET — real map tiles + custom HTML markers styled as .pin
   ============================================================ */
.map .leaflet-container { position: absolute; inset: 0; width: 100%; height: 100%;
  background: var(--surface-2); font: inherit; }
/* dim the OSM raster a touch in dark mode so pins/panel stay readable */
[data-theme="dark"] .map .leaflet-tile-pane { filter: brightness(.7) saturate(.85) hue-rotate(8deg); }
/* custom divIcon markers: head + tail, variant-colored */
.fm-pin .pin__body { position: relative; width: 38px; height: 38px; border-radius: 50%;
  background: var(--brand); color: var(--on-brand); display: grid; place-items: center;
  border: 3px solid var(--surface); box-shadow: 0 4px 8px rgba(0,0,0,.22); }
.fm-pin .pin__body::after { content: ""; position: absolute; z-index: -1; width: 14px; height: 14px;
  bottom: -3px; left: 50%; transform: translateX(-50%) rotate(45deg);
  background: var(--brand); border-radius: 0 0 3px 0; }
.fm-pin .pin__body svg { width: 18px; height: 18px; }
.fm-pin.is-checkedin .pin__body { background: var(--success); color: var(--on-success); }
.fm-pin.is-checkedin .pin__body::after { background: var(--success); }
.fm-pin.is-want .pin__body { background: var(--surface); color: var(--brand); }
.fm-pin.is-want .pin__body::after { background: var(--surface); }
.fm-pin { transition: transform .18s var(--ease); }
.fm-pin.is-active { z-index: 600 !important; }
.fm-pin.is-active .pin__body { transform: scale(1.12); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 920px) {
  .hero__grid { grid-template-columns: 1fr; }
  .hero__art { display: none; }
  .footer__grid { grid-template-columns: 1fr 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .footer__grid { grid-template-columns: 1fr; gap: var(--sp-5); }
}
@media (max-width: 768px) {
  /* ซ่อน nav links และปุ่ม CTA ใน nav บนมือถือ — ใช้ sidebar แทน */
  .nav__links { display: none; }
  .nav__hide-mobile { display: none !important; }
  .nav__burger { display: grid !important; }
}
