/* ------------------------------------------------------------------ *
 * Open House Festival — local browser
 * ------------------------------------------------------------------ */

:root {
  --ink: #17181a;
  --ink-soft: #5c6066;
  --line: #e3e1dc;
  --paper: #f5f4f1;
  --card: #ffffff;
  --accent: #e4002b;
  --accent-dark: #b30022;
  --blue: #2563eb;
  --green: #16a34a;
  --violet: #7c3aed;
  --amber: #d97706;
  --grey: #9aa0a6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 20, 25, .06), 0 8px 24px rgba(20, 20, 25, .07);
  --shadow-lg: 0 12px 40px rgba(20, 20, 25, .18);
  --topbar-h: 118px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.2; }

a { color: var(--accent); }

code {
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: .88em;
  background: rgba(20, 20, 25, .06);
  padding: .1em .35em;
  border-radius: 5px;
}

button { font: inherit; cursor: pointer; }

.muted { color: var(--ink-soft); }

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 22px 10px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 260px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  letter-spacing: .5px;
  border-radius: 12px;
  font-size: 15px;
  user-select: none;
  -webkit-user-select: none;
}

.brand h1 { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.subtitle { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-soft); }

.topbar-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.searchbox {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 11px;
  transition: border-color .15s, box-shadow .15s;
}
.searchbox:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(23,24,26,.08); }
.searchbox svg { width: 16px; height: 16px; fill: var(--ink-soft); flex: none; }
.searchbox input {
  border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 14px; width: 230px; color: var(--ink);
}

.segmented {
  display: flex;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
}
.segmented button {
  border: 0; background: transparent;
  padding: 6px 16px; border-radius: 8px;
  font-size: 14px; font-weight: 600; color: var(--ink-soft);
}
.segmented button.active { background: var(--ink); color: #fff; }

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  transition: border-color .15s, background .15s;
}
.ghost-button:hover { border-color: var(--ink); background: var(--paper); }

.primary-button {
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 700;
}
.primary-button:hover { background: var(--accent-dark); }

.link-button {
  border: 0; background: none; padding: 4px 2px;
  color: var(--accent); font-size: 13px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 2px;
}

.small-button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  transition: border-color .15s, background .15s;
}
.small-button:hover { border-color: var(--ink); background: var(--paper); }

/* ------------------------------------------------------------ filterbar */

.filterbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 22px 12px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-soft);
}

.chips { display: flex; gap: 7px; flex-wrap: wrap; }

.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
  transition: all .12s;
}
.chip:hover { border-color: var(--ink); }
.chip .n { font-size: 11px; color: var(--ink-soft); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.active .n { color: rgba(255,255,255,.7); }

.filter-toggles { display: flex; align-items: center; gap: 16px; margin-left: auto; flex-wrap: wrap; }

.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 600; cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* --------------------------------------------------------------- layout */

main {
  display: flex;
  min-height: calc(100vh - var(--topbar-h));
  position: relative;
}

.list-view {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
  padding: 22px;
  align-content: start;
}

.map-view { flex: 1; position: relative; min-height: calc(100vh - var(--topbar-h)); }
#map { position: absolute; inset: 0; background: #dfe4e8; }

.map-fallback {
  position: absolute; inset: 0; z-index: 500;
  display: grid; place-content: center; gap: 6px; text-align: center;
  background: #eef0f2; color: var(--ink-soft);
}

.map-legend {
  position: absolute; left: 12px; bottom: 22px; z-index: 700;
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12px;
  box-shadow: var(--shadow);
}
.map-legend span { display: flex; align-items: center; gap: 7px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.dot.saved { background: var(--blue); }
.dot.itinerary { background: var(--green); }
.dot.both { background: var(--violet); }
.dot.imported { background: var(--amber); }
.dot.favourited { background: var(--amber); }
.dot.other { background: var(--grey); }

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

.card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform .16s, box-shadow .16s;
  border: 1px solid transparent;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card.selected { border-color: var(--accent); }

.card-image {
  position: relative;
  aspect-ratio: 3 / 2;
  background: #e8e6e2;
  overflow: hidden;
}
.card-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-image .no-photo {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  color: var(--ink-soft); font-size: 13px;
  background: repeating-linear-gradient(45deg, #eceae6, #eceae6 12px, #e5e2dd 12px, #e5e2dd 24px);
}
.card-badges {
  position: absolute; top: 9px; left: 9px;
  display: flex; gap: 5px; flex-wrap: wrap;
}
.badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(23,24,26,.82);
  color: #fff;
  backdrop-filter: blur(4px);
}
.badge.saved { background: rgba(37,99,235,.92); }
.badge.itinerary { background: rgba(22,163,74,.92); }
.badge.imported { background: rgba(217,119,6,.95); }
.badge.favourited { background: rgba(217,119,6,.95); }

.star-button {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  cursor: pointer;
  z-index: 10;
  transition: transform 0.15s ease, background 0.15s ease;
  padding: 0;
}
.star-button:hover {
  transform: scale(1.1);
  background: #ffffff;
}
.star-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--ink-soft);
  stroke-width: 2;
  transition: fill 0.15s ease, stroke 0.15s ease;
}
.star-button.active svg {
  fill: #f59e0b;
  stroke: #d97706;
}

