/* MIT Campus Photos — search-first map. One control (the search box), a
   results panel (bottom sheet < 900px, side panel above), and a centered
   detail card. Restrained product palette: one accent, evidence-coded
   pins, 44px touch targets, motion that conveys state only. */

:root {
  --ink: #101d33;
  --ink-2: #33415c;
  --muted: #5d6b84;
  --line: #dbe3ee;
  --line-soft: #edf1f7;
  --paper: #f4f7fb;
  --panel: #ffffff;
  --accent: #1c5fd6;
  --accent-deep: #12488f;
  --accent-tint: #e7efff;
  --dark-blue: #16357a;
  --blue: #2f7dd1;
  --green: #177c3f;
  --green-tint: #e9f4ec;
  --green-line: #cde5d2;
  --amber: #946200;
  --amber-tint: #fdf3dd;
  --glow: #ffb020;
  --radius: 12px;
  --radius-lg: 18px;
  --hit: 44px;
  --shadow-panel: 0 -8px 32px rgba(13, 20, 38, 0.16);
  --shadow-modal: 0 24px 64px rgba(10, 16, 30, 0.28);
  --dur: 180ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

button { font: inherit; }

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

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

#status-strip {
  flex: none;
  position: relative;
  background: #0e1a2e;
  color: #fff;
  padding: 10px 16px 13px;
}

.strip-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.wordmark {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.status-text {
  font-size: 12.5px;
  color: #b8c7e0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.locate-box { color: #9db4d8; font-size: 12.5px; margin-top: 2px; }

.locate-box summary {
  cursor: pointer;
  padding: 3px 0;
  user-select: none;
  width: fit-content;
}

.locate-box summary:hover { color: #cfe0ff; }

.locate-list {
  list-style: none;
  margin: 6px 0 2px;
  padding: 0;
  max-height: 28vh;
  overflow-y: auto;
}

.locate-item {
  display: block;
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.07);
  color: #dce8ff;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  margin: 4px 0;
  font-size: 12.5px;
  min-height: 40px;
  cursor: pointer;
}

.locate-item:hover { background: rgba(255, 255, 255, 0.16); }

/* Confirm progress: full-width hairline at the bottom edge. */
.confirm-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.14);
}

.confirm-progress-fill {
  height: 100%;
  width: 0;
  background: #6fd18b;
  transition: width 0.4s var(--ease);
}

/* ---- search control ------------------------------------------------------ */

.controls {
  flex: none;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

#search-box {
  width: 100%;
  font-size: 16px; /* >=16px prevents iOS zoom-on-focus */
  padding: 10px 14px;
  min-height: var(--hit);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  transition: border-color var(--dur) var(--ease);
}

#search-box::placeholder { color: var(--muted); }

#search-box:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

/* ---- map + pins ------------------------------------------------------------ */

#map {
  flex: 1;
  min-height: 0;
  background: #e8eef6;
}

/* Pin path styling by evidence class (SVG paths created by Leaflet). */
.pin { stroke-width: 2; }

.pin-room_number { fill: var(--dark-blue); stroke: var(--dark-blue); }

.pin-vision { fill: var(--blue); stroke: var(--blue); }

/* museum_inference / web places: outlined with a "?" tooltip prefix. */
.pin-museum_inference,
.pin-web {
  fill: rgba(47, 125, 209, 0.15);
  stroke: var(--blue);
}

.pin-confirmed {
  stroke: var(--green) !important;
  stroke-width: 3;
}

.pin-match {
  filter: drop-shadow(0 0 6px var(--glow)) drop-shadow(0 0 2px var(--glow));
}

.pin-dim { opacity: 0.3; }

.leaflet-tooltip { font-size: 12px; }

.leaflet-container { font: inherit; }

/* ---- results panel: bottom sheet on small screens, side panel >= 900px --- */

.drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 64vh;
  background: var(--panel);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  z-index: 1000;
}

.drawer[hidden] { display: none !important; }

.drawer-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.drawer-head h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.drawer-close {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--line-soft);
  color: var(--ink-2);
  font-size: 15px;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}

.drawer-close:hover { background: var(--line); }

.drawer-body {
  overflow-y: auto;
  padding: 12px 14px 20px;
  -webkit-overflow-scrolling: touch;
}

.drawer-empty { color: var(--muted); font-size: 14px; line-height: 1.5; }

/* Rows: thumbnail + text, shared by place features and search results. */
.row-list { display: flex; flex-direction: column; gap: 8px; }

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  min-height: var(--hit);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease),
    background var(--dur) var(--ease);
}

.row:hover { border-color: var(--accent); background: #f8faff; }

.row:active { border-color: var(--accent-deep); }

.row-thumb {
  flex: none;
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 9px;
  background: #e8eef6;
}

.row-text {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.row-subject {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2.5px 8px;
  border-radius: 999px;
  background: var(--line-soft);
  color: var(--muted);
}

.badge-building { background: var(--accent-tint); color: var(--accent-deep); }
.badge-confirmed { background: var(--green-tint); color: var(--green); }
.badge-none { background: var(--amber-tint); color: var(--amber); }

/* ---- centered detail modal ----------------------------------------------- */

.detail-modal {
  border: 0;
  border-radius: var(--radius-lg);
  padding: 0;
  width: min(720px, calc(100vw - 28px));
  max-height: min(86dvh, 900px);
  max-width: none;
  box-shadow: var(--shadow-modal);
  overflow: visible;
  background: var(--panel);
  color: var(--ink);
}

.detail-modal::backdrop {
  background: rgba(10, 16, 30, 0.55);
}

.detail-modal[open] {
  animation: modal-in 220ms var(--ease);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
}

/* The scroll container: the close button stays pinned to the card. */
.modal-body {
  display: block;
  max-height: min(86dvh, 900px);
  overflow-y: auto;
  border-radius: var(--radius-lg);
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(14, 24, 44, 0.72);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}

.modal-close:hover { background: rgba(14, 24, 44, 0.92); }

.detail-hero {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  background: #e8eef6;
}

.detail-content {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-subject {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
  text-wrap: balance;
}

.detail-meta { font-size: 13px; }

.doc-desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
}

.evidence-chain {
  font-size: 13px;
  background: var(--green-tint);
  border: 1px solid var(--green-line);
  color: #14522a;
  border-radius: 10px;
  padding: 9px 12px;
  line-height: 1.45;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.photo-link { display: block; }

.photo-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 9px;
  background: #e8eef6;
  display: block;
  transition: transform var(--dur) var(--ease);
}

.photo-link:hover .photo-thumb { transform: scale(1.03); }

.detail-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.copy-report {
  min-height: 42px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}

.copy-report:hover { background: var(--accent-deep); }

.detail-photo-count {
  font-size: 12.5px;
  color: var(--muted);
}

/* ---- reduced motion -------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .detail-modal[open] { animation: none; }
  .confirm-progress-fill,
  .row,
  .photo-thumb,
  .copy-report,
  .drawer-close,
  .modal-close { transition: none; }
}

/* ---- wide layout: panel becomes a side panel ------------------------------- */

@media (min-width: 900px) {
  .drawer {
    left: auto;
    top: 0;
    bottom: 0;
    right: 0;
    width: 420px;
    max-height: none;
    height: 100dvh;
    border-radius: 0;
    box-shadow: -8px 0 32px rgba(13, 20, 38, 0.14);
    border-left: 1px solid var(--line);
  }

  .drawer-body { padding: 14px 16px 24px; }

  .row-subject { white-space: normal; }

  #controls { padding: 12px 16px; }
}
