/*
 * Hand-written CSS for the static events page.
 *
 * Deliberately no Tailwind and no build step: the point of this page is to be
 * plain HTML/CSS/JS over the same API. Every colour, radius, shadow and weight
 * comes from the tokens in theme.css, so it tracks the Svelte app's design
 * rather than re-inventing one.
 */

@font-face {
  font-family: 'Barlow Condensed';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/ui/fonts/barlow-condensed-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow Condensed';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/ui/fonts/barlow-condensed-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow Condensed';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/ui/fonts/barlow-condensed-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow Condensed';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/ui/fonts/barlow-condensed-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow Condensed';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/ui/fonts/barlow-condensed-latin-800-normal.woff2') format('woff2');
}

:root {
  --font-sans:
    ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Barlow Condensed', var(--font-sans);
  --shell-max: 68rem;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-weight: var(--weight-body);
  line-height: 1.5;
}

a {
  color: inherit;
}

/*
 * `el.hidden = true` is used throughout the static pages to toggle
 * visibility. The browser's own `[hidden] { display: none }` UA-stylesheet
 * rule loses to *any* author rule that sets `display` on the same element
 * (CSS origin beats specificity), and several classes here do — `.filter`
 * being the one that first caught this. Restated as an author rule with
 * !important so `hidden` always wins, regardless of what else the element's
 * class sets `display` to.
 */
[hidden] {
  display: none !important;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 20;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-foreground);
}

.skip-link:focus {
  left: 0.75rem;
  top: 0.75rem;
}

:where(a, button, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* Masthead ---------------------------------------------------------------- */

.masthead {
  border-bottom: 1px solid var(--border);
  background: color-mix(in hsl, var(--card) 92%, var(--background));
  box-shadow: var(--shadow-edge);
}

.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 1rem 1.25rem;
}

.masthead-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 0.5rem;
  height: 2.25rem;
  border-radius: calc(var(--radius) / 2);
  background: linear-gradient(180deg, var(--primary), var(--accent));
}

.brand-kicker {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: var(--weight-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: var(--weight-display);
  line-height: 1.1;
}

.masthead-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.masthead-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.field-input.compact {
  width: auto;
  height: 2.25rem;
  padding: 0 0.5rem;
  font-size: 0.8125rem;
}

.masthead-nav a {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: var(--weight-label);
  text-decoration: none;
  transition: background 160ms ease;
}

.masthead-nav a:hover {
  background: color-mix(in hsl, var(--secondary) 70%, transparent);
}

.masthead-nav a[aria-current='page'] {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-edge);
}

/* Shell ------------------------------------------------------------------- */

.shell {
  display: grid;
  gap: 1.25rem;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 1.25rem;
}

.section-heading {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--weight-heading);
  font-size: 1.25rem;
  letter-spacing: 0;
}

/* Filters ----------------------------------------------------------------- */

.control-strip {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in hsl, var(--card) 88%, var(--background));
  box-shadow: var(--shadow-edge);
}

.filters {
  padding: 1rem;
}

.filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.875rem;
}

.filters-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.filter {
  display: grid;
  gap: 0.375rem;
}

.filter > span {
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: var(--weight-label);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field-input {
  width: 100%;
  height: 2.5rem;
  padding: 0 0.75rem;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  background: color-mix(in hsl, var(--background) 84%, transparent);
  color: var(--foreground);
  font: inherit;
  font-size: 0.875rem;
  box-shadow: var(--shadow-edge);
}

.field-input::placeholder {
  color: color-mix(in hsl, var(--muted-foreground), transparent 12%);
}

.filter-toggles {
  margin-top: 0.875rem;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: var(--weight-label);
}

.ghost-button {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--foreground);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: var(--weight-label);
  cursor: pointer;
  transition: background 160ms ease;
}

.ghost-button:hover {
  background: color-mix(in hsl, var(--secondary) 70%, transparent);
}

/* Results ----------------------------------------------------------------- */

.results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.results-count {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.8125rem;
  font-weight: var(--weight-label);
}

