/* css/discover.css — the "Discover" tab: a dense, two-column swipeable grid
 * of real live places, events, and driver-authored local tips near the
 * car's current location. Packed and readable-at-a-glance rather than one
 * oversized hero card — every tile's text is clamped so the grid's
 * pagination math (js/components/carousel.js's paginateToGridPages())
 * stays exact regardless of how much content a given source provided. */

.discover-carousel-mount {
  flex: 1;
  min-height: 0;
  padding: var(--space-sm);
  display: flex;
  background: radial-gradient(circle at 70% 100%, var(--color-accent-faint), transparent 55%), var(--color-surface);
}

.discover-carousel-mount:has(.ambient-placeholder) {
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

/* Row height is fixed here rather than left to content, and must match
 * GRID_OPTIONS.tileHeightPx in js/cards/discover-card.js — that constant is
 * only ever used to decide how many rows fit the measured mount; the
 * actual on-screen row height is this rule, so the two have to agree or
 * tiles either overflow their row (clipped by .discover-tile's own
 * overflow:hidden) or leave dead space below shorter content. */
.discover-carousel-mount .carousel-grid-page {
  grid-auto-rows: 300px;
  /* When a page's row(s) don't fill the mount's full height (a short page,
   * or a mount taller than an exact row multiple), center the block rather
   * than pinning it to the top — leftover space reads as an intentional
   * layout, not a half-loaded page. */
  align-content: center;
}

.discover-skeleton-grid {
  width: 100%;
  grid-template-columns: repeat(2, 1fr);
}

.discover-tile--skeleton {
  height: 300px;
}

/* ---- Tile (shared by all three kinds) ------------------------------------
 * A grid cell, not a hero surface — smaller radius and a plain raised
 * surface rather than .glass-card's heavier blur/gradient treatment, which
 * is tuned for one full-bleed surface per view, not dozens of small cells.
 * The mount above keeps that glass treatment as the single backdrop the
 * grid sits on. */

/* Tappable — opens the full write-up in the shared detail modal
 * (js/components/detail-modal.js) since a tile's own clamped text can't
 * hold everything a source provides. */
.discover-tile {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-hairline-faint);
  border-radius: var(--radius-sm);
  padding: var(--space-sm);
  gap: 0.35rem;
  cursor: pointer;
}

/* A fixed pixel height, not aspect-ratio — a tile's width varies with
 * however many columns fit the mount (paginateToGridPages measures rather
 * than fixing a column count), and an aspect-ratio media box would scale
 * with that width, making the tile's total content height unpredictable
 * against the fixed grid-auto-rows height set above. */
.discover-tile__media {
  position: relative;
  flex: none;
  height: 150px;
  margin: calc(var(--space-sm) * -1) calc(var(--space-sm) * -1) 0;
  border-radius: calc(var(--radius-sm) - 4px) calc(var(--radius-sm) - 4px) 0 0;
  overflow: hidden;
}

.discover-tile__photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Sits underneath the real photo at all times (not just when one is
 * missing) — a broken/404ing photoUrl is only discovered once the browser
 * tries to load it (see discover-card.js's mediaMarkup()'s inline
 * `onerror`), so this layer has to already be in the DOM, just hidden,
 * rather than swapped in after the fact. */
.discover-tile__photo-fallback {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, var(--color-accent-faint), var(--color-surface-raised));
}

/* Missing photoUrl (set at render time) or a load failure (set by the
 * <img>'s onerror at runtime) both land here — one CSS state instead of
 * two separate "empty" vs. "broken" treatments. */
.discover-tile__media--broken .discover-tile__photo-fallback {
  display: flex;
}

.discover-tile__media--broken .discover-tile__photo {
  display: none;
}

.discover-tile__photo-fallback svg {
  width: 72px;
  height: 72px;
  color: var(--color-text-secondary);
  opacity: 0.6;
}

/* Open-now / closed-now (place tiles, top-right) and date (event tiles,
 * top-left) — opposite corners so the badge kind is identifiable by
 * position alone, before a passenger even reads it. */
.discover-tile__badge {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-caption);
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--color-scrim);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

.discover-tile__badge--open {
  color: var(--color-accent);
}

.discover-tile__badge--closed {
  color: var(--color-text-secondary);
}

.discover-tile__badge--date {
  right: auto;
  left: var(--space-xs);
  color: var(--color-accent);
}

.discover-tile__kicker {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--text-caption);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-accent);
  margin-top: 0.35rem;
}

.discover-tile__kicker svg {
  width: 0.9rem;
  height: 0.9rem;
  flex: none;
}

.discover-tile__kicker span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.discover-tile__name {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--text-body);
  color: var(--color-text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.discover-tile__meta {
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.discover-tile__description {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Driver-tip tile ------------------------------------------------------
 * The one kind with no photo and no coordinates — general local knowledge
 * (safety notes, customs, hidden-gem calls) a passenger can't get from any
 * API. Accent-tinted so it reads as "a person told you this," distinct at a
 * glance from the data-driven place/event tiles around it. */

.discover-tile--tip {
  background: radial-gradient(circle at 70% 0%, var(--color-accent-faint), transparent 60%), var(--color-surface-raised);
  justify-content: center;
}

.discover-tile__tip-title {
  font-family: var(--font-serif);
  font-size: var(--text-body);
  color: var(--color-text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.discover-tile__tip-body {
  font-family: var(--font-serif);
  font-size: var(--text-caption);
  line-height: var(--leading-body);
  color: var(--color-text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- "There's more" affordance --------------------------------------------
 * Only shown when js/utils/dom.js's markTruncatedCards() (run from
 * discover-card.js's refresh(), after layout) actually detects clipped
 * text on this specific tile — a fixed always-on hint would be wrong as
 * often as it's right across this app's range of tablet screen sizes,
 * since the type scale is viewport-relative (css/theme.css's clamp()-based
 * --text-* tokens). */
.discover-tile__continue {
  display: none;
  align-items: center;
  gap: 0.25rem;
  align-self: flex-end;
  margin-top: auto;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-caption);
  font-weight: 600;
  color: var(--color-accent);
  background: var(--color-accent-faint);
}

.discover-tile__continue svg {
  width: 0.75rem;
  height: 0.75rem;
}

.discover-tile.is-truncated .discover-tile__continue {
  display: inline-flex;
}
