/*
 * FlipStudy landing page. The colors and sizes match the app's design
 * tokens (src/styles/tokens.css) so the two feel like one product.
 */
:root {
  /* Height of the zigzag tilt between sections (see .tilt-up / .tilt-down). */
  --tilt: 80px;
  --section-pad: 96px;

  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-primary-soft: #eef2ff;
  --color-bg: #f7f8fb;
  --color-surface: #ffffff;
  --color-surface-muted: #f1f3f8;
  --color-border: #e4e7ef;
  --color-border-strong: #cfd4e0;
  --color-text: #161a2b;
  --color-text-muted: #5b6275;
  --color-text-subtle: #868ca0;

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-sm: 0 1px 2px rgba(22, 26, 43, 0.06);
  --shadow-md: 0 4px 14px rgba(22, 26, 43, 0.08);
  --shadow-lg: 0 18px 40px rgba(22, 26, 43, 0.14);
  --focus-ring: 0 0 0 3px rgba(79, 70, 229, 0.35);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

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

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.02em;
}

a {
  color: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

.eyebrow {
  margin-bottom: 12px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-primary);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn--lg {
  height: 50px;
  padding: 0 26px;
  font-size: 1rem;
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
}

.btn--primary:hover {
  background: var(--color-primary-hover);
}

.btn--secondary {
  background: var(--color-surface);
  border-color: var(--color-border-strong);
}

.btn--secondary:hover {
  background: var(--color-surface-muted);
}

.btn--ghost {
  color: var(--color-text-muted);
}

.btn--ghost:hover {
  background: var(--color-surface-muted);
  color: var(--color-text);
}

.btn--light {
  background: #fff;
  color: var(--color-primary);
}

.btn--light:hover {
  background: var(--color-primary-soft);
}

/* ---------- Navigation ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--color-border);
  background: rgba(247, 248, 251, 0.88);
  backdrop-filter: blur(10px);
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  border-radius: 6px;
}

/* The logo (icon + wordmark). Its height sets the size; width follows. */
.brand__logo {
  display: block;
  width: auto;
  height: 38px;
}


.nav__links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav__link {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}

.nav__link:hover {
  color: var(--color-text);
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  isolation: isolate; /* keeps the background layer behind the hero content */
  /* Generous space around the content; the bottom also makes room for the tilt. */
  padding: 136px 0 216px;
  /* The tilted cards behind the demo card must not widen the page on phones. */
  overflow-x: clip;
  color: #fff;
}

/* ---------- Hero text on the dark background ---------- */
.hero .eyebrow {
  color: #67e8f9; /* bright cyan */
}

.hero h1 {
  color: #fff;
}

.hero .btn--primary {
  background: #6366f1;
  box-shadow: 0 8px 28px rgba(99, 102, 241, 0.5);
}

.hero .btn--primary:hover {
  background: #7477ff;
}

/* Glass-style secondary button. */
.hero .btn--secondary {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.hero .btn--secondary:hover {
  background: rgba(255, 255, 255, 0.16);
}

.hero .btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(103, 232, 249, 0.6);
}

/* ---------- Hero background: drifting gradient + falling letters ---------- */
.hero__bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  /* Deep night-sky base with a touch of pink low on the right. */
  background:
    radial-gradient(circle at 75% 100%, rgba(236, 72, 153, 0.28), transparent 45%),
    linear-gradient(160deg, #0b0a24 0%, #17134a 55%, #221a5c 100%);
}

/* Two soft color blobs that slowly drift around. */
.hero__bg::before,
.hero__bg::after {
  content: '';
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.75;
  will-change: transform;
}

.hero__bg::before {
  top: -30vmax;
  right: -15vmax;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.7), transparent 65%); /* violet */
  animation: blob-drift-a 18s ease-in-out infinite alternate;
}

.hero__bg::after {
  bottom: -35vmax;
  left: -20vmax;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.45), transparent 65%); /* cyan */
  animation: blob-drift-b 22s ease-in-out infinite alternate;
}

@keyframes blob-drift-a {
  to {
    transform: translate(-18vmax, 14vmax) scale(1.15);
  }
}

@keyframes blob-drift-b {
  to {
    transform: translate(22vmax, -12vmax) scale(1.1);
  }
}

