/* ==========================================================================
   Model card (catalog), variant A: the name on the photo
   - Photo 4:5. The name (up to 4 lines) and "24 y.o. · Online" lie on a dark fade at the
     bottom of the photo and grow UP over it: a long name never changes the card height.
   - Under the photo: city + price in one row, then the description, always 2 lines high.
     So all cards are the same height, without empty gaps.
   - Type size depends on the card's own width (container query), not the screen.
   Positioning: .model-card and .model-card__media are positioned. The name link's ::after covers
   the photo only (with the name on it): the city, price and description under it are not a link.
   Badges are placed from the photo's corner; the favorites button from the card's corner,
   which is the same point (the photo is at the top of the card).
   ========================================================================== */

.model-card-wrap { container-type: inline-size; }

.model-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.2s;
}

.model-card:hover { box-shadow: 0 6px 20px rgba(16, 35, 44, 0.1); }

/* Media: the photo and the overlay share one grid cell ------------------- */

/* Until the photo is loaded the card shows a neutral placeholder: one even light-grey panel
   (--color-skeleton) with a small spinner, the name in dark text right on it — no dark fade.
   This is the DEFAULT, so it is there from the first paint, before any script runs.
   card-photos.js marks the card when the photo is ready:
     .is-loaded — the photo fades in, the dark fade under the name and white text come with it,
                  the spinner stops;
     .is-empty  — the photo failed: the even panel stays, without the spinner.
   Without JS: model-card-nojs.css (in <noscript>) shows the photos as they load.
   Layers in the one grid cell: spinner (0) < photo (1) < name overlay (2) < badges (3). */
.model-card__media {
  position: relative;   /* the link area of the name (::after below) is the photo */
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--color-skeleton);
}

.model-card__media::after,
.model-card__media > img,
.model-card__overlay { grid-area: 1 / 1; }

.model-card__media::after { z-index: 0; }
.model-card__media > img { z-index: 1; }
.model-card__overlay { z-index: 2; }

/* The spinner, a little above the middle (the name lies at the bottom) */
.model-card__media::after {
  content: "";
  place-self: center;
  width: 32px;
  height: 32px;
  margin-bottom: 20%;
  border: 3px solid rgba(16, 35, 44, 0.1);
  border-top-color: var(--color-pink);
  border-radius: 50%;
  animation: card-photo-spin 0.8s linear infinite;
}

.model-card__media.is-loaded::after,
.model-card__media.is-empty::after { animation: none; opacity: 0; }

@keyframes card-photo-spin { to { rotate: 360deg; } }

.model-card__media > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 20%;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.model-card__media.is-loaded > img { opacity: 1; }

/* Narrow cards (two in a row on phones): a smaller spinner */
@container (max-width: 239px) {
  .model-card__media::after { width: 24px; height: 24px; border-width: 2.5px; }
}

/* The name block: dark text on the panel; on the loaded photo — white text on a dark fade */
.model-card__overlay {
  align-self: end;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 72px var(--space-4) 14px;
  color: var(--color-text);
}

.model-card__media.is-loaded .model-card__overlay {
  background: linear-gradient(to top, rgba(16, 35, 44, 0.82) 0%, rgba(16, 35, 44, 0.45) 55%, rgba(16, 35, 44, 0) 100%);
  color: #FFFFFF;
}

@media (prefers-reduced-motion: reduce) {
  .model-card__media::after { animation-duration: 1.6s; }
  .model-card__media > img { transition: none; }
}

/* Up to 4 lines (3 on narrow cards), then "…" (the full name is in the title attribute).
   The name grows UP over the photo, so the card height stays the same. */
.model-card__name {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.15;
  color: inherit;
}

.model-card__media.is-loaded .model-card__name { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }

.model-card__name a { color: inherit; text-decoration: none; }

/* The name link covers the photo (not the text under it); the favorites button sits above it */
.model-card__name a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* Keyboard focus: a frame on the link area — around the photo, inside its edge
   (an outline of the photo itself would be painted under the photo) */
.model-card__name a:focus-visible { outline: none; }
.model-card__name a:focus-visible::after { box-shadow: inset 0 0 0 3px var(--color-pink); }

/* "24 y.o. · ● Online" */
.model-card__facts {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.model-card__media.is-loaded .model-card__facts { color: rgba(255, 255, 255, 0.9); }

/* Online status ---------------------------------------------------------- */

.presence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.presence__text { overflow: hidden; text-overflow: ellipsis; }

.presence__dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ADE80;
  animation: presence-pulse 2s ease-out infinite;
}

@keyframes presence-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.75); }
  70%  { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .presence__dot { animation: none; box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.3); }
}

/* Badges and favorites, from the card's (= the photo's) top corners ------ */

.model-card__badges {
  position: absolute;
  z-index: 3;
  top: var(--space-3);
  left: var(--space-3);
  display: flex;
  gap: var(--space-2);
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
}

.badge--new { background: var(--color-pink-strong); color: #FFFFFF; }
.badge--verified { background: var(--color-verified); color: var(--color-text); }

.model-card__fav {
  position: absolute;
  z-index: 2;
  top: var(--space-2);
  right: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.9);
  color: var(--color-text);
}

.model-card__fav .icon { width: 26px; height: 26px; fill: none; }
.model-card__fav:hover { color: var(--color-pink); }
.model-card__fav[aria-pressed="true"] { color: var(--color-pink); }
.model-card__fav[aria-pressed="true"] .icon { fill: currentColor; }

/* Body ------------------------------------------------------------------- */

.model-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex-grow: 1;
  padding: 14px var(--space-4) var(--space-4);
}

.model-card__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.model-card__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 1rem;
  color: var(--color-text);
}

.model-card__meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-card__meta .icon { flex: none; width: 17px; height: 17px; color: var(--color-pink); }

.model-card__price {
  flex: none;
  margin-left: auto;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
}

.model-card__desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(2em * 1.4); /* 2 lines even for a short text: all cards the same height */
  font-size: 1rem;
  line-height: 1.4;
  color: #3A444B;
}

/* ---------- Wide card (single column on phones): larger type ---------- */
@container (min-width: 340px) {
  .model-card__name { font-size: 1.625rem; }
  .model-card__facts { font-size: 1.0625rem; }
  .model-card__meta { font-size: 1.0625rem; }
  .model-card__price { font-size: 1.375rem; }
  .model-card__desc { font-size: 1.0625rem; }
}

/* ---------- Narrow card (two columns on phones): compact ---------- */
@container (max-width: 239px) {
  .model-card__overlay { gap: 0; padding: 48px 10px 8px; }
  .model-card__name { -webkit-line-clamp: 3; font-size: 1.0625rem; }
  .model-card__facts { gap: 4px; font-size: 0.8125rem; }
  .presence { gap: 4px; }
  .presence__dot { width: 7px; height: 7px; }
  .model-card__badges { top: var(--space-2); left: var(--space-2); gap: 4px; flex-wrap: wrap; }
  .badge { height: 22px; padding: 0 6px; font-size: 0.75rem; }
  .model-card__fav { top: 4px; right: 4px; width: 40px; height: 40px; }
  .model-card__fav .icon { width: 22px; height: 22px; }
  .model-card__body { padding: var(--space-2) 10px 10px; }
  .model-card__row { gap: 6px; }
  .model-card__meta { gap: 4px; font-size: 0.8125rem; }
  .model-card__meta .icon { width: 14px; height: 14px; }
  .model-card__price { font-size: 1rem; }
  .model-card__desc { font-size: 0.8125rem; }
}
