/* home-crm.css: the Real-estate CRM case in home.html (31.10; was _crm-case.css, which keeps only the draft's extras).
   Loads after the shared CSS of home.html (style, style-layout, style-shuttle, home, home-text, typography).
   The chapters come in from p/crm/case.html once the password is right (home.js, "a case under a password").
   Same grammar as the Mum's Health Diary case (home-mum.css), with its own names:
     .crm-desk    a 3:2 tile with one desktop screen (2880 × 1800, 16:10) standing in it at 90% of the width
     .crm-screen  that desktop screen: a small corner and a soft lift off the tile
     .crm-pp      a 3:4 tile with one phone standing in it (half the column)
     .crm-phone   one phone screen (780 × 1688), whole, with the iPhone's own corner
     .crm-strip   a wide tile with a row of three phones, a caption under each (a swipeable row on a phone)
     .crm-beside  a .pair: words in one half, a 3:4 phone tile in the other (the tile left on wide screens)
     .crm-fig     a tile with a caption under it
   Grounds: light grey for light screens, near black for dark ones. */

.case[data-project="crm"] {
  --crm-ground: #ececec;   /* a step under the page #fafafa, so the stand's white screens keep their edge */
  --crm-ground-dark: #2a2a2b;
  /* the iPhone the phones are shot on is 390 × 844 pt with a 47.33 pt display corner:
     12.14% of the width; percent radii run against height vertically, 47.33 / 844 = 5.61% */
  --crm-r: 12.14% / 5.61%;
  --crm-shape: round;
  /* a phone is 88% of its tile's height, standing 6% above the foot:
     in a 3:4 tile 88% × 4/3 × 780/1688 = 54.2% of the width; in a 3:2 tile 88% × 2/3 × 780/1688 = 27.1% */
  --crm-w-p: 54.2%;
  --crm-w-w: 27.1%;
}
/* iOS draws the corner as a continuous curve: the squircle that matches it is 1.69× the circle (as in home-mum.css),
   80 pt on the 390 pt screen = 20.5% of the width, 9.48% of the height */
@supports (corner-shape: squircle) {
  .case[data-project="crm"] { --crm-r: 20.5% / 9.48%; --crm-shape: squircle; }
}

/* ---------- desktop ---------- */
.tile.crm-desk { background: var(--crm-ground); }
.tile.crm-desk > .crm-screen {
  position: absolute; inset: 50% auto auto 50%;
  width: 90%; height: auto;
  aspect-ratio: 2880 / 1800;
  translate: -50% -50%;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .05), 0 12px 32px -12px rgba(0, 0, 0, .16);
}
.pair > .crm-fig > .tile.crm-desk > .crm-screen,
.pair > .tile.crm-desk > .crm-screen { border-radius: 4px; }
@media (max-width: 760px) {
  /* a dense table at phone width: the screen takes more of its tile, the tile a little less height */
  .tile.crm-desk { aspect-ratio: 16 / 11; }
  .tile.crm-desk > .crm-screen { width: 94%; border-radius: 4px; }
}

/* ---------- phones ---------- */
.crm-phone {
  display: block;
  width: 100%; height: auto;
  aspect-ratio: 780 / 1688;
  object-fit: cover;
  border-radius: var(--crm-r);
  corner-shape: var(--crm-shape);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .05), 0 1px 2px rgba(0, 0, 0, .05), 0 12px 32px -12px rgba(0, 0, 0, .16);
}
.tile.crm-pp { background: var(--crm-ground); }
.tile.crm-pp > .crm-phone {
  position: absolute; inset: auto auto 6% 50%;
  width: var(--crm-w-p); height: auto;   /* .tile > img sets height: 100% */
  translate: -50% 0;
}

/* dark screens on a dark ground: the lift is a light hairline instead of a shadow */
.tile.crm-dark { background: var(--crm-ground-dark); }
.tile.crm-dark > .crm-screen,
.tile.crm-dark .crm-phone { box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 12px 32px -12px rgba(0, 0, 0, .5); }

/* a row of phones, each the size of a 3:2 tile's phone, a caption under each, all on one top line */
.tile.crm-strip {
  aspect-ratio: auto;
  background: var(--crm-ground);
  display: flex; justify-content: center; align-items: flex-start;
  gap: 4%;
  padding: 4% 0 3%;
}
.crm-strip > .crm-step { flex: 0 0 var(--crm-w-w); min-width: 0; margin: 0; }
.crm-step > .crm-shot { position: relative; display: block; }
.crm-step > figcaption {
  margin-top: 14px;
  color: #5e5e5e;   /* 5.2:1 on the ground */
  font-size: var(--fs-small); line-height: 1.4;
  text-align: center; text-wrap: balance;
}
a.crm-shot { cursor: zoom-in; border-radius: var(--crm-r); corner-shape: var(--crm-shape); transition: opacity .2s ease; }
@media (hover: hover) { a.crm-shot:hover { opacity: .92; } }
a.crm-shot:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

@media (max-width: 760px) {
  /* the row scrolls sideways, one phone at the size of a 3:4 tile's, the next one peeking in */
  .tile.crm-strip {
    justify-content: flex-start;
    gap: 16px;
    padding: 8% 22.9% 6%;   /* 22.9% centres the first phone: (100% − 54.2%) / 2 */
    overflow-x: auto; overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 22.9%;
  }
  .crm-strip > .crm-step { flex-basis: 100%; scroll-snap-align: center; }
}
@media (max-width: 760px) and (hover: none) {
  .tile.crm-strip { scrollbar-width: none; }
  .tile.crm-strip::-webkit-scrollbar { display: none; }
}

/* ---------- words beside a phone: plain text, no card (as .md-beside) ---------- */
.case[data-project="crm"] .crm-beside { margin-top: var(--text-pause); }
.case[data-project="crm"] .card.text + .crm-beside { margin-top: 0; }
.case[data-project="crm"] .crm-beside > .card.text {
  width: auto; min-width: 0;
  padding: 0; background: none; border: 0; border-radius: 0; overflow: visible;
  font-size: var(--fs-body); line-height: 1.55; color: var(--ink);
}
.crm-beside > .card.text p + p { margin-top: 1em; }
@media (min-width: 761px) {
  /* the phone in the left half, the words in the right, from the tile's top, tight to the picture (only the pair's gap);
     the same as .md-beside in home-mum.css — keep the two in step */
  .case[data-project="crm"] .crm-beside > .card.text { order: 2; padding: 0; }
}
@media (max-width: 760px) {
  .crm-beside > .card.text { margin-bottom: 24px; }
}

/* ---------- captions ---------- */
.crm-fig { margin: 0; min-width: 0; }
.crm-fig > figcaption { margin-top: 8px; color: var(--muted); font-size: var(--fs-small); line-height: 1.5; }

/* ---------- v4 (30.10): clips ----------
   A clip stands in its tile exactly as a still does (.crm-screen / .crm-phone above): same size, corner and lift.
   The posters are the clips' first frames, so the tile looks the same before a clip starts. */
.crm-clip > video { background: var(--crm-ground); }
.crm-clip.crm-pp > video.crm-phone { background: #fcfcfc; }

/* ---------- keys in the text: <kbd> moved to typography.css (shared by all cases) ---------- */

/* lightbox: an opaque ground while this case is open. style.css has rgba(255,255,255,.97), and through those 3% the page
   showed behind the open image, the cover tile's table among it, like a ghost below the picture. */
html:has(.case[data-project="crm"]:not([hidden])) .lb { --lb-bg: #fff; }
