/*
 * Sections of the home page, on top of site.css. Columns: one below 768px, two up to
 * 1023px, three (clubs) or four (steps) from 1024px. The hero has its own query, at the end.
 */

.home-section {
  padding-block: 32px;
}

.home-lead {
  margin: var(--space-inline) 0 var(--space-section-gap);
  color: var(--text-muted);
}

.home-lead--plain {
  color: var(--text-body);
}

.home-section-title {
  margin-bottom: var(--space-section-gap);
}

.home-link {
  color: var(--text-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.home-link:hover {
  color: var(--text-brand);
  text-decoration-thickness: 2px;
}

/*
 * Hero: the training green stands in for the photo until it loads, or if it fails.
 * By default the photo is a band above the text: the group is a thin strip of a portrait
 * photo, so a full-screen photo put a wide sky on top and the faces under the text. Phones and
 * tablets held upright keep the band; the end of the file has the screens that don't.
 */
.home-hero {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface-training);
}

.home-hero > picture {
  display: block;
}

/* The band files are already cropped on the group; the box keeps its place while it loads. */
.home-hero__photo {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  /* Melts the road in front of the group into the green the text sits on. */
  mask-image: linear-gradient(to bottom, black 70%, transparent);
}

.home-hero__content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-stack);
  padding-block: var(--space-section-gap) var(--space-page-margin-wide);
}

.home-hero__title {
  margin: 0;
}

/* The logotype is the page title: its alt text is the h1. */
.home-hero__logo {
  display: block;
  width: auto;
  height: 72px;
}

/*
 * The official badges, untouched, at one height. Apple and Google both ask for a quarter of that
 * height free around a badge: the gap between them, and more on every other side. Side by side
 * while both fit (from about 350px wide), one under the other below.
 */
.home-hero__stores {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-stack);
  margin-top: var(--space-inline);
}

.store-badge {
  display: block;
  border-radius: var(--radius-field);
}

.store-badge img {
  display: block;
  width: auto;
  height: var(--size-touch);
}

/* Clubs and steps */
.home-clubs,
.home-steps {
  display: grid;
  gap: var(--space-stack);
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-club,
.home-step,
.home-contact__card {
  display: grid;
  align-items: center;
  gap: var(--space-inline) var(--space-stack);
  padding: var(--space-card-padding);
  border-radius: var(--radius-card);
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
}

.home-club {
  grid-template-columns: 56px 1fr;
}

.home-club picture {
  grid-row: span 2;
}

/* A square box so the titles line up whatever the logo's shape. */
.home-club__logo {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.home-club__text,
.home-step__text {
  grid-column: 1 / -1;
}

.home-step {
  grid-template-columns: 40px 1fr;
}

.home-step__number {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--surface-brand-soft);
  color: var(--text-brand);
}

/* Upcoming sessions: only the empty state until the feed exists. */
.home-section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-tight) var(--space-section-gap);
  margin-bottom: var(--space-section-gap);
}

.home-empty {
  margin: 0;
  padding: var(--space-card-padding);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  background: var(--surface-card);
}

.home-outing {
  display: grid;
  gap: var(--space-inline);
  margin-top: var(--space-section-gap);
  padding: var(--space-screen);
  border-radius: var(--radius-hero);
  background: var(--surface-inverse);
}

/* Gallery: the sunken tile shows if a photo fails, under its alt text. */
.home-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-stack);
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-gallery__item {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--surface-sunken);
}

.home-gallery__photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Contact */
.home-contact {
  display: grid;
  gap: var(--space-stack);
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-contact__card {
  grid-template-columns: 24px 1fr;
  color: var(--text-strong);
}

.home-contact__link {
  display: inline-flex;
  align-items: center;
  grid-column: 2;
  min-height: var(--size-touch);
}

/* Training Club card: the whole card follows its link. */
.home-training {
  position: relative;
  display: grid;
  gap: var(--space-inline);
  margin-top: var(--space-section-gap);
  padding: var(--space-screen);
  border-radius: var(--radius-hero);
  background: var(--surface-training);
  transition: background-color var(--motion-press) var(--ease-press);
}

.home-training:hover {
  background: var(--surface-training-pressed);
}

.home-training__overline {
  opacity: 0.8;
}

.home-training__link {
  position: static;
  margin-top: var(--space-inline);
}

.home-training__link::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
}

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

  .home-clubs,
  .home-steps {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-section-gap);
  }

  .home-club,
  .home-step {
    grid-template-columns: 1fr;
    align-content: start;
  }

  .home-club picture {
    grid-row: auto;
  }

  .home-contact {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-section-gap);
  }

  .home-training {
    justify-items: start;
  }
}

@media (min-width: 1024px) {
  .home-hero__logo {
    height: 96px;
  }

  .home-clubs {
    grid-template-columns: repeat(3, 1fr);
  }

  .home-steps {
    grid-template-columns: repeat(4, 1fr);
  }

  .home-gallery {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-card-padding);
  }
}

/*
 * The text goes on the photo where the 640-high hero crops the sky. Its height never follows the
 * screen's, so from 1024 wide it does in either orientation, and a band would be wider than the
 * largest crop file. Between 768 and 1023, a tablet held upright keeps the band; a landscape
 * screen keeps the photo, since a 3:2 band would fill it before the text. The hero's and the
 * gallery's pictures switch files under the same query.
 */
@media (min-width: 1024px), (min-width: 768px) and (orientation: landscape) {
  .home-hero {
    justify-content: flex-end;
    min-height: 640px;
  }

  .home-hero__photo {
    position: absolute;
    inset: 0;
    z-index: -2;
    height: 100%;
    aspect-ratio: auto;
    /* The group stands in the lower half of the photo, under a wide sky. */
    object-position: center 62%;
    mask-image: none;
  }

  /* The text sits on the full scrim, never on the bare photo. */
  .home-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(to bottom, transparent 0%, var(--scrim-media) 25%);
  }

  .home-hero__content {
    padding-block: 48px var(--space-page-margin-wide);
  }
}
