/* Rentev PWA — mobile-first, dark, EV-brand feel */
:root {
  --bg: #0b0f14;
  --bg-raised: #131a22;
  --bg-card: #171f29;
  --border: #263241;
  --text: #eef3f8;
  --text-dim: #9db0c3;
  --accent: #29d3a4;
  --accent-ink: #05261c;
  --danger: #ff6b6b;
  --warn: #ffcc66;
  --radius: 16px;
  /* One step above a card, for controls that sit ON a card and still need to
     read as raised — progress tracks, inactive pills, thumbnails. */
  --bg-elevated: #1f2836;
  /* An inset hairline plus a deep soft drop, which is what stops a dark card
     from looking like a flat patch of slightly different background. */
  --shadow-card: 0 1px 0 0 rgba(255, 255, 255, 0.04) inset, 0 18px 40px -24px rgba(0, 0, 0, 0.9);
  --shadow-glow: 0 0 0 1px rgba(41, 211, 164, 0.25), 0 12px 40px -8px rgba(41, 211, 164, 0.35);
  --radius-lg: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 20px 12px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: 0.02em; color: var(--text); text-decoration: none; }
.brand-mark { color: var(--accent); }
.nav-auth a, .nav-auth button {
  color: var(--text-dim); background: none; border: none; font-size: 0.9rem; cursor: pointer; text-decoration: none;
}

.view { flex: 1; padding: 20px 20px calc(32px + var(--safe-bottom)); }

/* --- Tesla phone key --- */
/* The invite link is the single most important thing on the trip screen once
   a rental is active: without accepting it, the renter has no key. */
.key-card { border-color: var(--accent); }
.key-link {
  display: block; width: 100%; text-align: center; text-decoration: none;
  margin: 14px 0 4px;
}
.key-card .btn-small { width: 100%; margin-top: 10px; }

