/* Free Food at UofT
   Ink is UofT-ish navy; mustard marks what's happening now; pickle green means "just walk in". */

:root {
  --ink: #14213d;
  --ink-2: #4b5670;
  --ink-3: #737d95;
  --paper: #ffffff;
  --wash: #f2f4f9;
  --line: #dde2ec;
  --navy: #1e3765;
  --mustard: #f2b200;
  --mustard-wash: #fff4d1;
  --mustard-ink: #6b4d00;
  --pickle: #2c7a47;
  --pickle-wash: #e2f3e8;
  --later: #8c96ad;
  --focus: #1f64d8;
  --shadow: 0 1px 2px rgb(20 33 61 / 0.12), 0 6px 18px rgb(20 33 61 / 0.12);

  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", ui-sans-serif, system-ui, sans-serif;

  --panel-w: 410px;
  --radius-s: 8px;
  --radius-m: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e9edf7;
    --ink-2: #b1bad0;
    --ink-3: #8690a8;
    --paper: #131a2a;
    --wash: #1b2337;
    --line: #2b3550;
    --navy: #93aee6;
    --mustard-wash: #3a3014;
    --mustard-ink: #ffd766;
    --pickle: #6fca90;
    --pickle-wash: #183324;
    --later: #6c7791;
    --focus: #7fb0ff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 22px rgb(0 0 0 / 0.35);
    color-scheme: dark;
  }
}

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

html, body { height: 100%; margin: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
a { color: var(--navy); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

[hidden] { display: none !important; }

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

/* ---------- Layout ---------- */

.app {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  height: 100dvh;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--paper);
  border-right: 1px solid var(--line);
  z-index: 500;
}

.map { height: 100%; min-height: 0; background: var(--wash); }

.sheet-handle { display: none; }

/* ---------- Panel header ---------- */

.panel-head {
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}

.brand {
  margin: 0;
  font: 700 15px/1.2 var(--font-display);
  color: var(--ink-2);
}

.headline {
  margin: 6px 0 16px;
  font: 800 clamp(26px, 3.2vw, 34px)/1.05 var(--font-display);
  font-variation-settings: "opsz" 96;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.when {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  padding: 3px;
  background: var(--wash);
  border-radius: 999px;
}

.when button {
  border: 0;
  background: transparent;
  padding: 7px 4px;
  border-radius: 999px;
  font: 700 13.5px/1 var(--font-display);
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.when button:hover { color: var(--ink); }
.when button[aria-checked="true"] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 3px rgb(20 33 61 / 0.18);
}

.refine {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 12px;
}

.search { flex: 1 1 100%; }
.search input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--paper);
}
.search input::placeholder { color: var(--ink-3); }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
}
.toggle input { width: 16px; height: 16px; margin: 0; accent-color: var(--navy); }

/* ---------- List ---------- */

.panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.place-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 22px 0;
  padding: 9px 12px;
  background: var(--wash);
  border-radius: var(--radius-s);
  font-size: 14px;
}
.place-filter button {
  border: 0; background: none; padding: 2px 4px;
  font-weight: 700; color: var(--navy); cursor: pointer;
}

.day-group { padding: 6px 0 4px; }

.day-title {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 10px 22px 6px;
  background: var(--paper);
  font: 700 15px/1.2 var(--font-display);
  color: var(--ink-2);
}

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

.event-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  width: 100%;
  padding: 11px 22px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.event-row:hover, .event-row.is-hovered { background: var(--wash); }

.plate {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid var(--ring, var(--later));
  background: var(--paper);
  font-size: 22px;
  line-height: 1;
}
.plate.is-maybe { border-style: dashed; }

.t-now   { --ring: var(--mustard); }
.t-today { --ring: var(--navy); }
.t-later { --ring: var(--later); }

.row-title {
  display: block;
  font: 700 16px/1.25 var(--font-display);
  color: var(--ink);
}
.row-meta { display: block; margin-top: 2px; font-size: 14px; color: var(--ink-2); }
.row-meta strong { color: var(--ink); font-weight: 700; }
.row-food { display: block; margin-top: 3px; font-size: 14px; color: var(--ink-2); }

.row-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  background: var(--wash);
  color: var(--ink-2);
}
.tag.is-now { background: var(--mustard-wash); color: var(--mustard-ink); }
.tag.is-walkin { background: var(--pickle-wash); color: var(--pickle); }
.tag.is-offmap { background: transparent; border: 1px dashed var(--line); font-weight: 400; }

.empty {
  margin: 28px 22px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-m);
  color: var(--ink-2);
}
.empty p { margin: 0 0 10px; }
.empty button {
  border: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--navy);
  color: var(--paper);
  font-weight: 700;
  cursor: pointer;
}

/* ---------- Detail ---------- */

.detail { padding: 14px 22px 28px; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  padding: 6px 0;
  border: 0;
  background: none;
  font-weight: 700;
  color: var(--navy);
  cursor: pointer;
}

.detail-image {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--radius-m);
  background: var(--wash);
  margin-bottom: 16px;
}