/*
 * Divider: a simple tilt (an SVG in the HTML). One slanted edge in the page
 * color, so the dark hero runs into the next section at an angle.
 */
.hero__tilt {
  position: absolute;
  inset: auto 0 -1px; /* -1px avoids a hairline gap from rounding */
  z-index: -1; /* behind the hero content, in front of the background */
  display: block;
  width: 100%;
  height: 120px;
  fill: var(--color-bg);
  pointer-events: none;
}

/*
 * The falling letters are drawn on this canvas by matrix-rain.js.
 * The mask keeps them faint behind the headline (right) and fuller on the left.
 */
.hero__rain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  -webkit-mask-image: linear-gradient(270deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.35) 40%, #000 80%);
  mask-image: linear-gradient(270deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.35) 40%, #000 80%);
}

.hero__inner {
  display: grid;
  grid-template-columns: 1fr 1.1fr; /* cards on the left, text on the right */
  align-items: center;
  gap: 96px;
}

.hero h1 {
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  font-weight: 800;
}

.hero__lead {
  max-width: 520px;
  margin-top: 20px;
  font-size: 1.125rem;
  color: #c9cbea; /* light text on the dark hero */
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

/* ---------- "Mobile app coming soon" line (hero and closing box) ---------- */
/* Plain text, not a button: a pulsing dot, a phone icon and shimmering text. */
.soon {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* In the closing box: its own centred row below the button (and override
   the box's paragraph styles). */
.cta .soon {
  display: flex;
  justify-content: center;
  margin: 24px 0 0;
  font-size: 0.875rem;
}

/* A live dot with a ring that keeps pulsing outwards. */
.soon__dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #67e8f9;
  box-shadow: 0 0 10px #67e8f9;
}

.soon__dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #67e8f9;
  animation: soon-ping 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes soon-ping {
  to {
    transform: scale(3);
    opacity: 0;
  }
}

.soon__icon {
  flex-shrink: 0;
  color: #c4b5fd;
}

/* Shimmering gradient text: cyan → violet → pink, sliding slowly. */
.soon__text {
  background: linear-gradient(90deg, #67e8f9, #c4b5fd, #f9a8d4, #c4b5fd, #67e8f9);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: soon-shimmer 4s linear infinite;
}

@keyframes soon-shimmer {
  to {
    background-position: 200% center;
  }
}

.hero__visual {
  position: relative;
  /* Shown in the left column; it stays second in the HTML, so screen readers
     and keyboard users still get the headline first. */
  order: -1;
  max-width: 460px;
  width: 100%;
  justify-self: center;
  /* Floats gently up and down. Hover zoom uses `scale`, a separate property,
     so it combines with the floating `transform` instead of replacing it. */
  animation: card-float 6s ease-in-out infinite;
  transition: scale 350ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.hero__visual:hover {
  scale: 1.05;
}

/* Soft shadow under the floating cards; it shrinks as the cards rise. */
.hero__visual::after {
  content: '';
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -44px;
  z-index: -1;
  height: 28px;
  border-radius: 50%;
  background: rgba(5, 4, 20, 0.55);
  filter: blur(14px);
  animation: card-float-shadow 6s ease-in-out infinite;
}

@keyframes card-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-14px);
  }
}

@keyframes card-float-shadow {
  0%,
  100% {
    transform: translateY(0) scale(1);
    opacity: 0.9;
  }
  /* The shadow stays put while the cards rise, so it moves down to compensate. */
  50% {
    transform: translateY(14px) scale(0.85);
    opacity: 0.6;
  }
}

/* Two cards peeking out behind the demo card. */
.stack,
.stack::before {
  position: absolute;
  inset: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.stack {
  transform: rotate(6deg) translate(14px, 6px);
  transition: transform 350ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.stack::before {
  content: '';
  transform: rotate(-11deg) translate(-26px, 4px);
  background: var(--color-primary-soft);
  transition: transform 350ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* On hover the cards behind fan out a little further. */
.hero__visual:hover .stack {
  transform: rotate(9deg) translate(24px, 8px);
}

.hero__visual:hover .stack::before {
  transform: rotate(-16deg) translate(-40px, 6px);
}

/* ---------- Demo flashcard ---------- */
.demo-card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  border: none;
  border-radius: var(--radius-xl);
  background: transparent;
  font: inherit;
  color: var(--color-text); /* light card on the dark hero */
  perspective: 1400px;
  cursor: pointer;
}

.demo-card__inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 500ms cubic-bezier(0.4, 0.2, 0.2, 1);
}

.demo-card.is-flipped .demo-card__inner {
  transform: rotateY(180deg);
}

.demo-card__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  text-align: center;
}

.demo-card__face--back {
  transform: rotateY(180deg);
  background: linear-gradient(160deg, var(--color-primary-soft), var(--color-surface) 70%);
}

.demo-card__tag {
  position: absolute;
  top: 20px;
  left: 24px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-primary);
}

