/* Hero animation: a driver offers a ride and accepts a passenger.
   Screens mirror the Hopla app (publish ride → confirm → done → chat → trip).
   Colours come from the app's PeukkuColors. */

.ride-demo {
  --rd-brand: #2048C8;
  --rd-brand-dark: #16359e;
  --rd-text: #1A1A1A;
  --rd-text-2: #333333;
  --rd-muted: #666666;
  --rd-border: #B3B3B3;
  --rd-subtle: #F2F2F2;
  --rd-line: #E5E5E5;
  --rd-positive: #007C29;
  --rd-positive-soft: #E2F4E8;
  --rd-info-soft: #D0D8FF;
  --rd-gold: #F2A728;
  --rd-warm: #FFF9EE;
  --rd-warn-text: #8A4400;
  --rd-scale: .92;

  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  user-select: none;
}

.rd-phone {
  flex: none;
  width: 300px;
  height: 612px;
  padding: 12px;
  border-radius: 48px;
  background: var(--ink, #0F1B33);
  box-shadow: 0 30px 60px rgba(15, 27, 51, .22);
  transform: scale(var(--rd-scale));
  /* Press and hold pauses the demo (see ride-demo.js) */
  pointer-events: auto;
  touch-action: pan-y;
  -webkit-touch-callout: none;
}
.ride-demo.is-paused * { animation-play-state: paused !important; }

.rd-screen {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: 38px;
  background: #fff;
  color: var(--rd-text);
  font-size: 13px;
  line-height: 1.35;
}

.rd-screen svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Status bar */
.rd-status {
  position: absolute;
  z-index: 3;
  inset: 0 0 auto;
  height: 34px;
  padding: 12px 24px 0;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
}
.rd-status-icons { display: flex; align-items: flex-end; gap: 2px; }
.rd-status-icons i { display: block; width: 3px; border-radius: 1px; background: currentColor; }
.rd-status-icons i:nth-child(1) { height: 5px; }
.rd-status-icons i:nth-child(2) { height: 8px; }
.rd-status-icons i:nth-child(3) { height: 11px; }

/* Views: stacked, one visible at a time */
.rd-view {
  position: absolute;
  inset: 0;
  padding-top: 34px;
  display: flex;
  flex-direction: column;
  background: #fff;
  opacity: 0;
  transform: translateX(24px);
  transition: opacity .35s ease, transform .35s ease;
}
.rd-view.is-active { opacity: 1; transform: none; }
.rd-view.is-left { transform: translateX(-24px); }

.rd-pad { padding: 4px 18px 0; }
.rd-title { display: block; font-size: 19px; font-weight: 700; letter-spacing: -.2px; margin: 6px 0 12px; }
.rd-title.is-big { font-size: 22px; line-height: 1.2; margin-top: 28px; text-wrap: balance; }

.rd-appbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 8px;
  font-size: 14px;
  font-weight: 600;
}
.rd-appbar svg { width: 22px; height: 22px; }

/* Buttons */
.rd-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border-radius: 999px;
  background: var(--rd-brand);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  transition: transform .12s ease, background-color .12s ease;
}
.rd-btn.is-outline { background: #fff; color: var(--rd-text); border: 1.5px solid var(--rd-border); }
.rd-btn.is-small { height: 34px; font-size: 13px; }
.rd-btn.is-pressed { transform: scale(.96); background: var(--rd-brand-dark); }
.rd-btn.is-outline.is-pressed { background: var(--rd-subtle); }
.rd-actions { margin-top: auto; padding: 0 18px 22px; display: flex; gap: 10px; }
.rd-actions .rd-btn { flex: 1; }

.rd-spinner {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  opacity: 0;
}
.rd-btn.is-loading .rd-btn-label { opacity: 0; }
.rd-btn.is-loading .rd-spinner { opacity: 1; animation: rd-spin .7s linear infinite; }

/* 1. Publish – matches the app's "Tarjoa kyytiä" tab */
.rd-warm {
  position: absolute;
  inset: 0 0 auto;
  height: 240px;
  overflow: hidden;
  border-radius: 0 0 28px 28px;
  background: linear-gradient(var(--rd-warm), rgba(242, 167, 40, .35));
}
.rd-warm::before,
.rd-warm::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .3);
}
.rd-warm::before { top: -20px; right: -20px; width: 120px; height: 120px; }
.rd-warm::after { bottom: 30px; left: -30px; width: 90px; height: 90px; background: rgba(255, 255, 255, .2); }
.rd-hello {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
}
.rd-hello div { display: flex; flex-direction: column; gap: 1px; }
.rd-hello small { font-size: 11.5px; font-weight: 600; color: var(--rd-warn-text); }
.rd-hello strong { font-size: 21px; font-weight: 700; line-height: 1.2; }
.rd-hello span { font-size: 10.5px; color: var(--rd-text-2); }
.rd-bunny {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #fff;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(15, 27, 51, .18);
}

