/**
 * Project page: "შეარჩიე ბინა" — building-map card and bedroom-type tiles.
 *
 * Frame and heading come from .deka-section / .deka-section-head (base.css).
 * With a building map: the photo card takes 5/12 and the tiles 7/12, two to a
 * row. Without one: the tiles take the full width, as many columns as the PHP
 * sets in --deka-apt-cols-lg (at most four). Under 64rem the card stacks above
 * the tiles; under 40rem the tiles are one column.
 *
 * Organised with hairlines rather than boxes: each tile is a 1px rule that
 * turns to the text colour on hover, and its size and price sit on ruled lines.
 * Between the heading and those lines, the plan of one apartment of the type,
 * contained on a sunken (fog) ground and drawn a touch closer on hover.
 *
 * Plan box, by the modifier the PHP sets on the list:
 * - --fill (one row beside the map): from 64rem the tiles take the map card's
 *   height and the plan takes what the text leaves; the card's height is set
 *   for the photo (about 5:4 → 3:2), not left to the tiles.
 * - --compact (more than one row beside the map): from 64rem no plan, so
 *   half-height tiles still fit their text.
 * - --ratio, and every list below 64rem: the plan box keeps a 3:2 proportion,
 *   capped at 20rem tall on wide tiles.
 */

.deka-project-apartments {
  --deka-apt-gap: clamp(0.75rem, 0.5rem + 0.6vw, 1rem);
  /* Small: the drawings carry an empty margin of their own. */
  --deka-apt-plan-inset: clamp(0.5rem, 0.25rem + 0.5vw, 1rem);
}

.deka-project-apartments__body {
  display: grid;
  gap: var(--deka-apt-gap);
}

/* --- Building-map card ----------------------------------------------------- */

.deka-project-apartments__map {
  position: relative;
  isolation: isolate; /* keeps the image and gradient off the page's z-index scale */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--deka-space-lg);
  min-height: 22rem;
  padding: clamp(1.25rem, 0.9rem + 1.2vw, 2rem);
  overflow: hidden;
  border-radius: var(--deka-radius-sm);
  background: var(--deka-black);
  color: var(--deka-white);
  text-decoration: none;
}

.deka-project-apartments__map-image {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--deka-duration-slower) var(--deka-ease-out);
}

/* Heavier at the foot, where the line sits, light enough at the top that the
   building still reads. */
.deka-project-apartments__map::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    to top,
    color-mix(in srgb, var(--deka-black) 88%, transparent) 0%,
    color-mix(in srgb, var(--deka-black) 40%, transparent) 55%,
    color-mix(in srgb, var(--deka-black) 20%, transparent) 100%
  );
}

/* base.css recolours every a:hover with the action hover colour; the card
   keeps its light text over the photo. */
.deka-project-apartments__map:hover { color: var(--deka-white); }

.deka-project-apartments__map:hover .deka-project-apartments__map-image,
.deka-project-apartments__map:focus-visible .deka-project-apartments__map-image {
  transform: scale(1.04);
}

.deka-project-apartments__map-eyebrow {
  font-size: var(--deka-text-xs);
  font-weight: var(--deka-weight-medium);
  text-transform: uppercase;
  color: inherit;
}

.deka-project-apartments__map-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--deka-space-md);
}

.deka-project-apartments__map-title {
  max-width: 22rem;
  font-family: var(--deka-font-display);
  font-size: clamp(1.375rem, 1.15rem + 0.8vw, 1.75rem); /* 22 → 28 */
  font-weight: var(--deka-weight-medium);
  line-height: 1.2;
  text-wrap: balance;
}

.deka-project-apartments__map-button {
  display: grid;
  flex: none;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: var(--deka-radius-xs);
  background: var(--deka-white);
  color: var(--deka-black);
}

.deka-project-apartments__map-button svg,
.deka-project-apartments__arrow svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  transition: transform var(--deka-duration-base) var(--deka-ease-out);
}

.deka-project-apartments__map:hover .deka-project-apartments__map-button svg,
.deka-project-apartments__map:focus-visible .deka-project-apartments__map-button svg {
  transform: translateX(3px);
}

/* --- Bedroom-type tiles ---------------------------------------------------- */

.deka-project-apartments__types {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--deka-apt-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.deka-project-apartments__types > li { display: flex; }

.deka-project-apartments__type {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--deka-space-2xs);
  padding: clamp(1.125rem, 0.95rem + 0.6vw, 1.5rem);
  border: 1px solid var(--deka-border);
  border-radius: var(--deka-radius-sm);
  background: var(--deka-surface-page);
  color: var(--deka-text);
  text-decoration: none;
  transition: border-color var(--deka-duration-base) var(--deka-ease-out);
}

/* Only the rule changes on hover: color is restated so base.css's a:hover
   does not tint the tile's text. */
.deka-project-apartments__type:hover,
.deka-project-apartments__type:focus-visible {
  border-color: var(--deka-text);
  color: var(--deka-text);
}

.deka-project-apartments__type-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--deka-space-sm);
}

