/* MOTION store locator
   Layout: white page. Phones stack header, heading, search, map, stores, footer.
   Desktop (900px+) puts search and stores in a left column (35%) beside a large map (65%). */

:root {
  /* MOTION Original can: navy at the top, purple in the middle, red at the bottom */
  --navy: #0b1b3f;
  --purple: #4a1d6b;        /* only inside the can gradient */
  --red: #e83232;           /* MOTION red, matched to the logo and Instagram */
  --red-pressed: #c92727;
  --red-ink: #d02727;       /* red text on white (5.2:1 contrast) */
  --white: #ffffff;
  --can-gradient: linear-gradient(90deg, var(--navy) 0%, var(--purple) 50%, var(--red) 100%);

  /* Cool neutrals that sit with the navy */
  --text: #1c2333;
  --muted: #5c6577;
  --line: #e2e5eb;
  --line-strong: #c8cdd7;
  --tint: #f2f4f7;

  /* Brand typeface: swap the Google Fonts link in index.html and this name */
  --font: "Archivo", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --radius: 8px;
  --gutter: 18px;
  --max: 1320px;

  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--white);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

.wrap {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left, 0px));
}

/* ---------- Header ---------- */

.site-header { background: var(--white); }
.site-header .wrap {
  display: flex;
  justify-content: center;
  padding-block: calc(12px + env(safe-area-inset-top, 0px)) 12px;
}
.logo { display: block; height: 60px; width: auto; }

/* ---------- Heading ---------- */

.intro { padding-block: 22px 18px; }

h1 {
  margin: 0;
  color: var(--navy);
  font-weight: 900;
  font-stretch: 78%;
  font-size: clamp(2rem, 8.6vw, 3.25rem);
  line-height: 0.95;
  letter-spacing: 0.005em;
  text-transform: uppercase;
  text-wrap: balance;
}

.tagline { margin: 8px 0 0; color: var(--muted); font-size: 1rem; }

/* ---------- Locator grid ---------- */

.locator {
  display: grid;
  gap: 16px;
  grid-template-areas: "finder" "map" "results";
  margin-bottom: 40px;
}
.finder { grid-area: finder; }
.map { grid-area: map; }
.results { grid-area: results; }

/* ---------- Search ---------- */

.finder { display: grid; gap: 10px; }

.search { display: flex; gap: 8px; }

.search input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
  font: 500 16px/1 var(--font);   /* 16px keeps iPhone from zooming in on focus */
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(11, 27, 63, 0.12); }
.search input::-webkit-search-decoration,
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.search button {
  flex: 0 0 52px;
  height: 52px;
  border: 0;
  border-radius: var(--radius);
  background: var(--red);
  color: var(--white);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 0.15s;
}
.search button:active { background: var(--red-pressed); }
@media (hover: hover) { .search button:hover { background: var(--red-pressed); } }
.search button:disabled { opacity: 0.6; cursor: wait; }

.locate,
.more {
  width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--navy);
  font-weight: 700;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.locate svg { color: var(--red); }
.locate:active,
.more:active { background: var(--tint); }
@media (hover: hover) {
  .locate:hover,
  .more:hover { background: var(--tint); border-color: var(--line-strong); }
}
.locate:disabled { cursor: wait; }
.locate[aria-busy="true"] svg { animation: spin 1s linear infinite; }

.status {
  margin: 0;
  min-height: 1.4em;
  font-size: 0.875rem;
  color: var(--muted);
}
.status.is-error { color: var(--red-ink); font-weight: 600; }

/* ---------- Map ---------- */

.map {
  height: 340px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #eceee9;
  isolation: isolate;
}

.leaflet-container { font-family: var(--font); background: #eceee9; }

/* Softens the standard map colors slightly: pale land, blue water, green parks stay */
.map-tiles { filter: saturate(0.8) brightness(1.02); }

.leaflet-bar,
.leaflet-touch .leaflet-bar {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(11, 27, 63, 0.08);
  overflow: hidden;
}
.leaflet-bar a,
.leaflet-touch .leaflet-bar a {
  width: 36px; height: 36px; line-height: 36px;
  background: var(--white); color: var(--navy);
  border-bottom-color: var(--line);
}
.leaflet-bar a:hover { background: var(--tint); color: var(--navy); }

.leaflet-container .leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
  font-size: 10px;
}
.leaflet-container .leaflet-control-attribution a { color: var(--muted); }

