/*
 * Kiosk / public listing styles. Colours are the renter theme tokens as custom
 * properties: these defaults are the renter's base palette, and js/brand.js replaces
 * them with the fleet's brand ramp once its config loads.
 *
 * Sizing is fluid so one layout serves any screen: everything is in rem, and the
 * root font size follows the viewport's short side (vmin), so a 4K wall screen and a
 * 1280x800 tablet look the same, just bigger or smaller. `?density=` scales it all
 * for screens read from across a room.
 */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-muted: #dbeafe;
  --primary-border: #bfdbfe;
  --on-primary: #ffffff;
  --secondary: #1d4ed8;
  --success: #059669;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --error: #ef4444;
  --error-light: #fef2f2;
  --text: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border-medium: #d1d5db;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --background: #f9fafb;
  --background-light: #f3f4f6;
  --white: #ffffff;

  --on-error: #ffffff;
  --density: 1;
  --radius: 0.75rem;
  --radius-small: 0.5rem;
  --gap: 1rem;
  --card-min: 17rem;
  --qr-size: 6.5rem;
  --tap: 2.75rem;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.06), 0 2px 8px rgba(17, 24, 39, 0.06);
  color-scheme: light;
}

/* Dark only for a fleet with a dark logo: app.js sets html.allow-dark. */
@media (prefers-color-scheme: dark) {
  :root.allow-dark {
    color-scheme: dark;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: #141f33;
    --primary-muted: #182a44;
    --primary-border: #1e3a5f;
    --secondary: #60a5fa;
    --success: #34d399;
    --success-light: #0c231b;
    --warning: #fbbf24;
    --warning-light: #2a2412;
    --error-light: #241111;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-medium: #475569;
    --border: #334155;
    --border-light: #1e293b;
    --background: #0b1220;
    --background-light: #0f172a;
    --white: #111a2b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

/* ------------------------------------------------------------------ sizing */

html {
  font-size: clamp(15px, calc((0.45vmin + 11px) * var(--density)), 28px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html.kiosk {
  font-size: calc((1.2vmin + 5px) * var(--density));
  --card-min: 18rem;
  --qr-size: 7rem;
  --tap: 3.25rem;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--background);
  color: var(--text);
  line-height: 1.4;
}

[hidden] { display: none !important; }

/* Read by screen readers, not shown (e.g. the " to " behind the date arrow). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

p, h1, h2, h3, ul { margin: 0; }

/* ------------------------------------------------------------------ layout */

/*
 * Stacked by default (phones, portrait screens): the panel is a header above the
 * grid. A kiosk keeps the whole thing in the viewport and scrolls only the grid;
 * the web page just scrolls.
 */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100dvh;
}

html.kiosk .app {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.panel {
  display: grid;
  gap: var(--gap);
  padding: 1.25rem max(1rem, env(safe-area-inset-right)) 1.25rem max(1rem, env(safe-area-inset-left));
  background: var(--white);
  border-bottom: 1px solid var(--border);
  align-content: start;
}

.listing {
  padding: 1rem max(1rem, env(safe-area-inset-right)) 1.5rem max(1rem, env(safe-area-inset-left));
  min-width: 0;
}

html.kiosk .listing {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/*
 * Portrait or narrow kiosk: brand + heading on the left, get-app QR on the right, dates below.
 * The get-app column is capped: sized `auto`, its hint text would stay on one line and
 * squeeze the heading into a narrow strip.
 */
html.kiosk .panel {
  grid-template-columns: minmax(0, 1fr) fit-content(min(26rem, 50%));
  grid-template-areas:
    "brand   getapp"
    "heading getapp"
    "dates   dates";
  column-gap: 1.5rem;
}
html.kiosk .brand { grid-area: brand; }
html.kiosk .heading { grid-area: heading; }
html.kiosk .dates { grid-area: dates; }
html.kiosk .get-app { grid-area: getapp; align-self: start; }

/* Landscape with room: the panel becomes a side column next to the grid. */
@media (orientation: landscape) and (min-width: 56rem) {
  .app {
    grid-template-columns: clamp(17rem, 27vw, 26rem) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
  }
  .panel {
    border-bottom: 0;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 1.5rem;
  }
  .listing {
    overflow-y: auto;
    padding: 1.5rem;
  }
  html.kiosk .panel {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "brand" "heading" "dates" "getapp";
    align-content: start;
    gap: 1.5rem;
  }
  html.kiosk .get-app { align-self: end; }
}

/* ------------------------------------------------------------------ panel */

/*
 * The block shrinks to its content and sits at the panel's start, with the logo centred
 * over the tagline; the inline padding keeps a logo with no built-in margin off the edge.
 */
.brand {
  display: grid;
  gap: 0.5rem;
  justify-self: start;
  justify-items: center;
  text-align: center;
  padding-inline: 0.5rem;
}

.brand-logo {
  max-height: 3.5rem;
  max-width: 100%;
  object-fit: contain;
}
html.kiosk .brand-logo { max-height: 5rem; }

.brand-name { font-size: 1.5rem; font-weight: 700; }
.brand-tagline { color: var(--text-secondary); font-size: 0.95rem; }

.heading { display: grid; gap: 0.35rem; }
.title { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; color: var(--primary); }
.location-name { font-size: 1.15rem; font-weight: 600; }

.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.dates { display: grid; gap: 0.9rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.chip {
  min-height: var(--tap);
  padding: 0 1rem;
  border-radius: 999px;
  border: 1px solid var(--border-medium);
  background: var(--white);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover { border-color: var(--primary); }
.chip[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}
.chip:focus-visible, .range-summary:focus-visible, .button:focus-visible, .select:focus-visible, .input:focus-visible, .card-link:focus-visible {
  outline: 3px solid var(--primary-border);
  outline-offset: 2px;
}

.range-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  align-items: baseline;
  width: 100%;
  min-height: var(--tap);
  padding: 0.75rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  background: var(--primary-light);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.range-summary:hover { border-color: var(--primary); }
.range-arrow { color: var(--text-secondary); }

.custom-dates { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }

.input, .select {
  width: 100%;
  min-height: var(--tap);
  padding: 0 0.75rem;
  border-radius: var(--radius-small);
  border: 1px solid var(--border-medium);
  background: var(--white);
  color: var(--text);
  font: inherit;
}

.get-app {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--background);
  border: 1px solid var(--border);
}
.get-app-qr { flex: none; width: var(--qr-size); }
.get-app-qr:empty { display: none; }
.get-app-text { display: grid; gap: 0.35rem; }
.get-app-title { font-weight: 800; font-size: 1.1rem; }
.get-app-hint { color: var(--text-secondary); font-size: 0.9rem; }

.badges { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.badges:empty { display: none; }
.badge-clip { display: block; overflow: hidden; }
.badge { --badge-h: 2.5rem; height: var(--badge-h); width: auto; display: block; }
/* Google's PNG (646x250) carries 41px of transparent padding around a 168px-tall badge:
   scale by the visible badge and crop the padding so both badges read the same height
   (same numbers as StoreButton.js in the renter app). */
.badge-google { height: calc(var(--badge-h) * 250 / 168); margin: calc(var(--badge-h) * -41 / 168); }

/* A phone visitor can't scan their own screen: links instead of the get-app QR. */
@media (max-width: 40rem) {
  html:not(.kiosk) .get-app-qr { display: none; }
}

/* ------------------------------------------------------------------ listing */

.listing-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.25rem 1rem;
  margin-bottom: 1rem;
}
.count { font-size: 1.25rem; font-weight: 700; }
.status { color: var(--text-secondary); font-size: 0.9rem; }

.notice {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-small);
  background: var(--warning-light);
  border: 1px solid var(--warning);
}

.grid {
  list-style: none;
  padding: 0;
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--card-min)), 1fr));
}

