/* ============================================================
   Rovinj Guide - mobile-first, DRY, themeable
   Edit the variables in :root (light) and [data-theme=dark] to
   restyle the whole app. Accent colors drive buttons/badges.
   ============================================================ */

:root {
  /* Accent colors - edit these to rebrand */
  --accent:          #1E88E5;
  --accent-contrast: #ffffff;

  /* Light theme surfaces/text */
  --bg:        #f4f5f7;
  --surface:   #ffffff;
  --surface-2: #eceef1;
  --text:      #1b1d22;
  --text-soft: #6b7280;
  --text-faint:#aab0ba;
  --border:    #e2e5ea;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);

  /* Layout tokens */
  --radius:    14px;
  --radius-sm: 9px;
  --gap:       12px;
  --topbar-h:  56px;
  --tabbar-h:  62px;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg:        #15171c;
  --surface:   #1e2128;
  --surface-2: #272b33;
  --text:      #eceef2;
  --text-soft: #9aa2ad;
  --text-faint:#5b626d;
  --border:    #2d313a;
  --shadow:    0 1px 3px rgba(0,0,0,.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top, 0);
}

/* ---------- Icons ---------- */
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor;
        stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px; border: none; border-radius: 50%;
  background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar__title { font-size: 1.1rem; font-weight: 600; margin: 0; }

/* ---------- Sort row ---------- */
.sortrow {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px;
  font-size: .85rem; color: var(--text-soft);
}
.sortrow__sort { display: flex; align-items: center; gap: 8px; }
.sortrow__sort select {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 10px; font-size: .85rem;
}

/* ---------- List + cards ---------- */
.list {
  padding: 4px 12px calc(var(--tabbar-h) + 20px);
  overflow-y: auto;
}
.card {
  display: flex; gap: var(--gap);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.card:active { transform: scale(.995); }
.card__thumb {
  width: 76px; height: 76px; flex: 0 0 76px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--accent-contrast); font-size: 1.5rem; font-weight: 700;
  overflow: hidden;
}
.card__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.card__name { font-weight: 600; font-size: 1rem; margin: 2px 0;
              white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card__desc { font-size: .82rem; color: var(--text-soft);
              display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
              overflow: hidden; }
.card__meta { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 6px; }
.badge {
  font-size: .68rem; font-weight: 600; padding: 2px 8px;
  border-radius: 20px; color: #fff; white-space: nowrap;
}
.card__dist { font-size: .72rem; color: var(--text-faint); margin-left: auto; }

/* Group separator (type sort) */
.group-sep {
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-soft);
  padding: 14px 4px 6px;
}

.empty-note { text-align: center; color: var(--text-faint); padding: 40px 20px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0));
  padding-bottom: env(safe-area-inset-bottom, 0);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1; border: none; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-soft); font-size: .7rem;
}
.tab.is-active { color: var(--accent); }
.tab .icon { width: 24px; height: 24px; }

/* ---------- Panels (filter / menu) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0,0,0,.4);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.overlay.is-open { opacity: 1; pointer-events: auto; }
.panel {
  position: fixed; top: 0; bottom: 0; z-index: 31;
  width: 82%; max-width: 340px;
  background: var(--surface);
  display: flex; flex-direction: column;
  transition: transform .25s ease;
}
.panel--left  { left: 0;  transform: translateX(-100%); border-right: 1px solid var(--border); }
.panel--right { right: 0; transform: translateX(100%);  border-left: 1px solid var(--border); }
.panel--left.is-open, .panel--right.is-open { transform: translateX(0); }
.panel__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 12px 14px 20px;
  border-bottom: 1px solid var(--border);
  padding-top: calc(14px + env(safe-area-inset-top, 0));
}
.panel__header h2 { margin: 0; font-size: 1.1rem; }
.panel__body { flex: 1; overflow-y: auto; padding: 12px 20px; }
.panel__footer {
  display: flex; gap: 10px; padding: 14px 20px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0));
  border-top: 1px solid var(--border);
}

/* Filter checkboxes */
.filter-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
  cursor: pointer; font-size: .95rem;
}
.filter-item input { width: 20px; height: 20px; accent-color: var(--accent); }
.filter-item__dot { width: 10px; height: 10px; border-radius: 50%; }

/* ---------- Buttons ---------- */
.btn {
  flex: 1; border: none; border-radius: var(--radius-sm);
  padding: 12px; font-size: .95rem; font-weight: 600; cursor: pointer;
}
.btn--primary { background: var(--accent); color: var(--accent-contrast); }
.btn--ghost   { background: var(--surface-2); color: var(--text); }

/* ---------- Theme switch ---------- */
.menu-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.switch { position: relative; width: 48px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__slider {
  position: absolute; inset: 0; border-radius: 28px;
  background: var(--surface-2); transition: .2s;
}
.switch__slider::before {
  content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .switch__slider { background: var(--accent); }
.switch input:checked + .switch__slider::before { transform: translateX(20px); }

/* ---------- Detail view ---------- */
.detail {
  position: fixed; inset: 0; z-index: 40;
  background: var(--bg); display: flex; flex-direction: column;
}
.detail[hidden] { display: none; }   /* hidden attribute must win over display:flex */
.detail__bar {
  display: flex; align-items: center; gap: 6px;
  height: var(--topbar-h); padding: 0 8px;
  padding-top: env(safe-area-inset-top, 0);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.detail__barTitle { font-weight: 600; font-size: 1rem;
                    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail__scroll { flex: 1; overflow-y: auto; padding-bottom: 40px; }
.detail__hero {
  height: 180px; background: var(--surface-2);
  display: grid; place-items: center; color: #fff; font-size: 3rem; font-weight: 800;
}
.detail__content { padding: 16px 20px; }
.detail__name { font-size: 1.5rem; font-weight: 700; margin: 0 0 6px; }
.detail__sub { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.detail__desc { font-size: .95rem; line-height: 1.5; color: var(--text); margin-bottom: 20px; }

/* Info rows - fixed layout, grayed when empty */
.info-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 0; border-top: 1px solid var(--border);
}
.info-row__icon { color: var(--accent); flex: 0 0 22px; margin-top: 1px; }
.info-row__label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
                   color: var(--text-soft); margin-bottom: 2px; }
.info-row__value { font-size: .95rem; color: var(--text); word-break: break-word; }
.info-row.is-empty .info-row__icon { color: var(--text-faint); }
.info-row.is-empty .info-row__value { color: var(--text-faint); font-style: italic; }
.info-row__value a { color: var(--accent); text-decoration: none; }
