/*
 * Gindi Innovations — homepage-only layout adjustments
 *
 * Loaded by templates/core/home.html only; everything is scoped under
 * <main class="home">, so other pages keep their own spacing.
 */

/* ---------- Spacing between sections ----------
   Each section gets the same, smaller padding on both sides of every
   boundary, instead of --space-section (up to 12rem) on both sides, which
   stacked into ~380px gaps between neighbours. Total separation between two
   sections' content: about 32px on phones to 64px on desktop. Sections still
   size to their content; the hero and "From Vision to Reality" keep their
   one-screen minimum heights. */
.home {
  --home-section-space: clamp(1rem, 0.6rem + 1.6vw, 2rem);
}

.home > .section {
  padding-block: var(--home-section-space);
}

/* Projects: the faint monogram sits 1.5rem above the details and the section
   clips overflow (overflow: clip), so its top padding never goes below
   1.75rem; otherwise the monogram's top is cut off on phones. */
.home > .featured {
  padding-block-start: max(var(--home-section-space), 1.75rem);
}

/* "From Vision to Reality" fills the screen below the navbar: heading, image,
   labels and project navigation, with every spare pixel going to the image
   (its frame is the flexible row, sections.css). So the section's own
   padding stays small: about 20-28px above the heading, and 12px below, which
   puts the pagination dots about 20px above the screen edge (each dot button
   adds 8px of its own around the dot). */
.home > .vision {
  padding-block: clamp(1rem, 2.6vh, 1.75rem) 0.75rem;
}

/* "From Vision to Reality" keeps its one-screen height (below the navbar) on
   landscape screens, where the frame grows into it. On portrait screens the
   frame is limited by the width (4:3 at most), so that height only added
   empty bands above and below: there the section fits its content and the
   frame takes its 4:3 height directly. */
@media (max-aspect-ratio: 1 / 1) {
  .home > .vision {
    min-height: 0;
  }

  .home .vision .compare {
    flex: none;
  }

  .home .vision .compare__frame {
    flex: none;
    height: 75cqw;
  }
}

/* Heading block to content: --space-lg rather than --space-xl. */
.home .section-head {
  margin-block-end: var(--space-lg);
}

/* Stacked layouts (mobile/tablet): image or intro to the next block. */
.home .about__layout {
  row-gap: var(--space-lg);
}

/* ---------- Services: header, then Studio Services | Free Services ----------
   Two panels (ivory with a thin gold border | navy), each a 2 x 2 grid with
   fine dividers. On desktop the whole section fits one screen below the
   navbar: the vertical rhythm (--svc-v) and the heading sizes follow the
   viewport height within readable limits. Nothing is scaled, clipped or
   scrolled; on smaller or short screens, or with larger text, it grows.
   Stacked panels below 64rem; one column inside them below 36rem. */
.home .services {
  --svc-v: clamp(0.75rem, 0.05rem + 1.7vh, 1.75rem);
  --svc-gold-line: color-mix(in srgb, var(--gindi-gold) 55%, transparent);
  --svc-gold-soft: color-mix(in srgb, var(--gindi-gold) 26%, transparent);
  --svc-pad: clamp(1.25rem, 0.4rem + 2vw, 2.75rem);
}

/* Header: eyebrow and heading at the start, the supporting line at the end. */
.home .services-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5rem 2.5rem;
  margin-block-end: var(--svc-v);
}

.home .services-head__eyebrow {
  margin-block-end: 0.375rem;
  color: var(--gindi-gold);
}

.home .services-head__title {
  font-family: var(--font-heading);
  font-size: min(clamp(2rem, 1rem + 2.6vw, 3.5rem), calc(0.5rem + 7.2vh));
  font-weight: var(--fw-medium);
  line-height: 1.08;
  letter-spacing: var(--tracking-display);
  text-wrap: balance;
}

:lang(ar) .home .services-head__title {
  line-height: 1.25;
}

.home .services-head__lead {
  max-width: 24rem;
  padding-block-end: 0.5rem;
  color: var(--muted);
  line-height: 1.5;
}

/* The two panels, a hairline apart. They share four rows (subgrid): header,
   the two rows of items and the footer, so their headers, items and
   dividers line up across both panels and their tops and bottoms match. */
.home .services-panels {
  display: grid;
  grid-template-columns: minmax(0, 53fr) minmax(0, 47fr);
  grid-template-rows: repeat(4, auto);
  column-gap: 0.375rem;
}

.home .svc-panel {
  display: grid;
  grid-row: span 4;
  grid-template-rows: subgrid;
  row-gap: 0;
  min-width: 0;
  padding: calc(var(--svc-v) * 1.2) var(--svc-pad);
}

.home .svc-panel__head {
  grid-row: 1;
  align-self: start;
}

.home .svc-panel__foot {
  grid-row: 4;
}

.home .svc-panel--studio {
  border: 1px solid var(--svc-gold-line);
  background: color-mix(in srgb, var(--gindi-ivory) 45%, #fff);
}

.home .svc-panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  margin-block-end: calc(var(--svc-v) * 0.4);
}

.home .svc-panel__head--stack {
  display: grid;
  justify-content: start;
  gap: 0.25rem;
}

