/* The Roommates page: your flat with a free room, and people to fill it (js/story-worlds.mjs),
   instead of the city from the Rent story. Colours come from the --st-* tokens in css/story.css, so both themes follow the brand.
   js/roommates-hero.js adds the reveal and the parallax; without it everything simply shows.

   Everything inside .st-demo is an illustration with example details. See docs/homepage-seo.md. */

/* ── Hero ─────────────────────────────────────────────────────────────── */
/* One screen when it fits, and taller when it does not, so the search never covers the words. */
html.st-pinned .rx-hero { height: auto; }
html.st-pinned .rx-hero .st-pin { position: relative; height: auto; min-height: 100vh; min-height: 100svh; }
.rx-hero { background: radial-gradient(58% 72% at 80% 32%, color-mix(in srgb, var(--st-accent) 13%, transparent), transparent 72%), var(--st-bg); }
.rx-hero .st-pin { padding-top: 92px; }
.rx-hero__grid { flex: 1 1 auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); align-items: center; gap: clamp(28px, 4vw, 72px); width: 100%; max-width: 1280px; }
.rx-hero .st-hero__copy { max-width: none; margin: 0; text-align: left; }
.rx-hero h1 { color: var(--st-ink); font-size: clamp(2.5rem, 4.3vw, 4.75rem); line-height: 1.04; }
.rx-hero h1 .rx-kicker { display: block; margin-bottom: 14px; color: var(--st-body); font-family: Manrope, sans-serif; font-size: clamp(.8125rem, .78rem + .16vw, .9375rem); font-weight: 600; line-height: 1.4; letter-spacing: 0; }
.rx-hero h1 .rx-line { display: block; color: var(--st-ink); }
.rx-hero h1 em { color: var(--st-accent); font-style: normal; }
@media (min-width: 1001px) { .rx-hero h1 .rx-line { white-space: nowrap; } }
.rx-hero .st-lead { max-width: 33rem; margin: 18px 0 0; color: var(--st-body); }

/* The room, and the two people layered over it. */
.rx-visual { position: relative; align-self: stretch; min-height: 340px; max-height: 580px; margin: 8px 0; container-type: size; }
.rx-room { position: absolute; inset: 0 7% 5%; overflow: hidden; border-radius: 28px; background: var(--st-bg-2); box-shadow: var(--st-shadow); transform: translate3d(calc(var(--rx-x, 0) * 8px), calc(var(--rx-y, 0) * 6px), 0); }
.rx-room img { display: block; width: 108%; max-width: none; height: 108%; margin: -4% 0 0 -4%; object-fit: cover; object-position: 24% 50%; }
[data-theme="dark"] .rx-room img { filter: brightness(.66) saturate(.92); }
.rx-room::after { content: ''; position: absolute; inset: 0; background: radial-gradient(34% 40% at 48% 34%, rgba(255, 196, 120, .26), transparent 70%); animation: rx-glow 7s ease-in-out infinite alternate; pointer-events: none; }
@keyframes rx-glow { to { opacity: .35; } }

