/* Wandry legal pages — modern, app-flavoured stylesheet.
 *
 * Visual language pulled directly from the Android app:
 *   • palette mirrors ui/theme/Theme.kt (sage / cream / gold / terracotta)
 *   • hero artwork echoes ui/components/SplashView.kt — unfolding panels,
 *     dashed travel route, drop-pin landmarks
 *   • cards use Material-3 elevated-surface tokens with the same soft
 *     double shadow used in TripCard / SectionChip
 *
 * Adaptive across every device:
 *   • mobile-first (320 px+ usable), fluid `clamp()` type, container-relative
 *     spacing
 *   • >= 880 px viewport gains a sticky sidebar ToC; below that the ToC
 *     becomes a horizontally-scrollable pill rail under the hero
 *   • >= 1280 px viewport adds a third column of breathing room
 *   • respects `prefers-color-scheme`, `prefers-reduced-motion`, and
 *     iOS safe-area insets
 */

/* ─── Tokens ──────────────────────────────────────────────────────── */
:root {
  --sage:        #7A8B6F;
  --sage-dark:   #5E6E55;
  --sage-soft:   rgba(122, 139, 111, 0.16);
  --sage-glow:   rgba(122, 139, 111, 0.55);
  --cream:       #F5F1EA;
  --cream-card:  #FBF8F5;
  --cream-line:  #E6DFD2;
  --gold:        #C9A876;
  --gold-soft:   rgba(201, 168, 118, 0.16);
  --gold-glow:   rgba(201, 168, 118, 0.55);
  --terra:       #B5715A;
  --terra-soft:  rgba(181, 113, 90, 0.16);
  --ink:         #1A1F1B;
  --ink-soft:    #4A5249;
  --ink-faint:   #76806F;

  --radius-card: 24px;
  --radius-pill: 999px;
  --shadow-1:    0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.03);
  --shadow-2:    0 4px 12px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.03);
  --shadow-3:    0 24px 40px rgba(26, 31, 27, 0.10), 0 8px 16px rgba(26, 31, 27, 0.06);

  /* Fluid type scale — small phone (320 px) → desktop.
   * Mins are tuned so the longest unbreakable hero word
   * ("Wandry.", "phone.") still fits on a 320 px viewport
   * with 16 px outer padding. Max hero is intentionally
   * capped below the 1080×fluid extreme so the desktop
   * header doesn't dominate the page. */
  --t-hero:      clamp(1.6rem, 2.6vw + 0.85rem, 2.85rem);
  --t-h2:        clamp(1.2rem, 0.9vw + 0.95rem, 1.65rem);
  --t-h3:        clamp(1rem,   0.4vw + 0.85rem, 1.18rem);
  --t-body:      clamp(0.95rem, 0.2vw + 0.88rem, 1.06rem);
  --t-small:     clamp(0.82rem, 0.1vw + 0.78rem, 0.92rem);
  --t-eyebrow:   clamp(0.68rem, 0.06vw + 0.66rem, 0.76rem);

  --space-card-x: clamp(16px, 4vw, 32px);
  --space-card-y: clamp(20px, 3.5vw, 30px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --sage:        #A8B59C;
    --sage-dark:   #8A9A82;
    --sage-soft:   rgba(168, 181, 156, 0.16);
    --sage-glow:   rgba(168, 181, 156, 0.55);
    --cream:       #14181A;
    --cream-card:  #1F2422;
    --cream-line:  #2D332E;
    --gold:        #D9BC8E;
    --gold-soft:   rgba(217, 188, 142, 0.18);
    --gold-glow:   rgba(217, 188, 142, 0.50);
    --terra:       #C99479;
    --terra-soft:  rgba(201, 148, 121, 0.18);
    --ink:         #ECECEC;
    --ink-soft:    #BEC3BB;
    --ink-faint:   #8A9085;
    --shadow-1:    0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-2:    0 4px 12px rgba(0, 0, 0, 0.36), 0 2px 4px rgba(0, 0, 0, 0.30);
    --shadow-3:    0 24px 40px rgba(0, 0, 0, 0.55), 0 8px 16px rgba(0, 0, 0, 0.35);
  }
}

/* ─── Reset ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 96px; }

body {
  background: var(--cream);
  color: var(--ink);
  font-family: "Google Sans", "Roboto", -apple-system, BlinkMacSystemFont,
               "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: var(--t-body);
  line-height: 1.62;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  /* Honour the gesture/notch safe areas on iOS / foldables. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Subtle background mesh — two soft gradient orbs in the corners, exactly
 * the palette the marketing screenshots use behind the phone frame. Fixed
 * so the mesh doesn't shift as you scroll. */
