/* ============================================================
   SmartPark — base & primitive component styles
   Maps Pro · Google base + vivid Linear-style accents
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-size: 16px; }

body {
  font-family: var(--font-sans);
  font-size: var(--t-base);
  line-height: var(--lh-base);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01" on, "ss02" on, "cv11" on;
  transition: background var(--d-base) var(--ease-out), color var(--d-base) var(--ease-out);
}

button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* TYPE PRIMITIVES ------------------------------------------- */
.t-display   { font-family: var(--font-display); font-size: var(--t-display); line-height: var(--lh-tight); letter-spacing: var(--tr-tight); font-weight: 600; }
.t-h1        { font-size: var(--t-4xl); line-height: var(--lh-tight); letter-spacing: var(--tr-tight); font-weight: 600; }
.t-h2        { font-size: var(--t-3xl); line-height: var(--lh-tight); letter-spacing: var(--tr-snug); font-weight: 600; }
.t-h3        { font-size: var(--t-2xl); line-height: var(--lh-snug); letter-spacing: var(--tr-snug); font-weight: 600; }
.t-h4        { font-size: var(--t-xl); line-height: var(--lh-snug); letter-spacing: var(--tr-snug); font-weight: 600; }
.t-h5        { font-size: var(--t-lg); line-height: var(--lh-snug); font-weight: 600; }
.t-body      { font-size: var(--t-base); line-height: var(--lh-base); }
.t-body-lg   { font-size: var(--t-md); line-height: var(--lh-base); }
.t-caption   { font-size: var(--t-sm); line-height: var(--lh-snug); color: var(--ink-3); }
.t-micro     { font-size: var(--t-xs); line-height: var(--lh-snug); color: var(--ink-3); }
.t-mono      { font-family: var(--font-mono); font-feature-settings: "tnum" on, "zero" on, "ss01" on; }
.t-mono-label{
  font-family: var(--font-mono); font-size: var(--t-xs);
  letter-spacing: var(--tr-mono-label); text-transform: uppercase;
  color: var(--ink-3); font-weight: 500;
}

/* LINK ------------------------------------------------------ */
.lnk {
  color: var(--primary); cursor: pointer; transition: opacity var(--d-fast);
}
.lnk:hover { opacity: 0.7; }

/* BUTTONS --------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s-3);
  height: var(--control-h);
  padding: 0 var(--s-5);
  border-radius: var(--r-2);
  border: 1px solid transparent;
  font-size: var(--t-base);
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background var(--d-fast) var(--ease-out),
              border-color var(--d-fast) var(--ease-out),
              color var(--d-fast) var(--ease-out),
              transform var(--d-fast) var(--ease-out),
              box-shadow var(--d-fast) var(--ease-out);
  user-select: none; white-space: nowrap;
}
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-primary {
  background: var(--primary); color: var(--primary-ink);
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-accent {
  background: var(--ink); color: var(--bg);
  border-color: var(--ink);
}
.btn-accent:hover { background: var(--ink-2); border-color: var(--ink-2); }

.btn-secondary {
  background: var(--surface); color: var(--ink);
  border-color: var(--rule-strong);
}
.btn-secondary:hover { background: var(--surface-sunken); border-color: var(--rule-strong); }

.btn-ghost {
  background: transparent; color: var(--ink-2);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-sunken); color: var(--ink); }

.btn-danger {
  background: var(--danger); color: white; border-color: var(--danger);
}
.btn-danger:hover { filter: brightness(0.92); }

.btn-sm { height: calc(var(--control-h) * 0.8); padding: 0 var(--s-4); font-size: var(--t-sm); border-radius: var(--r-1); }
.btn-lg { height: calc(var(--control-h) * 1.2); padding: 0 var(--s-7); font-size: var(--t-md); border-radius: var(--r-2); }
.btn-icon { width: var(--control-h); padding: 0; }
.btn-block { width: 100%; }

/* INPUT ----------------------------------------------------- */
.input {
  display: flex; align-items: center;
  gap: var(--s-3);
  width: 100%;
  height: var(--control-h);
  padding: 0 var(--s-4);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-2);
  color: var(--ink);
  font-size: var(--t-base);
  transition: border-color var(--d-fast), box-shadow var(--d-fast);
}
.input::placeholder { color: var(--ink-4); }
.input:focus, .input:focus-within {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea.input { height: auto; padding: var(--s-3) var(--s-4); line-height: var(--lh-base); resize: vertical; min-height: 80px; }

.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field-label {
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--ink-2);
}
.field-hint { font-size: var(--t-sm); color: var(--ink-3); }
.field-error { font-size: var(--t-sm); color: var(--danger); }