.fine-print {
  margin-top: 1.25rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ------------------------------------------------------------------ cards */

.card {
  position: relative;
  container-type: inline-size;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-link, .card-body {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  color: inherit;
  text-decoration: none;
}
.card-link:hover .card-title { color: var(--primary); }

.photo {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--background-light);
  display: grid;
  place-items: center;
  overflow: hidden;
}
/* The renditions are framed on the vehicle with transparent padding: `contain`, never
   `cover`, or the ends of a side-on car get cut off (backend IMAGE_DELIVERY_ARCHITECTURE §8). */
.photo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.photo-empty { width: 40%; color: var(--text-muted); }

.info {
  display: grid;
  gap: 0.6rem;
  padding: 0.9rem 1rem 1rem;
  align-content: start;
}

.card-title { font-size: 1.15rem; font-weight: 700; line-height: 1.25; }
.card-sub { color: var(--text-secondary); font-size: 0.9rem; }

.card-foot {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: auto;
}

.price { display: grid; gap: 0.2rem; min-width: 0; }
.price-total { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.35rem; }
.price-amount { font-size: 1.5rem; font-weight: 800; }
.price-label { color: var(--text-secondary); font-size: 0.85rem; }
.price-breakdown {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.75rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
}
.price-compact { display: none; color: var(--text-secondary); font-size: 0.85rem; }
.price-unpriced { color: var(--text-secondary); font-weight: 600; }

.card-qr { flex: none; display: grid; justify-items: center; gap: 0.2rem; width: var(--qr-size); }
.card-qr-label { font-size: 0.75rem; font-weight: 700; color: var(--text-secondary); text-align: center; }

.qr { display: block; width: 100%; height: auto; border-radius: 0.25rem; }

.next-available { color: var(--text); font-weight: 600; font-size: 0.95rem; }

.stamp {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%) rotate(-6deg);
  padding: 0.3rem 1rem;
  border-radius: var(--radius-small);
  background: var(--error);
  color: var(--on-error);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: var(--shadow);
}