body::before {
  content: "";
  position: fixed; inset: -10%;
  background:
    radial-gradient(50% 40% at 92% 6%, var(--gold-glow), transparent 60%),
    radial-gradient(45% 38% at 6% 86%, var(--sage-glow), transparent 60%);
  opacity: 0.45;
  pointer-events: none;
  z-index: -1;
}
@media (prefers-color-scheme: dark) {
  body::before { opacity: 0.30; }
}

/* ─── Layout ──────────────────────────────────────────────────────── */
.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 48px) clamp(16px, 4vw, 40px) 96px;
}

/* Desktop: hero spans full width, then a two-column [ToC | content] grid. */
.shell-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(20px, 2.5vw, 32px);
}
@media (min-width: 880px) {
  .shell-grid {
    grid-template-columns: 240px minmax(0, 1fr);
    align-items: start;
  }
}
@media (min-width: 1280px) {
  .shell-grid { grid-template-columns: 260px minmax(0, 1fr) 60px; }
}

/* ─── Hero ────────────────────────────────────────────────────────── */
.hero {
  position: relative;
  grid-column: 1 / -1;
  border-radius: var(--radius-card);
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 0% 100%, rgba(255,255,255,0.18), transparent 55%),
    radial-gradient(80% 100% at 100% 0%, rgba(255,255,255,0.10), transparent 55%),
    linear-gradient(135deg, var(--sage) 0%, var(--sage-dark) 45%, var(--gold) 100%);
  color: #FFFFFF;
  /* Vertical padding is what makes the desktop hero feel "big" — keep
   * it modest so the page leads with content, not chrome. */
  padding: clamp(20px, 3.4vw, 38px) clamp(18px, 4vw, 48px);
  box-shadow: var(--shadow-3);
  margin-bottom: clamp(18px, 2.4vw, 26px);
  min-width: 0;
}
.hero h1 { overflow-wrap: break-word; }
.hero-body { position: relative; z-index: 2; max-width: 640px; }

/* App-icon logo at the top of the hero — uses the real launcher icon
 * shipped in mipmap-xxxhdpi/. Sits above the eyebrow on a soft glass
 * tile so it reads against any hero gradient. */
.brand-mark {
  display: inline-flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}
.brand-mark img {
  width: clamp(40px, 6vw, 52px);
  height: clamp(40px, 6vw, 52px);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.18);
  padding: 2px;
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.16),
    inset 0 0 0 1px rgba(255, 255, 255, 0.24);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.brand-mark .wordmark {
  display: grid; gap: 2px;
  min-width: 0;
}
.brand-mark .wordmark .name {
  font-size: clamp(0.98rem, 0.4vw + 0.88rem, 1.08rem);
  font-weight: 700; letter-spacing: -0.01em; color: #FFFFFF;
  white-space: nowrap;
}
.brand-mark .wordmark .sub {
  font-size: var(--t-eyebrow); font-weight: 500;
  letter-spacing: 0.10em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
  white-space: nowrap;
}

.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: var(--t-eyebrow); font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  background: rgba(255, 255, 255, 0.16);
  padding: 5px 12px; border-radius: var(--radius-pill);
  margin-bottom: 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.hero .eyebrow .dot {
  width: 6px; height: 6px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.32);
}
.hero h1 {
  font-size: var(--t-hero);
  font-weight: 700; letter-spacing: -0.025em; line-height: 1.05;
  text-wrap: balance;
}
.hero .lede {
  margin-top: 12px; max-width: 520px;
  font-size: clamp(0.95rem, 0.25vw + 0.88rem, 1.05rem);
  line-height: 1.5; color: rgba(255, 255, 255, 0.92);
}
.hero .meta {
  margin-top: 14px; font-size: var(--t-small);
  color: rgba(255, 255, 255, 0.78);
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
}
.hero .meta .sep { width: 1px; height: 11px; background: rgba(255, 255, 255, 0.30); }

/* "Cross-page" pill — sits inside the hero, lets the reader jump to the
 * sibling legal page without scrolling to the footer. */
.hero-cross {
  margin-top: 14px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 12px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #FFFFFF;
  border-radius: var(--radius-pill);
  font-size: var(--t-small); font-weight: 600;
  text-decoration: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 140ms ease, transform 140ms ease;
}
.hero-cross:hover {
  background: rgba(255, 255, 255, 0.26);
  transform: translateY(-1px);
}
.hero-cross .arrow {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.20);
  font-size: 10px; font-weight: 700;
}
.hero-cross .label-soft { font-weight: 400; opacity: 0.85; }

