/* ============================================================
   RunFromHere — landing page layout & responsive rules
   (page-level rules that can't live in inline styles)
   ============================================================ */
html { scroll-behavior: smooth; }
body { overflow-x: hidden; }

/* Native multi-page transitions: unsupported browsers retain normal navigation. */
@view-transition { navigation: auto; }
header > a:first-child { view-transition-name: rfh-brand; }
::view-transition-old(root) { animation: rfh-page-out 180ms ease-in both; }
::view-transition-new(root) { animation: rfh-page-in 260ms var(--ease-out) both; }
::view-transition-group(rfh-brand) { animation-duration: 260ms; }

@keyframes rfh-page-out { to { opacity: 0; filter: blur(2px); } }
@keyframes rfh-page-in {
  from { opacity: 0; filter: blur(2px); }
  to { opacity: 1; filter: blur(0); }
}

/* The hero art lands exactly on the section boundary, so its crop reads as
   intentional rather than as an image ending in open space. */
.rfh-hero-shell {
  overflow: hidden;
  background: #000;
  border-bottom: 1px solid var(--border);
}
.rfh-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, calc((var(--container-max) - 112px) / 2)) minmax(420px, 1fr);
  align-items: center;
  gap: 32px;
  max-width: none;
  min-height: 700px;
  margin: 0 auto;
  padding: 0 0 0 max(40px, calc((100vw - var(--container-max)) / 2 + 40px));
}
.rfh-hero-copy { padding: 56px 0; }
.rfh-hero-highlight {
  color: var(--cyan);
  font-weight: var(--weight-bold);
}
.rfh-hero-art {
  position: relative;
  align-self: stretch;
  width: 100%;
  min-height: 700px;
  margin: 0;
  overflow: hidden;
}
.rfh-hero-art-fallback { display: none; }
.rfh-hero-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: left center;
}

/* Android's route preferences are weighted 0-10 controls, not switches. */
.rfh-preference-list { display: grid; gap: 14px; }
.rfh-preference {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px 14px;
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--cyan) 14%, var(--white-04));
}
.rfh-preference-copy { display: flex; flex-direction: column; gap: 4px; }
.rfh-preference-title { font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.01em; }
.rfh-preference-description { color: var(--text-tertiary); font-size: var(--text-sm); }
.rfh-preference-value {
  flex: none;
  color: var(--cyan);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--text-sm);
  font-weight: 700;
}
.rfh-preference-slider { position: relative; height: 34px; margin: 0 8px; }
.rfh-preference-track {
  position: absolute;
  top: 15px;
  left: 0;
  right: 0;
  height: 5px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--white-14);
}
.rfh-preference-track::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), var(--white-40) calc(10% - 1px) 10%);
  opacity: 0.55;
}
.rfh-preference-track > span {
  display: block;
  width: calc(var(--preference-value) * 10%);
  height: 100%;
  background: var(--cyan);
}
.rfh-preference-thumb {
  position: absolute;
  z-index: 1;
  top: 7px;
  left: calc(var(--preference-value) * 10%);
  width: 21px;
  height: 21px;
  border: 3px solid var(--blue);
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 2px var(--cyan);
  transform: translateX(-50%);
}
.rfh-preference--off { background: var(--white-04); }
.rfh-preference--off .rfh-preference-value { color: var(--text-tertiary); }
.rfh-preference--off .rfh-preference-track > span { background: var(--surface-raised); }
.rfh-preference--off .rfh-preference-thumb { background: var(--text-tertiary); box-shadow: none; }

.rfh-feature-art {
  width: min(100%, 520px);
  margin: 0 auto;
}
.rfh-feature-art img {
  display: block;
  width: 100%;
  height: auto;
}
.rfh-offline-art {
  width: min(100%, 520px);
  margin: 0 auto;
}
.rfh-offline-art img {
  display: block;
  width: 100%;
  height: auto;
}

/* Typographic roles: display type stays deliberately tight and athletic;
   reading text gets enough leading and measure to remain calm and legible. */
