/*
 * pages/home.css: the landing (GET /, api/src/views/pages/home.js and views/sections/*.js).
 * Composes: .c-section/.c-container, .c-trazos--hero, .c-search, .c-button, .c-link--standalone, .c-bento,
 * .c-steps, .c-comuna-map, .c-card-grid + .c-card, .c-empty, .c-notice, .c-field/.c-input/.c-select,
 * .c-chip-option, .c-public-fields, .c-bottom-bar. Page-only rules (prefix hm-): the hero block, the family
 * tiles, the two "how it works" tracks, the jornada items, the ally cards, the contact block and the FAQ.
 * Tokens only, no hex, dvh not vh, mobile first.
 *
 * Grounds: the page alternates white and surface-alt sections and decides each one's ground (a section
 * can move when "recién llegados" is omitted). Every panel here therefore takes its fill from --_bg and
 * flips to white inside .c-section--alt, the way .c-card does, so nothing ever vanishes into its ground.
 * Motion: only transform and opacity; every entrance is a motion.css helper (.m-stagger, .m-reveal) that
 * is disabled under prefers-reduced-motion; nothing is hidden by default.
 */

/*
 * The thumb bar (components/bottom-bar.css) is fixed over the bottom edge below 48em, where it
 * covers whatever sits behind it. Focused fields and the submit button of the contact form scroll
 * clear of it: base.css only reserves room under the sticky header. Same height as the page's own
 * bottom padding for the bar (has-bottom-bar), and the same breakpoint as the bar itself.
 */
@media (max-width: 47.99em) {
  :root:has(body.has-bottom-bar) {
    scroll-padding-block-end: calc(var(--md-target) + var(--md-space-6) + env(safe-area-inset-bottom, 0px));
  }
}

/* ---- hero ---- */
.hm-hero {
  /* Phone: the trazo composition sits at the bottom edge, below the copy; the padding reserves ~18rem for it. */
  padding-block: var(--md-space-7) calc(var(--md-space-9) * 3);
}

.hm-hero__inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: var(--md-space-5);
}

/* Two lines or fewer at every width; text-wrap: balance (base.css) evens them out. */
.hm-hero__title {
  max-inline-size: 16ch;
}

.hm-hero__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--md-space-5);
  max-inline-size: 34rem;
}

.hm-hero__lede {
  max-inline-size: var(--md-measure);
  font-size: var(--md-font-size-lg);
  color: var(--md-color-ink-soft);
}

.hm-search {
  inline-size: 100%;
  max-inline-size: 36rem;
}

@media (min-width: 64em) {
  .hm-hero {
    padding-block: var(--md-space-9);
    min-block-size: 36rem;
  }
}

/* ---- the comuna map ---- */
.hm-map .c-comuna-map {
  margin-inline: auto;
}

/* ---- families (categorias) ---- */
/* A compact row: the family's picture on the left, its name and count on the right. */
.hm-family {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  grid-template-areas:
    'art title'
    'art count';
  align-content: center;
  align-items: center;
  column-gap: var(--md-space-4);
  row-gap: var(--md-space-1);
  min-block-size: 0;
  padding: var(--md-space-4);
}

.hm-family__art {
  grid-area: art;
  inline-size: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--md-radius-md);
  object-fit: cover;
}

.hm-family__title {
  grid-area: title;
  align-self: end;
  font-size: var(--md-font-size-lg);
  overflow-wrap: anywhere;
}

.hm-family__count {
  grid-area: count;
  align-self: start;
  font-size: var(--md-font-size-sm);
}

@media (min-width: 40em) {
  .hm-family.c-bento__tile--wide {
    grid-template-columns: 8rem minmax(0, 1fr);
    column-gap: var(--md-space-5);
    padding: var(--md-space-5);
  }

  .hm-family.c-bento__tile--wide .hm-family__title {
    font-size: var(--md-font-size-xl);
  }
}

/* ---- how it works ---- */
.hm-how__tracks {
  display: grid;
  gap: var(--md-space-5);
}