.drawer-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.drawer-title-row h2 {
  flex: 1;
  margin-bottom: 0 !important;
}
.drawer-title-row .star-button {
  position: static;
  flex-shrink: 0;
  background: var(--paper);
  box-shadow: none;
  border: 1px solid var(--line);
}
.drawer-title-row .star-button:hover {
  background: var(--line);
}

.card-body { padding: 14px 15px 15px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.card-body h3 { font-size: 16.5px; font-weight: 750; letter-spacing: -.01em; }
.card .types { font-size: 12px; color: var(--ink-soft); text-transform: lowercase; margin: 0; }
.card .address { font-size: 13px; color: var(--ink-soft); margin: 0; display: flex; gap: 5px; align-items: baseline; }
.card .address svg { flex: none; width: 12px; height: 12px; fill: var(--ink-soft); transform: translateY(1px); }

.plan-strip {
  margin-top: auto;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 12.5px;
  color: #14532d;
  display: flex; flex-direction: column; gap: 4px;
}
.plan-strip .plan-slot { display: flex; gap: 7px; align-items: baseline; }
.plan-strip strong { font-weight: 700; }
.plan-strip .slot-time { font-variant-numeric: tabular-nums; color: #166534; }

.day-pills { display: flex; gap: 5px; flex-wrap: wrap; margin-top: auto; }
.day-pill {
  font-size: 11px; font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px 7px;
  color: var(--ink-soft);
  background: #fff;
}
.day-pill.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.day-pill.plan { background: var(--green); color: #fff; border-color: var(--green); }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 70px 20px;
  color: var(--ink-soft);
}
.empty-state h2 { font-size: 20px; color: var(--ink); margin-bottom: 8px; }

/* --------------------------------------------------------------- drawer */

.drawer {
  position: fixed;
  top: var(--topbar-h, 0);
  right: 0; bottom: 0;
  width: min(460px, 100vw);
  background: #fff;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  transform: translateX(0);
  animation: drawer-in .22s ease;
  display: flex;
  flex-direction: column;
}
@keyframes drawer-in { from { transform: translateX(40px); opacity: .4; } to { transform: translateX(0); opacity: 1; } }
@keyframes drawer-in-mobile { from { transform: translateY(24px) scale(.98); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 16, 18, .5);
  z-index: 999;
}
@media (min-width: 861px) {
  .drawer-backdrop { display: none !important; }
}

.drawer-close {
  position: absolute; top: 12px; right: 12px; z-index: 10;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 0;
  background: rgba(23,24,26,.72);
  color: #fff;
  font-size: 20px; line-height: 1;
  display: grid; place-items: center;
}
.drawer-close:hover { background: rgba(23,24,26,.9); }

.drawer-content { overflow-y: auto; height: 100%; }

.drawer-hero { position: relative; aspect-ratio: 16 / 10; background: #e8e6e2; }
.drawer-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-credit {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 20px 14px 8px;
  font-size: 11px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
}
.photo-strip { display: flex; gap: 7px; padding: 10px 18px 0; overflow-x: auto; }
.photo-strip button { border: 2px solid transparent; border-radius: 8px; padding: 0; background: none; flex: none; overflow: hidden; }
.photo-strip button.active { border-color: var(--accent); }
.photo-strip img { width: 64px; height: 48px; object-fit: cover; display: block; }

.drawer-body { padding: 18px 20px 40px; }
.drawer-body h2 { font-size: 23px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 6px; }
.drawer .types { font-size: 12.5px; color: var(--ink-soft); text-transform: lowercase; margin: 0 0 4px; }
.drawer .design { font-size: 13px; font-weight: 600; color: var(--ink); margin: 0 0 12px; }

.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
.drawer-actions a, .drawer-actions button {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 650;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 12px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}
.drawer-actions a:hover, .drawer-actions button:hover { border-color: var(--ink); }
.drawer-actions .primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.drawer-actions .primary:hover { background: var(--accent-dark); }

.drawer-section { margin-top: 22px; }
.drawer-section > h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-soft); margin-bottom: 10px;
}

.description { font-size: 14.5px; line-height: 1.55; color: #2c2e33; }

.plan-list { display: flex; flex-direction: column; gap: 8px; }
.plan-item {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 10px 12px;
}
.plan-item .when { font-size: 13.5px; font-weight: 750; color: #14532d; }
.plan-item .what { font-size: 13px; color: #166534; margin-top: 2px; }

.day-group { margin-bottom: 14px; }
.day-group h4 {
  font-size: 13.5px;
  font-weight: 750;
  padding-bottom: 5px;
  margin-bottom: 7px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: baseline; gap: 8px;
}
.day-group h4 .iso { font-size: 11px; color: var(--ink-soft); font-weight: 500; }
.day-group.plan-day h4 { color: #15803d; border-color: #bbf7d0; }
.activity {
  display: flex; gap: 12px;
  padding: 7px 0;
  font-size: 13.5px;
}
.activity + .activity { border-top: 1px dashed var(--line); }
.activity .time { font-variant-numeric: tabular-nums; font-weight: 700; flex: none; width: 92px; color: var(--ink); }
.activity .what { line-height: 1.45; }
.activity .act-type { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); display: block; margin-bottom: 2px; }
.activity .act-desc { color: var(--ink-soft); font-size: 12.5px; margin-top: 3px; }
.activity .act-action { font-size: 11.5px; color: var(--green); font-weight: 600; margin-top: 3px; }

.info-block { border-top: 1px solid var(--line); }
.info-block:last-child { border-bottom: 1px solid var(--line); }
.info-block summary {
  cursor: pointer;
  padding: 11px 2px;
  font-size: 14px;
  font-weight: 700;
  list-style: none;
  display: flex; justify-content: space-between; align-items: center;
}
.info-block summary::-webkit-details-marker { display: none; }
.info-block summary::after { content: "+"; font-size: 17px; color: var(--ink-soft); font-weight: 400; }
.info-block[open] summary::after { content: "–"; }
.info-block .info-body { padding: 0 2px 14px; font-size: 13.5px; line-height: 1.5; color: #2c2e33; }
.info-body dl { margin: 0; }
.info-body dt { font-weight: 700; margin-top: 8px; }
.info-body dt:first-child { margin-top: 0; }
.info-body dd { margin: 2px 0 0; }
.info-body ul { margin: 4px 0 0; padding-left: 18px; }
.info-body p + p { margin-top: 8px; }

.about-block { margin-bottom: 16px; }
.about-block h4 { font-size: 14.5px; font-weight: 750; margin-bottom: 5px; }
.about-block p { font-size: 13.5px; line-height: 1.55; color: #2c2e33; margin: 0 0 8px; }

.website-list { display: flex; flex-direction: column; gap: 5px; }
.website-list a { font-size: 13.5px; word-break: break-all; }

.stub-note {
  background: #fffbeb; border: 1px solid #fde68a; color: #78350f;
  border-radius: 10px; padding: 12px; font-size: 13px; line-height: 1.5;
}

/* --------------------------------------------------------------- modal */

.modal {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(15, 16, 18, .55);
  display: grid; place-items: center;
  padding: 20px;
}
.modal-window {
  position: relative;
  background: #fff;
  border-radius: 16px;
  width: min(620px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: 26px 26px 22px;
  box-shadow: var(--shadow-lg);
  animation: drawer-in .2s ease;
}
.modal-window h2 { font-size: 20px; margin-bottom: 10px; }
.modal-window > p { font-size: 13.5px; line-height: 1.55; }

.dropzone {
  margin: 16px 0;
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 26px 18px;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone.dragover { border-color: var(--accent); background: #fff5f6; }
.dropzone p { margin: 4px 0; font-size: 14px; }

.import-result { margin: 12px 0; font-size: 13.5px; line-height: 1.5; }
.import-result ul { margin: 8px 0 0; padding-left: 20px; max-height: 180px; overflow-y: auto; }
.import-result li { margin-bottom: 3px; }

.modal-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* --------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 10px;
  z-index: 1300;
  box-shadow: var(--shadow-lg);
  max-width: min(560px, 90vw);
}

/* ---------------------------------------------------------- responsive */

@media (max-width: 860px) {
  .topbar-main { padding: 10px 14px 8px; }
  .searchbox input { width: 100%; }
  .searchbox { flex: 1 1 180px; }
  .filterbar { padding: 4px 14px 10px; }
  .filter-toggles { margin-left: 0; }
  .list-view { padding: 14px; gap: 14px; }
  .map-legend { display: none; }
  .drawer {
    top: 12px;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    border-radius: 16px;
    overflow: hidden;
    animation: drawer-in-mobile .22s ease;
  }

  /* Horizontal scrolling chips for map view on mobile */
  body.view-map .filterbar {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 12px;
    padding: 6px 14px 8px;
  }
  body.view-map .filter-label {
    grid-column: 1;
    grid-row: 1;
    white-space: nowrap;
    align-self: center;
  }
  body.view-map .chips {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    align-items: center;
    padding-bottom: 2px;
  }
  body.view-map .chip {
    flex: none;
  }
  body.view-map .chips::-webkit-scrollbar {
    display: none;
  }
  body.view-map .chips {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  body.view-map .filter-toggles {
    grid-column: 1 / span 2;
    grid-row: 2;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    margin-left: 0;
  }
}
