/* ============================================================
   Type One Run — Member Map
   Stays visually consistent with BCF (dark surfaces, cyan accent).
============================================================ */

:root {
  --bg:           #0a0e14;
  --surface:      #11161f;
  --surface-2:    #1a212c;
  --border:       #25303f;
  --text:         #e8edf4;
  --text-muted:   #9aa6b7;
  --text-dim:     #6b7689;
  --accent:       #1ccdfe;
  --accent-soft:  rgba(28,205,254,0.14);
  --accent-glow:  rgba(28,205,254,0.32);
  --warning:      #ffd23c;
  --error:        #ff6b6b;
  --radius:       12px;
  --radius-sm:    8px;
  --mono:         'DM Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans:         'DM Sans', system-ui, -apple-system, Segoe UI, sans-serif;
  --display:      'Syne', var(--sans);
}

* { box-sizing: border-box; }

/* HTML5 `hidden` attribute must beat any later class rule that sets display. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.15; margin: 0 0 12px; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

p { line-height: 1.55; margin: 0 0 12px; }

.eyebrow {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 8px;
}

/* ---------- Map fill layout (public + admin) ------------- */

body.map-app {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#map {
  flex: 1;
  width: 100%;
  background: #0a0e14;
}

/* Floating header — used only on standalone, hidden when iframed */
.map-header {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: rgba(10, 14, 20, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.map-header .logo-mark {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ---------- Top-right control stack ---------------------- */
/* Holds: "+ Add your location" (signed-out) OR identity cluster
   (signed-in) OR admin copy button (admin). Stacked vertically. */
.map-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 700;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

/* Prominent "Add your location" — visible when signed out (or in embed) */
.map-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 999px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 18px rgba(28, 205, 254, 0.35);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.map-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(28, 205, 254, 0.55);
  text-decoration: none;
}
.map-action .plus { font-size: 16px; line-height: 0; }

/* Identity cluster: "Signed in as X" + edit + sign out, when signed in */
.map-identity {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 14px;
  background: rgba(10, 14, 20, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  max-width: calc(100vw - 28px);
}
.map-identity .me { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.map-identity .me strong { color: var(--text); font-weight: 500; }

.btn-mini {
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.btn-mini:hover { text-decoration: none; opacity: 0.9; }
.btn-mini.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-mini.ghost:hover { color: var(--accent); border-color: var(--accent); opacity: 1; }

/* Admin "Copy emails in view" — bottom-left, above stats. Lives outside
   the top-right control stack so it never crowds the identity pill on
   mobile and so admin actions sit visually grouped with stats.
   Explicit width:auto + right:auto so no inherited rule can stretch it. */
.map-admin-action {
  position: absolute;
  bottom: 62px;
  left: 18px;
  right: auto;
  width: auto;
  z-index: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(10, 14, 20, 0.85);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.map-admin-action:hover { background: var(--accent-soft); }
.map-admin-action:disabled { opacity: 0.5; cursor: not-allowed; }
.map-admin-action .count {
  padding: 2px 8px;
  background: var(--accent-soft);
  border-radius: 999px;
  font-size: 11px;
  color: var(--accent);
}

/* In embedded mode: only the "Add your location" action is visible.
   Identity + admin live on the standalone subdomain. */
body.embedded .map-identity,
body.embedded .map-admin-action { display: none; }

/* In embedded mode the search bar moves from top-center to top-left
   (no brand to fight with) and sits beside the "+ Add your location"
   button which stays in the top-right cluster. */
body.embedded .admin-search {
  left: 14px;
  right: auto;
  transform: none;
  width: auto;
  max-width: calc(100% - 220px);   /* room for the add-location button */
  min-width: 200px;
}

/* In embed at very narrow widths the side-by-side breaks down; stack:
   search drops below the add-action button. */
@media (max-width: 640px) {
  body.embedded .admin-search {
    top: 60px;
    left: 8px;
    right: 8px;
    max-width: none;
  }
}

/* Stats strip on public map (lower-left) */
.map-stats {
  position: absolute;
  bottom: 18px;
  left: 18px;
  z-index: 600;
  display: flex;
  gap: 16px;
  padding: 10px 14px;
  background: rgba(10, 14, 20, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}
.map-stats strong { color: var(--text); font-weight: 500; }

/* Hide chrome when iframed (parent controls layout) */
body.embedded .map-header,
body.embedded .map-stats { display: none; }

/* ---------- Page layout (submit + admin pages) ----------- */

.page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.page-header .brand {
  font-family: var(--display);
  font-weight: 700;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.page-header .brand .logo-mark {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent-glow);
}
.page-header nav a {
  margin-left: 18px;
  color: var(--text-muted);
  font-size: 13px;
}
.page-header nav a:hover { color: var(--text); text-decoration: none; }

.page-main {
  flex: 1;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 24px;
}

.page-main.wide { max-width: 1200px; }

/* ---------- Form controls -------------------------------- */

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.input, .select {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 15px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.help {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 999px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 18px var(--accent-glow); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.callout {
  margin: 18px 0;
  padding: 14px 16px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}
.callout.error {
  background: rgba(255,107,107,0.10);
  border-color: var(--error);
}
.callout.success {
  background: rgba(28,205,254,0.12);
  border-color: var(--accent);
}

/* ---------- Leaflet overrides ---------------------------- */

.leaflet-container {
  background: #0a0e14;
  font-family: var(--sans);
}

.leaflet-control-attribution {
  background: rgba(10, 14, 20, 0.75) !important;
  color: var(--text-dim) !important;
  font-size: 10px !important;
  border-top: 1px solid var(--border);
  padding: 2px 6px !important;
}
.leaflet-control-attribution a {
  color: var(--text-muted) !important;
}

.leaflet-control-zoom {
  border: 1px solid var(--border) !important;
  background: var(--surface) !important;
  box-shadow: none !important;
}
.leaflet-control-zoom a {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-bottom: 1px solid var(--border) !important;
  width: 32px !important; height: 32px !important;
  line-height: 32px !important;
}
.leaflet-control-zoom a:hover {
  background: var(--surface-2) !important;
  color: var(--accent) !important;
}

/* Tooltip on hover */
.leaflet-tooltip.bcf-tip {
  background: rgba(10, 14, 20, 0.92);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--sans);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  white-space: nowrap;
}
.leaflet-tooltip.bcf-tip strong {
  display: block;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
  font-weight: 500;
}
.leaflet-tooltip.bcf-tip:before { display: none; }

/* Tier-sized pins (circle markers) — built in JS */
.bcf-pin {
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid rgba(255,255,255,0.6);
  box-shadow: 0 0 0 2px rgba(10,14,20,0.8), 0 0 12px rgba(28,205,254,0.5);
}

/* Cluster overrides */
.marker-cluster-bcf {
  background: rgba(28,205,254,0.25);
  border: 1px solid var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-family: var(--mono);
  font-weight: 500;
  font-size: 12px;
  box-shadow: 0 0 16px rgba(28,205,254,0.35);
}
.marker-cluster-bcf div {
  background: rgba(28,205,254,0.45);
  border-radius: 50%;
  width: 70%; height: 70%;
  display: flex; align-items: center; justify-content: center;
}

/* Loading / empty states for the map */
.map-overlay {
  position: absolute;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10,14,20,0.75);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 13px;
  pointer-events: none;
}

/* ---------- Admin floating controls ---------------------- */

.admin-search {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 700;
  display: flex;
  gap: 6px;
  width: min(440px, calc(100% - 28px));
  padding: 6px;
  background: rgba(10, 14, 20, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
}
.admin-search input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  padding: 8px 10px;
  outline: none;
}
.admin-search input::placeholder { color: var(--text-dim); }
.admin-search button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.admin-search button:disabled { opacity: 0.5; cursor: not-allowed; }
.admin-search .hits {
  position: absolute;
  top: calc(100% + 6px); left: 0; right: 0;
  background: rgba(10, 14, 20, 0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 240px; overflow-y: auto;
  padding: 4px;
}
.admin-search .hit {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
}
.admin-search .hit:hover { background: var(--surface-2); color: var(--text); }
.admin-search .hits:empty { display: none; }   /* no empty pill when no results */

/* (old .admin-copy-fab and .admin-identity removed — replaced by
   .map-action / .map-identity / .map-admin-action in the top-right stack) */

/* Admin toast (copy confirmation) — sits above primary FAB + admin button */
.admin-toast {
  position: absolute;
  bottom: 134px;
  right: 18px;
  z-index: 700;
  max-width: 320px;
  padding: 10px 14px;
  background: rgba(10,14,20,0.95);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}
.admin-toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.admin-toast.error { border-color: var(--error); }


/* Email preview modal (shown after copy) */
.email-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.65);
  padding: 24px;
}
.email-modal.open { display: flex; }
.email-modal .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.email-modal .panel-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.email-modal .panel-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}
.email-modal textarea {
  width: 100%;
  min-height: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  border-radius: var(--radius-sm);
  padding: 10px;
  resize: vertical;
}
.email-modal .panel-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* Medium widths (tablets, narrow laptops, narrow desktop browsers).
   The brand + identity-pill no longer leave 440px clear in the middle
   for the search bar, so we drop the search to a second row below them.
   Threshold sized for the worst case: brand (~220px) + identity pill
   with a longer email + Edit + Sign out (~480px) + padding + the 440px
   search. */
@media (max-width: 1100px) {
  body:not(.embedded) .admin-search {
    top: 64px;
    left: 14px;
    right: 14px;
    width: auto;
    transform: none;
    max-width: none;
  }
}

/* Mobile */
@media (max-width: 640px) {
  /* Brand (top-left): align with controls (8px), tighter padding, ellipsize.
     display:block (instead of flex) so text-overflow:ellipsis actually
     kicks in for the text node.
     Reserve right-side room for the controls cluster. */
  .map-header {
    top: 8px;
    left: 8px;
    display: block;
    font-size: 11px;
    line-height: 1.6;
    padding: 5px 10px;
    max-width: calc(55% - 16px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Controls top-right: tighter spacing */
  .map-controls { top: 8px; right: 8px; gap: 6px; }
  .map-action   { padding: 7px 12px; font-size: 11px; }
  .map-action .plus { font-size: 14px; }

  /* Identity pill: drop the email text on mobile — the user still sees
     it on /submit. Keep just the "Edit" + "Sign out" buttons compact. */
  .map-identity     { padding: 4px 6px; gap: 6px; font-size: 10px; }
  .map-identity .me { display: none; }
  .btn-mini         { padding: 4px 9px; font-size: 10px; }

  /* Admin "Copy emails in view" pill — pinned to bottom-left, above stats */
  .map-admin-action       { bottom: 54px; left: 12px; padding: 5px 10px;
                            font-size: 10px; gap: 6px; }
  .map-admin-action .count{ padding: 1px 6px; font-size: 9px; }

  /* Search drops below the controls. 56px clears the identity pill +
     add-action row (now that admin button lives at the bottom). */
  .admin-search        { top: 56px; left: 8px; right: 8px; width: auto;
                         transform: none; padding: 4px; }
  .admin-search input  { font-size: 12px; padding: 6px 8px; }
  .admin-search button { font-size: 11px; padding: 6px 10px; }
  .admin-search .hits  { font-size: 12px; }

  /* Stats */
  .map-stats { font-size: 10px; padding: 6px 10px; bottom: 12px; left: 12px; }

  /* Page layout (submit / admin login / auth callback). Allow header
     contents to wrap so "Back to map" never breaks across two lines. */
  .page-header        { padding: 14px 16px; gap: 10px; flex-wrap: wrap; }
  .page-header .brand { font-size: 13px; line-height: 1.3; white-space: nowrap; }
  .page-header nav    { white-space: nowrap; }
  .page-header nav a  { margin-left: 14px; font-size: 12px; }

  .page-main { padding: 32px 18px; }
  h1 { font-size: 24px; }
}

/* Extra-narrow phones — abbreviate brand so it always fits. */
@media (max-width: 380px) {
  .map-header { font-size: 10px; max-width: calc(50% - 16px); }
}