@media (min-width: 64em) {
  .hm-how__tracks {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--md-space-6);
  }
}

.hm-track {
  --_bg: var(--md-color-surface-alt);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--md-space-5);
  padding: var(--md-space-5);
  border-radius: var(--md-radius-lg);
  background: var(--_bg);
}

.c-section--alt .hm-track {
  --_bg: var(--md-color-surface);
}

/* The two tracks sit side by side with different step counts and copy lengths: the link goes to the
   foot of each card, so both end on one line. */
.hm-track > .c-link--standalone {
  margin-block-start: auto;
}

.hm-track__title {
  font-family: var(--md-font-display);
  font-size: var(--md-font-size-xl);
  font-weight: var(--md-weight-black);
  line-height: var(--md-leading-tight);
  letter-spacing: var(--md-tracking-tight);
}

/* ---- jornadas ---- */
.hm-jornadas {
  display: grid;
  gap: var(--md-space-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
}

.hm-jornada {
  --_bg: var(--md-color-surface-alt);
  display: flex;
  flex-direction: column;
  gap: var(--md-space-2);
  padding: var(--md-space-5);
  border-radius: var(--md-radius-lg);
  background: var(--_bg);
  overflow-wrap: anywhere;
}

.c-section--alt .hm-jornada {
  --_bg: var(--md-color-surface);
}

.hm-jornada__date {
  font-family: var(--md-font-display);
  font-size: var(--md-font-size-lg);
  font-weight: var(--md-weight-black);
  line-height: var(--md-leading-snug);
  color: var(--md-color-primary);
}

/* The place is the item's title: a venue name can be long, so it wraps (the item sets overflow-wrap). */
.hm-jornada__place {
  font-family: var(--md-font-display);
  font-size: var(--md-font-size-xl);
  font-weight: var(--md-weight-black);
  line-height: var(--md-leading-tight);
  letter-spacing: var(--md-tracking-tight);
  color: var(--md-color-ink);
}

.hm-jornada__meta {
  font-size: var(--md-font-size-sm);
  color: var(--md-color-ink-soft);
}

.hm-jornada__notes {
  font-size: var(--md-font-size-sm);
  line-height: var(--md-leading-body);
  color: var(--md-color-ink);
}

/* The empty state is a panel too: white on the alternate ground, so it does not vanish into it. */
.hm-jornadas-section .c-empty {
  background: var(--md-color-surface);
}

/* ---- recién llegados ---- */
/* A card title can be as long as a business name (up to 160 characters): break inside words and cap at three lines. */
.hm-recent .c-card__title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.hm-recent__more {
  margin-block-start: var(--md-space-6);
}

/* ---- aliados ---- */
.hm-allies {
  display: grid;
  gap: var(--md-space-4);
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 40em) {
  .hm-allies {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hm-allies > .hm-ally--invite {
    grid-column: 1 / -1;
  }
}

@media (min-width: 64em) {
  .hm-allies {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--md-space-5);
  }

  .hm-allies > .hm-ally--invite {
    grid-column: auto;
  }
}

.hm-ally {
  --_bg: var(--md-color-surface-alt);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--md-space-3);
  padding: var(--md-space-5);
  border-radius: var(--md-radius-lg);
  background: var(--_bg);
  color: var(--md-color-ink);
  overflow-wrap: anywhere;
}

.c-section--alt .hm-ally {
  --_bg: var(--md-color-surface);
}

.hm-ally__role {
  font-size: var(--md-font-size-sm);
  font-weight: var(--md-weight-bold);
  color: var(--md-color-ink-soft);
}

.hm-ally__name {
  font-family: var(--md-font-display);
  font-size: var(--md-font-size-xl);
  font-weight: var(--md-weight-black);
  line-height: var(--md-leading-tight);
  letter-spacing: var(--md-tracking-tight);
}

