/* Denton Market Days
   Palette pulled from a market table: kale, squash, beet, on a pale sage field. */
:root {
  --field: #EEF2EA;
  --paper: #FFFFFF;
  --ink: #1B211E;
  --muted: #56625A;
  --line: #D3DBD0;
  --kale: #22463A;
  --on-kale: #FFFFFF;
  --kale-soft: #DDE8E0;
  --squash: #F2B632;
  --beet: #8C2D4F;
  --display: "Familjen Grotesk", "Helvetica Neue", Arial, sans-serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --r-sm: 6px;
  --r-lg: 14px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --field: #121815;
    --paper: #1A221E;
    --ink: #E6ECE7;
    --muted: #A1AFA6;
    --line: #2F3B35;
    --kale: #7DBE9C;
    --on-kale: #0F1A14;
    --kale-soft: #22332A;
    --beet: #E08AAB;
  }
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0;
  background: var(--field);
  color: var(--ink);
  font: 17px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--kale); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--squash); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Header ---------- */
.top {
  display: flex; flex-wrap: wrap; gap: 16px 24px;
  align-items: end; justify-content: space-between;
  padding: 28px clamp(16px, 4vw, 40px) 12px;
}
.brand h1 {
  font: 700 clamp(2rem, 5vw, 3rem)/1 var(--display);
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--kale);
}
.brand p { margin: 6px 0 0; color: var(--muted); max-width: 46ch; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 2px solid var(--kale);
  border-radius: 999px;
  padding: 9px 18px;
  font-weight: 700;
  cursor: pointer;
  background: transparent;
  color: var(--kale);
  line-height: 1.2;
}
.btn.primary { background: var(--kale); color: var(--on-kale); }
.btn.ghost:hover { background: var(--kale-soft); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.small { padding: 6px 14px; font-size: 0.9rem; }
.btn:disabled { opacity: 0.55; cursor: progress; }

/* ---------- Week strip: the one loud element ---------- */
.week { padding: 8px clamp(16px, 4vw, 40px) 4px; }
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(84px, 1fr));
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.week-strip::-webkit-scrollbar { display: none; }
.day {
  position: relative;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 10px 12px 12px;
  cursor: pointer;
  min-height: 118px;
  display: flex; flex-direction: column;
}
.day .dname {
  font: 700 clamp(1.9rem, 3.4vw, 2.7rem)/0.95 var(--display);
  letter-spacing: -0.03em;
}
.day .ddate { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
.day .dots { margin-top: auto; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding-top: 10px; }
.day .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--kale); }
.day .more { font-size: 0.8rem; color: var(--muted); }
.day .none { font-size: 0.85rem; color: var(--muted); }
.day.today::after {
  content: ""; position: absolute; left: 12px; right: 12px; top: 0;
  height: 5px; border-radius: 0 0 4px 4px; background: var(--squash);
}
.day.empty .dname { color: var(--muted); }
.day[aria-pressed="true"] { background: var(--kale); border-color: var(--kale); color: var(--on-kale); }
.day[aria-pressed="true"] .ddate, .day[aria-pressed="true"] .none, .day[aria-pressed="true"] .more,
.day[aria-pressed="true"].empty .dname { color: var(--on-kale); opacity: 0.85; }
.day[aria-pressed="true"] .dot { background: var(--squash); }
.day:hover:not([aria-pressed="true"]) { border-color: var(--kale); }

/* ---------- Filters ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px);
}
.kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 6px 13px; cursor: pointer; font-size: 0.93rem;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--field); border-color: var(--ink); }
.search { flex: 0 1 340px; }
.search input {
  width: 100%;
  border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 8px 16px;
}

/* ---------- List + map ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(340px, 520px) 1fr;
  gap: 20px;
  padding: 0 clamp(16px, 4vw, 40px) 24px;
  align-items: start;
}
.map-wrap { position: sticky; top: calc(12px + env(safe-area-inset-top, 0px)); }
#map {
  height: calc(100vh - 40px);
  min-height: 420px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--kale-soft);
}
.list-head { margin: 0 0 10px; color: var(--muted); }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px 18px 14px;
  margin-bottom: 12px;
  scroll-margin-top: 16px;
}
.card.selected { border-color: var(--kale); box-shadow: 0 0 0 2px var(--kale); }
.card h3 { font: 700 1.35rem/1.15 var(--display); margin: 0; letter-spacing: -0.01em; }
.card .kind { color: var(--muted); font-size: 0.92rem; margin: 2px 0 10px; }
.next {
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
  margin: 0 0 10px;
}
.next .when {
  background: var(--squash); color: #1B211E; font-weight: 700;
  padding: 2px 10px; border-radius: var(--r-sm);
}
.next .when.later { background: var(--kale-soft); color: var(--ink); }
.next.none { color: var(--muted); }
.where { margin: 0 0 10px; }
.where .venue { display: block; font-weight: 700; }
.scheds { margin: 0 0 10px; padding: 0; list-style: none; font-size: 0.95rem; }
.scheds li { padding: 6px 0; border-top: 1px dashed var(--line); }
.scheds .lbl { color: var(--muted); }
.desc { margin: 0 0 10px; font-size: 0.95rem; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 10px; padding: 0; list-style: none; }
.tags li { font-size: 0.82rem; padding: 2px 9px; border-radius: 999px; background: var(--kale-soft); }
.unverified { font-size: 0.88rem; color: var(--beet); margin: 0 0 10px; }
.links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 12px; font-size: 0.95rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--line); padding-top: 12px; }
.link-btn {
  background: none; border: none; padding: 4px 2px; cursor: pointer; color: var(--kale);
  font-weight: 700; font-size: 0.93rem; margin-right: 12px;
}
.link-btn:hover { text-decoration: underline; }

.empty-state {
  background: var(--paper); border: 2px dashed var(--line); border-radius: var(--r-lg);
  padding: 24px; text-align: center;
}
.empty-state p { margin: 0 0 12px; }

.foot { padding: 8px clamp(16px, 4vw, 40px) 40px; color: var(--muted); font-size: 0.9rem; max-width: 80ch; }

/* Leaflet popups */
.leaflet-popup-content { font-family: var(--body); font-size: 15px; }
.leaflet-popup-content strong { font-family: var(--display); font-size: 1.05rem; }