/* CHIP / TAG / BADGE --------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: calc(32px * var(--density)); padding: 0 var(--s-5);
  background: var(--surface); border: 1px solid var(--rule-strong);
  border-radius: var(--r-pill);
  font-size: var(--t-sm); font-weight: 500;
  color: var(--ink-2);
  cursor: pointer; transition: all var(--d-fast);
}
.chip:hover { background: var(--surface-sunken); color: var(--ink); }
.chip[data-on="true"] {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}
.chip[data-on="true"]:hover { background: var(--ink-2); }

.tag {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 3px var(--s-3);
  background: var(--surface-sunken);
  border-radius: var(--r-1);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-2);
}
.tag[data-tone="success"] { background: var(--success-soft); color: var(--success); }
.tag[data-tone="danger"]  { background: var(--danger-soft);  color: var(--danger); }
.tag[data-tone="warning"] { background: var(--warning-soft); color: var(--warning); }
.tag[data-tone="primary"] { background: var(--primary-soft); color: var(--primary); }
.tag[data-tone="info"]    { background: var(--info-soft);    color: var(--info); }
.tag[data-tone="accent"]  { background: var(--accent-soft);  color: var(--accent); }

/* Status dot — small colored dot for inline badges */
.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 999px;
  background: var(--ink-3);
}
.dot[data-tone="success"] { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.dot[data-tone="warning"] { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.dot[data-tone="danger"]  { background: var(--danger);  box-shadow: 0 0 0 3px var(--danger-soft); }
.dot[data-tone="primary"] { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.dot.pulse { animation: dot-pulse 1.8s infinite ease-in-out; }
@keyframes dot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* CARD ------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: var(--pad-card);
}
.card-flat     { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-3); }
.card-elevated { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-3); box-shadow: var(--e-2); }
.card-floating { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-3); box-shadow: var(--e-3); }

/* DIVIDERS / RULES ----------------------------------------- */
.hr        { height: 1px; background: var(--rule); border: 0; margin: 0; }
.hr-strong { height: 1px; background: var(--rule-strong); border: 0; }

/* SECTION HEAD --------------------------------------------- */
.sec-head {
  display: flex; align-items: baseline; gap: var(--s-3);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--s-6);
}
.sec-head .num {
  font-family: var(--font-mono); font-size: var(--t-xs);
  letter-spacing: var(--tr-mono-label); text-transform: uppercase;
  color: var(--ink-3); font-weight: 500;
}
.sec-head .ttl {
  font-size: var(--t-md);
  font-weight: 600;
  letter-spacing: -0.005em;
}
.sec-head .ext { margin-left: auto; }

/* AVATAR ---------------------------------------------------- */
.avatar {
  width: calc(36px * var(--density)); height: calc(36px * var(--density));
  border-radius: var(--r-pill);
  background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: var(--t-sm);
  flex-shrink: 0;
}

/* SWITCH ---------------------------------------------------- */
.switch {
  --w: 36px; --h: 20px;
  position: relative; width: var(--w); height: var(--h);
  background: var(--rule-strong); border-radius: var(--r-pill);
  cursor: pointer; transition: background var(--d-fast);
  flex-shrink: 0;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: calc(var(--h) - 4px); height: calc(var(--h) - 4px);
  background: var(--surface); border-radius: var(--r-pill);
  box-shadow: var(--e-1);
  transition: transform var(--d-base) var(--ease-out);
}
.switch[data-on="true"] { background: var(--primary); }
.switch[data-on="true"]::after { transform: translateX(calc(var(--w) - var(--h))); }

/* SKELETON ------------------------------------------------- */
.skel {
  background: linear-gradient(90deg, var(--surface-sunken) 0%, var(--rule) 50%, var(--surface-sunken) 100%);
  background-size: 200% 100%; animation: skel 1.4s linear infinite;
  border-radius: var(--r-2);
}
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* SCROLLBAR ------------------------------------------------- */
.scroll, .scroll-y { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; }
.scroll::-webkit-scrollbar, .scroll-y::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll::-webkit-scrollbar-thumb, .scroll-y::-webkit-scrollbar-thumb { background: var(--rule-strong); border-radius: 999px; }
.scroll::-webkit-scrollbar-track { background: transparent; }