.demo-card__text {
  font-size: clamp(1.25rem, 2.6vw, 1.75rem);
  font-weight: 650;
  line-height: 1.3;
}

.demo-card__hint {
  position: absolute;
  bottom: 20px;
  font-size: 0.8125rem;
  color: var(--color-text-subtle);
}

.demo-card:focus-visible {
  box-shadow: none;
}

.demo-card:focus-visible .demo-card__face {
  box-shadow: var(--focus-ring), var(--shadow-lg);
}

/* ---------- Sections ---------- */
.section {
  padding: var(--section-pad) 0;
}

.section--muted {
  background: #eceafe; /* soft lavender */
}

/* An opaque page-color background, needed for a tilted section. */
.section--plain {
  background: var(--color-bg);
}


.section__header {
  max-width: 640px;
  margin: 0 auto 48px;
  text-align: center;
}

.section__header h2 {
  font-size: clamp(1.75rem, 3.5vw, 2.375rem);
  font-weight: 800;
}

/* ---------- Features ---------- */
/* Cards stacked on the left, photo on the right. */
.features-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  align-items: center;
  gap: 48px;
}

/* The title sits left-aligned above the cards, so the photo can rise beside it. */
#features .section__header {
  max-width: none;
  margin: 0 0 28px;
  text-align: left;
}

/* Title + cards. The section has no bottom padding (for the photo), so the
   space below the cards lives here. */
.features-main {
  position: relative;
  z-index: 1; /* on top of the photo's soft left side */
  align-self: start;
  margin-bottom: 64px;
}

/* No bottom padding: the photo sits right on the section's bottom edge. */
#features {
  /* Space between the container and the window edge (container max 1120px, padding 24px). */
  --bleed: calc(max(0px, (100vw - 1120px) / 2) + 24px);
  padding-top: 56px; /* tighter than other sections */
  padding-bottom: 0;
  overflow-x: clip; /* the photo reaches the window edge; never scroll sideways */
}