/* The way in: a deep green card on either ground (same specificity as the flip above, and later). */
.hm-allies > .hm-ally--invite {
  --_bg: var(--md-color-primary);
  color: var(--md-color-on-primary);
  justify-content: flex-end;
}

.hm-ally--invite .c-button {
  margin-block-start: auto;
}

/* ---- contacto ---- */
.hm-contact__inner {
  display: grid;
  gap: var(--md-space-6);
}

@media (min-width: 64em) {
  .hm-contact__inner {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: var(--md-space-8);
    align-items: start;
  }
}

.hm-contact__intro {
  display: flex;
  flex-direction: column;
  gap: var(--md-space-6);
}

.hm-contact__intro .c-section__header {
  margin-block-end: 0;
}

.hm-contact__direct {
  display: flex;
  flex-direction: column;
  gap: var(--md-space-3);
}

.hm-contact__direct-title {
  font-weight: var(--md-weight-bold);
}

.hm-contact__direct-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--md-space-3);
}

.hm-contact__panel {
  --_bg: var(--md-color-surface-alt);
  display: flex;
  flex-direction: column;
  gap: var(--md-space-5);
  padding: var(--md-space-5);
  border-radius: var(--md-radius-lg);
  background: var(--_bg);
}

.c-section--alt .hm-contact__panel {
  --_bg: var(--md-color-surface);
}

/* The status region is focused by the script after a send; it is not a control, so no ring (base.css). */
.hm-contact__status:empty {
  display: none;
}

.hm-contact-form {
  display: grid;
  gap: var(--md-space-5);
}

/* The script hides the contact field that was not chosen; a class display would beat the UA's [hidden]. */
.hm-contact-form [hidden] {
  display: none;
}

/* A fieldset is a group of radios here: reset the browser box and keep the legend as the label. */
.hm-channel {
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.hm-channel .c-field__label {
  padding: 0;
  margin-block-end: var(--md-space-2);
}

/* The consent label can run to two lines at 390 px. */
.hm-consent {
  max-inline-size: 100%;
}

.hm-consent .c-chip {
  text-align: start;
}

.hm-contact-form__actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--md-space-2);
}

/* ---- faq ---- */
.hm-faq__list {
  display: flex;
  flex-direction: column;
  gap: var(--md-space-3);
}

.hm-faq__item {
  --_bg: var(--md-color-surface-alt);
  border-radius: var(--md-radius-lg);
  background: var(--_bg);
}

.c-section--alt .hm-faq__item {
  --_bg: var(--md-color-surface);
}

.hm-faq__question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--md-space-4);
  min-block-size: var(--md-target);
  padding: var(--md-space-3) var(--md-space-5);
  border-radius: var(--md-radius-lg);
  font-weight: var(--md-weight-bold);
  line-height: var(--md-leading-snug);
  cursor: pointer;
  list-style: none;
}

.hm-faq__question::-webkit-details-marker {
  display: none;
}

/* A drawn chevron (two strokes), like the select's: it turns when the answer opens. */
.hm-faq__question::after {
  content: '';
  flex: none;
  inline-size: 0.625rem;
  block-size: 0.625rem;
  border-inline-end: var(--md-border-width-strong) solid var(--md-color-primary);
  border-block-end: var(--md-border-width-strong) solid var(--md-color-primary);
  transform: rotate(45deg);
  transition: transform var(--md-duration-base) var(--md-ease-out);
}

.hm-faq__item[open] > .hm-faq__question::after {
  transform: rotate(-135deg);
}

.hm-faq__answer {
  display: flex;
  flex-direction: column;
  gap: var(--md-space-3);
  max-inline-size: var(--md-measure);
  padding: 0 var(--md-space-5) var(--md-space-5);
  overflow-wrap: anywhere;
}

/* Between 64em and 80em the left half is narrow for a display headline: draw the composition smaller and
   further right so no text lies over the strokes. */
@media (min-width: 64em) and (max-width: 79.99em) {
  .hm-hero .c-trazos--hero {
    background-position: right -8% bottom 4%;
    background-size: auto 78%;
  }
}
