/* Roommates page. Follows the roommates mock-up, on a 1600px canvas like the
   homepage. Tokens, the search bar and trust strip come from css/home.css. */

/* Sits to the right of Rent, so it slides in from the right: see css/home.css. */
:root { --hm-slide-from: 100%; }

/* ── Search ───────────────────────────────────────────────────────────── */
/* The hero itself is shared with the homepage: see .hm-hero in css/home.css. */
.rm-form .rm-life { flex: 1.35 1 0; }

/* Lifestyle: looks like the selects beside it, and opens a list of tick boxes. */
.rm-life details { position: static; flex: 1; min-width: 0; }
.rm-life summary { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 12px 0 43px; overflow: hidden; color: var(--hm-ink); cursor: pointer; font-size: 1rem; font-weight: 600; list-style: none; text-overflow: ellipsis; white-space: nowrap; }
.rm-life summary::-webkit-details-marker { display: none; }
.rm-life__menu { position: absolute; left: 0; top: calc(100% + 12px); z-index: 6; display: grid; gap: 2px; min-width: 230px; margin: 0; padding: 8px; border: 1px solid var(--hm-line); border-radius: 14px; background: var(--hm-field); box-shadow: var(--hm-shadow); }
.rm-life__menu label { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 8px; border-radius: 8px; color: var(--hm-ink); cursor: pointer; font-size: .875rem; font-weight: 600; }
.rm-life__menu label:hover { background: var(--hm-peach); }
.hm-field .rm-life__menu input { flex: none; width: 17px; height: 17px; appearance: auto; accent-color: var(--orange); }

/* ── Head of the list ─────────────────────────────────────────────────── */
.rm-people { margin-top: 26px; }
.rm-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.rm-head h2 { flex: 1 1 auto; font-size: 1.25rem; font-weight: 500; letter-spacing: -.01em; }
.rm-head h2 span { color: var(--hm-body); }
.rm-head h2 strong { font-size: 1.625rem; font-weight: 700; }
.rm-seg { display: flex; padding: 4px; border: 1px solid var(--hm-line); border-radius: 14px; background: var(--hm-card); }
.rm-seg button { min-height: 34px; padding: 0 26px; border: 0; border-radius: 10px; background: transparent; color: var(--hm-ink); cursor: pointer; font: 600 .875rem/1.2 var(--font); white-space: nowrap; }
.rm-seg button[aria-pressed="true"] { background: var(--hm-pop); color: var(--orange); font-weight: 700; }
.rm-seg button:focus-visible, .rm-btn:focus-visible, .rm-life summary:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.rm-sort { width: 240px; }
.rm-note { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--hm-soft); font-size: .875rem; line-height: 1.4; }
.rm-note svg { flex: none; width: 17px; height: 17px; }
.rm-note a { color: var(--orange); font-weight: 600; }

/* ── Cards ────────────────────────────────────────────────────────────── */
.rm-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; margin: 16px 0 44px; padding: 0; list-style: none; }
/* The name button is stretched over the card, so the whole card opens the profile. */
.rm-card { position: relative; display: flex; flex-direction: column; min-width: 0; overflow: hidden; border: 1px solid var(--hm-line); border-radius: 18px; background: var(--hm-card); box-shadow: var(--hm-lift); transition: border-color .15s ease; }
.rm-card:hover { border-color: var(--orange); }
.rm-card__media { aspect-ratio: 8 / 5; background: var(--hm-peach); }
.rm-card__media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.rm-card__open { padding: 0; border: 0; background: none; color: inherit; cursor: pointer; font: inherit; letter-spacing: inherit; text-align: left; }
.rm-card__open::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.rm-card__open:focus-visible { outline: 0; }
.rm-card__open:focus-visible::after { outline: 2px solid var(--orange); outline-offset: -2px; border-radius: 18px; }
/* Sized from the card, not the screen, so the columns keep the mock-up's proportions. */
.rm-card__body { container-type: inline-size; display: flex; flex: 1; flex-direction: column; padding: 16px 18px 18px; }
.rm-card h3, .rm-sheet h2 { color: var(--hm-ink); font-size: clamp(1.375rem, 8cqi, 1.75rem); font-weight: 700; line-height: 1.2; letter-spacing: -.015em; }
.rm-role { margin-top: 2px; color: var(--hm-soft); font-size: clamp(.875rem, 4.4cqi, 1rem); font-weight: 500; line-height: 1.35; }
.rm-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; padding: 0; list-style: none; }
.rm-tags li { padding: 5px 10px; border-radius: 999px; background: var(--hm-peach); color: var(--hm-ink); font-size: clamp(.75rem, 3.6cqi, .8125rem); font-weight: 500; line-height: 1.25; }
/* Three equal columns. The space and divider live in the gap, not in padding, so the
   middle column isn't left narrower than the outer two. */