.home .svc-panel__eyebrow {
  color: var(--gindi-gold);
}

.home .svc-panel__title {
  font-family: var(--font-heading);
  font-size: min(clamp(1.75rem, 0.9rem + 1.7vw, 3rem), calc(0.25rem + 5.4vh));
  font-weight: var(--fw-medium);
  line-height: 1.1;
}

:lang(ar) .home .svc-panel__title {
  line-height: 1.3;
}

.home .svc-panel__text {
  color: var(--muted);
  line-height: 1.5;
}

.home .svc-panel__more {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding-block: 0.375rem;
  color: var(--gindi-gold);
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  text-underline-offset: 0.3em;
}

.home .svc-panel__more:hover {
  text-decoration: underline;
}

.home .svc-arrow {
  flex: none;
  width: 1.125rem;
  height: auto;
}

.home .svc-arrow--up {
  width: 0.875rem;
}

/* Arrows point the reading way. */
[dir="rtl"] .home .svc-arrow {
  transform: scaleX(-1);
}

/* The 2 x 2 grids, on the panels' shared rows 2 and 3. Studio Services has
   no footer, so its second row of items runs on to the panel's bottom. */
.home .svc-cells {
  display: grid;
  grid-row: 2 / span 2;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: subgrid;
}

.home .svc-panel--studio .svc-cells {
  grid-row: 2 / span 3;
}

.home .svc-panel--studio .svc-cell:nth-child(n + 3) {
  grid-row: 2 / span 2;
}

/* Free Services has five tools: its own rows (two, two, then the fifth across both
   columns), a little more compact, instead of the 2 x 2 rows it shares with Studio Services. */
.home .svc-panel--free .svc-cells {
  grid-template-rows: none;
}

.home .svc-panel--free .svc-cell {
  padding-block: calc(var(--svc-v) * 0.62);
}

.home .svc-panel--free .svc-cell:nth-child(2n)::before {
  inset-block: calc(var(--svc-v) * 0.4);
}

.home .svc-panel--free .svc-cell:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.home .svc-cell {
  position: relative;
  display: grid;
  align-content: start;
  gap: 0.25rem;
  padding-block: var(--svc-v);
  padding-inline: 0 clamp(1rem, 0.25rem + 1.6vw, 2.25rem);
}

.home .svc-cell:nth-child(2n) {
  padding-inline: clamp(1rem, 0.25rem + 1.6vw, 2.25rem) 0;
}

/* Fine dividers: vertical between the columns (stopping short of the
   crossing), horizontal between the rows. */
.home .svc-cell:nth-child(2n)::before,
.home .svc-cell:nth-child(n + 3)::after {
  content: "";
  position: absolute;
  background: var(--svc-divider, var(--svc-gold-soft));
  pointer-events: none;
}

.home .svc-cell:nth-child(2n)::before {
  inset-block: calc(var(--svc-v) * 0.6);
  inset-inline-start: 0;
  width: 1px;
}

.home .svc-cell:nth-child(n + 3)::after {
  inset-block-start: 0;
  inset-inline: 0;
  height: 1px;
}

.home .svc-panel--free {
  --svc-divider: var(--ivory-18);
}

.home .svc-cell__num {
  color: var(--gindi-gold);
  font-family: var(--font-heading);
  font-size: 1.125rem;
  line-height: 1.2;
}

.home .svc-cell__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-block-end: 0.375rem;
}

.home .svc-cell__icon {
  flex: none;
  width: clamp(2rem, 0.75rem + 2.8vh, 3rem);
  height: auto;
  color: var(--gindi-gold);
}

.home .svc-cell__title {
  font-family: var(--font-heading);
  font-size: min(clamp(1.375rem, 0.85rem + 1vw, 1.875rem), calc(0.35rem + 3.9vh));
  font-weight: var(--fw-medium);
  line-height: 1.15;
}

:lang(ar) .home .svc-cell__title {
  line-height: 1.35;
}

.home .svc-panel--studio .svc-panel__title,
.home .svc-panel--studio .svc-cell__title {
  color: var(--gindi-navy);
}

.home .svc-cell__text {
  max-width: 19rem;
  color: var(--muted);
  font-size: clamp(0.9375rem, 0.85rem + 0.25vw, 1.0625rem);
  line-height: 1.5;
}

/* Tools: description with the arrow at its end. */
.home .svc-cell--tool .svc-cell__text {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  max-width: none;
}

.home .svc-cell--tool .svc-cell__text > span {
  max-width: 17rem;
}

.home .svc-cell__arrow {
  margin-block-end: 0.35em;
  color: var(--gindi-gold);
  transition: transform var(--dur-fast) var(--ease-out);
}

/* The whole cell opens its service or tool. */
.home .svc-cell__link {
  color: inherit;
  text-decoration: none;
}

.home .svc-cell__link::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.home .svc-cell__link:focus-visible {
  outline: none;
}