/* Store markers: the MOTION logo as a small sticker */
.pin img {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.15s ease;
  filter: drop-shadow(0 1px 1.5px rgba(11, 27, 63, 0.35));
}
@media (hover: hover) { .pin:hover img { transform: scale(1.12); } }
.pin.is-active img { transform: scale(1.3); }

/* Visitor's location */
.me span {
  display: block;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--navy);
  border: 3px solid var(--white);
  box-shadow: 0 0 0 0 rgba(11, 27, 63, 0.35);
  animation: pulse 2s ease-out infinite;
}

/* Marker popup */
.leaflet-popup-content-wrapper {
  border-radius: 10px;
  background: var(--white);
  color: var(--text);
  box-shadow: 0 6px 20px rgba(11, 27, 63, 0.18);
}
.leaflet-popup-tip { background: var(--white); }
.leaflet-popup-content { margin: 14px 16px; font-size: 0.875rem; line-height: 1.35; }
.popup-name {
  color: var(--navy);
  font-weight: 800;
  font-stretch: 85%;
  font-size: 1.0625rem;
  line-height: 1.1;
  text-transform: uppercase;
}
.popup-addr { margin-top: 4px; color: var(--muted); }
.popup-dist { margin-top: 4px; color: var(--navy); font-weight: 700; font-variant-numeric: tabular-nums; }
.leaflet-container a.popup-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--red-ink);
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
}

/* ---------- Store list ---------- */

.results { display: flex; flex-direction: column; margin-top: 8px; }

.results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.results h2 {
  margin: 0;
  color: var(--navy);
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.results-count {
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.store-list { list-style: none; margin: 0; padding: 0; }

.store {
  display: grid;
  gap: 4px;
  padding: 16px 0 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.store-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.store-title { margin: 0; min-width: 0; font-size: inherit; }

.store-name {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  color: var(--navy);
  font-weight: 800;
  font-stretch: 88%;
  font-size: 1.125rem;
  line-height: 1.15;
  text-transform: uppercase;
  overflow-wrap: anywhere;
  transition: color 0.15s;
}
.store.is-active .store-name { color: var(--red-ink); }
@media (hover: hover) { .store:hover .store-name { color: var(--red-ink); } }

.store-dist {
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--tint);
  color: var(--navy);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.store-addr { margin: 0; color: var(--muted); font-size: 0.9375rem; }

.store-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  margin-top: 4px;
}

.flavors {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.flavor {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}
/* Small can-colored dot for each flavor */
.flavor::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
}
.flavor[data-flavor="original"]::before { background: linear-gradient(180deg, var(--navy), var(--purple) 50%, var(--red)); }
.flavor[data-flavor="sugar-free"]::before { background: linear-gradient(180deg, #d9dde3, #9aa1ab 50%, var(--red)); }

.directions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  color: var(--red-ink);
  font-weight: 800;
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}
.directions:hover { text-decoration: underline; text-underline-offset: 3px; }

.store-empty {
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.more { margin-top: 16px; flex: none; }

/* ---------- Footer ---------- */

.site-footer { background: var(--red); color: var(--white); }
.site-footer::before { content: ""; display: block; height: 4px; background: var(--can-gradient); }
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 24px;
  padding-block: 22px calc(22px + env(safe-area-inset-bottom, 0px));
}

.footer-tagline {
  margin: 0;
  font-weight: 900;
  font-stretch: 80%;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.footer-tagline span { color: var(--navy); }

.footer-contact { display: grid; gap: 2px; }
.footer-link { color: var(--white); font-size: 0.875rem; text-decoration: none; overflow-wrap: anywhere; }
.footer-link strong { font-weight: 700; }
.footer-link:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.site-footer :focus-visible { outline-color: var(--white); }

/* ---------- Desktop ---------- */

@media (min-width: 900px) {
  :root { --gutter: 32px; }

  .site-header .wrap { justify-content: flex-start; padding-block: 16px; }
  .logo { height: 72px; }

  .intro { padding-block: 34px 24px; }

  .locator {
    grid-template-columns: minmax(0, 35fr) minmax(0, 65fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "finder map"
      "results map";
    column-gap: 32px;
    row-gap: 20px;
    height: clamp(520px, calc(100vh - 256px), 780px);
    margin-bottom: 56px;
  }
  .map { height: 100%; }
  .results { min-height: 0; margin-top: 0; }
  .store-list { overflow-y: auto; min-height: 0; }
}

/* ---------- Motion ---------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(11, 27, 63, 0.35); }
  100% { box-shadow: 0 0 0 14px rgba(11, 27, 63, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