.features {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Each card is a row: icon on the left (vertically centred), text on the right. */
.feature {
  display: grid;
  grid-template-columns: 44px 1fr;
  column-gap: 18px;
  align-items: center;
  padding: 20px 24px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  /* Two layers: a tight one for crisp edges, a soft violet one for lift. */
  box-shadow:
    0 2px 6px rgba(22, 26, 43, 0.06),
    0 14px 32px rgba(79, 70, 229, 0.14);
}

/*
 * Flip-in on scroll, for any element with the `flip-in` class (feature cards
 * and the closing box). flip-in.js adds .js-flip to <html>, then .is-flipped
 * to each element as it comes into view. Without the script, they just show.
 * `flip-in--x` flips top-over (for wide elements) instead of sideways.
 */
.js-flip .flip-in {
  opacity: 0;
  transform: perspective(900px) rotateY(-90deg);
}

.js-flip .flip-in--x {
  transform: perspective(1600px) rotateX(-90deg);
}

.js-flip .flip-in.is-flipped {
  animation: flip-in-y 1100ms cubic-bezier(0.2, 0.7, 0.2, 1) var(--flip-delay, 0ms) both;
}

.js-flip .flip-in--x.is-flipped {
  animation-name: flip-in-x;
  animation-duration: 1300ms;
}

@keyframes flip-in-y {
  0% {
    opacity: 0;
    transform: perspective(900px) rotateY(-90deg);
  }
  60% {
    opacity: 1;
    transform: perspective(900px) rotateY(12deg); /* a little overshoot */
  }
  100% {
    opacity: 1;
    transform: perspective(900px) rotateY(0deg);
  }
}

@keyframes flip-in-x {
  0% {
    opacity: 0;
    transform: perspective(1600px) rotateX(-90deg);
  }
  60% {
    opacity: 1;
    transform: perspective(1600px) rotateX(10deg); /* a little overshoot */
  }
  100% {
    opacity: 1;
    transform: perspective(1600px) rotateX(0deg);
  }
}

.feature__icon {
  display: grid;
  grid-row: span 2;
  align-self: center;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.feature h3 {
  font-size: 1.125rem;
}

.feature p {
  margin-top: 4px;
  color: var(--color-text-muted);
}

/*
 * The photo fills the right side: its right edge is the window edge, it
 * reaches left behind the title and cards (soft, blurred background), and its
 * desk sits on the section's bottom edge. Capped at 1060px wide so very wide
 * screens don't make the section tall.
 */
.features__photo {
  align-self: end;
  justify-self: end; /* anchor to the right, so the cap trims the left side */
  width: min(calc(145% + var(--bleed)), 1060px);
  /* Reach at most 220px past the content edge (not all the way to the window
     edge), so on wide screens the photo stays near the centre. Same size. */
  margin: 0 calc(-1 * min(var(--bleed), 220px)) 0 0;
}

/* The photo comes with its own soft white edges, so it's shown as-is. */
.features__photo img {
  display: block;
  width: 100%;
  height: auto;
}

/* ---------- Steps ---------- */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step {
  position: relative;
  text-align: center;
}

/*
 * Dotted arrows between the steps (images/dotted-arrow.svg), level with the
 * 80px badges: 1 -> 2 as drawn, 2 -> 3 flipped upside down. Decorative only,
 * so they're CSS and screen readers skip them. Hidden when the steps stack.
 */
@media (min-width: 861px) {
  .step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 40px; /* middle of the badge */
    /*
     * --space: room between this badge and the next (column + 32px gap - one
     * 80px badge). The arrow is 70% of that minus 48px each side, centred.
     */
    --space: calc(100% + 32px - 80px);
    --arrow: calc((var(--space) - 96px) * 0.7);
    left: calc(50% + 40px + (var(--space) - var(--arrow)) / 2);
    width: var(--arrow);
    aspect-ratio: 161.251 / 103.203; /* the SVG's own proportions */
    background: url('images/dotted-arrow.svg') center / contain no-repeat;
    opacity: 0.5;
    transform: translateY(-50%);
    pointer-events: none;
  }

  .step:nth-child(2)::after {
    transform: translateY(-50%) scaleY(-1);
  }
}

/*
 * Step badges: rounded-square gradient tiles in the same night-sky colors as
 * the closing box (dark base with violet, cyan and pink glows).
 */
.step__number {
  display: inline-grid;
  place-items: center;
  width: 80px;
  height: 80px;
  margin-bottom: 20px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 28% 22%, rgba(139, 92, 246, 0.85), transparent 55%),
    radial-gradient(circle at 78% 82%, rgba(236, 72, 153, 0.55), transparent 50%),
    radial-gradient(circle at 18% 88%, rgba(34, 211, 238, 0.5), transparent 50%),
    linear-gradient(160deg, #0b0a24 0%, #17134a 55%, #221a5c 100%);
  box-shadow: 0 14px 30px rgba(79, 70, 229, 0.3);
  color: #fff;
  font-size: 1.625rem;
  font-weight: 800;
}

.step h3 {
  font-size: 1.125rem;
}

.step p {
  max-width: 300px;
  margin: 6px auto 0;
  color: var(--color-text-muted);
}

/* ---------- Call to action ---------- */
/* Same night-sky look as the hero: dark base, glows that slowly drift. */
.cta {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 72px 32px;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 80% 110%, rgba(236, 72, 153, 0.35), transparent 45%),
    linear-gradient(160deg, #0b0a24 0%, #17134a 55%, #221a5c 100%);
  box-shadow: var(--shadow-lg);
  color: #fff;
  text-align: center;
}

.cta::before,
.cta::after {
  content: '';
  position: absolute;
  z-index: -1;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(50px);
  opacity: 0.75;
  will-change: transform;
}

.cta::before {
  top: -300px;
  right: -120px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.7), transparent 65%); /* violet */
  animation: blob-drift-a 18s ease-in-out infinite alternate;
}