.home .svc-cell:has(.svc-cell__link:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

@media (hover: hover) {
  .home .svc-cell:hover .svc-cell__link {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-decoration-color: var(--gindi-gold);
    text-underline-offset: 0.18em;
  }

  .home .svc-cell:hover .svc-cell__arrow {
    transform: translateX(0.25rem);
  }

  [dir="rtl"] .home .svc-cell:hover .svc-cell__arrow {
    transform: scaleX(-1) translateX(0.25rem);
  }
}

/* "Explore free tools", then a thin gold rule to the panel's end. */
.home .svc-panel__foot {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-block-start: calc(var(--svc-v) * 0.5);
}

.home .svc-panel__rule {
  flex: 1 1 auto;
  height: 1px;
  background: var(--svc-gold-line);
}

/* Short desktop windows (e.g. 1280 x 720): a tighter rhythm and smaller
   icons, so the section still fits one screen; text sizes are unchanged. */
@media (min-width: 64.01rem) and (max-height: 46rem) {
  .home .services {
    --svc-v: 0.625rem;
  }

  .home .svc-cell__icon {
    width: 1.75rem;
  }

  .home .svc-cell__top {
    margin-block-end: 0.25rem;
  }
}

/* Narrower screens: the panels stack, each keeping two columns. */
@media (max-width: 64rem) {
  .home .services-panels {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    row-gap: 0.375rem;
  }

  .home .svc-panel {
    display: flex;
    flex-direction: column;
    grid-row: auto;
  }

  .home .svc-cells,
  .home .svc-panel--studio .svc-cells,
  .home .svc-panel--studio .svc-cell:nth-child(n + 3) {
    grid-row: auto;
    grid-template-rows: none;
  }
}

/* Phones: one column inside the panels; a line between every item. */
@media (max-width: 36rem) {
  .home .svc-cells {
    grid-template-columns: minmax(0, 1fr);
  }

  .home .svc-cell,
  .home .svc-cell:nth-child(2n) {
    padding-inline: 0;
  }

  .home .svc-cell:nth-child(2n)::before {
    content: none;
  }

  .home .svc-cell:nth-child(n + 2)::after {
    content: "";
    position: absolute;
    inset-block-start: 0;
    inset-inline: 0;
    height: 1px;
    background: var(--svc-divider, var(--svc-gold-soft));
  }
}

/* ---------- Gindi Innovations: the arch image ----------
   The figure is a 3:4 arch sized by its grid column, which made it taller
   than the screen on common laptops. Cap its width so its height (4/3 of the
   width) stays at most 82% of the viewport below the navbar:
   0.82 * 3/4 = 0.615. The container itself shrinks (no transform), keeping
   the ratio, the arch and the crop; it stays centred in its column, and the
   text stays vertically centred beside it (.about__layout align-items). */
.home .about__media .media--arch {
  max-width: calc((100vh - var(--header-h)) * 0.615);
  max-width: calc((100dvh - var(--header-h)) * 0.615);
  margin-inline: auto;
}

/* Phones (stacked layout): a smaller image, scaling with the screen. */
@media (max-width: 40rem) {
  .home .about__media .media--arch {
    max-width: min(100%, 60vw + 1rem, 18rem);
  }
}

/* ---------- GINDI Design Studio invitation ----------
   A navy band between "From Vision to Reality" and Services: the question
   and its two links beside the three studio rooms (stills of the 3D scenes);
   stacked on tablets and phones. Its own padding, as a band needs more room
   than the shared section spacing. */
.home > .studio-invite {
  padding-block: clamp(2.5rem, 1.5rem + 3.6vw, 4.5rem);
}

.studio-invite__grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  align-items: center;
  gap: clamp(1.75rem, 1rem + 3vw, 4rem);
}

.studio-invite__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--gindi-gold);
}

.studio-invite__title {
  margin-block-start: 0.75rem;
  font-family: var(--font-heading);
  font-size: clamp(1.875rem, 1.3rem + 2vw, 3rem);
  font-weight: var(--fw-regular);
  line-height: 1.1;
}

.studio-invite__text {
  max-width: 32rem;
  margin-block-start: 1rem;
  color: var(--muted);
}

.studio-invite__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.75rem;
  margin-block-start: 1.75rem;
}

.studio-invite__media {
  margin: 0;
}

.studio-invite__rooms {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 0.625rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.studio-invite__room {
  position: relative;
  overflow: hidden;
}

.studio-invite__room:first-child {
  grid-row: 1 / span 2;
}

.studio-invite__room img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 16 / 10;
}

.studio-invite__room:first-child img {
  aspect-ratio: auto;
}

.studio-invite__name {
  position: absolute;
  inset-block-end: 0.625rem;
  inset-inline-start: 0.625rem;
  padding: 0.25rem 0.625rem;
  background: rgb(28 44 74 / 0.82);
  color: var(--gindi-ivory);
  font-size: 0.8125rem;
  font-weight: var(--fw-medium);
}

.studio-invite__caption {
  margin-block-start: 0.75rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

@media (max-width: 64rem) {
  .studio-invite__grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 40rem) {
  .studio-invite__rooms {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }

  .studio-invite__room:first-child {
    grid-row: auto;
    grid-column: 1 / -1;
  }

  .studio-invite__room:first-child img {
    aspect-ratio: 16 / 10;
  }
}
