/* ==========================================================================
   Cross Kashmir — Homepage
   Requires tokens, base, typography, layout, components (and header/footer
   for the page shell). Everything is scoped under .home so nothing here can
   leak into other pages.

   Mobile-first. Breakpoints used: 640, 768, 1024.

   Since Session 14 the stories are generated into the HTML at build time
   (templates/partials/card-home-*.html, one per card identity below). The markup of every card is the same
   as before, so the variants here apply unchanged; .home-state (further down)
   styles the loading / error / empty blocks.

   Card variants (all built on the .card component from components.css):
     .card--compact  row (thumbnail beside text) below 768px, normal card above
     .card--person   flat, portrait image, human/editorial feel
     .card--bare     no box at all, image-led, calm
     .card--lead     the large card of a section
   Image ratio is set per card with --media-ratio.

   Placeholder images: .ph is a flat tinted box with a "sample image" label.
   It is decorative (aria-hidden). When real photos arrive, replace the
   <div class="card__media ph" aria-hidden="true"> with
   <div class="card__media"><img src="..." alt="meaningful description" ...></div>;
   components.css already crops images with object-fit: cover.
   ========================================================================== */

/* hidden is made binding here: several parts below set their own display. */
.home [hidden] {
  display: none !important;
}

/* ---- Page rhythm ------------------------------------------------------------ */
.home .home-section {
  padding-block: var(--space-6);
}

/* Full-width bands give the page rhythm without decoration */
.home .home-section--surface,
.home .home-section--tint {
  padding-block: var(--space-8);
}

.home .home-section--surface {
  background-color: var(--color-surface);
  border-block: var(--border);
}

.home .home-section--tint {
  background-color: var(--color-primary-light);
}

@media (min-width: 768px) {
  .home .home-section {
    padding-block: var(--space-8);
  }

  .home .home-section--surface,
  .home .home-section--tint {
    padding-block: var(--space-12);
  }
}

/* ---- Section heading: title + "more" link over a hairline with a gold tab --- */
.home .section-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-block-end: var(--space-4);
  border-block-end: var(--border);
}

.home .section-head::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  inset-block-end: calc(-1 * var(--border-width));
  inline-size: var(--space-12);
  block-size: 3px;
  background-color: var(--color-accent);       /* decorative accent only */
}

.home .section-head__title {
  font-size: var(--fs-section);
  font-weight: var(--fw-bold);
  line-height: var(--lh-heading);
}

.home .section-head__more {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--tap-target);
  font-size: var(--fs-nav);
  font-weight: var(--fw-medium);
  line-height: var(--lh-ui);
  white-space: nowrap;
  text-decoration: none;
}

.home .section-head__more:hover {
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
  text-decoration-thickness: 2px;
  text-underline-offset: var(--underline-offset);
}

@media (min-width: 768px) {
  .home .section-head {
    margin-block-end: var(--space-6);
  }
}

/* ---- Image placeholders ------------------------------------------------------ */
.home .ph {
  display: grid;
  place-items: center;
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  font-size: var(--fs-caption);
  line-height: var(--lh-ui);
}

.home .ph--alt {
  background-color: var(--color-border);
}

/* "Sample content" markers */
.home .sample-badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3) 0;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
  font-size: var(--fs-meta);
  line-height: var(--lh-ui);
}

/* ---- Media ratio hook (replaces the fixed 16/9 for homepage cards) ------------ */
.home .card__media {
  aspect-ratio: var(--media-ratio, 16 / 9);
}

/* A little air between a label and the headline under it: Nastaliq ascenders
   rise above the line box and otherwise touch the label. */
.home .card__title {
  margin-block-start: var(--space-1);
}

/* ---- Hero / lead story ------------------------------------------------------- */
.home .hero {
  padding-block: var(--space-4) var(--space-6);
}

.home .hero__story {
  position: relative;                      /* anchors the stretched link */
  display: grid;
  gap: var(--space-4);
  border-radius: var(--radius-md);
}

