/* Mobile-first styles for the nursing assignment map.
   Brand palette ("Be A School Nurse!", beaschoolnurse.com) is centralized in
   :root below. Pin colors, the legend, badges, and CTAs all read from the same
   variables so "possibly covered" and the brand colors look identical
   everywhere. */

:root {
  /* Brand palette (exact) */
  --purple-mid: #87529C;    /* header/nav + footer background */
  --purple-deep: #6A2E7F;   /* headings, button label on gold, standard pins */
  --gold: #E7A940;          /* primary CTAs, active states, possibly-covered */
  --white: #FFFFFF;         /* page bg, header text/logo */
  --lavender: #FAF3FF;      /* card / list panel backgrounds */
  --gray-line: #F0F0F0;     /* borders / dividers */
  --black: #000000;         /* body text */

  /* Semantic aliases (component code reads these) */
  --pin-open: var(--purple-deep);  /* standard open assignment */
  --pin-covered: var(--gold);      /* possibly covered */
  --ink: var(--black);
  --ink-soft: #5a4a63;             /* muted purple-gray for secondary text */
  --line: var(--gray-line);
  --panel-shadow: 0 2px 10px rgba(58, 26, 71, 0.18);

  --header-height: 52px;  /* brand bar height; the map fills below it */
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must always win, even over display: flex below */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Assistant", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-weight: 500;
  color: var(--ink);
  background: var(--white);
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
}

/* Headings: deep purple, bold, across the whole app */
h1, h2, h3 {
  color: var(--purple-deep);
  font-weight: 700;
}

/* ---------------------------------------------------------- brand header */

.site-header {
  height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  align-items: center;
  padding-left: 16px;
  background: var(--purple-mid);
  box-shadow: 0 1px 6px rgba(58, 26, 71, 0.25);
  position: relative;
  z-index: 1500; /* above the map's overlaid controls */
}

/* White-text logo: must sit on the purple bar, never on white. */
.site-logo {
  height: 38px;
  width: auto;
  display: block;
}

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

.noscript-note {
  padding: 16px;
  text-align: center;
}

/* ------------------------------------------------------------- map shell */

.map-shell {
  position: relative;
  /* Fill the viewport below the brand header. dvh tracks the real visible
     viewport on mobile; vh is the fallback for browsers without dvh. */
  height: calc(100vh - var(--header-height));
  height: calc(100dvh - var(--header-height) - env(safe-area-inset-top, 0px));
}

#map {
  height: 100%;
}

/* Legend + "Updated N min ago", bottom-left over the map (attribution is
   bottom-right). */
#map-info {
  position: absolute;
  left: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 1000;
  background: rgba(250, 243, 255, 0.95); /* pale lavender */
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink);
  box-shadow: var(--panel-shadow);
}

#map-info p {
  margin: 0 0 4px;
}

#map-info p:last-child {
  margin-bottom: 0;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(58, 26, 71, 0.35);
}

.legend-dot--open {
  background: var(--pin-open);
}

.legend-dot--covered {
  background: var(--pin-covered);
}

/* Freshness footer line: purple bar with white text, inset into the panel */
#updated-line {
  margin-top: 6px;
  padding: 5px 8px;
  background: var(--purple-mid);
  color: var(--white);
  font-weight: 700;
  border-radius: 6px;
  text-align: center;
}

/* Empty state banner: only over a successful zero-assignment response */
#empty-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  margin: 0;
  max-width: min(320px, 84vw);
  background: var(--lavender);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
  text-align: center;
  font-size: 16px;
  color: var(--purple-deep);
  font-weight: 700;
  box-shadow: var(--panel-shadow);
}

/* Non-blocking failed-refetch notice: gold pill on the map */
#refresh-notice {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  min-height: 44px;
  padding: 10px 18px;
  border: none;
  border-radius: 999px;
  background: var(--gold);
  color: var(--purple-deep);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--panel-shadow);
}

/* ------------------------------------------------------------ map actions */

#map-actions {
  position: fixed;
  top: calc(var(--header-height) + env(safe-area-inset-top, 0px) + 10px);
  left: 50%;
  z-index: 1100;
  width: min(370px, calc(100vw - 20px));
  transform: translateX(-50%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}

#map-actions > * {
  pointer-events: auto;
}

#case-request-panel {
  position: relative;
  flex: 0 1 auto;
  min-width: 0;
}

#list-toggle,
#case-request-toggle {
  min-height: 44px;
  padding: 9px 14px;
  border: 2px solid var(--purple-mid);
  border-radius: 999px;
  background: var(--white);
  color: var(--purple-deep);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--panel-shadow);
  white-space: nowrap;
}

