/* Page-level styles: home, results, product, markets and the admin review screen. Tokens and components live elsewhere. */

/* ---------- Home ---------- */
.hero { padding-top: var(--sp-4); }
.hero-title { margin-bottom: var(--sp-3); }
.search-box { margin-bottom: var(--sp-4); }
.search-box input { min-height: 56px; font-size: var(--text-lg); }



.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); margin: var(--sp-5) 0 var(--sp-2); }
.section-heading h2 { margin: 0; font-size: var(--text-lg); }

/* Featured carousel: horizontal scroll with snap, each card a comfortable tap target. */
.carousel {
  display: flex; gap: var(--sp-3);
  overflow-x: auto; padding: var(--sp-1) var(--sp-1) var(--sp-3);
  scroll-snap-type: x mandatory; scrollbar-width: none;
  /* This used to be a grid. Bisecting the home on a 360 px phone (hiding one block at a time) showed that the grid's
     1600 px of cards made the Chrome mobile layout viewport 1377 px wide, so the page appeared shifted sideways. A flex row
     with a bounded width does not have that effect: the row scrolls inside itself and the layout stays at the screen width. */
  width: 100%; max-width: 100%; min-width: 0; contain: inline-size;
  /* The real cause (found by hiding blocks one at a time, then by forcing this line): each card holds a .visually-hidden span,
     which is position: absolute. With no positioned ancestor it was anchored to the page, so the six cards' hidden texts
     spread out to x = 1377 and widened the whole page. Making the carousel the containing block keeps them inside it. */
  position: relative;
}
.carousel::-webkit-scrollbar { display: none; }
.carousel > * { flex: 0 0 min(78vw, 16rem); scroll-snap-align: start; margin-bottom: 0; }

/* ---------- Results ---------- */
.result-count { color: var(--muted); font-size: var(--text-sm); margin-bottom: var(--sp-3); }
.results-list { list-style: none; margin: 0; padding: 0; position: relative; }
.load-more { margin: var(--sp-4) 0 var(--sp-5); }
.load-more .button { width: 100%; }
.sheet-section { border-bottom: 1px solid var(--line); padding: var(--sp-3) 0; }
.sheet-section:last-child { border-bottom: 0; }
.sheet-section h3 { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: var(--sp-2); }
.option-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); min-height: var(--tap); }

/* ---------- Product comparison ---------- */
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank {
  display: grid; grid-template-columns: auto 1fr auto; gap: var(--sp-3); align-items: center;
  padding: var(--sp-3); margin-bottom: var(--sp-2);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.rank.is-best { border: 2px solid var(--primary); box-shadow: var(--shadow-sm); }
.rank-position { font-family: var(--font-numeric); font-weight: 700; color: var(--muted); }
.rank-body { min-width: 0; }
.rank-body .rank-market { font-weight: 600; }
.rank-meta { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-2); align-items: center; margin-top: var(--sp-1); font-size: var(--text-sm); color: var(--muted); }
.rank-price { text-align: right; white-space: nowrap; }
.rank-diff { font-size: var(--text-xs); color: var(--muted); }

/* ---------- Admin review ---------- */
.review { max-width: 56rem; }
.review-image { width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: var(--sp-3); }
.review-item .row { margin-top: var(--sp-2); }
.review-item .button { flex: 1; }
.review-desc { font-weight: 600; margin: 0 0 .35rem; }
summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; }

/* ---------- Blazor boot UI ---------- */
#blazor-error-ui {
  background: var(--warning-bg); color: var(--warning-ink);
  bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
  display: none; left: 0; padding: var(--sp-3) var(--sp-5); position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: var(--sp-3); top: var(--sp-2); }
.loading-progress { position: relative; display: block; width: 8rem; height: 8rem; margin: 20vh auto 1rem; }
.loading-progress circle { fill: none; stroke: var(--line); stroke-width: .6rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child {
  stroke: var(--primary); stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * .8), 500%;
  transition: stroke-dasharray .05s ease-in-out;
}
.loading-progress-text { position: absolute; text-align: center; font-weight: bold; inset: calc(20vh + 3.25rem) 0 auto .2rem; }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Carregando"); }

/* Leaflet needs an explicit colour source, otherwise the empty area behind the tiles stays light. */
.leaflet-container { background: var(--surface-alt); }
/* Dark map: the OpenStreetMap tiles are light, so only the tile pane is inverted and tinted; pins and popups keep their own colours. */
:root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.7); }
@media (prefers-color-scheme: light) { :root:not([data-theme]) .leaflet-tile-pane { filter: none; } }
.theme-picker { border: 0; padding: 0; margin: var(--sp-3) 0 0; }
.theme-picker legend { font-weight: 700; font-size: var(--text-sm); color: var(--muted); margin-bottom: var(--sp-2); padding: 0; }
/* Route links in a ranking row: stacked, short, so the price column stays narrow. */
.route-links { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }

/* "Nova versão disponível": a calm strip under the header, never a modal; the person chooses the moment. */
.update-banner {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-4); background: var(--info-bg); color: var(--info-ink); border-bottom: 1px solid var(--line);
  font-size: var(--text-sm); font-weight: 600;
}
.update-banner .button { width: auto; min-height: 36px; }