/* --- Sign in with Apple --- */
.divider {
  display: flex; align-items: center; gap: 12px; margin: 22px 0 14px;
  color: var(--text-dim); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* Apple's Human Interface Guidelines for this button are prescriptive: black
   fill, white glyph and label, the exact phrase, and nothing competing with
   it visually. Do not restyle to match the brand accent. */
.apple-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: #000; color: #fff; border: 1px solid #3a3a3c;
  border-radius: 12px; padding: 14px; font-size: 1rem; font-weight: 500; cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.apple-btn:active { background: #1a1a1a; }
.apple-btn svg { width: 18px; height: 18px; fill: currentColor; }

h1 { font-size: 1.7rem; line-height: 1.2; margin: 0.4em 0; }
h2 { font-size: 1.2rem; margin: 1.2em 0 0.5em; }
p { color: var(--text-dim); margin: 0.5em 0; }
.lead { font-size: 1.05rem; }

.hero { padding: 8vh 0 24px; text-align: left; }
.hero .kicker {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  background: var(--bg-raised); border: 1px solid var(--border);
  color: var(--accent); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
}
.hero h1 { font-size: 2.1rem; margin-top: 16px; }
.hero-car {
  width: 100%; height: 150px; margin: 20px 0; border-radius: var(--radius);
  background: var(--bg-card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.hero-car img, .car-photo img { width: 85%; height: auto; }

.steps { list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 10px; }
.steps li {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
}
.steps .num {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-weight: 800;
  display: flex; align-items: center; justify-content: center; font-size: 0.9rem;
}
.steps strong { display: block; }
.steps span { color: var(--text-dim); font-size: 0.9rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 20px; border-radius: 14px; border: none;
  background: var(--accent); color: var(--accent-ink);
  font-size: 1.05rem; font-weight: 700; cursor: pointer;
  transition: transform 0.06s ease, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-small { width: auto; padding: 8px 16px; font-size: 0.9rem; }
.btn-row { display: grid; gap: 10px; margin-top: 16px; }

form { display: grid; gap: 12px; margin: 20px 0; }
label { font-size: 0.85rem; color: var(--text-dim); display: grid; gap: 6px; }
input, select {
  width: 100%; padding: 13px 14px; border-radius: 12px;
  background: var(--bg-raised); border: 1px solid var(--border); color: var(--text); font-size: 1rem;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin: 12px 0;
}
.card.clickable { cursor: pointer; transition: border-color 0.15s; }
.card.clickable:active { border-color: var(--accent); }

.car-photo {
  height: 120px; border-radius: 12px; background: var(--bg-raised);
  display: flex; align-items: center; justify-content: center; margin-bottom: 12px; overflow: hidden;
}
.car-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.car-head h3 { margin: 0; font-size: 1.1rem; }
.price { color: var(--accent); font-weight: 700; white-space: nowrap; }
.car-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; color: var(--text-dim); font-size: 0.85rem; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700;
  background: var(--bg-raised); border: 1px solid var(--border); color: var(--text-dim);
}
.badge.ok { color: var(--accent); border-color: var(--accent); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.bad { color: var(--danger); border-color: var(--danger); }

.summary-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 0.95rem; }
.summary-row:last-child { border-bottom: none; }
.summary-row .amount { font-weight: 700; }
.summary-row.total { font-size: 1.05rem; }

.trip-timer { text-align: center; padding: 24px 0 8px; }
.trip-timer .time { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.trip-timer .sub { color: var(--text-dim); font-size: 0.9rem; }

.unlock-ring {
  width: 150px; height: 150px; margin: 20px auto; border-radius: 50%;
  border: 3px solid var(--accent); display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 4px; background: radial-gradient(circle, rgba(41,211,164,0.12), transparent 70%);
  font-weight: 800; font-size: 1.1rem; cursor: pointer; -webkit-user-select: none; user-select: none;
}
.unlock-ring:active { background: radial-gradient(circle, rgba(41,211,164,0.3), transparent 70%); }
.unlock-ring.disabled { border-color: var(--border); opacity: 0.65; background: none; }
.unlock-ring .icon { font-size: 2rem; }

.inspect-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0; }
.inspect-slot {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--bg-card); border: 1.5px dashed var(--border); border-radius: var(--radius);
  padding: 14px 10px 12px; cursor: pointer; text-align: center; font-size: 0.95rem;
  transition: border-color 0.15s;
}
.inspect-slot:active { border-color: var(--accent); }
.inspect-slot.done { border-style: solid; border-color: var(--accent); }
.inspect-slot .thumb {
  width: 100%; height: 84px; border-radius: 10px; background: var(--bg-raised);
  display: flex; align-items: center; justify-content: center; font-size: 1.8rem; overflow: hidden;
}
.inspect-slot .thumb img { width: 100%; height: 100%; object-fit: cover; }
.inspect-slot .slot-state { color: var(--text-dim); font-size: 0.75rem; }
.inspect-cta { cursor: pointer; border-color: var(--warn); }
.inspect-cta.ok { cursor: default; border-color: var(--accent); }

.verify-status { text-align: center; padding: 32px 0; }
.spinner {
  width: 42px; height: 42px; margin: 0 auto 16px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.check-big { font-size: 3rem; }

.a2hs {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + var(--safe-bottom)); width: min(440px, calc(100% - 32px));
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 12px 16px; z-index: 30; box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.a2hs p { margin: 0; font-size: 0.82rem; }
.a2hs div { flex: 1; }
.icon-btn { background: none; border: none; color: var(--text-dim); font-size: 1rem; cursor: pointer; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(90px + var(--safe-bottom)); width: min(420px, calc(100% - 40px));
  background: var(--bg-raised); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 12px; padding: 12px 16px; font-size: 0.92rem; z-index: 40;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.toast.error { border-left-color: var(--danger); }
.hidden { display: none !important; }

.muted-note { font-size: 0.8rem; color: var(--text-dim); text-align: center; margin-top: 18px; }
.link { color: var(--accent); text-decoration: none; font-weight: 600; cursor: pointer; }
.empty { text-align: center; color: var(--text-dim); padding: 40px 0; }

/* --- surfaces, motion, and the hero treatment -----------------------------
   Ported from the Lovable design pass. The palette was already ours; what is
   new here is depth (a real card shadow instead of a flat fill), the gridded
   hero, and a little motion on entry. Kept as plain CSS utilities so the
   no-build architecture is unchanged — there is no Tailwind here to give us
   `surface` or `animate-rise`, so they are written out. */

.card {
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-lg);
}

/* The hero sits on a faint grid, which is what makes the dark background read
   as a surface rather than an absence. Masked so it fades out before the fold
   instead of ending on a hard line. */
.hero {
  position: relative;
  isolation: isolate;
}
.hero::before {
  content: '';
  position: absolute;
  inset: -8vh -20px 20% -20px;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: linear-gradient(to bottom, #000 30%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 30%, transparent 100%);
}

/* The headline resolves from white into mint across its own text. */
.hero h1 {
  background-image: linear-gradient(100deg, var(--text) 15%, var(--accent) 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
}

.hero .kicker { animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both; }
.hero h1 { animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.05s both; }
.hero .lead { animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both; }
.hero .btn-row { animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both; }

.steps li { box-shadow: var(--shadow-card); }
.steps .num {
  background: var(--bg-elevated);
  color: var(--accent);
}

/* The primary action is the one thing on screen that should glow. */
.btn:not(.btn-secondary):not(.btn-danger) { box-shadow: var(--shadow-glow); }
/* A disabled button that still glows reads as the thing to press. The glow is
   the affordance, so it has to go when the affordance does. */
.btn:disabled { box-shadow: none; }

.card.clickable { transition: border-color 0.15s, transform 0.15s; }
.card.clickable:active { transform: scale(0.995); }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* Motion is decoration here; anyone who has asked for less of it gets none. */
@media (prefers-reduced-motion: reduce) {
  .hero .kicker, .hero h1, .hero .lead, .hero .btn-row { animation: none; }
  .card.clickable:active { transform: none; }
}

/* The existing add-to-home-screen prompt, given the same depth as the cards.
   A mint outline on a fixed overlay reads as an alert; the card shadow plus a
   raised mark reads as an offer, which is what it is. */
.a2hs {
  border-color: var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  /* Its own keyframes, NOT `rise`: this element is centred with
     translateX(-50%), and an animation that ends at `transform: none` cancels
     that and throws the banner half a screen to the right. Any animated
     transform on a transform-positioned element has to carry the positioning
     through every frame. */
  animation: rise-centered 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes rise-centered {
  from { opacity: 0; transform: translateX(-50%) translateY(14px); }
  to   { opacity: 1; transform: translateX(-50%); }
}
.a2hs::before {
  content: '\26A1';
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  background: var(--bg-elevated); color: var(--accent);
  border-radius: 11px; font-size: 1.05rem;
}
.a2hs strong { display: block; font-size: 0.92rem; }
@media (prefers-reduced-motion: reduce) {
  .a2hs { animation: none; transform: translateX(-50%); }
}

/* --- vehicle cards -------------------------------------------------------
   Full-bleed photograph with the availability pill over it, then the numbers
   a resident actually chooses on. The battery meter is the same figure as the
   tile above it, drawn — a percentage is a fact, a bar is a glance. */
.car-card { padding: 0; overflow: hidden; }
.car-card .car-photo {
  position: relative;
  height: auto;
  aspect-ratio: 16 / 10;
  margin: 0;
  border-radius: 0;
}
/* Overrides the shared rule that insets the stock SVG illustrations: a real
   photograph should fill the frame, not float in the middle of it. */
.car-card .car-photo img { width: 100%; height: 100%; object-fit: cover; }
.car-status {
  position: absolute; left: 12px; top: 12px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.car-status .badge { background: color-mix(in srgb, var(--bg) 65%, transparent); }
.car-body { padding: 18px; }
.car-sub { margin: 2px 0 0; font-size: 0.78rem; color: var(--text-dim); }

.stat-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 16px 0 0; text-align: center;
}
.stat-row div { background: var(--bg-elevated); border-radius: 12px; padding: 10px 6px; }
.stat-v { display: block; font-weight: 700; font-size: 0.98rem; }
.stat-l {
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--text-dim);
}

/* Also used for inspection progress — same idea, same drawing. */
.meter {
  height: 6px; margin-top: 14px; border-radius: 999px;
  background: var(--bg-elevated); overflow: hidden;
}
.meter span {
  display: block; height: 100%; border-radius: 999px;
  background: var(--accent); transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.car-card .car-distance { margin: 12px 0 0; font-size: 0.82rem; color: var(--text-dim); }
.car-card .btn { margin-top: 14px; }
.car-unavailable {
  margin: 14px 0 0; padding: 14px; text-align: center; font-size: 0.88rem;
  background: var(--bg-elevated); border-radius: 14px; color: var(--text-dim);
}

/* --- inspection tiles ----------------------------------------------------
   Square, because the photo is the content. Once captured the image fills the
   tile and the label moves onto a bar across the bottom, so four captured
   angles read as four photographs rather than four form fields. */
.inspect-slot {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--radius-lg);
}
.inspect-slot .thumb {
  position: absolute; inset: 0;
  width: auto; height: auto; border-radius: 0; background: none;
}
.inspect-slot .slot-face {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  position: relative; z-index: 1;
}
.inspect-slot .slot-icon { font-size: 1.6rem; }
.inspect-slot .slot-bar { display: none; }

.inspect-slot.done .slot-face { display: none; }
.inspect-slot.done .slot-bar {
  position: absolute; inset: auto 0 0 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; font-size: 0.72rem;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.inspect-slot.done .slot-ok { color: var(--accent); font-weight: 700; }
.inspect-slot.done .slot-retake { color: var(--text-dim); }

/* --- the unlock control --------------------------------------------------
   The one control on the screen that opens a car, so it gets a halo that
   breathes while it is actionable and goes completely still when it is not.
   Motion here is doing a job: it is the difference between "ready" and
   "blocked" read at arm's length, without reading the label. */
.unlock-ring {
  position: relative;
  width: 168px; height: 168px;
  isolation: isolate;
}
.unlock-ring::before {
  content: '';
  position: absolute; inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: pulse-ring 2.4s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  z-index: -1;
}
.unlock-ring.disabled::before { animation: none; opacity: 0; }
.unlock-ring:active { transform: scale(0.97); }

@keyframes pulse-ring {
  0%   { transform: scale(0.92); opacity: 0.7; }
  70%  { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1.18); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .unlock-ring::before { animation: none; opacity: 0.5; }
  .meter span { transition: none; }
}

/* --- hero photography ----------------------------------------------------
   Applied only once a real photograph has loaded (see upgradeHeroImage).
   Without the file the hero keeps its SVG illustration and none of this
   applies, so dropping the image in is the whole install step. */
.hero-car.photo {
  height: auto;
  aspect-ratio: 16 / 10;
  position: relative;
  padding: 0;
}
.hero-car.photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
/* A photograph of a dark garage still has bright spots, and the headline sits
   right above it. The scrim guarantees the contrast rather than hoping for it. */
.hero-car.photo::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(11, 15, 20, 0.35) 0%, rgba(11, 15, 20, 0) 45%, rgba(11, 15, 20, 0.55) 100%);
  pointer-events: none;
}
