/* ============================================================
   Loppis — loppisfunn.no front-end app (list + map + directions)
   Drop-in PopUP plugin. All components .lf- prefixed; shell styles
   live in the theme layer. Map-first single-page app: ONE icon
   toolbar outside the map; Liste/Kart are in-app views.
   ============================================================ */

/* ----- App frame: toolbar on top, views fill the rest ----- */
.lf-app {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  position: relative;
}
.lf-view--map { flex: 1; min-height: 0; position: relative; }
.lf-view--list { flex: 1; min-height: 0; overflow-y: auto; }
.lf-app.lf-mode-map .lf-view--map { display: block; }
.lf-app.lf-mode-map .lf-view--list { display: none; }
.lf-app.lf-mode-list .lf-view--map { display: none; }
.lf-app.lf-mode-list .lf-view--list { display: block; }
.lf-mapwrap { position: absolute; inset: 0; }
.lf-mapwrap > .lf-map { position: absolute; inset: 0; background: #dfe8e6; }
/* Sized by insets at higher-than-class specificity, never percentages:
   maplibre's own runtime css (.maplibregl-map, position:relative, NO
   height) loads after ours and Firefox resolves height:100% to 0 for it
   inside the flex wrapper (owner-verified: relative=0px, static=541px). */

/* ----- Toolbar: one icon row, outside the map ----- */
.lf-toolbar {
  display: flex; align-items: center; gap: .2rem;
  padding: .3rem .5rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
  position: relative; z-index: 1200;
  flex: 0 0 auto;
}
.lf-toolbar::-webkit-scrollbar { display: none; }
.lf-tb-group { display: flex; gap: .1rem; }
.lf-tb-sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 .15rem; flex: 0 0 auto; }
.lf-tb-btn {
  width: 32px; height: 30px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: none; border-radius: 8px;
  color: var(--muted); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lf-tb-btn svg { width: 16px; height: 16px; }
.lf-tb-btn:hover { background: var(--bg); color: var(--ink); }
.lf-tb-btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.lf-tb-btn[aria-pressed="true"] { background: var(--teal); color: #fff; }
.lf-tb-btn--loc[aria-pressed="true"] { background: var(--blue); }
@media (max-width: 399px) { .lf-tb-sep { display: none; } }

/* expanding search: a real input with the icon inside. Collapsed it is
   icon-sized; focusing it expands across the toolbar line (the :has()
   rule hides the other controls on mobile) and it minimizes on blur.
   Pure CSS via :focus-within — no state classes to lose. */
.lf-search {
  position: relative; display: flex; align-items: center;
  flex: 0 0 auto; width: 32px; height: 30px;
  transition: width .16s ease, flex .16s ease;
  cursor: text;
}
.lf-search > svg {
  position: absolute; left: 8px; width: 15px; height: 15px;
  color: var(--muted); pointer-events: none;
}
.lf-search input {
  width: 100%; height: 100%; font: inherit; font-size: .92rem; color: var(--ink);
  border: 1px solid transparent; background: none; border-radius: 999px;
  padding: 0 8px 0 27px;
  -webkit-appearance: none; appearance: none; outline: none;
  min-width: 0;
}
.lf-search input::placeholder { color: transparent; }
.lf-search:focus-within { flex: 1 1 auto; width: auto; cursor: auto; }
.lf-search:focus-within input { border-color: var(--line); background: var(--bg); }
.lf-search:focus-within input::placeholder { color: var(--muted); }
/* mobile: focused search takes over the whole toolbar line */
@media (max-width: 719px) {
  .lf-toolbar:has(.lf-search:focus-within) .lf-tb-btn,
  .lf-toolbar:has(.lf-search:focus-within) .lf-tb-sep,
  .lf-toolbar:has(.lf-search:focus-within) .lf-tb-filters-mobile { display: none; }
}

/* word filters (desktop) */
.lf-tb-word {
  border: 0; background: none; cursor: pointer; font: inherit;
  font-size: .88rem; font-weight: 600; color: var(--muted);
  padding: .4rem .7rem; border-radius: 999px; white-space: nowrap;
}
.lf-tb-word:hover { color: var(--ink); background: var(--bg); }
.lf-tb-word.is-active { background: var(--teal); color: #fff; }
.lf-tb-word:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
@media (max-width: 719px) { .lf-tb-filters-desktop { display: none; } }
/* funnel button only exists on mobile */
.lf-tb-filters-mobile { display: none; }
@media (max-width: 719px) { .lf-tb-filters-mobile { display: inline-flex; color: var(--ink); } }

/* full-screen filter pane (mobile) */
.lf-filterpane {
  position: fixed; inset: 0; z-index: 1400;
  background: var(--bg); display: flex; flex-direction: column;
  padding: 1rem max(1rem, env(safe-area-inset-left)) calc(1rem + env(safe-area-inset-bottom));
}
.lf-filterpane[hidden] { display: none; }
.lf-filterpane-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .8rem;
}
.lf-filterpane-head strong { font-size: 1.05rem; }
.lf-filterpane .lf-note-x { font-size: 1rem; padding: .2rem .4rem; border-radius: 8px; }
.lf-filterpane .lf-note-x:hover { background: var(--surface); }
.lf-filter-opt {
  display: flex; flex-direction: column; gap: .1rem; text-align: left;
  font: inherit; width: 100%;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: .8rem .9rem; margin-bottom: .55rem; cursor: pointer;
}
.lf-filter-opt span { color: var(--muted); font-size: .8rem; }
.lf-filter-opt:hover { border-color: var(--teal); }
.lf-filter-opt.is-active { border-color: var(--teal); box-shadow: 0 0 0 2px color-mix(in srgb, var(--teal) 25%, transparent); }
.lf-filter-opt.is-active span { color: var(--teal-ink); }

/* ----- Market list (list view) ----- */
.lf-list { padding: .4rem 1rem 2.5rem; }
.lf-week-head { margin: 1.1rem 0 .5rem; display: flex; align-items: baseline; gap: .5rem; }
.lf-week-head h2 { margin: 0; font-size: 1.02rem; letter-spacing: -.01em; }
.lf-week-head.current h2 { color: var(--teal-ink); }
.lf-week-count {
  font-size: .78rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line);
  padding: .05rem .5rem; border-radius: 999px;
}
.lf-count-line { color: var(--muted); font-size: .84rem; padding: .4rem 0 0; }
.lf-skel {
  margin: 1rem 0; padding: 1.1rem; border-radius: var(--lf-radius);
  background: linear-gradient(100deg, var(--surface) 40%, color-mix(in srgb, var(--line) 40%, var(--surface)) 50%, var(--surface) 60%);
  background-size: 200% 100%; animation: lf-shimmer 1.4s infinite;
  color: transparent; height: 90px;
}
@keyframes lf-shimmer { to { background-position-x: -200%; } }

.lf-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--lf-radius); box-shadow: var(--lf-shadow);
  padding: .85rem .95rem; margin: 0 0 .65rem;
}
.lf-card-top { display: flex; gap: .6rem; align-items: flex-start; }
.lf-dot {
  flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%;
  margin-top: .42rem; background: var(--t-other, var(--slate));
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent);
}
.lf-card-main { flex: 1; min-width: 0; }
.lf-card-venue { font-weight: 800; font-size: 1.04rem; letter-spacing: -.01em; }
.lf-venue-link { color: inherit; text-decoration: none; }
.lf-venue-link:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 2px; }
.lf-card-when { color: var(--teal-ink); font-weight: 700; font-size: .92rem; }
.lf-card-hours { color: var(--muted); font-size: .86rem; }
.lf-card-addr { color: var(--muted); font-size: .86rem; margin-top: .1rem; }
.lf-card-dist {
  flex: 0 0 auto; font-size: .8rem; font-weight: 700; color: var(--blue);
  background: color-mix(in srgb, var(--blue) 8%, var(--surface));
  border-radius: 999px; padding: .2rem .55rem; margin-top: .15rem;
}
.lf-card-note { font-size: .88rem; margin: .45rem 0 0; color: var(--ink); }
.lf-card-actions { display: flex; gap: .5rem; margin-top: .7rem; align-items: center; }