/* Splash-style route decoration in the hero — echoes SplashView.kt's
 * dashed route + landmark pins. SVG sits absolutely; the @keyframes
 * animation draws the route on load. Subtle on phones, prominent on
 * larger screens. */
.hero-route {
  position: absolute; right: -8%; top: -8%;
  width: clamp(140px, 38%, 480px); aspect-ratio: 1 / 1;
  opacity: 0.32;
  pointer-events: none;
  z-index: 1;
}
/* Hide the decoration entirely on the narrowest phones so it never
 * competes with text — preserves taste at 320–360 px. */
@media (max-width: 380px) {
  .hero-route { display: none; }
}
.hero-route .path {
  fill: none; stroke: #FFFFFF; stroke-width: 3;
  stroke-linecap: round; stroke-dasharray: 6 10;
  stroke-dashoffset: 400;
  animation: draw-route 1.6s 0.3s ease-out forwards;
}
.hero-route .pin { transform-origin: center; transform: scale(0); }
.hero-route .pin.p1 { animation: pop-in 0.55s 1.05s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.hero-route .pin.p2 { animation: pop-in 0.55s 1.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.hero-route .pin.p3 { animation: pop-in 0.55s 1.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }

@keyframes draw-route { to { stroke-dashoffset: 0; } }
@keyframes pop-in { to { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-route .path, .hero-route .pin { animation: none; }
  .hero-route .path { stroke-dashoffset: 0; }
  .hero-route .pin { transform: scale(1); }
}

/* ─── Sticky ToC ──────────────────────────────────────────────────── */
.toc {
  background: var(--cream-card);
  border-radius: var(--radius-card);
  padding: 18px 14px;
  box-shadow: var(--shadow-2);
  position: sticky; top: clamp(12px, 2vw, 24px);
}
.toc-title {
  font-size: var(--t-eyebrow); font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-faint);
  padding: 4px 12px 10px;
}
.toc ol { list-style: none; counter-reset: toc; display: grid; gap: 2px; }
.toc a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 14px;
  font-size: var(--t-small); font-weight: 500;
  color: var(--ink-soft); text-decoration: none;
  transition: background 140ms ease, color 140ms ease;
  counter-increment: toc;
}
.toc a::before {
  content: counter(toc, decimal-leading-zero);
  font-variant-numeric: tabular-nums;
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--ink-faint);
  min-width: 22px;
}
.toc a:hover { background: var(--sage-soft); color: var(--ink); }
.toc a:hover::before { color: var(--sage-dark); }

/* Mobile / tablet (< 880 px) — flatten the ToC into a horizontally
 * scrolling pill rail under the hero. Strict overflow-x: auto on the
 * <ol> + min-width: 0 on the wrapping aside guarantee it never bursts
 * the column it sits in. */
aside { min-width: 0; }
@media (max-width: 879px) {
  .toc {
    position: static;
    padding: 12px;
    overflow: hidden;
  }
  .toc-title { display: none; }
  .toc ol {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    margin: -2px;
    /* Tiny right pad so the last pill isn't kissing the edge once
     * scrolled to the end. */
    padding-right: 8px;
  }
  .toc ol::-webkit-scrollbar { display: none; }
  .toc a {
    scroll-snap-align: start;
    padding: 8px 14px;
    background: var(--sage-soft);
    color: var(--ink);
    white-space: nowrap;
  }
  .toc a::before { color: var(--sage-dark); }
}

/* ─── Section cards ───────────────────────────────────────────────── */
.content { display: grid; gap: clamp(14px, 1.8vw, 22px); min-width: 0; }
.shell-grid > * { min-width: 0; }

.card {
  background: var(--cream-card);
  border-radius: var(--radius-card);
  padding: var(--space-card-y) var(--space-card-x);
  box-shadow: var(--shadow-1);
  transition: box-shadow 200ms ease, transform 200ms ease;
}
@media (hover: hover) and (min-width: 880px) {
  .card:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
}

.card.lead {
  background: linear-gradient(135deg, var(--cream-card), var(--gold-soft));
  border: 1px solid var(--cream-line);
  font-size: clamp(1.05rem, 0.4vw + 0.95rem, 1.18rem);
  color: var(--ink); line-height: 1.55; text-wrap: balance;
}