.rfh-hero p, #prefs .rfh-sticky p, #offline > .rfh-split > div:last-child > p,
#join .rfh-split > div:first-child > p { max-width: 42ch !important; }
#routes p, #guidance p, #privacy p, #how p { max-width: 62ch; }
#routes h3, #guidance h3, #privacy h3 { line-height: var(--leading-tight) !important; }

/* Reusable multi-column grids collapse on narrow viewports */
.rfh-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); }
.rfh-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); }
.rfh-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); }

/* App-badge button group inherits hover from .rfh-appbadge in tokens */

/* Language switcher (in nav) ------------------------------- */
.rfh-lang { position: relative; }
.rfh-lang > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-strong);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  transition: border-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
}
.rfh-lang > summary::-webkit-details-marker { display: none; }
.rfh-lang[open] > summary,
.rfh-lang > summary:hover { color: var(--text-primary); border-color: var(--white-100); }
.rfh-lang > summary::after {
  content: ""; width: 6px; height: 6px; margin-left: 1px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
}
.rfh-lang-menu {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 60;
  min-width: 150px; padding: 8px;
  display: flex; flex-direction: column; gap: 2px;
  background: color-mix(in srgb, var(--blue) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-lg);
  box-shadow: var(--glow);
}
.rfh-lang-menu a {
  padding: 9px 12px; border-radius: var(--radius-md);
  color: var(--text-secondary); font-size: var(--text-base);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.rfh-lang-menu a:hover { background: var(--fill); color: var(--text-primary); }
.rfh-lang-menu a[aria-current="page"] { color: var(--text-primary); background: var(--fill-subtle); }
.rfh-nav:has(.rfh-lang[open]) { border-bottom-color: var(--border-strong) !important; }
.rfh-lang[open] .rfh-lang-menu {
  transform-origin: top right;
  animation: rfh-menu-in 240ms linear(0, 0.72 35%, 1.08 72%, 1) both;
}

@keyframes rfh-menu-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Scroll-linked polish. These are progressive enhancements with no JS and no
   hidden-content fallback in browsers that do not support view timelines. */
@keyframes rfh-reveal {
  from { opacity: 0; translate: 0 24px; }
  to { opacity: 1; translate: 0 0; }
}
@keyframes rfh-art-drift {
  from { transform: translateY(2.5%); }
  to { transform: translateY(-2.5%); }
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    main > section:not(.rfh-hero-shell) h2,
    main > section:not(.rfh-hero-shell) .rfh-card--interactive,
    main > section:not(.rfh-hero-shell) .rfh-preference,
    main > section:not(.rfh-hero-shell) .rfh-phone {
      animation: rfh-reveal linear both;
      animation-timeline: view(block);
      animation-range: entry 5% cover 28%;
    }
    .rfh-feature-art img {
      animation: rfh-art-drift linear both;
      animation-timeline: view(block);
      animation-range: entry 0% exit 100%;
    }
  }
}

/* Responsive ---------------------------------------------- */
@media (max-width: 940px) {
  .rfh-grid-2, .rfh-grid-3, .rfh-grid-4,
  .rfh-hero, .rfh-split { grid-template-columns: 1fr !important; }
  .rfh-split--reverse .rfh-phone,
  .rfh-split--reverse .rfh-feature-art { order: -1; }
  .rfh-sticky { position: static !important; }
  .rfh-nav-links { display: none !important; }
  .rfh-finalcta-img { min-height: 320px !important; }
  .rfh-hero { min-height: 0; padding: 0; }
  .rfh-hero-copy { padding: 64px 40px; }
  .rfh-hero-art { width: 100%; min-height: 0; aspect-ratio: 16 / 9; margin: 0; }
  .rfh-split > * { min-width: 0; }
}