.home .hero__media {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.home .hero__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

.home .hero__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.home .hero__title {
  margin-block-start: var(--space-1);      /* Nastaliq ascenders rise above the line box */
  font-size: var(--fs-article);
  font-weight: var(--fw-bold);
  line-height: var(--lh-display);
  text-wrap: balance;
}

.home .hero__title a {
  color: var(--color-text);
  text-decoration: none;
}

.home .hero__title a::after {              /* whole hero is one link, no JavaScript */
  content: "";
  position: absolute;
  inset: 0;
}

.home .hero__title a:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
  text-decoration-thickness: 2px;
  text-underline-offset: calc(var(--underline-offset) - 0.1em);
}

.home .hero__story:has(a:focus-visible) {
  outline: var(--focus-ring-width) solid var(--color-focus);
  outline-offset: var(--focus-ring-offset);
}

.home .hero__title a:focus-visible {
  outline: none;                           /* the ring is drawn on the whole story */
}

.home .hero__summary {
  font-size: var(--fs-lead);
  line-height: var(--lh-body);
}

@media (min-width: 768px) {
  .home .hero {
    padding-block: var(--space-6) var(--space-8);
  }

  .home .hero__story {
    grid-template-columns: 1fr 1fr;        /* image on the inline-start (right) side */
    align-items: center;
    gap: var(--space-6);
  }

  .home .hero__title {
    font-size: var(--fs-page);
  }
}

@media (min-width: 1024px) {
  .home .hero__story {
    grid-template-columns: 7fr 5fr;
    gap: var(--space-8);
  }

  .home .hero__title {
    font-size: var(--fs-article);
  }
}

/* ---- Card grids ---------------------------------------------------------------- */
.home .home-grid {
  display: grid;
  gap: var(--space-4);
}

@media (min-width: 768px) {
  .home .home-grid {
    gap: var(--space-6);
  }
}