/* ---------- Dialogs ---------- */
.sheet {
  border: none; padding: 0; border-radius: var(--r-lg);
  width: min(680px, 100vw - 24px); max-height: calc(100vh - 32px);
  background: var(--paper); color: var(--ink);
}
.sheet.narrow-sheet { width: min(460px, 100vw - 24px); }
.sheet::backdrop { background: rgba(18, 28, 22, 0.55); }
.sheet-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-head h2 { font: 700 1.6rem/1.1 var(--display); margin: 0; color: var(--kale); }
.sheet-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  position: sticky; bottom: 0; background: var(--paper);
  padding: 12px 0 18px; margin-bottom: -20px; border-top: 1px solid var(--line);
}
.x {
  border: none; background: var(--kale-soft); width: 36px; height: 36px; border-radius: 50%;
  font-size: 1.4rem; line-height: 1; cursor: pointer; flex: none;
}
.x.small { width: 30px; height: 30px; font-size: 1.1rem; align-self: end; margin-bottom: 4px; }
.hint { color: var(--muted); margin: 0; font-size: 0.95rem; }
.opt { color: var(--muted); font-weight: 400; font-size: 0.85rem; margin-left: 4px; }
fieldset { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px 14px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
legend { font: 700 1.05rem var(--display); padding: 0 6px; }
label { display: block; font-weight: 700; font-size: 0.93rem; }
label > input:not([type="checkbox"]):not([type="radio"]), label > select, label > textarea { display: block; margin-top: 4px; }
label.check, .radios label, .checks label, .only-market { display: flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 400; font-size: 0.97rem; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px;
  background: var(--field); font-weight: 400; width: 100%;
}
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--kale); flex: none; }
.row { display: flex; gap: 10px; }
.row > label { flex: 1; min-width: 0; }
.row > .narrow { flex: 0 0 110px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 12px; }
.sched { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; background: var(--field); }
.sched input, .sched select { background: var(--paper) !important; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.days label { display: inline-flex; }
.days input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.days span {
  display: inline-block; min-width: 46px; text-align: center; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--paper);
  font-weight: 700; cursor: pointer;
}
.days input:checked + span { background: var(--kale); color: var(--on-kale); border-color: var(--kale); }
.days input:focus-visible + span { outline: 3px solid var(--squash); outline-offset: 2px; }
.form-msg { margin: 0; color: var(--beet); font-weight: 700; min-height: 0; }
.form-msg:empty { display: none; }
.form-msg.ok { color: var(--kale); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--field); padding: 12px 18px; border-radius: 999px;
  font-weight: 700; z-index: 2000; max-width: calc(100vw - 32px);
}

/* ---------- Small screens: map on top, list below ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .map-wrap { position: static; order: -1; }
  #map { height: 42vh; min-height: 260px; }
  .week-strip { grid-template-columns: repeat(7, 92px); }
  .day { min-height: 104px; }
  .day .dname { font-size: 1.65rem; }
  .filters { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
  .filters > * { min-width: 0; }
  .kinds { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * clamp(16px, 4vw, 40px)); padding: 0 clamp(16px, 4vw, 40px); }
  .kinds::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .search { flex: none; width: 100%; }
  .search input { min-width: 0; }
  .row { flex-wrap: wrap; }
  .row > .narrow { flex: 1 1 110px; }
  .sheet { max-height: calc(100vh - 16px); }
}
@media (prefers-reduced-motion: no-preference) {
  .card.selected { transition: box-shadow 0.2s; }
}