#list-toggle:hover,
#case-request-toggle:hover {
  background: var(--lavender);
}

#case-request-toggle[aria-expanded="true"] {
  background: var(--purple-mid);
  color: var(--white);
}

#case-request-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toggle-arrow {
  font-size: 13px;
  line-height: 1;
}

#case-request-toggle[aria-expanded="true"] .toggle-arrow {
  transform: rotate(180deg);
}

#case-request-help {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(280px, calc(100vw - 20px));
  margin: 0;
  padding: 10px 12px 0;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid #d8c9e2;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  box-shadow: 0 2px 10px rgba(58, 26, 71, 0.12);
}

#case-request-toggle[aria-expanded="true"] + #case-request-form,
#case-request-panel:has(#case-request-toggle[aria-expanded="true"]) #case-request-help {
  display: flex;
}

#case-request-form {
  position: absolute;
  top: calc(100% + 42px);
  right: 0;
  width: min(280px, calc(100vw - 20px));
  margin: 0;
  padding: 10px 12px 12px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid #d8c9e2;
  border-top: 0;
  border-radius: 0 0 10px 10px;
  box-shadow: var(--panel-shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#case-request-form .field-label {
  font-size: 13px;
}

#case-request-submit {
  width: 100%;
}

.case-request-success {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(280px, calc(100vw - 20px));
  margin-top: 0;
  box-shadow: var(--panel-shadow);
}

/* ------------------------------------------------------------------ pins */

/* divIcon: a 44x44 invisible tap target around a smaller visible dot */
.pin {
  display: grid;
  place-items: center;
  background: none;
  border: none;
}

.pin-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--pin-open); /* deep purple: standard open assignment */
  /* White stroke + halo so pins pop on the light CARTO basemap */
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(58, 26, 71, 0.35), 0 1px 4px rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: grid;
  place-items: center;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.pin--covered .pin-dot {
  background: var(--pin-covered); /* gold: possibly covered */
  color: var(--purple-deep);      /* dark count text stays legible on gold */
}

.pin:focus-visible {
  outline: none;
}

.pin:focus-visible .pin-dot {
  outline: 3px solid var(--purple-deep);
  outline-offset: 2px;
}

.pin--selected .pin-dot {
  transform: scale(1.32);
  border-color: var(--gold);
  box-shadow:
    0 0 0 3px rgba(231, 169, 64, 0.85),
    0 0 0 7px rgba(106, 46, 127, 0.28),
    0 3px 10px rgba(0, 0, 0, 0.35);
}

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

/* Pale-lavender list panel; fills at least the map area so it reads as its
   own surface, not floating cards on white. */
#list-section {
  padding: calc(var(--header-height) + 72px) 16px calc(24px + env(safe-area-inset-bottom, 0px));
  min-height: 100vh;
  background: var(--lavender);
}

#list-section > * {
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

#list-heading {
  margin: 0 0 16px;
  font-size: 20px;
}

#list-heading:focus {
  outline: none;
}

#list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ----------------------------------------------------------------- cards */

.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--white);
  box-shadow: 0 1px 3px rgba(58, 26, 71, 0.08);
}

.card-school {
  margin: 0 0 2px;
  font-size: 17px;
  line-height: 1.3;
  color: var(--purple-deep);
  font-weight: 700;
}

.card-borough {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 14px;
}

/* Unmappable rows: a clear "not on the map" treatment, gold left rail */
.card:has(.tag-unmapped) {
  border-left: 4px solid var(--gold);
}

.tag-unmapped {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--purple-deep);
  font-weight: 700;
}

.badges {
  margin: 0 0 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

/* 1:1 / Ongoing badge: purple */
.badge--type {
  background: var(--lavender);
  color: var(--purple-deep);
  border: 1px solid var(--purple-mid);
}

/* Possibly-covered badge: gold */
.badge--covered {
  background: var(--gold);
  color: var(--purple-deep);
  border: 1px solid #c78a24;
}

.card-details {
  margin: 0 0 12px;
}

.card-detail-row {
  display: flex;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 4px;
}

.card-detail-row dt {
  flex: 0 0 84px;
  color: var(--ink-soft);
}

.card-detail-row dd {
  margin: 0;
}

/* --------------------------------------------------------- interest form */

/* Primary CTAs: gold background, deep-purple bold label, >=44px touch target */
.interest-toggle,
.interest-submit,
.back-to-map,
#load-retry {
  min-height: 44px;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  background: var(--gold);
  color: var(--purple-deep);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.12s ease, filter 0.12s ease;
}