.event-list {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.module-card {
  position: relative;
  border: 1px solid color-mix(in hsl, var(--border), var(--primary) 12%);
  border-radius: var(--radius);
  background: color-mix(in hsl, var(--card) 94%, var(--background));
  box-shadow: var(--shadow-edge);
}

.module-card::before {
  position: absolute;
  inset: -1px auto -1px -1px;
  width: 3px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: linear-gradient(
    180deg,
    var(--primary),
    transparent 52%,
    var(--accent)
  );
  opacity: 0;
  content: '';
  transition: opacity 160ms ease;
}

.module-card:hover::before {
  opacity: 1;
}

.event {
  padding: 1rem;
}

.event-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.event-title {
  margin: 0;
  font-size: 1rem;
  font-weight: var(--weight-strong);
  line-height: 1.3;
}

.event-host {
  margin: 0.25rem 0 0;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  font-weight: 500;
}

.venue-link {
  color: inherit;
  text-decoration: none;
}

.venue-link:hover,
.venue-link:focus-visible {
  text-decoration: underline;
}

.event-when {
  margin: 0.625rem 0 0;
  font-size: 0.875rem;
  font-weight: var(--weight-label);
}

.event-description {
  /* Imported descriptions run to 1000 characters; clamp so one verbose event
     cannot dominate the list. The full text stays in the DOM for search. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  margin: 0.5rem 0 0;
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.75rem;
}

.chip {
  padding: 0.1875rem 0.5rem;
  border: 1px solid color-mix(in hsl, var(--border), transparent 20%);
  border-radius: calc(var(--radius) / 1.5);
  background: color-mix(in hsl, var(--secondary) 55%, transparent);
  font-size: 0.75rem;
  font-weight: var(--weight-label);
}

.chip[data-tone='unlocated'] {
  border-color: color-mix(in hsl, var(--warning), transparent 55%);
  background: color-mix(in hsl, var(--warning), transparent 86%);
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
  padding: 0.25rem 0.5rem;
  border: 1px solid color-mix(in hsl, var(--primary), transparent 75%);
  border-radius: calc(var(--radius) / 1.5);
  background: color-mix(in hsl, var(--primary), transparent 88%);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: var(--weight-label);
  text-decoration: none;
  box-shadow: var(--shadow-edge);
}

.notice,
.empty {
  margin: 0;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in hsl, var(--card) 92%, var(--background));
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

.notice {
  border-color: color-mix(in hsl, var(--destructive), transparent 60%);
  color: var(--destructive);
}

/* Results split (list + map), used by the merged /events/ page ------------- */

.results-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

@media (min-width: 64rem) {
  .results-split {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }

  .map-panel {
    position: sticky;
    top: 1.25rem;
  }
}

.event-list-scroll {
  max-height: 40rem;
  overflow-y: auto;
}

.event.selected {
  border-color: var(--primary);
  background: color-mix(in hsl, var(--card) 84%, var(--primary) 10%);
}

.event.selected::before {
  opacity: 1;
}

/* Map ----------------------------------------------------------------------
   Ported from the equivalent rules in src/app.css (`.city-map-marker*`,
   `.city-map-legend`, `.city-legend-*`, `.maplibregl-popup-*`) so the static
   map page matches the Svelte app's map styling without a build step. Same
   token names, same look. */

.map-frame {
  position: relative;
  height: 32rem;
  min-height: 22rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--map-land);
  box-shadow: var(--shadow-edge);
}

.map-canvas {
  position: absolute;
  inset: 0;
}

.city-map-marker {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--map-marker-border);
  border-radius: 0.45rem;
  background: var(--map-marker-bg);
  color: var(--marker-color, var(--map-marker-fg));
  cursor: pointer;
}

.city-map-marker svg,
.city-legend-dot svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.city-map-marker-food {
  --marker-color: var(--marker-food);
  border-color: var(--marker-food);
}

.city-map-marker-park {
  --marker-color: var(--marker-park);
  border-color: var(--marker-park);
}

.city-map-marker-culture {
  --marker-color: var(--marker-culture);
  border-color: var(--marker-culture);
}

.city-map-marker-nightlife {
  --marker-color: var(--marker-nightlife);
  border-color: var(--marker-nightlife);
}

.city-map-marker-event {
  --marker-color: var(--marker-event);
  border-color: var(--marker-event);
}

.city-map-marker-other {
  --marker-color: var(--marker-other);
  border-color: var(--marker-other);
}

.city-map-marker-event-shape {
  border-radius: 999px;
}

.city-map-legend {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-width: min(32rem, calc(100% - 2rem));
  border: 1px solid hsl(0 0% 100% / 18%);
  background: var(--map-legend-bg);
  padding: 0.6rem;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-edge);
}

.city-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--map-legend-fg);
  font-size: 0.72rem;
  font-weight: var(--weight-label);
}