.detail h2 {
  margin: 0 0 4px;
  font: 800 25px/1.12 var(--font-display);
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.detail .club { margin: 0 0 16px; color: var(--ink-2); }

.food-callout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  align-items: center;
  padding: 14px;
  border-radius: var(--radius-m);
  background: var(--mustard-wash);
  margin-bottom: 18px;
}
.food-callout.is-maybe { background: var(--wash); }
.food-emoji { grid-row: span 2; font-size: 34px; line-height: 1; }
.food-what { font: 700 17px/1.2 var(--font-display); }
.food-quote { font-size: 14px; font-style: italic; color: var(--ink-2); overflow-wrap: anywhere; }

.facts { margin: 0 0 18px; }
.fact {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.fact dt { font-weight: 700; color: var(--ink-2); font-size: 14px; }
.fact dd { margin: 0; overflow-wrap: anywhere; }
.fact .sub { display: block; font-size: 14px; color: var(--ink-2); }

.cta {
  display: inline-block;
  margin-top: 6px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--navy);
  color: var(--paper);
  font-weight: 700;
  text-decoration: none;
}
.cta:hover { filter: brightness(1.1); }

.desc {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
  color: var(--ink);
}
.desc.is-clamped {
  display: -webkit-box;
  -webkit-line-clamp: 7;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.more {
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: none;
  font-weight: 700;
  color: var(--navy);
  cursor: pointer;
}

.links { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.links a {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  text-decoration: none;
}
.links a:hover { background: var(--wash); }

.caveat { margin: 18px 0 0; font-size: 13.5px; color: var(--ink-3); }

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

.panel-foot {
  padding: 10px 22px 14px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-3);
}
.panel-foot p { margin: 0; }
.panel-foot a { color: inherit; }

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

.pin-wrap { background: none; border: 0; }

.pin {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3.5px solid var(--ring);
  background: var(--paper);
  box-shadow: var(--shadow);
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
  transition: transform 160ms ease;
}
.pin.is-maybe { border-style: dashed; }
.pin.is-selected, .pin.is-hovered { transform: scale(1.2); }
.pin.is-selected { box-shadow: 0 0 0 4px var(--paper), 0 0 0 6px var(--ring), var(--shadow); }

.pin-count {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font: 800 11.5px/20px var(--font-display);
  text-align: center;
}

/* The one moving thing on the page: food that's out right now. */
.pin.t-now::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 3px solid var(--mustard);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  from { transform: scale(1); opacity: 0.9; }
  to   { transform: scale(1.7); opacity: 0; }
}

.leaflet-tooltip.pin-tip {
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-s);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  font: 400 13.5px/1.35 var(--font-body);
  width: max-content;
  max-width: 250px;
  white-space: normal;
}
.leaflet-tooltip.pin-tip::before { border-top-color: var(--paper); }
.pin-tip strong { display: block; font: 700 14px/1.25 var(--font-display); }
.pin-tip span { display: block; color: var(--ink-2); }
.pin-tip span + strong { margin-top: 6px; }

.legend {
  padding: 9px 12px;
  border-radius: var(--radius-s);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.3;
}
.legend div { display: flex; align-items: center; gap: 8px; }
.legend div + div { margin-top: 5px; }
.legend i {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid var(--ring);
  background: var(--paper);
}
.legend i.is-maybe { --ring: var(--ink-3); border-style: dashed; }

.leaflet-container { font-family: var(--font-body); background: var(--wash); }
/* Quiet, cool-grey basemap; the emoji pins carry the colour. */
.leaflet-tile-pane { filter: grayscale(0.9) sepia(0.08) hue-rotate(180deg) saturate(0.6) brightness(1.04) contrast(0.92); }
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) grayscale(0.85) brightness(0.82) contrast(0.95); }
}
.leaflet-control-attribution { font-size: 11px; }
.leaflet-bar a { background: var(--paper); color: var(--ink); border-color: var(--line); }
@media (prefers-color-scheme: dark) {
  .leaflet-control-attribution { background: rgb(19 26 42 / 0.8) !important; color: var(--ink-3); }
  .leaflet-control-attribution a { color: var(--ink-2); }
}

/* ---------- Phones: map fills the screen, the list is a bottom sheet ---------- */

@media (max-width: 760px) {
  .app { display: block; }
  .map { position: fixed; inset: 0; }

  .panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 46dvh;
    border-right: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -6px 24px rgb(20 33 61 / 0.18);
    transition: height 240ms ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel.is-expanded { height: 88dvh; }
  /* Collapsed: just the headline, the time filter and the first events. */
  .panel:not(.is-expanded) .refine,
  .panel:not(.is-expanded) .panel-foot { display: none; }

  .sheet-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
    padding: 8px 0 2px;
    border: 0;
    background: none;
    cursor: pointer;
  }
  .sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
  .sheet-label { font-size: 12px; font-weight: 700; color: var(--ink-3); }

  .panel-head { padding: 4px 16px 12px; }
  .headline { font-size: 24px; margin-bottom: 12px; }
  .brand { font-size: 13px; }
  .day-title, .event-row, .detail { padding-left: 16px; padding-right: 16px; }
  .place-filter { margin-left: 16px; margin-right: 16px; }
  .panel-foot { padding: 8px 16px 12px; }
  .legend { display: none; }
  .leaflet-top.leaflet-right { top: env(safe-area-inset-top); }
}

@media (prefers-reduced-motion: reduce) {
  .pin.t-now::after { animation: none; opacity: 0.5; transform: scale(1.25); }
  .pin, .panel { transition: none; }
}