.rx-person { position: absolute; z-index: 2; display: grid; grid-template-columns: 52px minmax(0, 1fr); align-items: center; gap: 12px; width: min(258px, 46cqw); padding: 12px 14px 12px 12px; border: 1px solid var(--st-line); border-radius: 18px; background: var(--st-glass); box-shadow: var(--st-shadow); -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3); color: var(--st-ink); text-align: left; }
.rx-person--a { left: 0; top: 9%; --rx-depth: 20px; animation: rx-float-a 7s ease-in-out infinite alternate; }
.rx-person--b { right: 0; bottom: 14%; --rx-depth: 30px; animation: rx-float-b 8s ease-in-out infinite alternate; }
.rx-person { translate: calc(var(--rx-x, 0) * var(--rx-depth)) calc(var(--rx-y, 0) * var(--rx-depth)); }
@keyframes rx-float-a { to { transform: translateY(-7px); } }
@keyframes rx-float-b { from { transform: translateY(-6px); } to { transform: translateY(3px); } }
.rx-person img, .rx-faces img, .rx-pair img { display: block; object-fit: cover; object-position: 50% 22%; border-radius: 50%; }
.rx-person img { width: 52px; height: 52px; }
.rx-person b { display: block; font-size: 1rem; font-weight: 700; line-height: 1.25; }
.rx-person small { display: block; overflow: hidden; color: var(--st-body); font-size: .75rem; font-weight: 500; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.rx-tag { display: inline-block; margin-top: 3px; color: var(--st-accent); font-size: .6875rem; font-weight: 700; letter-spacing: .02em; }

.rx-link { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.rx-link path { fill: none; stroke: var(--st-accent); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 2 8; vector-effect: non-scaling-stroke; animation: rx-flow 2.4s linear infinite; }
@keyframes rx-flow { to { stroke-dashoffset: -30; } }

.rx-likes { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 2px; padding-top: 10px; border-top: 1px solid var(--st-line); }
.rx-likes > span { color: var(--st-body); font-size: .6875rem; font-weight: 600; white-space: nowrap; }
.rx-likes .rx-chips { justify-content: flex-start; }
.rx-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; list-style: none; margin: 0; padding: 0; }
.rx-chips--start { justify-content: flex-start; }
.rx-chips li { padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--st-accent) 14%, transparent); color: var(--st-ink); font-size: .75rem; font-weight: 600; white-space: nowrap; }