.deka-project-apartments__label {
  margin: 0;
  font-family: var(--deka-font-display);
  font-size: 1.375rem;
  font-weight: var(--deka-weight-medium);
  line-height: 1.15;
  color: inherit;
}

.deka-project-apartments__arrow {
  flex: none;
  padding-top: 0.125rem;
  color: inherit;
}

.deka-project-apartments__type:hover .deka-project-apartments__arrow svg,
.deka-project-apartments__type:focus-visible .deka-project-apartments__arrow svg {
  transform: translateX(4px);
}

/* A small square marks the line as live stock. */
.deka-project-apartments__count {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--deka-text-xs);
  font-weight: var(--deka-weight-medium);
  text-transform: uppercase;
  color: var(--deka-text-muted);
}

.deka-project-apartments__count::before {
  content: '';
  width: 0.375rem;
  height: 0.375rem;
  background: var(--deka-action);
}

/* --- Plan ------------------------------------------------------------------ */

/* The drawings are square with a transparent ground, so they sit contained on
   the sunken tone, inset from its edges; the image is laid out absolutely, so
   the box takes its size from the layout and never from the file. */
.deka-project-apartments__plan {
  position: relative;
  overflow: hidden;
  aspect-ratio: 3 / 2;
  max-height: 20rem;
  margin-block: var(--deka-space-xs) var(--deka-space-2xs);
  background: var(--deka-surface-sunken);
}

/* object-fit works inside the content box, so the padding is the inset. */
.deka-project-apartments__plan-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: var(--deka-apt-plan-inset);
  object-fit: contain;
  transition: transform var(--deka-duration-slower) var(--deka-ease-out);
}

.deka-project-apartments__type:hover .deka-project-apartments__plan-image,
.deka-project-apartments__type:focus-visible .deka-project-apartments__plan-image {
  transform: scale(1.06);
}

/* Pushed to the foot so tiles in one row line their rules up. */
.deka-project-apartments__specs {
  margin: auto 0 0;
  padding-top: var(--deka-space-sm);
}

.deka-project-apartments__spec {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--deka-space-sm);
  padding-block: 0.625rem;
  border-top: 1px solid var(--deka-border);
}

.deka-project-apartments__spec:last-child { padding-bottom: 0; }

.deka-project-apartments__spec dt {
  font-size: var(--deka-text-xs);
  font-weight: var(--deka-weight-medium);
  text-transform: uppercase;
  color: var(--deka-text-muted);
}

/* One line: a price that wrapped ("$101,200-" / "დან") would push its row,
   and the rules under it, out of line with the neighbouring tile. */
.deka-project-apartments__spec dd {
  margin: 0;
  font-size: var(--deka-text-base);
  font-weight: var(--deka-weight-medium);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.deka-project-apartments__map:focus-visible,
.deka-project-apartments__type:focus-visible {
  outline: 2px solid var(--deka-focus-ring, currentColor);
  outline-offset: 3px;
}

/* --- Layout ---------------------------------------------------------------- */

@media (min-width: 40rem) {
  .deka-project-apartments__map { min-height: 24rem; }

  .deka-project-apartments__types {
    grid-template-columns: repeat(var(--deka-apt-cols-md, 2), minmax(0, 1fr));
  }

  /* In two columns an odd last tile runs the full row rather than leave a gap. */
  .deka-project-apartments__types > li:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

@media (min-width: 64rem) {
  .deka-project-apartments__body--with-map {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  }

  /* 416 → 480: about 5:4 at 1440, 3:2 at the full frame — a building photo's
     proportion, and enough for a tile's text with a readable plan. */
  .deka-project-apartments__body--with-map .deka-project-apartments__map {
    min-height: clamp(26rem, 20rem + 9vw, 30rem);
  }

  /* Beside the card the tiles share its height evenly. */
  .deka-project-apartments__body--with-map .deka-project-apartments__types { grid-auto-rows: 1fr; }

  /* One row: the plan fills what the text leaves of the card's height. The
     8rem floor only matters if the text ever outgrows the card; then the row
     grows rather than the plan vanishing. */
  .deka-project-apartments__types--fill .deka-project-apartments__plan {
    flex: 1 1 0;
    min-height: 8rem;
    max-height: none;
    aspect-ratio: auto;
  }

  .deka-project-apartments__types--compact .deka-project-apartments__plan { display: none; }

  .deka-project-apartments__body:not(.deka-project-apartments__body--with-map) .deka-project-apartments__types {
    grid-template-columns: repeat(var(--deka-apt-cols-lg, 4), minmax(0, 1fr));
  }

  .deka-project-apartments__body:not(.deka-project-apartments__body--with-map) .deka-project-apartments__types > li:last-child:nth-child(odd) {
    grid-column: auto;
  }
}

/* No zoom on the photo or the plans: the hover is told by the rule alone. */
@media (prefers-reduced-motion: reduce) {
  .deka-project-apartments__map-image,
  .deka-project-apartments__plan-image { transition: none; }

  .deka-project-apartments__map:is(:hover, :focus-visible) .deka-project-apartments__map-image,
  .deka-project-apartments__type:is(:hover, :focus-visible) .deka-project-apartments__plan-image {
    transform: none;
  }
}