.cta::after {
  bottom: -320px;
  left: -140px;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.45), transparent 65%); /* cyan */
  animation: blob-drift-b 22s ease-in-out infinite alternate;
}

.cta h2 {
  font-size: clamp(1.75rem, 3.5vw, 2.375rem);
  font-weight: 800;
}

.cta p {
  margin: 10px 0 28px;
  font-size: 1.125rem;
  color: #c9cbea;
}

.cta .btn--light {
  box-shadow: 0 8px 28px rgba(139, 92, 246, 0.45);
}

/* ---------- Footer ---------- */
/* Dark like the hero, so the page opens and closes with the same color. */
.footer {
  --section-pad: 40px;
  padding: var(--section-pad) 0;
  background: linear-gradient(160deg, #0b0a24 0%, #17134a 60%, #221a5c 100%);
  font-size: 0.875rem;
  color: #c9cbea;
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.footer__links {
  display: flex;
  gap: 20px;
}

.footer__links a {
  text-decoration: none;
}

.footer__links a:hover {
  color: #fff;
}

/* ---------- Zigzag between sections ----------
 * (Kept after the section and footer styles so its padding-top wins.)
 *
 * Zigzag between sections: a tilted section slides up under the one above
 * by --tilt and cuts its own top edge on a slant, so the section above shows
 * through the cut. Alternate the two classes to zigzag:
 *   .tilt-down  top edge high on the left, low on the right  ( \ )
 *   .tilt-up    top edge low on the left, high on the right  ( / )
 * A tilted section needs its own (non-transparent) background.
 */
.tilt-down,
.tilt-up {
  margin-top: calc(-1 * var(--tilt));
  padding-top: calc(var(--section-pad) + var(--tilt));
}

.tilt-down {
  clip-path: polygon(0 0, 100% var(--tilt), 100% 100%, 0 100%);
}

.tilt-up {
  clip-path: polygon(0 var(--tilt), 100% 0, 100% 100%, 0 100%);
}

/* The section above a tilt loses --tilt of space to the overlap; give it back. */
.section:has(+ .tilt-down),
.section:has(+ .tilt-up),
main:has(+ .tilt-down) > .section:last-child, /* the last section, above a tilted footer */
main:has(+ .tilt-up) > .section:last-child {
  padding-bottom: calc(var(--section-pad) + var(--tilt));
}

/* ---------- Small screens ---------- */
@media (max-width: 860px) {
  /* Stacked: text first, then the cards. */
  .hero__visual {
    order: 0;
  }

  .hero {
    padding: 88px 0 128px;
  }

  /* Narrower screens: a gentler tilt. */
  .hero__tilt {
    height: 56px;
  }

  .hero__rain {
    -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.3) 45%, #000 85%);
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.3) 45%, #000 85%);
  }

  .hero__inner {
    grid-template-columns: 1fr;
    gap: 48px;
  }

  .steps {
    grid-template-columns: 1fr;
  }

  .features-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  /* Stacked: title and cards, then the photo on the section's bottom edge. */
  .features-main {
    margin-bottom: 0;
  }

  #features .section__header {
    text-align: center;
  }

  /* Edge to edge across the full width. */
  .features__photo {
    justify-self: stretch;
    width: auto;
    margin: 0 -24px;
  }

  :root {
    --tilt: 40px; /* a gentler zigzag on narrow screens */
    --section-pad: 72px;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 0 16px;
  }

  #features {
    padding-top: 40px;
  }

  #features .section__header {
    margin-bottom: 24px;
  }

  .features__photo {
    margin: 0 -16px;
  }


  .brand__logo {
    height: 32px;
  }

  /* Keep only the two buttons in the top bar. */
  .nav__link {
    display: none;
  }

  .hero__actions .btn {
    flex: 1 1 100%;
  }

  .hero__visual {
    max-width: 340px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .demo-card__inner {
    transition: none;
  }

  .hero__bg::before,
  .hero__bg::after,
  .hero__visual,
  .hero__visual::after,
  .cta::before,
  .cta::after,
  .soon__dot::after,
  .soon__text {
    animation: none;
  }
}