.card.booked .photo img { filter: grayscale(1); opacity: 0.55; }
.card.booked .card-title, .card.booked .price { opacity: 0.6; }

/* Narrow card: one price line instead of the breakdown. */
@container (max-width: 15rem) {
  .price-breakdown { display: none; }
  .price-compact { display: block; }
  .card-foot { flex-direction: column; align-items: stretch; }
  .card-qr { width: 60%; justify-self: center; margin: 0 auto; }
}

/* Wide card (one column on a tablet, few cars): photo beside the details. */
@container (min-width: 34rem) {
  .card-link, .card-body { grid-template-columns: 42% 1fr; grid-template-rows: none; }
  .photo { aspect-ratio: auto; min-height: 100%; }
}

/* Loading placeholders. */
.card.skeleton .photo, .skeleton-line {
  background: linear-gradient(90deg, var(--background-light), var(--border-light), var(--background-light));
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton-line { height: 1rem; border-radius: 0.25rem; }
.skeleton-line.short { width: 55%; }

@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.empty {
  grid-column: 1 / -1;
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-secondary);
}

/* ------------------------------------------------------------------ buttons & screens */

.button {
  min-height: var(--tap);
  padding: 0 1.25rem;
  border: 0;
  border-radius: var(--radius-small);
  background: var(--primary);
  color: var(--on-primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.button:hover { background: var(--primary-hover); }
.button-small { min-height: 2.25rem; padding: 0 0.9rem; font-size: 0.9rem; }

.screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.75rem;
  padding: 2rem;
  text-align: center;
  background: var(--background);
}
.screen-title { font-size: 1.5rem; font-weight: 700; }
.screen-text { color: var(--text-secondary); max-width: 32rem; }

.spinner {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 0.25rem solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner, .card.skeleton .photo, .skeleton-line { animation: none; }
}

/* ------------------------------------------------------------------ kiosk hardening */

html.kiosk {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
html.kiosk .input { -webkit-user-select: text; user-select: text; }
html.kiosk.cursor-idle, html.kiosk.cursor-idle * { cursor: none !important; }

/* A fade at the bottom of the kiosk grid hints there is more to scroll. */
html.kiosk .listing::after {
  content: "";
  position: sticky;
  bottom: -1.5rem;
  display: block;
  height: 3rem;
  background: linear-gradient(to bottom, transparent, var(--background));
  pointer-events: none;
}
