/* Study Spots: a campus utility in U of T's own colours.
   U of T Blue carries the app (header, actions, active states); the secondary colours are used only as
   status signals, per U of T's Colour Quick Guide ("use these colours as accents only").
   Hierarchy comes from size and type, not from boxes: one big best pick, then compact rows. */
:root {
  /* U of T palette (Colour Quick Guide) */
  --uoft-blue: #1e3765;          /* Pantone 655, primary */
  --uoft-blue-80: #4b5f84;       /* 80% tint */
  --uoft-blue-25: #c7cdd9;       /* 25% tint */
  --uoft-blue-10: #e9ebf0;
  --uoft-cyan: #007fa3;          /* Pantone 633 */
  --uoft-green: #00a189;         /* Pantone 3285: open */
  --uoft-red: #dc4633;           /* Warm Red: closed / full */
  --uoft-yellow: #f1c500;        /* Pantone 7406: highlight */
  --uoft-gray: #d0d1c9;          /* Cool Gray 2 */

  /* roles */
  --bg: #f5f5f2;
  --surface: #ffffff;
  --ink: #16213a;
  --muted: #5b6477;
  --line: #e1e2dc;
  --action: var(--uoft-blue);
  --action-ink: #ffffff;
  --link: var(--uoft-cyan);
  --header-bg: var(--uoft-blue);
  --header-ink: #ffffff;
  --open: var(--uoft-green);
  --closed: var(--uoft-red);
  --unknown: #9aa1ae;
  --mine: #6d247a;               /* Pantone 2613: "yours" */
  --highlight: var(--uoft-yellow);
  --placeholder: var(--uoft-blue-10);
  --placeholder-ink: var(--uoft-blue-80);

  --f-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --f-sans: "Public Sans", "Segoe UI", Roboto, system-ui, sans-serif;
  --tabbar-h: 62px;
  /* System bars. The Android app draws under them (edge-to-edge); Capacitor also sets --safe-area-inset-* for older WebViews. */
  --safe-top: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--safe-area-inset-bottom, 0px));
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    /* Deep U of T Blue rather than black (the guide says to avoid black backgrounds) */
    --bg: #0e1729; --surface: #15223b; --ink: #edf0f5; --muted: #a8b1c3; --line: #263552;
    --action: #6fc7ea; --action-ink: #0e1729; --link: #6fc7ea;
    --header-bg: #0b1324; --header-ink: #ffffff;
    --unknown: #6e7891; --mine: #c59ad0;
    --placeholder: #1f2e4d; --placeholder-ink: #8fa0c0;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 400 16px/1.5 var(--f-sans);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 20px);
}
h1, h2, h3 { margin: 0; line-height: 1.15; text-wrap: balance; }
h2 { font: 700 26px/1.15 var(--f-serif); letter-spacing: -0.01em; }
h3 { font: 600 19px/1.25 var(--f-serif); }
p { margin: 0; }
a { color: var(--link); }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--highlight); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hint { color: var(--muted); font-size: 14px; }

/* ---------- header: a blue band, like campus signage ---------- */
header.top {
  background: var(--header-bg); color: var(--header-ink);
  padding: calc(14px + var(--safe-top)) 16px 14px;
}
header.top .inner { max-width: 720px; margin: 0 auto; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.brand h1 { font: 700 28px/1 var(--f-serif); letter-spacing: -0.015em; }
.brand .sub { display: block; margin-top: 4px; font-size: 13px; opacity: .8; }
.feed { font-size: 12px; opacity: .75; text-align: right; }
.feed.bad { opacity: 1; color: var(--highlight); }

main { max-width: 720px; margin: 0 auto; padding-inline: 16px; }
.view { display: grid; gap: 18px; padding-top: 18px; }

/* ---------- controls ---------- */
.controls { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span, .field > label > span, .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field select, .field input {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; width: 100%; min-width: 0; font-size: 16px;
}
.near-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: stretch; }
.near-note { font-size: 13px; color: var(--muted); }
.near-note:empty { display: none; }
.locate { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.locate svg { width: 16px; height: 16px; }

/* time: a plain segmented control */
.seg { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg button { border: 0; border-left: 1px solid var(--line); background: transparent; padding: 9px 4px; cursor: pointer; font-size: 15px; }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--action); color: var(--action-ink); font-weight: 600; }

/* preferences: toggles with a check when on */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 14px; }
.chips button[aria-pressed="true"] { border-color: var(--action); color: var(--action); font-weight: 600; }
.chips button[aria-pressed="true"]::before { content: "✓ "; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--action); background: var(--action); color: var(--action-ink); border-radius: var(--radius); padding: 9px 14px; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--action); }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.link { background: none; border: 0; padding: 4px 0; color: var(--link); font-weight: 600; text-decoration: none; }
.btn.link:hover { text-decoration: underline; }
.btn[aria-pressed="true"] { background: transparent; color: var(--action); }
.text-actions { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.text-actions a, .text-actions button { background: none; border: 0; padding: 0; color: var(--link); font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; }
.text-actions a:hover, .text-actions button:hover { text-decoration: underline; }
.text-actions [aria-pressed="true"] { color: var(--mine); }
.text-actions .btn, .text-actions .btn:hover { background: var(--action); color: var(--action-ink); border: 1px solid var(--action); padding: 6px 12px; font-size: 14px; text-decoration: none; }

/* ---------- status: a coloured dot, neutral text ---------- */
.status { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--unknown); flex: none; }
.status.open::before { background: var(--open); }
.status.closed::before { background: var(--closed); }
.meta { color: var(--muted); font-size: 14px; }
.meta .sep, .line .sep { margin: 0 7px; color: var(--muted); opacity: .7; }
.mine { color: var(--mine); font-weight: 600; }
.warn-text { color: var(--ink); }
.warn-text::before { content: "! "; color: var(--uoft-red); font-weight: 700; }