.card h2 {
  display: flex; align-items: center; gap: 14px;
  font-size: var(--t-h2);
  font-weight: 700; letter-spacing: -0.018em; line-height: 1.2;
  margin-bottom: 14px;
}
.card h2 .num {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  background: var(--sage-soft);
  color: var(--sage-dark);
  border-radius: 12px;
  font-size: 14px; font-weight: 700; letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.card h3 {
  font-size: var(--t-h3);
  font-weight: 600; letter-spacing: -0.01em;
  margin: 18px 0 6px;
  color: var(--ink);
}

.card p { margin-bottom: 12px; color: var(--ink-soft); }
.card p:last-child { margin-bottom: 0; }
.card p strong, .card li strong { color: var(--ink); font-weight: 600; }

.card a {
  color: var(--sage-dark); text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--sage-dark) 32%, transparent);
  transition: border-color 120ms ease, color 120ms ease;
}
.card a:hover {
  border-bottom-color: var(--sage-dark);
  color: var(--sage);
}

/* Inline chip — matches SectionChip selected state from the trip detail. */
.chip {
  display: inline-flex; align-items: center;
  background: var(--sage-soft);
  color: var(--sage-dark);
  padding: 3px 11px; border-radius: var(--radius-pill);
  font-size: 0.85em; font-weight: 600;
  white-space: nowrap;
}

/* Bullet list — sage dot, app-flavoured. */
.card ul { list-style: none; display: grid; gap: 4px; }
.card ul li {
  position: relative;
  padding: 4px 0 4px 26px;
  color: var(--ink-soft);
}
.card ul li::before {
  content: ""; position: absolute; left: 4px; top: 0.85em;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--sage);
  box-shadow: 0 0 0 4px var(--sage-soft);
}

/* Callout — gold-tinted, used for the "what we don't collect" emphasis. */
.callout {
  position: relative;
  background: var(--gold-soft);
  border-radius: 16px;
  padding: 16px 18px 16px 56px;
  margin: 10px 0 14px;
  color: var(--ink);
  font-size: var(--t-body);
  line-height: 1.5;
  text-wrap: balance;
}
.callout::before {
  content: ""; position: absolute; left: 18px; top: 50%;
  transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--gold);
  /* Sparkle / shield icon in white. */
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M12 2 4 5v6c0 5 3.5 9.5 8 11 4.5-1.5 8-6 8-11V5l-8-3z"/></svg>') center / 18px no-repeat;
          mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M12 2 4 5v6c0 5 3.5 9.5 8 11 4.5-1.5 8-6 8-11V5l-8-3z"/></svg>') center / 18px no-repeat;
  background-color: #FFFFFF;
  /* The trick above colours the icon via mask; here we re-apply the real
   * gold pill behind it. */
  box-shadow: 0 0 0 999px var(--gold) inset;
}

/* Service row — one third-party endpoint per row, two-column on wide
 * screens (name | description), stacked on phones. */
.services { display: grid; gap: 0; margin: 6px 0 2px; }
.service {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 16px 0;
  border-top: 1px solid var(--cream-line);
}
.service:first-child { padding-top: 4px; border-top: 0; }
.service:last-child  { padding-bottom: 0; }
.service .name {
  font-weight: 600; color: var(--ink);
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px;
}
.service .name .host {
  font-weight: 400; color: var(--ink-faint); font-size: 0.85em;
  font-family: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  background: var(--sage-soft); padding: 2px 8px; border-radius: 6px;
}
.service .what { color: var(--ink-soft); font-size: 0.97em; }

@media (min-width: 720px) {
  .service { grid-template-columns: minmax(180px, 0.9fr) minmax(0, 1.6fr); column-gap: 28px; }
  .service .name .host { display: block; margin-top: 6px; align-self: start; }
}

/* ─── Footer ──────────────────────────────────────────────────────── */
.foot {
  grid-column: 1 / -1;
  margin-top: 28px;
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 6px 18px;
  text-align: center;
  color: var(--ink-faint);
  font-size: var(--t-small);
}
.foot a {
  color: var(--ink-faint); text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 120ms ease, border-color 120ms ease;
}
.foot a:hover {
  color: var(--sage-dark);
  border-bottom-color: var(--sage-dark);
}
.foot .brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 600; color: var(--ink-soft);
}
.foot .brand img {
  width: 24px; height: 24px; border-radius: 7px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10);
}

/* Skip link — invisible until focused. */
.skip-link {
  position: absolute; left: -9999px; top: 8px;
  background: var(--ink); color: var(--cream);
  padding: 8px 14px; border-radius: 10px;
  font-size: var(--t-small); font-weight: 500;
  z-index: 100;
}
.skip-link:focus { left: 16px; outline: 2px solid var(--gold); }