/* PLACEHOLDER IMAGE ----------------------------------------- */
.ph {
  position: relative; overflow: hidden;
  background: var(--surface-sunken);
  color: var(--ink-4);
  display: flex; align-items: center; justify-content: center;
}
.ph::before {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(135deg, transparent 49%, var(--rule) 49.5%, var(--rule) 50.5%, transparent 51%),
    linear-gradient(45deg, transparent 49%, var(--rule) 49.5%, var(--rule) 50.5%, transparent 51%);
  opacity: 0.4;
}
.ph-label {
  position: absolute; bottom: var(--s-3); left: var(--s-3); z-index: 1;
  font-family: var(--font-mono); font-size: var(--t-xs);
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ink-3);
  background: var(--surface);
  padding: 3px var(--s-3);
  border-radius: var(--r-1);
}

/* MAP MARKER ------------------------------------------------ */
.marker {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 30px; padding: 0 10px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-pill);
  font-family: var(--font-sans);
  font-size: var(--t-sm);
  font-weight: 600;
  box-shadow: var(--e-1);
  cursor: pointer;
  /* IMPORTANT: do NOT animate `transform` — Mapbox uses inline transforms on
     the marker wrapper for per-frame geo positioning. Transitioning transform
     here makes markers visibly lag (drift) during pan/zoom. */
  transition: background var(--d-fast),
              color var(--d-fast),
              border-color var(--d-fast),
              box-shadow var(--d-fast);
  position: relative;
}
.marker:hover { transform: translateY(-1px); border-color: var(--ink-3); }
.marker[data-active="true"] {
  z-index: 5;
  background: var(--primary);
  color: var(--primary-ink);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft), var(--e-2);
  transform: scale(1.08);
}
.marker[data-active="true"]:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.marker[data-active="true"]::after {
  content: ""; position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%);
  width: 8px; height: 8px; background: var(--primary); rotate: 45deg;
}

/* FOCUS ----------------------------------------------------- */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--r-1); }

/* KBD ------------------------------------------------------- */
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  font-family: var(--font-mono); font-size: var(--t-xs);
  background: var(--surface); border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-1); color: var(--ink-2);
}

/* MODAL ----------------------------------------------------- */
.backdrop {
  position: fixed; inset: 0; background: rgba(32, 33, 36, 0.45);
  backdrop-filter: blur(2px);
  z-index: 80;
  animation: fade 220ms var(--ease-out);
}
[data-theme="dark"] .backdrop { background: rgba(0, 0, 0, 0.6); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }

.modal {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  padding: var(--s-7);
  pointer-events: none;
}
.modal > * { pointer-events: auto; animation: rise 280ms var(--ease-out); }

/* TABS ------------------------------------------------------ */
.tabs {
  display: inline-flex; gap: var(--s-7);
  border-bottom: 1px solid var(--rule);
}
.tab {
  position: relative; padding: var(--s-4) 0;
  color: var(--ink-3); cursor: pointer; font-size: var(--t-base); font-weight: 500;
  transition: color var(--d-fast);
}
.tab:hover { color: var(--ink); }
.tab[data-on="true"] { color: var(--primary); }
.tab[data-on="true"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--primary); border-radius: 2px 2px 0 0;
}

/* UTILITY --------------------------------------------------- */
.row  { display: flex; align-items: center; }
.col  { display: flex; flex-direction: column; }
.gap-1 { gap: var(--s-1); } .gap-2 { gap: var(--s-2); } .gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); } .gap-5 { gap: var(--s-5); } .gap-6 { gap: var(--s-6); }
.gap-7 { gap: var(--s-7); } .gap-8 { gap: var(--s-8); }
.grow { flex: 1; }
.between { justify-content: space-between; }
.center { justify-content: center; }
.end { justify-content: flex-end; }
.baseline { align-items: baseline; }
.start { align-items: flex-start; }
.muted { color: var(--ink-3); }
.muted-2 { color: var(--ink-4); }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }

.balance { text-wrap: balance; }
.pretty { text-wrap: pretty; }