/* ── How matching works: one path, with the line drawn as you scroll ──── */
.rx-match { position: relative; z-index: 1; padding: clamp(72px, 12vh, 140px) var(--st-gutter); background: linear-gradient(180deg, var(--st-bg), var(--st-bg-2)); color: var(--st-ink); }
.rx-match__inner { width: 100%; max-width: 1180px; margin: 0 auto; }
.rx-match h2 { max-width: 22ch; color: var(--st-ink); font-family: var(--st-display); font-size: clamp(2rem, 1.2rem + 2.6vw, 3.75rem); font-weight: 700; line-height: 1.06; letter-spacing: -.035em; text-wrap: balance; }
.rx-match h2 em { color: var(--st-accent); font-style: normal; }
.rx-steps { --rx-gap: clamp(40px, 7vh, 72px); --rx-mid: 39px; --rx-top: 40px; display: grid; gap: var(--rx-gap); margin: clamp(40px, 7vh, 72px) 0 0; padding: 0; list-style: none; }
/* Each step draws its own stretch of line, from its circle to the next one. */
.rx-step:not(:last-child)::before, .rx-step:not(:last-child)::after { content: ''; position: absolute; left: var(--rx-mid); top: var(--rx-top); bottom: calc(-1 * var(--rx-gap) - var(--rx-top)); width: 2px; background: var(--st-line); }
.rx-step:not(:last-child)::after { background: var(--st-accent); transform: scaleY(var(--rx-p, 1)); transform-origin: top; }
.rx-step { position: relative; display: grid; grid-template-columns: 80px minmax(0, 1fr) minmax(0, 1.05fr); align-items: start; gap: clamp(20px, 3.5vw, 56px); }
.rx-num { position: relative; z-index: 1; display: grid; place-items: center; width: 80px; height: 80px; border: 2px solid var(--st-accent); border-radius: 50%; background: var(--st-bg); color: var(--st-accent); font-size: 1.375rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.rx-step h3 { color: var(--st-ink); font-size: clamp(1.625rem, 1.3rem + 1.1vw, 2.5rem); font-weight: 700; line-height: 1.1; letter-spacing: -.03em; }
.rx-step p { max-width: 30rem; margin-top: 10px; color: var(--st-body); font-size: clamp(1rem, .96rem + .2vw, 1.125rem); line-height: 1.55; }
.rx-demo { position: relative; min-height: 172px; padding: 20px 22px; border: 1px solid var(--st-line); border-radius: 22px; background: var(--st-card); box-shadow: var(--st-shadow); }
.rx-demo .rx-tag { position: absolute; right: 18px; top: 14px; margin: 0; }
.rx-demo__label { margin: 0 0 14px; color: var(--st-ink); font-size: .875rem; font-weight: 700; }

.rx-faces { display: flex; margin: 0 0 14px; padding: 0; list-style: none; }
.rx-faces li + li { margin-left: -12px; }
.rx-faces img { width: 62px; height: 62px; border: 3px solid var(--st-card); }
.rx-pair { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.rx-pair img { flex: none; width: 46px; height: 46px; }
.rx-fit { flex: 1; height: 8px; overflow: hidden; border-radius: 999px; background: var(--st-line); }
.rx-fit i { display: block; width: 78%; height: 100%; border-radius: inherit; background: var(--st-grad); transform-origin: left; }
.rx-chat { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; font-size: .875rem; line-height: 1.4; }
.rx-chat li { width: fit-content; max-width: 84%; padding: 9px 13px; border-radius: 14px 14px 14px 4px; background: var(--st-bg-2); color: var(--st-ink); }
.rx-chat li:nth-child(even) { justify-self: end; border-radius: 14px 14px 4px 14px; background: color-mix(in srgb, var(--st-accent) 16%, var(--st-card)); }

.rx-match__end { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 20px 40px; margin-top: clamp(40px, 7vh, 72px); padding-top: 28px; border-top: 1px solid var(--st-line); }
.rx-match__end p { max-width: 42rem; color: var(--st-body); font-size: 1rem; line-height: 1.55; }
.rx-match__end .st-cta { margin: 0; }

/* Reveal: only hidden once js/roommates-hero.js is here to show it again. */
.rx-match.rx-ready .rx-step > * { opacity: 0; translate: 0 26px; transition: opacity .6s ease, translate .7s cubic-bezier(.16, 1, .3, 1); }
.rx-match.rx-ready .rx-step > :nth-child(2) { transition-delay: 70ms; }
.rx-match.rx-ready .rx-step > :nth-child(3) { transition-delay: 140ms; }
.rx-match.rx-ready .rx-step.is-in > * { opacity: 1; translate: 0 0; }
.rx-match.rx-ready .rx-fit i { transform: scaleX(0); transition: transform 1s .35s cubic-bezier(.16, 1, .3, 1); }
.rx-match.rx-ready .rx-step.is-in .rx-fit i { transform: scaleX(1); }

/* ── Small responses ──────────────────────────────────────────────────── */
.st-btn:active { transform: translateY(0) scale(.97); }
.rx-after .rm-card { transition: translate .3s cubic-bezier(.2, .8, .2, 1), box-shadow .3s ease, border-color .25s ease; }
.rx-after .rm-card:hover { translate: 0 -5px; box-shadow: var(--st-shadow); }
.rx-after .rm-card__media { overflow: hidden; }
.rx-after .rm-card__media img { transition: transform .6s cubic-bezier(.2, .8, .2, 1); }
.rx-after .rm-card:hover .rm-card__media img { transform: scale(1.05); }
.rx-after .rm-btn { transition: filter .2s ease, transform .15s ease; }
.rx-after .rm-btn:active { transform: scale(.98); }

/* ── Smaller screens: not the desktop picture shrunk ──────────────────── */
@media (max-width: 1000px) {
  .rx-hero__grid { display: flex; flex-direction: column; flex: 1 1 auto; align-items: stretch; gap: 16px; }
  .rx-hero .st-hero__copy { text-align: center; }
  .rx-hero .st-lead { margin-inline: auto; }
  .rx-visual { flex: 1 1 0; width: 100%; max-width: 640px; min-height: 0; margin: 0 auto; overflow: hidden; }
  .rx-room { inset: 0; border-radius: 20px; }
  .rx-link { display: none; }
  @container (max-height: 150px) { .rx-person { display: none; } }
  .rx-person { width: min(216px, 62cqw); grid-template-columns: 38px minmax(0, 1fr); gap: 8px; padding: 7px 9px 7px 7px; border-radius: 14px; animation: none; translate: none; }
  .rx-person img { width: 38px; height: 38px; }
  .rx-person b { font-size: .875rem; }
  .rx-person--a { left: 8px; top: 8px; }
  .rx-person--b { right: 8px; bottom: 8px; }
  .rx-step { grid-template-columns: 56px minmax(0, 1fr); gap: 16px 18px; }
  .rx-num { width: 56px; height: 56px; font-size: 1.0625rem; }
  .rx-steps { --rx-mid: 27px; --rx-top: 28px; }
  .rx-demo { grid-column: 2; min-height: 0; padding: 16px; }
}
/* No room for a picture beside the search on a phone, and the tabs stay where they are on the
   other two pages, so the room sits directly below the first screen. */
@media (max-width: 640px) {
  .rx-hero { position: relative; margin-bottom: 268px; }
  html.st-pinned .rx-hero .st-pin { position: static; }
  .rx-visual { position: absolute; left: 20px; right: 20px; top: 100%; width: auto; max-width: none; height: 240px; }
  .rx-hero__grid { flex: 0 0 auto; }
  .rx-match__end { grid-template-columns: minmax(0, 1fr); }
  .rx-match__end .st-cta { justify-content: flex-start; }
  .rx-match__end .st-btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .rx-room::after, .rx-person, .rx-link path { animation: none; }
  .rx-after .rm-card, .rx-after .rm-card__media img, .rx-after .rm-btn { transition: none; }
  .rx-after .rm-card:hover { translate: none; }
  .rx-after .rm-card:hover .rm-card__media img { transform: none; }
}

/* ── The live room: desktops and tablets only. Phones keep the photograph, with no WebGL. ──── */
html.st-pinned .rx-match { height: auto; }
html.st-3d .rx-hero, html.st-pinned .rx-hero { background: transparent; }
/* Fades in from nothing, so the flat is not cut off in a hard line as this comes up over it. */
html.st-3d .rx-match { background: linear-gradient(180deg, rgba(var(--st-rgb), 0) 0, rgba(var(--st-rgb), .74) clamp(72px, 12vh, 140px)); }
/* From tablets up, the room is the page's background, live or as a still of the same scene, so
   the photo card is only for phones. */
@media (min-width: 768px) {
  .rx-room, .rx-link { display: none; }
}
html.st-live .rx-link { display: none; }
@media (min-width: 1001px) {
  .rx-hero.st-ch--hero .st-still::after,
  [data-theme="dark"] .rx-hero.st-ch--hero .st-still::after { background: linear-gradient(90deg, rgba(var(--st-rgb), .92) 0%, rgba(var(--st-rgb), .84) 34%, rgba(var(--st-rgb), .5) 50%, rgba(var(--st-rgb), .12) 66%, rgba(var(--st-rgb), 0) 76%); }
}
/* Where the room is a still, it drifts a little with the scroll. Set by js/roommates-hero.js. */
html:not(.st-3d) .rx-hero .st-still img { transform: translate3d(0, calc(var(--rx-s, 0) * -56px), 0) scale(1.14); will-change: transform; }
.rx-hero { --rx-s: 0; }
html.st-live .rx-hero .st-lead { color: var(--st-ink); }
html.st-live .rx-hero h1 .rx-kicker { color: var(--st-ink); }

/* The cards turn towards the pointer, in depth, and lift when you reach them. */
.rx-visual { perspective: 900px; }
.rx-person { rotate: calc(var(--rx-y, 0) * -1) calc(var(--rx-x, 0)) 0 11deg; transition: scale .28s cubic-bezier(.2, .8, .2, 1), box-shadow .28s ease; }
.rx-person:hover { scale: 1.04; }
@media (min-width: 1024px) { .rx-story .st-scrim[data-side="left"] { background: linear-gradient(90deg, rgba(var(--st-rgb), .92) 0%, rgba(var(--st-rgb), .82) 30%, rgba(var(--st-rgb), .55) 42%, rgba(var(--st-rgb), .2) 52%, rgba(var(--st-rgb), .05) 60%, rgba(var(--st-rgb), 0) 66%); } }
@media (max-width: 1023px) { .rx-story .st-scrim[data-side="left"] { background: linear-gradient(180deg, rgba(var(--st-rgb), .9) 0%, rgba(var(--st-rgb), .72) 24%, rgba(var(--st-rgb), .22) 38%, rgba(var(--st-rgb), 0) 48%); } }
/* In the live scene the flat is the picture: the cards sit round it, each by the person it names. */
@media (min-width: 1001px) {
  html.st-live .rx-person { width: min(216px, 34cqw); grid-template-columns: 40px minmax(0, 1fr); gap: 10px; padding: 8px 12px 8px 8px; border-radius: 14px; }
  html.st-live .rx-person img { width: 40px; height: 40px; }
  html.st-live .rx-person b { font-size: .875rem; }
  html.st-live .rx-person--a { left: 2%; top: 7%; }
  html.st-live .rx-person--b { right: 0; top: auto; bottom: 2%; width: min(272px, 42cqw); }
}
/* Sneha's card stays short on desktop so the "Room free" sign above it stays in view. */
@media (min-width: 1001px) {
  .rx-person--b { top: auto; right: 0; bottom: 2%; width: min(272px, 42cqw); grid-template-columns: 40px minmax(0, 1fr); gap: 10px; padding: 8px 12px 8px 8px; border-radius: 14px; }
  .rx-person--b img { width: 40px; height: 40px; }
  .rx-person--b b { font-size: .875rem; }
  .rx-person--b .rx-tag { position: absolute; right: 12px; top: 10px; margin: 0; }
  .rx-person--b .rx-likes { flex-wrap: nowrap; gap: 6px; margin-top: 0; padding-top: 8px; }
  .rx-person--b .rx-likes > span { margin-right: 2px; font-size: .65rem; }
  .rx-person--b .rx-chips { flex-wrap: nowrap; gap: 4px; }
  .rx-person--b .rx-chips li { padding: 3px 8px; font-size: .6875rem; }
}

@media (prefers-reduced-motion: reduce) {
  .rx-person { transition: none; rotate: none; }
  .rx-person:hover { scale: none; }
}

/* ── Desktop: one card and one calm row of rooms, nothing stacked over the flat ──────────── */
@media (min-width: 1001px) {
  .rx-person--a { display: none; }
}
@media (max-width: 1000px) {
  .rx-likes { display: none; }
}

/* ── Under the search: quick areas and what is true today ────────────────────────────────
   Absolutely placed in the room the hero already leaves below the bar, so the bar stays put. */
.rx-below { position: absolute; left: 0; right: 0; top: calc(100% + clamp(14px, 2.4vh, 26px)); display: grid; justify-items: center; gap: clamp(12px, 2vh, 20px); pointer-events: none; }
.rx-below > * { pointer-events: auto; }
.rx-quick { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; }
.rx-quick__label { margin-right: 4px; color: var(--st-body); font-size: .8125rem; font-weight: 600; }
.rx-quick button { padding: 7px 14px; border: 1px solid var(--st-line); border-radius: 999px; background: var(--st-glass); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); color: var(--st-ink); font: 600 .8125rem/1.2 Manrope, sans-serif; cursor: pointer; transition: border-color .2s ease, background-color .2s ease, color .2s ease, translate .2s ease; }
.rx-quick button:hover { border-color: color-mix(in srgb, var(--st-accent) 55%, transparent); background: color-mix(in srgb, var(--st-accent) 10%, var(--st-card)); color: var(--st-accent); translate: 0 -1px; }
.rx-quick button:focus-visible { outline: 2px solid var(--st-accent); outline-offset: 2px; }
.rx-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px clamp(18px, 2.6vw, 36px); margin: 0; padding: 0; list-style: none; color: var(--st-body); font-size: .8125rem; font-weight: 600; }
.rx-facts li { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.rx-facts svg { flex: none; width: 18px; height: 18px; padding: 5px; box-sizing: content-box; border-radius: 50%; background: color-mix(in srgb, var(--st-accent) 13%, transparent); fill: none; stroke: var(--st-accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
html.st-live .rx-facts { color: var(--st-ink); }
/* Short screens keep only the areas. */
@media (max-height: 780px) { .rx-facts { display: none; } }
@media (max-height: 640px) { .rx-below { display: none; } }
/* Phones already fill this space with the room below the search, and the bar must not move. */
@media (max-width: 767px) { .rx-below { display: none; } }
@media (prefers-reduced-motion: reduce) { .rx-quick button { transition: none; } }
