/* Agenda PT — azulejo blue on warm limestone. */
:root {
  color-scheme: light dark;
  --bg: #f7f4ef;
  --bg-elev: #ffffff;
  --bg-sunk: #efeae1;
  --ink: #17212b;
  --ink-soft: #5a6673;
  --ink-faint: #8b95a1;
  --line: #e2dbd0;
  --accent: #0f4c75;
  --accent-soft: #e3edf5;
  --accent-ink: #ffffff;
  --warm: #c1502e;
  --ok: #2f7d5b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 33, 43, .06), 0 8px 24px rgba(23, 33, 43, .07);
  --header-h: 56px;
  --filters-h: 148px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161b;
    --bg-elev: #1a2027;
    --bg-sunk: #0d1116;
    --ink: #e9eef3;
    --ink-soft: #a3b0bd;
    --ink-faint: #75828f;
    --line: #2a323b;
    --accent: #62b0e8;
    --accent-soft: #1c2c3a;
    --accent-ink: #08131d;
    --warm: #e08360;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
/* Author `display` rules beat the UA's `[hidden] { display: none }`, which
   silently un-hid the radius slider. Make the attribute authoritative. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.visually-hidden, .skip:not(:focus) {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip:focus { position: fixed; top: 8px; left: 8px; z-index: 999; background: var(--bg-elev); padding: .5rem .75rem; border-radius: 8px; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: .75rem;
  height: var(--header-h); padding: 0 .85rem;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .45rem; flex: 0 0 auto; }
.brand .mark { width: 26px; height: 26px; }
.brand-name { font-weight: 700; letter-spacing: -.02em; font-size: 1.02rem; }
.brand-name em { font-style: normal; color: var(--warm); }
@media (max-width: 640px) { .brand-name { display: none; } }

.searchbar {
  flex: 1 1 auto; display: flex; align-items: center; gap: .5rem;
  background: var(--bg-sunk); border: 1px solid var(--line);
  border-radius: 999px; padding: .3rem .75rem; max-width: 620px;
}
.searchbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.searchbar input { flex: 1; border: 0; background: none; outline: none; min-width: 0; padding: .25rem 0; }
.searchbar .ico { opacity: .6; font-size: .9em; }
.searchbar .clear { border: 0; background: none; cursor: pointer; font-size: 1.2rem; color: var(--ink-faint); padding: 0 .2rem; }

.topbar-actions { display: flex; gap: .35rem; flex: 0 0 auto; }
.pill {
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--ink);
  border-radius: 999px; padding: .38rem .8rem; cursor: pointer; white-space: nowrap;
}
.pill:hover { border-color: var(--accent); }
.pill.ghost { background: none; }
.lang { font-weight: 600; font-size: .8rem; letter-spacing: .04em; }

/* --------------------------------------------------------------- filters */
.filters {
  position: sticky; top: var(--header-h); z-index: 30;
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding: .55rem .85rem .5rem; display: grid; gap: .45rem;
}
.row { display: flex; gap: .4rem; align-items: center; overflow-x: auto; scrollbar-width: none; }
.row::-webkit-scrollbar { display: none; }
.row-cats { padding-bottom: .1rem; }

.chip {
  border: 1px solid var(--line); background: var(--bg-elev);
  border-radius: 999px; padding: .34rem .75rem; cursor: pointer;
  white-space: nowrap; font-size: .88rem; color: var(--ink-soft);
  display: inline-flex; align-items: center; gap: .35rem;
}
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.chip .n { opacity: .6; font-size: .78em; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .n { opacity: .8; }
.chip-date { padding: .18rem .5rem; gap: .25rem; cursor: default; }
.chip-date input { border: 0; background: none; font-size: .82rem; width: 8.4em; }
.chip-date .dash { opacity: .5; }

.where {
  position: relative; display: flex; align-items: center; gap: .4rem;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 999px; padding: .28rem .5rem .28rem .75rem; min-width: 240px; flex: 1 1 260px; max-width: 420px;
}
.where:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.where input { flex: 1; border: 0; background: none; outline: none; min-width: 0; font-size: .88rem; }
.mini { border: 0; background: none; cursor: pointer; font-size: .95rem; padding: .1rem .25rem; border-radius: 8px; }
.mini:hover { background: var(--bg-sunk); }
.suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 50;
  margin: 0; padding: .25rem; list-style: none; max-height: 46vh; overflow: auto;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.suggest li { padding: .45rem .6rem; border-radius: 8px; cursor: pointer; font-size: .88rem; display: flex; gap: .5rem; align-items: baseline; }
.suggest li:hover, .suggest li[aria-selected="true"] { background: var(--accent-soft); }
.suggest .kind { margin-left: auto; font-size: .74rem; color: var(--ink-faint); }

.radius { display: flex; align-items: center; gap: .45rem; font-size: .82rem; color: var(--ink-soft); }
.radius input { width: 110px; accent-color: var(--accent); }
.radius output { font-variant-numeric: tabular-nums; min-width: 4.2em; }

/* ---------------------------------------------------------------- layout */
.layout {
  display: grid; grid-template-columns: minmax(360px, 460px) 1fr;
  height: calc(100dvh - var(--header-h) - var(--filters-h));
}
.listpane { overflow-y: auto; border-right: 1px solid var(--line); overscroll-behavior: contain; }
.mappane { position: relative; }
#map { position: absolute; inset: 0; background: var(--bg-sunk); }

.listhead {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .55rem .85rem .35rem; position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.count { margin: 0; font-size: .82rem; color: var(--ink-soft); }
.listhead-actions { display: flex; align-items: center; gap: .4rem; }
.mini-select { border: 1px solid var(--line); background: var(--bg-elev); border-radius: 8px; padding: .2rem .35rem; font-size: .8rem; }
.mini-link { text-decoration: none; font-size: 1rem; padding: .15rem .3rem; border-radius: 8px; }
.mini-link:hover { background: var(--bg-sunk); }

.cards { list-style: none; margin: 0; padding: 0 .6rem .6rem; display: grid; gap: .5rem; }
.card {
  display: grid; grid-template-columns: 84px 1fr; gap: .7rem;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .55rem; cursor: pointer; text-align: left; width: 100%; align-items: start;
}
.card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.card .thumb {
  width: 84px; height: 84px; border-radius: 10px; object-fit: cover; background: var(--bg-sunk);
  display: grid; place-items: center; font-size: 1.6rem; overflow: hidden;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .title { display: block; margin: 0 0 .2rem; font-size: .95rem; line-height: 1.28; font-weight: 620; }
.card .meta { margin: 0; font-size: .8rem; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: .1rem .5rem; }
.card .when { color: var(--accent); font-weight: 600; }
/* Countdown next to the absolute date — secondary, never competing with it. */
.card .rel { color: var(--ink-faint); }
.card .tags { display: flex; gap: .3rem; margin-top: .3rem; flex-wrap: wrap; }
.tag {
  font-size: .7rem; padding: .1rem .45rem; border-radius: 999px;
  background: var(--bg-sunk); color: var(--ink-soft); white-space: nowrap;
}
.tag.free { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); font-weight: 600; }
.tag.dist { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.listfoot { padding: .5rem .85rem 2.5rem; display: grid; justify-items: center; gap: .5rem; }
.empty { color: var(--ink-soft); text-align: center; font-size: .9rem; max-width: 26rem; }
.skeleton { height: 96px; border-radius: var(--radius); background:
  linear-gradient(90deg, var(--bg-sunk) 25%, color-mix(in srgb, var(--bg-sunk) 60%, var(--bg-elev)) 50%, var(--bg-sunk) 75%);
  background-size: 300% 100%; animation: sk 1.3s infinite; }
@keyframes sk { from { background-position: 100% 0 } to { background-position: -100% 0 } }

.area-btn {
  position: absolute; top: .7rem; left: 50%; transform: translateX(-50%); z-index: 500;
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--ink);
  border-radius: 999px; padding: .42rem .95rem; cursor: pointer; box-shadow: var(--shadow); font-size: .85rem;
}

.fab { display: none; }

/* ---------------------------------------------------------------- drawer */
.scrim { position: fixed; inset: 0; background: rgba(10,14,18,.45); z-index: 60; }
.drawer {
  position: fixed; z-index: 70; background: var(--bg-elev);
  top: 0; right: 0; bottom: 0; width: min(460px, 100vw);
  border-left: 1px solid var(--line); overflow-y: auto; box-shadow: var(--shadow);
}
.drawer-inner { padding: 0 0 3rem; }
.dhero { position: relative; aspect-ratio: 16/9; background: var(--bg-sunk); overflow: hidden; }
.dhero img { width: 100%; height: 100%; object-fit: cover; }
.dhero .noimg { display: grid; place-items: center; height: 100%; font-size: 3rem; }
.dclose {
  position: absolute; top: .6rem; right: .6rem; border: 0; border-radius: 999px;
  width: 34px; height: 34px; background: rgba(255,255,255,.92); color: #17212b; cursor: pointer; font-size: 1.1rem;
}
.dbody { padding: .9rem 1.05rem; display: grid; gap: .8rem; }
.dbody h2 { margin: 0; font-size: 1.22rem; line-height: 1.25; }
.dfacts { display: grid; gap: .45rem; font-size: .9rem; }
.dfact { display: grid; grid-template-columns: 1.4rem 1fr; gap: .5rem; align-items: start; }
.dfact span:first-child { opacity: .75; }
.ddesc { font-size: .9rem; color: var(--ink-soft); white-space: pre-wrap; max-height: 22rem; overflow: auto; }
.dactions { display: flex; gap: .45rem; flex-wrap: wrap; }
.dactions .pill.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
#dmap { height: 190px; border-radius: 12px; border: 1px solid var(--line); }

.dlg { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; max-width: 34rem; background: var(--bg-elev); color: var(--ink); }
.dlg::backdrop { background: rgba(10,14,18,.5); }
.dlg table { border-collapse: collapse; font-size: .85rem; width: 100%; }
.dlg td { padding: .18rem .5rem .18rem 0; }
.dlg td:last-child { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-soft); }

/* map bits */
.leaflet-container { font: inherit; background: var(--bg-sunk); }
.pin-emoji {
  display: grid; place-items: center; width: 30px; height: 30px; font-size: 15px;
  background: var(--bg-elev); border: 2px solid var(--accent); border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg); box-shadow: var(--shadow);
}
.pin-emoji > span { transform: rotate(45deg); }
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
  background: var(--accent); color: var(--accent-ink); font: 600 12px/30px var(--font);
}
.leaflet-popup-content { margin: .6rem .7rem; font-size: .85rem; }
.leaflet-popup-content b { display: block; margin-bottom: .15rem; }

/* --------------------------------------------------------------- mobile */
@media (max-width: 860px) {
  :root { --filters-h: 152px; }
  .layout { grid-template-columns: 1fr; }
  .listpane { border-right: 0; }
  .mappane { display: none; }
  body.map-view .listpane { display: none; }
  body.map-view .mappane { display: block; }
  .fab {
    display: grid; place-items: center; position: fixed; right: 1rem; bottom: 1.1rem; z-index: 55;
    width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line);
    background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); cursor: pointer; font-size: 1.25rem;
  }
  .drawer { top: auto; left: 0; width: 100%; height: 86dvh; border-radius: 18px 18px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .where { max-width: none; }
}