.interest-toggle:hover,
.interest-submit:hover,
.back-to-map:hover,
#load-retry:hover {
  filter: brightness(1.05);
}

.interest-toggle:active,
.interest-submit:active,
.back-to-map:active,
#load-retry:active {
  filter: brightness(0.94);
}

.interest-submit:disabled {
  filter: brightness(0.9);
  cursor: default;
}

/* Expanded toggle acts as a secondary "close": outlined purple */
.interest-toggle[aria-expanded="true"] {
  background: var(--white);
  color: var(--purple-deep);
  border: 2px solid var(--purple-mid);
}

.interest-toggle[aria-expanded="true"]:hover {
  background: var(--lavender);
  filter: none;
}

.interest-form {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 14px;
  font-weight: 600;
}

.field input {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #d8c9e2; /* soft purple-tinted border */
  border-radius: 10px;
  font-size: 16px; /* 16px+ prevents iOS focus zoom */
}

.field input:focus {
  outline: none;
  border-color: var(--purple-mid);
  box-shadow: 0 0 0 3px rgba(135, 82, 156, 0.25);
}

/* Honeypot: offscreen but NOT display:none, so bots still fill it */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form-status {
  margin: 0;
  font-size: 14px;
  color: #9a3412;
  min-height: 1em;
}

.interest-success {
  margin-top: 12px;
  border: 1px solid var(--purple-mid);
  background: var(--lavender);
  border-radius: 10px;
  padding: 12px 14px;
}

.interest-success p {
  margin: 0 0 8px;
}

.interest-success-lead {
  font-weight: 700;
  color: var(--purple-deep);
}

.interest-success-note {
  font-size: 14px;
  color: var(--ink-soft);
}

/* ----------------------------------------------------------- bottom sheet */

#sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(0, 0, 0, 0.4);
}

#sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1300;
  margin: 0 auto;
  max-width: 560px;
  max-height: 80vh;   /* fallback */
  max-height: 80dvh;
  overflow-y: auto;
  background: var(--lavender);
  border-top: 4px solid var(--purple-mid);
  border-radius: 16px 16px 0 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 24px rgba(58, 26, 71, 0.28);
}

#sheet:focus {
  outline: none;
}

#sheet-title {
  margin: 6px 44px 12px 0;
  font-size: 18px;
}

/* Secondary "close": outlined purple */
#sheet-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  border: 2px solid var(--purple-mid);
  border-radius: 50%;
  background: var(--white);
  color: var(--purple-deep);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

#sheet-close:hover {
  background: var(--lavender);
}

#sheet-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ------------------------------------------------------- load-error state */

/* Opaque full-screen overlay: with nothing rendered yet the user must never
   see an empty map that reads as "no assignments" (R19). */
#load-error {
  position: fixed;
  inset: 0;
  z-index: 1400;
  background: var(--lavender);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

#load-error p {
  margin: 0;
  font-size: 18px;
  color: var(--purple-deep);
  font-weight: 700;
}

/* --------------------------------------------------------------- desktop */

@media (min-width: 720px) {
  #list-section {
    padding-top: 108px;
  }

  .card {
    padding: 16px 20px;
  }
}

/* ------------------------------------------------- per-diem floater pins */

/* Rounded-square purple marker: distinct from school pins by shape and label. */
.pin--perdiem .pin-dot {
  border-radius: 9px;
  background: var(--purple-deep);
  border: 2.5px solid #fff;
  color: #fff;
}

/* Always-visible label pill hanging below the dot. Accepted overlap risk at
   city-wide zoom -- borough centroids sit away from the school clusters. */
.pin--perdiem .pin-label {
  position: absolute;
  top: 38px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--purple-deep);
  background: #fff;
  border: 1px solid var(--purple-mid);
  border-radius: 8px;
  padding: 1px 7px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  pointer-events: none; /* the 44px dot area stays the tap target */
}

.pin--selected .pin-label {
  background: var(--purple-deep);
  border-color: var(--gold);
  color: var(--white);
}

.legend-dot--perdiem {
  background: var(--purple-deep);
  border-radius: 4px;
  border: 1.5px solid #fff;
  box-shadow: none;
}

/* Per-diem type badge: purple like the marker it describes */
.badge--perdiem {
  background: var(--lavender);
  color: var(--purple-deep);
  border: 1px solid var(--purple-mid);
}