.rd-form {
  position: relative;
  margin: 0 10px;
  padding: 14px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 27, 51, .1);
}
.rd-route-fields { display: flex; flex-direction: column; gap: 8px; }
.rd-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rd-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 12px;
  border: 1.5px solid var(--rd-line);
  border-radius: 12px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.rd-field svg { flex: none; width: 18px; height: 18px; color: var(--rd-muted); }
.rd-field.is-focus { border-color: var(--rd-brand); box-shadow: 0 0 0 3px rgba(32, 72, 200, .12); }
.rd-field-body { display: flex; flex-direction: column; min-width: 0; }
.rd-field label { font-size: 10.5px; color: var(--rd-muted); }
.rd-value, .rd-static { min-height: 18px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.rd-field.is-focus .rd-value::after {
  content: '';
  display: inline-block;
  width: 1.5px;
  height: 15px;
  margin-left: 1px;
  vertical-align: -2px;
  background: var(--rd-brand);
  animation: rd-blink .8s steps(1) infinite;
}
.rd-pin { flex: none; width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--rd-brand); }
.rd-pin.is-end { border-radius: 3px; background: var(--rd-brand); }
.rd-flash { animation: rd-flash .7s ease; }
.rd-btn.is-driver {
  height: 42px;
  margin: 4px -14px 0;
  border-radius: 0;
  background: var(--rd-gold);
  color: var(--rd-text);
}
.rd-btn.is-driver.is-pressed { background: #DE9617; transform: none; }

.rd-tabs {
  margin-top: auto;
  padding: 6px 4px 16px;
  display: flex;
  justify-content: space-around;
  background: #fff;
  font-size: 9.5px;
  color: var(--rd-text);
}
.rd-tabs span { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.rd-tabs svg { width: 18px; height: 18px; }
.rd-tabs .is-active { color: var(--rd-brand); }

/* 2. Confirm */
.rd-card {
  padding: 14px;
  border: 1px solid var(--rd-line);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.rd-date { font-size: 12px; font-weight: 600; color: var(--rd-muted); text-transform: capitalize; }
.rd-stops { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.rd-stops li {
  position: relative;
  display: grid;
  grid-template-columns: 42px 14px 1fr;
  align-items: center;
  column-gap: 8px;
}
.rd-stops li:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 55px;
  top: 16px;
  height: calc(100% + 2px);
  width: 2px;
  background: var(--rd-info-soft);
}
.rd-stops time { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rd-stops b { font-size: 14px; font-weight: 600; }
.rd-stops small { grid-column: 3; font-size: 11.5px; color: var(--rd-positive); font-weight: 600; }
.rd-stop-dot { position: relative; z-index: 1; width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--rd-brand); background: #fff; }
.rd-stop-dot.is-end { border-radius: 3px; background: var(--rd-brand); }
.rd-stop-dot.is-pickup { border-color: var(--rd-positive); }
.rd-card-foot {
  display: flex;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--rd-line);
  font-size: 13px;
  color: var(--rd-text-2);
}
.rd-card-foot b { font-size: 15px; color: var(--rd-text); }

/* 3. Done */
.rd-done .rd-pad { text-align: center; }
.rd-done-art { width: 230px; height: auto; margin: 36px auto 0; transform: scale(.7); opacity: 0; transition: transform .5s cubic-bezier(.3, 1.6, .5, 1), opacity .3s; }
.rd-done.is-active .rd-done-art { transform: none; opacity: 1; transition-delay: .2s; }

/* Push notification */
.rd-notif {
  position: absolute;
  z-index: 4;
  top: 40px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 12px 30px rgba(15, 27, 51, .22);
  /* Park it fully above the screen: its own height plus the 40px top offset */
  transform: translateY(calc(-100% - 48px));
  visibility: hidden;
  transition: transform .45s cubic-bezier(.2, .9, .3, 1.1), visibility 0s .45s;
}
.rd-notif.is-shown { transform: none; visibility: visible; transition-delay: 0s; }
.rd-notif.is-pressed { transform: scale(.97); }
.rd-notif img { width: 28px; height: 28px; border-radius: 7px; }
.rd-notif > span { display: grid; grid-template-columns: 1fr auto; column-gap: 8px; font-size: 12.5px; }
.rd-notif b { font-weight: 700; }
.rd-notif small { color: var(--rd-muted); font-size: 11px; }
.rd-notif > span > span { grid-column: 1 / -1; }
.rd-screen.is-dim .rd-view.is-active { filter: brightness(.82); transition: filter .4s; }

/* 4. Chat */
.rd-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--rd-info-soft);
  color: var(--rd-brand);
  font-size: 13px;
  font-weight: 700;
}
.rd-chat-name { display: flex; flex-direction: column; line-height: 1.2; }
.rd-chat-name small { font-size: 11px; font-weight: 500; color: var(--rd-muted); }
.rd-ride-banner {
  margin: 0 14px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--rd-subtle);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--rd-text-2);
}
.rd-messages {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
}
.rd-system { align-self: center; font-size: 11px; color: var(--rd-muted); }
.rd-request {
  padding: 12px;
  border: 1px solid var(--rd-line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: background-color .3s, border-color .3s;
}
.rd-request p { margin: 0; font-size: 13px; }
.rd-request-seats { font-size: 12px; color: var(--rd-muted); }
.rd-request-actions { display: flex; gap: 8px; }
.rd-request-actions .rd-btn { flex: 1; }
.rd-request-ok { display: none; align-items: center; gap: 10px; color: var(--rd-positive); }
.rd-request-ok svg { flex: none; width: 26px; height: 26px; padding: 4px; border-radius: 50%; background: #fff; stroke-width: 2.4; }
.rd-request-ok span { display: flex; flex-direction: column; }
.rd-request-ok small { font-size: 12px; color: var(--rd-text-2); }
.rd-request.is-accepted { background: var(--rd-positive-soft); border-color: transparent; }
.rd-request.is-accepted .rd-request-actions { display: none; }
.rd-request.is-accepted .rd-request-ok { display: flex; animation: rd-pop .4s ease; }

.rd-bubble {
  display: none;
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 16px;
  font-size: 13px;
}
.rd-bubble.is-shown { display: block; animation: rd-rise .3s ease; }
.rd-bubble.is-them { align-self: flex-start; background: var(--rd-subtle); border-bottom-left-radius: 4px; }
.rd-bubble.is-me { align-self: flex-end; background: var(--rd-brand); color: #fff; border-bottom-right-radius: 4px; }
.rd-bubble.is-typing.is-shown { display: flex; gap: 4px; padding: 12px 14px; }
.rd-bubble.is-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--rd-muted); animation: rd-dot 1s ease-in-out infinite; }
.rd-bubble.is-typing i:nth-child(2) { animation-delay: .15s; }
.rd-bubble.is-typing i:nth-child(3) { animation-delay: .3s; }

.rd-input { display: flex; align-items: center; gap: 8px; padding: 8px 12px 20px; border-top: 1px solid var(--rd-line); }
.rd-input-field {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 18px;
  background: var(--rd-subtle);
  font-size: 12.5px;
  display: flex;
  align-items: center;
}
.rd-input-text:empty { display: none; }
.rd-input-text:not(:empty) + .rd-input-hint { display: none; }
.rd-input-hint { color: var(--rd-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-input-text { overflow-wrap: anywhere; }
.rd-send {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--rd-brand);
  color: #fff;
  transition: transform .12s;
}
.rd-send svg { width: 18px; height: 18px; }
.rd-send.is-pressed { transform: scale(.9); }

/* 5. Trip */
.rd-map { margin: 0 14px; border-radius: 16px; overflow: hidden; background: #E9EEF5; }
.rd-map-svg { display: block; width: 100%; height: auto; }
.rd-map-water { fill: #D6E4F5; stroke: none; }
.rd-map-road { stroke: #fff; stroke-width: 6; }
.rd-map-route-bg { stroke: var(--rd-info-soft); stroke-width: 5; }
.rd-map-route { stroke: var(--rd-brand); stroke-width: 5; stroke-dasharray: 1; stroke-dashoffset: 1; }
.rd-map-start { fill: #fff; stroke: var(--rd-brand); stroke-width: 3.5; }
.rd-map-end { fill: var(--rd-brand); stroke: #fff; stroke-width: 2.5; }
.rd-map-pickup { opacity: 0; transition: opacity .3s; }
.rd-map-pickup.is-shown { opacity: 1; }
.rd-map-pickup circle { fill: var(--rd-positive); stroke: #fff; stroke-width: 2.5; }
.rd-map-pickup text { fill: #fff; stroke: none; font: 700 10px 'Hanken Grotesk', system-ui, sans-serif; text-anchor: middle; }
.rd-map-car rect { fill: var(--rd-gold); stroke: #fff; stroke-width: 2; }
.rd-map-car path { stroke: #fff; stroke-width: 2; }

.rd-trip .rd-pad { padding-top: 14px; }
.rd-stops.is-trip { gap: 12px; }
.rd-stop-pickup { opacity: 0; max-height: 0; transition: opacity .35s, max-height .35s; }
.rd-stop-pickup.is-shown { opacity: 1; max-height: 40px; }
.rd-seats {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--rd-subtle);
  font-size: 12.5px;
  font-weight: 600;
}
.rd-seats > span:first-child { flex: 1; }
.rd-seat-icons { display: flex; gap: 4px; }
.rd-seat-icons i {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px dashed var(--rd-border);
  font-style: normal;
  font-size: 10px;
  color: transparent;
}
.rd-seat-icons i.is-taken.is-shown { border: 0; background: var(--rd-positive); color: #fff; animation: rd-pop .4s ease; }
.rd-pay { margin: 12px 0 0; font-size: 11.5px; color: var(--rd-muted); opacity: 0; transition: opacity .4s; }
.rd-pay.is-shown { opacity: 1; }

/* Tap marker */
.rd-tap {
  position: absolute;
  z-index: 5;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  background: rgba(15, 27, 51, .22);
  border: 2px solid rgba(255, 255, 255, .8);
  opacity: 0;
}
.rd-tap.is-tapping { animation: rd-tap .55s ease-out; }

/* Fade between loops */
.rd-screen.is-fading .rd-view,
.rd-screen.is-fading .rd-notif { opacity: 0; transition: opacity .5s; }

@keyframes rd-tap {
  0% { opacity: 0; transform: scale(.4); }
  25% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.5); }
}
@keyframes rd-blink { 50% { opacity: 0; } }
@keyframes rd-flash { 30% { color: var(--rd-warn-text); } }
@keyframes rd-spin { to { transform: rotate(360deg); } }
@keyframes rd-rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes rd-pop { 0% { transform: scale(.6); } 70% { transform: scale(1.08); } 100% { transform: none; } }
@keyframes rd-dot { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }

@media (max-width: 1080px) {
  .ride-demo { --rd-scale: .8; }
}

@media (max-width: 560px) {
  .ride-demo { --rd-scale: .68; }
}

@media (prefers-reduced-motion: reduce) {
  .ride-demo *, .ride-demo *::before, .ride-demo *::after { animation: none !important; }
}