.rm-facts { --rm-facts-gap: clamp(10px, 4cqi, 20px); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: var(--rm-facts-gap); margin: 16px 0 0; padding: 0; list-style: none; }
.rm-facts li { position: relative; min-width: 0; }
.rm-facts li + li::before { content: ''; position: absolute; inset-block: 0; left: calc(var(--rm-facts-gap) / -2); border-left: 1px solid var(--hm-line); }
.rm-facts svg { display: block; width: 20px; height: 20px; margin-bottom: 4px; color: var(--orange); }
.rm-facts span { display: block; color: var(--hm-soft); font-size: .75rem; line-height: 1.3; white-space: nowrap; }
.rm-facts strong { display: block; margin-top: 2px; color: var(--hm-ink); font-size: clamp(.78125rem, 4.75cqi, 1.0625rem); font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.rm-bio { margin: 14px 0 16px; color: var(--hm-body); font-size: clamp(.8125rem, 3.9cqi, .9375rem); line-height: 1.5; }
.rm-btn { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 46px; margin-top: auto; padding: 0 12px; border: 0; border-radius: 12px; background: var(--grad-brand); color: #fff; cursor: pointer; font: 700 1rem/1.2 var(--font); text-decoration: none; white-space: nowrap; }
.rm-btn svg { width: 20px; height: 20px; }
.rm-btn:hover { filter: brightness(1.05); color: #fff; }

/* ── Profile sheet ────────────────────────────────────────────────────── */
/* Portrait on the left and details on the right, stacking below 761px. The picture's
   source in js/roommates.js switches at the same width, so keep the two together.
   display sits on [open], or the closed dialog would show. */
.rm-sheet { width: min(calc(100vw - 32px), clamp(760px, calc((100dvh - 32px) * 1.73), 960px)); max-height: calc(100dvh - 32px); margin: auto; padding: 0; overflow: auto; overscroll-behavior: contain; border: 0; border-radius: 24px; background: var(--hm-card); color: var(--hm-ink); box-shadow: var(--hm-shadow); }
.rm-sheet[open] { display: grid; grid-template-columns: minmax(0, 38.5fr) minmax(0, 61.5fr); }
.rm-sheet::backdrop { background: var(--hm-scrim); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.rm-sheet svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rm-sheet__media { position: relative; aspect-ratio: 2 / 3; overflow: hidden; background: var(--hm-peach); }
.rm-sheet__media img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; }
.rm-sheet .rm-card__body { padding: 28px 24px 24px; }
.rm-sheet h2 { padding-right: 44px; }
.rm-sheet__close { position: absolute; right: 12px; top: 12px; z-index: 2; display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1.5px solid var(--orange); border-radius: 50%; background: var(--hm-card); color: var(--hm-ink); cursor: pointer; font-size: 1.5rem; line-height: 1; }
.rm-sheet .rm-btn { margin-top: 14px; }
.rm-sheet__note { margin-top: 0; padding-top: 12px; border-top: 1px solid var(--hm-line); color: var(--hm-soft); font-size: .8125rem; line-height: 1.4; }

/* Opening: the sheet drifts in from the card that was tapped (--rm-from-x/y, set in
   js/roommates.js), the photo settles and the details follow one at a time. The curve
   starts gently on purpose: a fast start reads as a blink (same finding as the tab slide). */
.rm-sheet[open] { animation: rm-sheet-in .5s cubic-bezier(.3, 0, .15, 1) both; }
.rm-sheet[open]::backdrop { animation: rm-fade-in .4s ease both; }
.rm-sheet[open] .rm-sheet__media img { animation: rm-photo-in .75s cubic-bezier(.3, 0, .15, 1) both; }
.rm-sheet[open] .rm-card__body > * { animation: rm-rise-in .42s cubic-bezier(.3, 0, .15, 1) both; animation-delay: calc(140ms + var(--rm-step, 0) * 45ms); }
.rm-sheet .rm-card__body > :nth-child(2) { --rm-step: 1; }
.rm-sheet .rm-card__body > :nth-child(3) { --rm-step: 2; }
.rm-sheet .rm-card__body > :nth-child(4) { --rm-step: 3; }
.rm-sheet .rm-card__body > :nth-child(5) { --rm-step: 4; }
.rm-sheet .rm-card__body > :nth-child(6) { --rm-step: 5; }
.rm-sheet .rm-card__body > :nth-child(7) { --rm-step: 6; }
.rm-sheet[open].is-closing { animation: rm-sheet-out .24s ease-in both; }
.rm-sheet[open].is-closing::backdrop { animation: rm-fade-out .24s ease-in both; }
@keyframes rm-sheet-in { from { opacity: 0; transform: translate(var(--rm-from-x, 0), var(--rm-from-y, 16px)) scale(.93); } }
@keyframes rm-sheet-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes rm-photo-in { from { transform: scale(1.08); } }
@keyframes rm-rise-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes rm-fade-in { from { opacity: 0; } }
@keyframes rm-fade-out { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .rm-sheet[open], .rm-sheet[open].is-closing, .rm-sheet[open]::backdrop, .rm-sheet[open].is-closing::backdrop,
  .rm-sheet[open] .rm-sheet__media img, .rm-sheet[open] .rm-card__body > * { animation: none; }
}
/* Everything in the wide sheet is sized from the sheet, so a shorter screen shrinks the
   type and spacing with the box: the sheet's width above follows the screen's height,
   which keeps the photo's 2:3 on screen without scrolling. */
@media (min-width: 761px) {
  .rm-sheet { container-type: inline-size; }
  .rm-sheet .rm-card__body { container-type: normal; padding: clamp(28px, 4.2cqi, 40px) clamp(24px, 3.4cqi, 32px) clamp(24px, 3.4cqi, 32px); }
  .rm-sheet h2 { font-size: clamp(1.75rem, 3.75cqi, 2.25rem); }
  .rm-sheet .rm-role { margin-top: 4px; font-size: clamp(1rem, 1.98cqi, 1.1875rem); }
  .rm-sheet .rm-tags { gap: clamp(6px, .85cqi, 8px); margin-top: clamp(14px, 2.1cqi, 20px); }
  .rm-sheet .rm-tags li { padding: clamp(5px, .65cqi, 6px) clamp(10px, 1.3cqi, 13px); font-size: clamp(.8125rem, 1.56cqi, .9375rem); }
  .rm-sheet .rm-facts { margin-top: clamp(16px, 2.3cqi, 22px); }
  .rm-sheet .rm-facts svg { width: clamp(20px, 2.5cqi, 24px); height: clamp(20px, 2.5cqi, 24px); }
  .rm-sheet .rm-facts span { font-size: clamp(.75rem, 1.46cqi, .875rem); }
  .rm-sheet .rm-facts strong { font-size: clamp(1.0625rem, 2.19cqi, 1.3125rem); }
  .rm-sheet .rm-bio { margin: clamp(14px, 2.1cqi, 20px) 0 clamp(16px, 2.3cqi, 22px); font-size: clamp(.9375rem, 1.875cqi, 1.125rem); }
  /* Bios differ in length, so the note and Connect sit on the photo's bottom edge. */
  .rm-sheet__note { margin-top: auto; padding-top: clamp(12px, 1.7cqi, 16px); font-size: clamp(.8125rem, 1.56cqi, .9375rem); }
  .rm-sheet .rm-btn { min-height: clamp(46px, 5.6cqi, 54px); margin-top: clamp(14px, 1.9cqi, 18px); font-size: clamp(1rem, 1.875cqi, 1.125rem); }
}
@media (max-width: 760px) {
  .rm-sheet { width: min(460px, calc(100vw - 32px)); }
  .rm-sheet[open] { display: block; }
  .rm-sheet__media { aspect-ratio: 8 / 5; }
  .rm-sheet .rm-card__body { padding: 16px 18px 18px; }
}

@media (max-width: 1240px) {
  .rm-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .rm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rm-seg { order: 3; width: 100%; }
  .rm-seg button { flex: 1; padding-inline: 8px; }
}
/* Four fields plus Search: tightened so the bar stays one row, the same height as Rent's. */
@media (min-width: 1001px) and (max-width: 1100px) {
  .rm-form { gap: 8px; }
  .rm-form .rm-life { flex: 1.25 1 0; }
  .rm-form .hm-field { padding-inline: 12px 8px; }
  .rm-form .hm-field select { padding: 0 28px 0 39px; }
  .rm-form .rm-life summary { padding: 0 8px 0 39px; }
  .rm-form .hm-field__chev { right: 6px; }
  .rm-form .hm-go { padding-inline: 18px; }
}
@media (min-width: 761px) and (max-width: 1000px) {
  .rm-form { flex-wrap: wrap; gap: 6px 12px; padding: 10px 12px 12px; }
  .rm-form .hm-field, .rm-form .hm-field--where, .rm-form .rm-life { flex: 1 1 calc(50% - 6px); }
  .rm-form .hm-field::before { display: none; }
  .rm-form .hm-go { flex: 1 1 100%; height: 46px; }
}
@media (max-width: 760px) {
  .rm-form .rm-life { flex: none; }
  .rm-life__menu { right: 0; }
  .rm-grid { gap: 12px; }
  .rm-card__body { padding: 14px; }
  .rm-sort { flex: 1 1 100%; width: auto; }
  .rm-note { align-items: flex-start; }
}
@media (max-width: 640px) {
  .rm-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .rm-seg button { font-size: .8125rem; }
}
/* A little more room than the other fields, for an area chip and its "+2" (js/places.js). */
@media (min-width: 1001px) { .rm-form .hm-field--where { flex-grow: 1.12; } }
