:root {
  --accent: #4fc3b1;
  --accent-dark: #2f9c8c;
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #202124;
  --muted: #6b7280;
  --border: #e3e5e8;
  --late: #e8622c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Indeterminate top progress bar, shown while any request is in flight.
   Fixed at the very top so it stays visible even when results are scrolled
   off-screen (e.g. after tapping a filter on a slow connection). */
.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 100;
  background: rgba(79, 195, 177, 0.2);
  overflow: hidden;
}
.loading-bar[hidden] { display: none; }
.loading-bar span {
  display: block;
  height: 100%;
  width: 40%;
  background: var(--accent);
  animation: loading-slide 1s ease-in-out infinite;
}
@keyframes loading-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--text);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 20px; margin: 0; }
.topbar-brand { display: flex; align-items: baseline; gap: 10px; }
.topbar-brand .tagline { font-size: 13px; color: rgba(255,255,255,0.72); font-style: italic; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-home { color: inherit; text-decoration: none; }
.topbar-link { color: #fff; text-decoration: none; font-size: 14px; font-weight: 600; opacity: 0.9; }
.topbar-link:hover { opacity: 1; text-decoration: underline; }
.last-updated { color: rgba(255,255,255,0.72); text-decoration: none; font-size: 13px; white-space: nowrap; }
.last-updated:hover { color: #fff; }

/* The header day selector is a mobile-only affordance; on desktop the day
   chips live in the sidebar filter group instead. */
.topbar-day { display: none; }

/* About page: a single readable column of prose. */
.about {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  line-height: 1.55;
}
.about h2 { font-size: 22px; margin: 0 0 12px; }
.about h3 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px; }
.about-section { margin-top: 28px; }
.about-section ul { margin: 0; padding-left: 20px; }
.about-section li { margin-bottom: 4px; }
.about a { color: var(--accent-dark); }
.about-tmdb {
  border-top: 1px solid var(--border);
  padding-top: 24px;
}
.about-tmdb .tmdb-logo { width: 180px; max-width: 60%; height: auto; display: block; margin-bottom: 12px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: wait; }
.btn-secondary { background: #eef2f2; color: var(--text); }
.btn-secondary:hover { background: #e2e8e8; }
.btn-block { width: 100%; margin-bottom: 6px; }

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  padding: 20px;
  align-items: start;
}

.filters {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  position: sticky;
  top: 70px;
}

.filter-group { margin-bottom: 18px; }
.filter-group h2,
.filter-collapsible > summary { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px; }

/* Collapsible filter groups (genre, age rating): the <summary> matches the
   .filter-group h2 heading and gets a rotating disclosure marker. */
.filter-collapsible > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.filter-collapsible > summary::-webkit-details-marker { display: none; }
.filter-collapsible > summary::after {
  content: "▸";
  margin-left: auto;
  transition: transform .15s ease;
}
.filter-collapsible[open] > summary::after { transform: rotate(90deg); }

/* Area list nested inside the Περιοχή group: sits under the Κοντά μου / Τ.Κ.
   controls and is collapsed by default. */
.filter-subgroup { margin: 10px 0 0; }
.filter-subgroup > summary { margin-bottom: 6px; }

/* The filters drawer chrome is desktop-hidden; the mobile media query below
   turns the sidebar into an off-canvas drawer and reveals these. */
.mobile-filter-bar { display: none; }
.filters-close { display: none; }
.filters-backdrop { display: none; }
.filter-group select, .filter-group input[type="text"] {
  width: 100%;
  padding: 7px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 14px;
}
.stacked-label { display: block; font-size: 12px; margin-bottom: 4px; color: var(--muted); }

/* Location / Τ.Κ. sort status. Empty = hidden; otherwise a coloured pill so
   the active distance-sort (and any error) is obvious at a glance. */
.geo-status { margin-top: 8px; font-size: 12px; }
.geo-status:empty { display: none; }
.geo-status--active,
.geo-status--error,
.geo-status--loading {
  display: block;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 600;
  line-height: 1.3;
}
.geo-status--active { background: var(--accent); color: #fff; }
.geo-status--loading { background: #eef2f2; color: var(--muted); font-weight: 500; }
.geo-status--error { background: #fdecec; color: #c0392b; }

.tk-row { display: flex; gap: 6px; margin-top: 6px; }
.tk-row input {
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 14px;
}
.tk-row .btn { padding: 7px 10px; white-space: nowrap; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.checkbox-list { max-height: 132px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.checkbox-list label { font-size: 13px; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.checkbox-list .count { color: var(--muted); font-size: 11px; }

.results { min-height: 60vh; }
#resultsMeta { margin-bottom: 10px; }

.movie-grid {
  display: grid;
  /* min(340px, 100%) keeps a single column from overflowing on phones
     narrower than 340px instead of forcing a horizontal scrollbar. */
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
  gap: 16px;
}

.movie-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  gap: 12px;
}
/* Left column: the poster plus the ratings and source links stacked beneath
   it, so the card body (title + showtimes) stays compact and the otherwise
   empty space under the poster is put to use. */
.poster-col { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; width: 92px; flex-shrink: 0; }
.movie-card .poster {
  width: 92px;
  height: 130px;
  object-fit: cover;
  border-radius: 8px;
  background: #ddd;
  flex-shrink: 0;
}
.movie-body { flex: 1; min-width: 0; }
.movie-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.movie-title { font-size: 16px; font-weight: 700; margin: 0; }
.movie-original-title { font-size: 12px; color: var(--muted); margin: 0 0 4px; }
.movie-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.tag { background: #eef2f2; border-radius: 10px; padding: 2px 8px; font-size: 11px; color: var(--muted); }
.tag-age { background: #f0e6f4; color: #6a3d82; font-weight: 700; cursor: help; }
.movie-overview {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text);
  margin: 0 0 10px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}
.movie-overview:hover { color: var(--accent); }
.movie-overview:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.modal-movie-head { display: flex; gap: 16px; margin-bottom: 14px; }
.modal-movie-head .poster { width: 110px; height: 165px; flex: none; }
.modal-movie-meta { min-width: 0; }
.modal-movie-meta .modal-title { margin: 0 0 4px; }
.modal-overview { font-size: 14px; line-height: 1.5; color: var(--text); margin: 0 0 14px; }
.modal-credit { font-size: 13px; color: var(--text); margin: 0 0 6px; }
.modal-credit .credit-label { color: var(--muted); font-weight: 700; }

.ratings-row { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; margin-bottom: 8px; }
.rating-badge { display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.rating-badge b { font-size: 13px; }
/* Under the poster the ratings stack vertically in the narrow (92px) column.
   Each badge is a 3-column grid (icon | source label | value) with the same
   fixed column widths, so every value lines up on the same vertical edge. */
.poster-col .ratings-row { display: flex; flex-direction: column; gap: 4px; width: 100%; margin-bottom: 0; font-size: 11px; }
.poster-col .rating-badge {
  display: grid;
  grid-template-columns: 16px 30px 1fr;
  align-items: center;
  column-gap: 3px;
  width: 100%;
  white-space: nowrap;
}
.poster-col .r-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; font-size: 12px; line-height: 1; }
.poster-col .r-icon .r-fav { width: 15px; height: 15px; display: block; border-radius: 3px; }
.poster-col .r-label { color: var(--muted); font-size: 10px; overflow: hidden; }
.poster-col .r-val { font-variant-numeric: tabular-nums; }
.poster-col .r-val b { font-size: 12px; }
.poster-col .rating-badge.muted { display: block; color: var(--muted); }

.trailer-link { font-size: 12px; font-weight: 600; color: var(--accent-dark); text-decoration: none; white-space: nowrap; }
.trailer-link:hover { text-decoration: underline; }

/* Static row of outbound source links (Athinorama, LiFO, IMDb, Rotten
   Tomatoes), always rendered in the same order; absent sources are omitted. */
.source-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.source-links-label { font-size: 11px; color: var(--muted); }
.source-icons { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
/* Under the poster the "Πηγές:" label sits on its own line above a single
   row of source icons; the icons are sized so all four fit the 92px column. */
.poster-col .source-links { flex-direction: column; align-items: flex-start; width: 100%; margin-bottom: 0; gap: 3px; }
.poster-col .source-icons { gap: 3px; flex-wrap: nowrap; }
.source-link {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-dark);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 8px;
  background: #fff;
}
.source-link:hover { background: #eef2f2; }
/* Icon-only source links: a small square button showing just the emoji. */
.source-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
/* Compact icons under the poster so all four sources fit one row (92px). */
.poster-col .source-icon { width: 19px; height: 19px; font-size: 12px; border-radius: 6px; }
/* Favicon-based source icons (e.g. Athinorama) render as a small rounded image. */
.source-favicon { width: 16px; height: 16px; display: block; border-radius: 3px; object-fit: contain; }
.poster-col .source-favicon { width: 13px; height: 13px; }

.cinema-block { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 8px; }
.cinema-name-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 600; }
.cinema-distance { flex: 0 0 auto; font-size: 12px; font-weight: 700; color: var(--accent-dark); white-space: nowrap; }
.cinema-meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }

.time-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.time-chip {
  background: #eef2f2;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.time-chip .icon { margin-right: 3px; }

/* Start-time colour bands: light yellow (matinee) -> dark purple (late
   night). Kept in sync with timeBandClass() in app.js. */
.time-band-1 { background: #fdf3b0; color: #6b5900; } /* before 15:00 */
.time-band-2 { background: #ffd571; color: #6b4a00; } /* 15:00-16:59 */
.time-band-3 { background: #ff9f5a; color: #5c2900; } /* 17:00-18:59 */
.time-band-4 { background: #e56f96; color: #fff; }    /* 19:00-20:59 */
.time-band-5 { background: #9a54b0; color: #fff; }    /* 21:00-22:59 */
.time-band-6 { background: #4b2483; color: #fff; }    /* 23:00 and later */

.time-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.time-legend .legend-label { font-size: 12px; color: var(--muted); }
.time-legend .legend-note { font-size: 11px; opacity: 0.8; }

/* Clickable time-band chips (top legend + sidebar filter). Selecting bands
   highlights the active chips and dims the rest so the choice reads at a
   glance. Both legend <span>s and sidebar <button>s carry [data-band]. */
.time-band-chips { display: flex; flex-wrap: wrap; gap: 6px; }
button.time-chip { border: none; font: inherit; font-weight: 600; }
.time-chip[data-band] {
  cursor: pointer;
  border: 2px solid transparent;
  transition: opacity .15s, box-shadow .15s, border-color .15s;
}
.time-chip[data-band]:hover { box-shadow: 0 0 0 2px rgba(0, 0, 0, .18); }
.time-chip[data-band].active {
  border-color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .28);
}
.time-chip[data-band].dimmed { opacity: .4; }
.time-chip[data-band]:focus-visible { outline: 2px solid var(--accent-dark); outline-offset: 2px; }

.filter-hint { font-size: 11px; color: var(--muted); margin: 0 0 8px; }

/* Sort control lives at the far right of the legend row. */
.sort-control {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sort-control label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.sort-control select {
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: inherit;
}

/* Ratings rendered as outbound links (IMDb, Rotten Tomatoes). */
.rating-link { text-decoration: none; color: inherit; cursor: pointer; }
.rating-link:hover { text-decoration: underline; }
.rating-badge[data-tippy-content] { cursor: help; }

.more-cinemas-btn {
  margin-top: 10px;
  width: 100%;
  border: 1px dashed var(--border);
  background: #fafbfb;
  color: var(--accent-dark);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.more-cinemas-btn:hover { background: #eef2f2; }

.empty-state { text-align: center; color: var(--muted); padding: 60px 0; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 24, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal {
  position: relative;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 24px 20px 20px;
  max-width: 480px;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  background: #eef2f2;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
}
.modal-close:hover { background: #e2e8e8; }
.modal-title { font-size: 16px; font-weight: 700; margin: 0 0 12px; padding-right: 24px; }
.modal .cinema-block:first-child { margin-top: 0; border-top: none; padding-top: 0; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; gap: 14px; padding: 14px; }

  /* The day selector moves into the header (as a horizontally scrollable row
     below the brand); its sidebar copy is hidden to avoid duplication. */
  .topbar { flex-wrap: wrap; }
  .topbar-day {
    display: flex;
    order: 3;
    flex-basis: 100%;
    flex-wrap: nowrap;
    gap: 6px;
    margin-top: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  .topbar-day .chip { flex: 0 0 auto; color: var(--text); }
  .topbar-day .chip.active { color: #fff; }
  .filters .filter-day { display: none; }

  /* Two menu buttons split the filters: "Πού & πότε" and the rest. */
  .mobile-filter-bar { display: flex; gap: 8px; padding: 12px 14px 0; }
  .mobile-filter-bar .btn { flex: 1; }

  /* Each drawer mode reveals only its own sections. */
  .filters[data-mode="where"] .filter-other { display: none; }
  .filters[data-mode="other"] .filter-where { display: none; }

  /* The sidebar becomes an off-canvas drawer, opened by the menu button. */
  .filters {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 84%;
    max-width: 330px;
    border-radius: 0;
    overflow-y: auto;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 2px 0 18px rgba(0, 0, 0, .25);
    padding-top: 44px;
  }
  .filters.open { transform: translateX(0); }

  .filters-close {
    display: block;
    position: absolute;
    top: 10px;
    right: 10px;
    border: none;
    background: #eef2f2;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    color: var(--text);
  }
  .filters-close:hover { background: #e2e8e8; }

  .filters-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 150;
  }
  .filters-backdrop[hidden] { display: none; }
}

/* Phone layout: tighten spacing, let the legend/sort wrap cleanly, and keep
   posters and touch targets sensible on narrow screens. */
@media (max-width: 520px) {
  .topbar { padding: 12px 14px; }
  .topbar h1 { font-size: 17px; }
  .topbar-brand .tagline { display: none; }
  .topbar-actions { font-size: 12px; }

  .layout { padding: 10px; gap: 12px; }
  .movie-grid { gap: 12px; }
  .movie-card { padding: 12px; gap: 10px; }
  .movie-card .poster { width: 72px; height: 104px; }
  .poster-col { width: 72px; }
  .movie-title { font-size: 15px; }

  /* Tighten the rating grid so the icon, 4-char label and value all fit the
     72px column on phones without clipping. */
  .poster-col .rating-badge { grid-template-columns: 13px 26px 1fr; column-gap: 1px; }
  .poster-col .r-icon { width: 13px; font-size: 11px; }
  .poster-col .r-icon .r-fav { width: 12px; height: 12px; }
  .poster-col .r-label { font-size: 8px; }
  .poster-col .r-val { font-size: 9px; }
  .poster-col .r-val b { font-size: 10px; }

  /* Move the sort control onto its own full-width line under the legend. */
  .sort-control { margin-left: 0; flex-basis: 100%; }

  /* Comfortable tap targets for the filter controls. */
  .chip { padding: 8px 14px; }
  .checkbox-list label { padding: 2px 0; }

  .modal { padding: 20px 14px 14px; max-height: 88vh; }
}