@media (max-width: 620px) {
  .rfh-grid-2 { grid-template-columns: 1fr !important; }
  .rfh-nav { padding: 12px 22px !important; }
  .rfh-brand { gap: 7px !important; min-width: 0; }
  .rfh-brand-mark { width: 24px !important; height: 24px !important; }
  .rfh-brand-name { font-size: 18px !important; }
  .rfh-nav-actions { gap: 10px !important; }
  .rfh-privacy-back { display: none; }
  .rfh-legal-title { font-size: clamp(2rem, 9vw, 2.5rem) !important; }
  .rfh-section-pad { padding-left: 22px !important; padding-right: 22px !important; }
  .rfh-hero.rfh-section-pad { padding-left: 0 !important; padding-right: 0 !important; }
  .rfh-hero-copy { gap: 16px !important; padding: 22px 22px 12px; }
  .rfh-hero-art { aspect-ratio: 6 / 7; }
  .rfh-hero-video { object-position: 23% center; }
  #how, #prefs, #offline, #privacy,
  #routes > .rfh-section-pad, #guidance > .rfh-section-pad { padding-top: 72px !important; padding-bottom: 72px !important; }
  #how > div:first-child, #privacy > div:first-child { margin-bottom: 40px !important; }
  #join .rfh-split { padding-top: 0 !important; padding-bottom: 0 !important; }
  #join .rfh-split > div:first-child { padding: 72px 0 !important; }
  .rfh-card--interactive { min-height: 0 !important; padding: 24px !important; }
  .rfh-feature-art {
    width: calc(100% + 44px);
    max-width: none;
    margin-inline: -22px;
    overflow: hidden;
  }
  .rfh-offline-art {
    width: calc(100% + 44px);
    max-width: none;
    margin-inline: -22px;
    overflow: hidden;
  }
  .rfh-offline-art img {
    width: 105.3%;
    max-width: none;
    margin-left: -2.65%;
  }
  /* The exported WebP canvases contain transparent gutters. Scale each one
     by its measured visible bounds so the artwork—not just its canvas—fills
     the viewport. */
  #routes .rfh-feature-art img {
    width: 123.1%;
    max-width: none;
    margin-left: -11.55%;
  }
  #guidance .rfh-feature-art img {
    width: 113.1%;
    max-width: none;
    margin-left: -6.55%;
  }
  .rfh-phone { min-width: 0; }
  .rfh-phone > div { max-width: 100%; }
  h2[style*="var(--text-3xl)"] { font-size: clamp(2.5rem, 11.5vw, 3.25rem) !important; }
  .rfh-finalcta-img { min-height: 280px !important; }
  footer > .rfh-section-pad:first-child { grid-template-columns: 1fr 1fr !important; gap: 32px 20px !important; }
  footer > .rfh-section-pad:first-child > div:first-child { grid-column: 1 / -1; }
}

@media (max-width: 360px) {
  .rfh-nav { padding: 11px 14px !important; }
  .rfh-brand { gap: 6px !important; min-width: 0; }
  .rfh-brand-mark { width: 22px !important; height: 22px !important; }
  .rfh-brand-name { font-size: 16px !important; }
  .rfh-nav-actions { gap: 8px !important; }
  .rfh-lang > summary { padding: 7px 9px; font-size: 11px; }
  .rfh-section-pad { padding-left: 18px !important; padding-right: 18px !important; }
  .rfh-hero { padding-top: 0 !important; }
  .rfh-hero-copy { gap: 14px !important; padding: 18px 18px 10px; }
  .rfh-hero h1 { font-size: clamp(3.25rem, 16.25vw, 3.75rem) !important; }
  .rfh-hero-art { width: 100%; }
  .rfh-feature-art { width: calc(100% + 36px); margin-inline: -18px; }
  .rfh-offline-art { width: calc(100% + 36px); margin-inline: -18px; }
  .rfh-preference { padding-left: 16px; padding-right: 16px; }
  .rfh-preference-title { font-size: var(--text-base); }
  .rfh-phone { margin-inline: -8px; }
}

/* RTL niceties (future-proofing for ar/he locale files) ---- */
[dir="rtl"] .rfh-lang-menu { right: auto; left: 0; }
[dir="rtl"] .rfh-link::after { transform-origin: right; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; }
  .rfh-hero-video { display: none; }
  .rfh-hero-art-fallback { display: block; }
  .rfh-lang[open] .rfh-lang-menu { animation: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
    animation-duration: 1ms !important;
  }
}