.banner { border-left: 4px solid var(--highlight); background: var(--surface); padding: 10px 12px; font-size: 14px; border-radius: 0 var(--radius) var(--radius) 0; }

/* ---------- picks: one hero, then compact rows ---------- */
ol.picks { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.pick { display: grid; gap: 10px; padding: 14px 0; border-top: 1px solid var(--line); }
.pick:first-child { border-top: 0; padding-top: 0; }
.pick .where { color: var(--muted); font-size: 14px; margin-top: 2px; }
.pick .line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; font-size: 14px; }

.pick.hero { gap: 12px; padding-bottom: 18px; }
.pick.hero h3 { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.pick.hero .head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.walk { text-align: right; line-height: 1; white-space: nowrap; }
.walk b { display: block; font: 700 34px/1 var(--f-serif); color: var(--uoft-blue); font-variant-numeric: lining-nums tabular-nums; }
.walk span { font-size: 13px; color: var(--muted); }
@media (prefers-color-scheme: dark) { .walk b { color: var(--ink); } }
.eyebrow-best { font-size: 13px; font-weight: 700; color: var(--uoft-blue); display: inline-flex; align-items: center; gap: 6px; }
.eyebrow-best::before { content: ""; width: 14px; height: 4px; background: var(--highlight); border-radius: 2px; }
@media (prefers-color-scheme: dark) { .eyebrow-best { color: var(--highlight); } }

.pick.compact { grid-template-columns: 76px minmax(0, 1fr) auto; align-items: start; column-gap: 12px; }
.pick.compact .body { display: grid; gap: 4px; min-width: 0; }
.pick.compact .walk b { font-size: 22px; }
.pick.compact .text-actions { gap: 14px; }
.pick.compact .text-actions a, .pick.compact .text-actions button { font-size: 14px; }

.photo-btn { position: relative; display: block; padding: 0; border: 0; background: var(--placeholder); border-radius: var(--radius); overflow: hidden; cursor: pointer; }
.pick.hero .photo { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.pick.compact .photo-btn { width: 76px; height: 76px; }
.pick.compact .photo { width: 76px; height: 76px; object-fit: cover; display: block; }
.photo-label { position: absolute; left: 6px; bottom: 6px; font-size: 11px; font-weight: 600; color: #fff; background: rgb(14 23 41 / .72); padding: 2px 7px; border-radius: 3px; }
.pick.compact .photo-label { left: 4px; bottom: 4px; font-size: 10px; padding: 1px 5px; }
/* no photo: the building's official code, like a campus sign */
.no-photo, .no-thumb { display: grid; place-items: center; border-radius: var(--radius); background: var(--placeholder); color: var(--placeholder-ink); font: 700 18px/1 var(--f-serif); letter-spacing: .04em; }
.no-photo { width: 76px; height: 76px; }

.next-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.empty { color: var(--muted); padding: 10px 0; }

@media (prefers-reduced-motion: no-preference) {
  .pick { animation: rise .32s ease-out both; }
  .pick:nth-child(2) { animation-delay: .05s; }
  .pick:nth-child(3) { animation-delay: .1s; }
  @keyframes rise { from { opacity: .001; transform: translateY(6px); } }
  .picks.still .pick { animation: none; }
}

/* also yours */
.also { border-left: 3px solid var(--mine); padding: 4px 0 4px 14px; display: grid; gap: 6px; }
.also h3 { font-size: 17px; }
.also ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.also a { color: var(--ink); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--uoft-blue-25); }

/* ---------- explore ---------- */
#map { height: 300px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); z-index: 0; }
.controls.row { grid-template-columns: auto minmax(0, 1fr); align-items: end; gap: 12px; }
.controls.row .grow { grid-column: 1 / -1; order: -1; }  /* search gets the full width on a phone */
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 15px; padding-bottom: 10px; white-space: nowrap; }
.check input { width: 18px; height: 18px; accent-color: var(--uoft-blue); }
.count { font-size: 13px; color: var(--muted); }
ul.list { list-style: none; margin: 0; padding: 0; display: grid; border-top: 1px solid var(--line); }
.row-item { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 2px 12px; align-items: start; padding: 12px 0; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; width: 100%; cursor: pointer; }
.row-item:hover .name { text-decoration: underline; text-decoration-color: var(--uoft-blue-25); }
.row-item .thumb, .row-item .no-thumb { grid-row: span 3; width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius); background: var(--placeholder); }
.row-item .no-thumb { font-size: 16px; }
.row-item .name { font: 600 17px/1.25 var(--f-serif); }
.row-item .meta { grid-column: 2 / 3; }
.row-item .side { font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-item .line { grid-column: 2 / -1; font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; }

/* ---------- profile / about ---------- */
.profile, #onboard-fields { display: grid; gap: 14px; }
.profile .actions { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.about { border-top: 1px solid var(--line); padding-top: 16px; display: grid; gap: 8px; }
.about h3 { font-size: 18px; }
.about ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.disclaimer { font-size: 13px; color: var(--muted); }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: var(--safe-bottom); }
.tabbar button { border: 0; background: none; height: var(--tabbar-h); cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 600; display: grid; place-items: center; align-content: center; gap: 3px; position: relative; }
.tabbar svg { width: 22px; height: 22px; }
.tabbar button[aria-current="page"] { color: var(--uoft-blue); }
.tabbar button[aria-current="page"]::after { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; background: var(--highlight); border-radius: 0 0 3px 3px; }
@media (prefers-color-scheme: dark) { .tabbar button[aria-current="page"] { color: var(--ink); } }

/* ---------- dialogs ---------- */
/* Kept clear of the status and navigation bars, so nothing in a dialog sits under them. */
dialog { border: 0; padding: 0; background: var(--surface); color: var(--ink); width: min(640px, 100vw - 24px); border-radius: 10px;
  top: calc(var(--safe-top) + 12px); bottom: calc(var(--safe-bottom) + 12px); max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px); }