/* Latest: list of rows -> 2 x 2 -> four across */
@media (min-width: 640px) {
  .home .home-grid--latest {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .home .home-grid--latest {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Three-up sections (people, culture, technology) */
@media (min-width: 768px) {
  .home .home-grid--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Culture: on phones one large image with two smaller beside each other (a calm
   mosaic instead of three tall images in a row); three equal columns from 640px */
.home .home-grid--culture {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.home .home-grid--culture > :first-child {
  grid-column: 1 / -1;
}

@media (min-width: 640px) {
  .home .home-grid--culture {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .home .home-grid--culture > :first-child {
    grid-column: auto;
  }
}

/* Kashmir: one large card + two supporting cards */
@media (min-width: 640px) {
  .home .home-grid--lead {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home .home-grid--lead > .card--lead {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1024px) {
  .home .home-grid--lead {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: repeat(2, auto);
  }

  .home .home-grid--lead > .card--lead {
    grid-column: 1;
    grid-row: 1 / span 2;
  }
}

/* ---- Compact card: row on small screens, ordinary card from 768px ------------- */
.home .card--compact {
  flex-direction: row;
}

.home .card--compact .card__media {
  flex: 0 0 6.5rem;
  aspect-ratio: auto;                      /* the thumbnail follows the card's height */
  min-height: 6.5rem;
}

.home .card--compact .ph span {
  display: none;                           /* too small for a label */
}

.home .card--compact .card__body {
  min-width: 0;
  padding: var(--space-3);
}

@media (min-width: 640px) {
  .home .card--compact .card__media {
    flex-basis: clamp(6.5rem, 34%, 11rem);
  }

  .home .card--person.card--compact .card__media {
    flex-basis: 6.5rem;
  }
}

@media (min-width: 768px) {
  .home .card--compact {
    flex-direction: column;
  }

  .home .card--compact .card__media {
    flex: none;
    aspect-ratio: var(--media-ratio, 16 / 9);
    min-height: 0;
  }

  .home .card--compact .ph span {
    display: inline;
  }

  .home .card--compact .card__body {
    padding: var(--space-4);
  }
}

/* ---- Lead card (Kashmir) --------------------------------------------------------- */
.home .card--lead .card__title {
  font-size: var(--fs-section);
}

@media (min-width: 640px) {
  .home .card--lead {
    flex-direction: row;
  }

  .home .card--lead .card__media {
    flex: 0 0 50%;
    aspect-ratio: auto;
    min-height: 14rem;
  }

  .home .card--lead .card__body {
    justify-content: center;
    padding: var(--space-6);
  }
}

@media (min-width: 1024px) {
  .home .card--lead {
    flex-direction: column;
  }

  /* the image absorbs whatever height the two side cards need */
  .home .card--lead .card__media {
    flex: 1 1 auto;
    min-height: 16rem;
  }

  .home .card--lead .card__body {
    flex: none;
    justify-content: flex-start;
  }
}

/* ---- Person card: flat, portrait, human ------------------------------------------- */
.home .card--person {
  --media-ratio: 1 / 1;                    /* used from 768px; below that the thumbnail follows the row */
  gap: var(--space-3);
  padding-block-start: var(--space-3);
}

.home .card--person .card__media {
  border-radius: var(--radius-md);
}

.home .card--person .card__body {
  padding-block: 0;
}

.home .card--person .card__title {
  font-size: var(--fs-sub);
}

/* role label reads as an editorial byline, not a pill */
.home .card--person .tag {
  padding-inline: 0;
  background-color: transparent;
  color: var(--color-primary);
}

@media (min-width: 1024px) {
  .home .card--person .card__title {
    font-size: var(--fs-section);
  }
}

@media (min-width: 768px) {
  .home .card--person {
    gap: var(--space-4);
    padding-block-start: var(--space-4);
  }
}

/* ---- Bare card: image first, no box (culture) -------------------------------------- */
.home .card--bare {
  --media-ratio: 3 / 2;
  background-color: transparent;
  border: 0;
  border-radius: 0;
  overflow: visible;
}

.home .card--bare .card__media {
  border-radius: var(--radius-md);
}

.home .card--bare .card__body {
  padding: var(--space-3) 0 0;
}

/* ---- Technology: accent cards keep the Cross Kashmir editorial look ----------------- */
.home .card--accent {
  --media-ratio: 3 / 2;
  border-radius: 0;
  border-color: var(--color-border-strong);
}

.home .card--accent .card__media {
  border-block-end: var(--border);
}

.home .card--accent .tag {
  border-radius: var(--radius-sm);
}

/* ---- Services band ------------------------------------------------------------------- */
.home .services {
  display: grid;
  gap: var(--space-6);
}

.home .services__title {
  margin-block-end: var(--space-2);
  font-size: var(--fs-section);
  font-weight: var(--fw-bold);
  line-height: var(--lh-heading);
}

.home .services__intro p {
  margin-block-end: var(--space-4);
  max-width: 34rem;
}

.home .services__list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
}

@media (min-width: 640px) {
  .home .services__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.home .services__list .card__body {
  padding: var(--space-4);
}

@media (min-width: 768px) {
  .home .services__list {
    gap: var(--space-4);
  }
}

@media (min-width: 1024px) {
  .home .services {
    grid-template-columns: 1fr 2fr;
    align-items: center;
    gap: var(--space-12);
  }
}

/* Latest is a news ticker-style list: keep rows until the 4-column layout */
@media (min-width: 768px) and (max-width: 1023.98px) {
  .home .home-grid--latest .card--compact {
    flex-direction: row;
  }

  .home .home-grid--latest .card--compact .card__media {
    flex: 0 0 clamp(6.5rem, 34%, 11rem);
    aspect-ratio: auto;
    min-height: 6.5rem;
  }

  .home .home-grid--latest .card--compact .ph span {
    display: none;
  }

  .home .home-grid--latest .card--compact .card__body {
    padding: var(--space-3);
  }
}

/* ---- Loading / error / empty / no-JavaScript blocks (Session 11) ---------------------
   One reading-width block at the top of <main>. The loading block is tall on
   purpose: it keeps the Services band below the first screen until the stories
   arrive, so nothing visible jumps when they appear. */
.home .home-state {
  padding-block: var(--space-8);
}

.home .home-state > * {
  max-inline-size: var(--container-narrow);
}

.home .home-state > * + * {
  margin-block-start: var(--space-4);
}

.home .home-state[data-state="loading"] {
  min-block-size: 70svh;
}

.home .home-state__title {
  font-size: var(--fs-page);
  font-weight: var(--fw-bold);
  line-height: var(--lh-display);
}

.home .home-state__links {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--space-6);
}

.home .home-state__links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-target);
}