.lf-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: inherit; font-weight: 700; font-size: .95rem;
  border-radius: 999px; padding: .62rem 1.15rem; cursor: pointer;
  border: 1px solid transparent; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.lf-btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.lf-btn-primary { background: var(--teal); color: #fff; flex: 1; }
.lf-btn-primary:hover { background: var(--teal-ink); }
.lf-btn-ghost {
  background: var(--surface); color: var(--teal-ink);
  border-color: var(--line); padding: .62rem .8rem;
}
.lf-btn-ghost:hover { border-color: var(--teal); }
.lf-btn svg { width: 17px; height: 17px; }
.lf-empty { color: var(--muted); text-align: center; padding: 2.2rem 1rem; }
.lf-noscript { padding: 1rem 1.1rem; color: var(--muted); }

/* ----- Map (canvas sized by the wrap; controls live in the toolbar) ----- */
.lf-mapwrap { overflow: hidden; }
.lf-marker { background: none; border: 0; }
.lf-pin {
  width: 26px; height: 34px; position: relative;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.25));
  transition: translate .12s ease;
}
.lf-pin::before {
  content: ""; position: absolute; inset: 0;
  background: currentColor;
  clip-path: path("M13 0C6.4 0 1 5.2 1 11.7 1 20.3 13 34 13 34s12-13.7 12-22.3C25 5.2 19.6 0 13 0z");
}
.lf-pin::after {
  content: ""; position: absolute; left: 50%; top: 11px; translate: -50% 0;
  width: 8px; height: 8px; border-radius: 50%; background: #fff;
}
.lf-pin.is-weekend::before { animation: lf-pulse 2.2s infinite; }
@keyframes lf-pulse {
  0% { outline: 0 solid rgba(15,118,110,.35); }
  70% { outline: 8px solid rgba(15,118,110,0); }
  100% { outline: 0 solid rgba(15,118,110,0); }
}
.lf-pin.is-active { translate: 0 -4px; }

/* ----- Bottom sheet (market details on map) ----- */
.lf-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1100;
  background: var(--surface);
  border-radius: 18px 18px 0 0; border-top: 1px solid var(--line);
  box-shadow: 0 -8px 30px rgba(31,41,55,.16);
  padding: .5rem 1rem calc(.9rem + env(safe-area-inset-bottom));
  translate: 0 105%; transition: translate .22s ease;
  max-height: 62dvh; overflow-y: auto;
}
.lf-sheet.is-open { translate: 0 0; }
.lf-sheet-grip { width: 42px; height: 4px; border-radius: 2px; background: var(--line); margin: .15rem auto .55rem; }
.lf-route-banner {
  display: flex; gap: .5rem; align-items: center;
  background: color-mix(in srgb, var(--blue) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--blue) 30%, var(--line));
  color: var(--blue); font-weight: 700; font-size: .88rem;
  border-radius: 10px; padding: .45rem .7rem; margin: .5rem 0 0;
}
.lf-route-err { color: var(--muted); font-size: .85rem; padding: .4rem 0 0; }

@media (min-width: 720px) {
  .lf-list { max-width: 46rem; margin: 0 auto; padding: .4rem 1rem 3rem; }
}