dialog::backdrop { background: rgb(14 23 41 / .55); }
#onboard form { padding: 22px 20px; }
#onboard h2 { font-size: 24px; }
.sheet-inner { padding: 20px 18px 24px; }
/* Sticks to the top corner while the sheet scrolls; the negative margins keep it out of the flow. */
.close { position: sticky; top: 10px; z-index: 2; display: grid; place-items: center; width: 44px; height: 44px; margin: -10px -8px -34px auto; border: 0; border-radius: 50%; background: rgb(14 23 41 / .72); color: #fff; font-size: 26px; line-height: 1; cursor: pointer; }
.sheet { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }  /* minmax: a wide photo strip must not widen the sheet */
.sheet h2 { padding-right: 48px; }
.sheet .line { font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; }
.sheet h4 { margin: 12px 0 0; font: 700 13px/1 var(--f-sans); color: var(--muted); letter-spacing: .02em; }
/* photos: one, or a sideways strip that snaps to each photo */
.sheet-gallery { position: relative; margin: -20px -18px 4px; }
.sheet-photos { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; border-radius: 10px 10px 0 0; }
.sheet-photos::-webkit-scrollbar { display: none; }
.sheet-photo { flex: 0 0 100%; margin: 0; scroll-snap-align: start; min-width: 0; }
.sheet-photo .frame { position: relative; background: var(--placeholder); }
.sheet-photo img { display: block; width: 100%; height: 250px; object-fit: cover; }
.sheet-photo figcaption { font-size: 12px; color: var(--muted); padding: 6px 18px 0; }
.sheet-photo figcaption a { color: var(--muted); }
.photo-count { position: absolute; left: 10px; bottom: 10px; font-size: 12px; font-weight: 600; color: #fff; background: rgb(14 23 41 / .72); padding: 2px 8px; border-radius: 3px; }
.gallery-step { position: absolute; top: 103px; width: 36px; height: 44px; border: 0; background: rgb(14 23 41 / .55); color: #fff; font-size: 26px; line-height: 1; cursor: pointer; }
.gallery-step.prev { left: 0; border-radius: 0 6px 6px 0; }
.gallery-step.next { right: 0; border-radius: 6px 0 0 6px; }
@media (hover: none) { .gallery-step { display: none; } }  /* phones swipe */
.hours-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.hours-table td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.hours-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.hours-table tr.today td { font-weight: 700; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; font-size: 15px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.sources { font-size: 14px; padding-left: 18px; margin: 0; display: grid; gap: 4px; }

/* map pins */
.pin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgb(14 23 41 / .35); }
.pin.open { background: #00a189; }
.pin.closed { background: #8f9bb2; }
.pin.here { background: #f1c500; border-color: #1e3765; width: 18px; height: 18px; }
.leaflet-popup-content { font: 14px/1.45 var(--f-sans); }
.leaflet-popup-content b { font-family: var(--f-serif); }
.leaflet-popup-content button { font: inherit; }

@media (min-width: 560px) {
  .controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: end; }
  .controls .chips { grid-column: 1 / -1; }
  #map { height: 380px; }
  .pick.hero .photo { aspect-ratio: 21 / 9; }
  .controls.row { grid-template-columns: auto 170px minmax(0, 1fr); }
  .controls.row .grow { grid-column: auto; order: 0; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