.city-legend-dot {
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border: 1px solid currentColor;
  border-radius: 0.3rem;
  color: var(--map-marker-fg);
  background: var(--map-legend-dot-bg);
}

.city-legend-dot-food {
  color: var(--marker-food);
}

.city-legend-dot-park {
  color: var(--marker-park);
}

.city-legend-dot-culture {
  color: var(--marker-culture);
}

.city-legend-dot-nightlife {
  color: var(--marker-nightlife);
}

.city-legend-dot-event {
  color: var(--marker-event);
}

.city-legend-dot-other {
  color: var(--marker-other);
}

.maplibregl-popup-content {
  display: grid;
  gap: 0.2rem;
  border: 1px solid var(--popup-border);
  border-radius: 0;
  background: var(--popup-bg);
  color: var(--popup-fg);
  padding: 0.65rem 0.75rem;
  box-shadow: var(--popup-shadow);
}

.maplibregl-popup-content strong {
  color: var(--popup-fg);
  font-size: 0.9rem;
  font-weight: var(--weight-heading);
  line-height: 1.1;
}

.maplibregl-popup-content span {
  display: block;
  color: var(--popup-muted);
  font-size: 0.78rem;
  font-weight: var(--weight-body);
}

.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
  border-bottom-color: var(--popup-bg);
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
  border-top-color: var(--popup-bg);
}

.maplibregl-popup-anchor-left .maplibregl-popup-tip {
  border-right-color: var(--popup-bg);
}

.maplibregl-popup-anchor-right .maplibregl-popup-tip {
  border-left-color: var(--popup-bg);
}

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

.footer {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  color: var(--muted-foreground);
  font-size: 0.8125rem;
}

.footer p {
  margin: 0;
}

.footer-note {
  margin-top: 0.25rem;
  opacity: 0.8;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* Buttons, form feedback --------------------------------------------------- */

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: 2.25rem;
  padding: 0.375rem 0.875rem;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-foreground);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: var(--weight-label);
  cursor: pointer;
  box-shadow: var(--shadow-edge);
  transition: background 160ms ease;
}

.primary-button:hover {
  background: color-mix(in hsl, var(--primary) 86%, var(--foreground));
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.danger-button {
  border-color: color-mix(in hsl, var(--destructive), transparent 55%);
  color: var(--destructive);
}

.field-textarea {
  height: auto;
  min-height: 4.5rem;
  padding: 0.5rem 0.75rem;
  resize: vertical;
}

.field-hint {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  line-height: 1.4;
}

.form-error {
  margin: 0;
  color: var(--destructive);
  font-size: 0.8125rem;
  font-weight: var(--weight-label);
}

.form-error:empty {
  display: none;
}

.field-input[aria-invalid='true'] {
  border-color: var(--destructive);
}

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

/* Masthead account control (atproto sign-in) ------------------------------ */

.account {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.account:empty {
  display: none;
}

.account .ghost-button {
  height: 2.25rem;
}

.account-handle {
  max-width: 14rem;
  overflow: hidden;
  font-size: 0.8125rem;
  font-weight: var(--weight-label);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-popover {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 20;
  width: min(20rem, calc(100vw - 2.5rem));
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-soft), var(--shadow-edge);
}

.account-form {
  display: grid;
  gap: 0.5rem;
}

.account-hint {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  line-height: 1.4;
}

/* Narrow screens: the masthead controls wrap, so the account control can sit
   anywhere in the row. Open the form in-flow, full width, instead of as an
   absolutely positioned popover that could run off-screen. */
@media (max-width: 40rem) {
  .account.open {
    flex-basis: 100%;
    flex-wrap: wrap;
  }

  .account-popover {
    position: static;
    width: 100%;
  }
}

/* ?notice= banner under the masthead -------------------------------------- */

.site-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  max-width: var(--shell-max);
  margin: 0 auto 0.75rem;
  padding: 0.5rem 0.75rem 0.5rem 1rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  background: var(--card);
  font-size: 0.875rem;
}

.site-notice[data-tone='success'] {
  border-left-color: var(--success);
}

.site-notice[data-tone='error'] {
  border-left-color: var(--destructive);
}

.site-notice p {
  margin: 0;
}

.site-notice-dismiss {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted-foreground);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.site-notice-dismiss:hover {
  background: color-mix(in hsl, var(--secondary) 70%, transparent);
}

@media (max-width: 70rem) {
  .site-notice {
    margin-inline: 1.25rem;
  }
}
