/*
 * The brochure homepage, for visitors who aren't logged in (docs/adr/0037).
 * Everything it needs beyond the base layout, buttons and form fields is
 * here, so the page can move to a site of its own.
 */

/*
 * The header (docs/adr/0065): the hero's blue, so the two read as one. Once
 * scripts run, the home-header controller keeps it at the top and turns it
 * black when the hero's scrolled away from under it.
 */
.page--home #site-header {
  background-color: var(--primary);
  transition: background-color 0.3s ease;
}

.home-header--sticky {
  position: sticky;
  top: 0;
  z-index: 40;
}

.home-header--past-hero #site-header {
  background-color: var(--black);
}

/* Keep what's focused, or jumped to, clear of the header. */
html:has(.home-header--sticky) {
  scroll-padding-top: 5rem;
}

@media (prefers-reduced-motion: reduce) {
  .page--home #site-header {
    transition: none;
  }
}

/* A message sits above the hero here, so it needs room below it too. */
.page--home .flash-messages {
  padding-bottom: 1rem;
}

/* What bintold is, beside a pitch. Clipped sideways, so the tilted answer never widens a narrow screen. */
.home-hero {
  padding-top: 1.5rem;
  padding-bottom: 3rem;
  box-shadow: var(--box-shadow);
  overflow-x: clip;
}

/*
 * On phones, one column: the question, the pitch it's answered across, then
 * what bintold is and the way in - so the intro plays at the top of the
 * screen. The words' box steps aside to let the pitch in between; from
 * 48rem it's a column again, beside the pitch.
 */
.home-hero__inner {
  display: grid;
  grid-template-areas: "questions" "show" "lead" "actions";
  align-items: center;
}

.home-hero__text {
  display: contents;
}

/*
 * No bigger than its column allows for the white words on one line, with
 * the card on the next (docs/adr/0066): "Who's playing", the widest, is 6.9
 * times the size, so 14% of the column fits it. Phones and wide screens
 * have room anyway; it's smaller only where the column's narrow, beside the
 * pitch on a tablet. The first line is for browsers without container units.
 */
.home-hero__heading {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-size: min(clamp(2.5rem, 8vw, 4.5rem), 14cqi);
  font-weight: 700;
  line-height: 1.1;
}

.home-hero__ask {
  display: block;
  text-wrap: balance;
}

/*
 * The intro's questions (docs/adr/0066), stacked in one place: the heading
 * is as tall as the tallest, so nothing under it moves as they change.
 * Without the motion, only the first shows.
 */
.home-hero__questions {
  grid-area: questions;
  display: grid;
  container-type: inline-size;
}

.home-hero__question {
  grid-area: 1 / 1;
}

.home-hero__question:not(:first-child) {
  display: none;
}

/* The hero heading's yellow card (hero.css), around part of the line. */
.home-hero__highlight {
  display: inline-block;
  padding: 0 0.5rem;
  border: 0.25rem solid var(--black);
  border-radius: 0.5rem;
  background-color: var(--tertiary);
  color: var(--black);
  box-shadow: 0.375rem 0.375rem var(--black);
}

/* Lines of even length, so none ends on a word or two. */
.home-hero__lead {
  grid-area: lead;
  max-width: 34rem;
  margin-top: 1.5rem;
  font-size: 1.25rem;
  text-wrap: balance;
}

.home-hero__actions {
  grid-area: actions;
  margin-top: 2rem;
}

.home-hero__button {
  padding: 0.75rem 1.5rem;
  font-size: 1.125rem;
  box-shadow: 0.375rem 0.375rem var(--black);
}

/* The pitch, with the intro's answer across it, and the button to replay it under it. */
.home-hero__show {
  grid-area: show;
  display: grid;
  gap: 1.25rem;
  width: 100%;
  max-width: 18rem;
  margin: 2rem 0 0.5rem;
}

.home-hero__visual {
  position: relative;
}

/* Its own layer, so its players' dots (pitch.css) stay under the answer. */
.home-hero__pitch {
  border: 0.25rem solid var(--black);
  border-radius: 0.5rem;
  box-shadow: 0.375rem 0.375rem var(--black);
  overflow: hidden;
  isolation: isolate;
}

/* The pitch's own line would double up with the card's border. */
.home-hero__pitch .pitch {
  border: 0;
}

/*
 * Replay (docs/adr/0072): quiet beside "Start your team", at the pitch's
 * right. Only where the intro plays, and from 48rem: on phones the pitch
 * comes before the words, and the button would only push them down. Shown
 * once it's over (the intro controller's home-hero--played); until then it
 * keeps its place, so nothing moves when it shows.
 */
.home-hero__replay {
  display: none;
}

@media (min-width: 48rem) and (prefers-reduced-motion: no-preference) {
  .home-hero__replay {
    display: inline-flex;
    justify-self: end;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.875rem 0.25rem 0.625rem;
    border: 0.125rem solid currentColor;
    border-radius: 999px;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 700;
    cursor: pointer;
    visibility: hidden;
  }

  .home-hero__replay:hover,
  .home-hero__replay:focus-visible {
    background-color: var(--white);
    color: var(--black);
  }

  .home-hero--played .home-hero__replay {
    visibility: visible;
    animation: home-replay-in 0.3s ease-out;
  }
}

@keyframes home-replay-in {
  from { opacity: 0; }
}

/*
 * The answer, a card like the heading's slapped across the pitch
 * (docs/adr/0066): "You've been told!", corrected to "You've bintold!" with
 * the logo's whistle for its "o". A word a line, so it can be big and still
 * fit the pitch's width; the two endings share a place, so the card keeps
 * its size as one becomes the other. In the pitch's upper half on phones,
 * just under the question it answers, so both fit on a short screen.
 */
.home-hero__told {
  position: absolute;
  top: 35%;
  left: 50%;
  display: grid;
  justify-items: center;
  width: max-content;
  padding: 0.25rem 0.75rem 0.375rem;
  border: 0.3125rem solid var(--black);
  border-radius: 0.625rem;
  background-color: var(--tertiary);
  color: var(--black);
  box-shadow: 0.5rem 0.5rem var(--black);
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
  translate: -50% -50%;
  rotate: -6deg;
}

.home-hero__told-been,
.home-hero__told-bintold {
  grid-area: 2 / 1;
}

/* Without the motion, it's corrected already. */
.home-hero__told-been {
  display: none;
  position: relative;
}

/* The line through "been told", across the middle of its small letters, drawn from the left. */
.home-hero__told-been::after {
  content: "";
  position: absolute;
  top: 0.55em;
  left: -0.1em;
  right: -0.1em;
  height: 0.14em;
  border-radius: 0.07em;
  background-color: currentColor;
  rotate: -4deg;
  scale: 0 1;
  transform-origin: left center;
}

@media (min-width: 48rem) {
  .home-hero {
    padding-top: 4.5rem;
    padding-bottom: 4.5rem;
  }

  .home-hero__inner {
    grid-template-columns: minmax(0, 1fr) 18rem;
    grid-template-areas: "text show";
    gap: 4rem;
  }

  .home-hero__text {
    display: block;
    grid-area: text;
  }

  .home-hero__show {
    margin: 0;
  }

  .home-hero__pitch {
    transform: rotate(3deg);
  }

  /* A little left of the pitch's middle, into the gap beside the words: the pitch reaches the screen's right. */
  .home-hero__told {
    top: 50%;
    left: calc(50% - 0.75rem);
    font-size: 3.5rem;
  }
}

/*
 * The intro, once, in five seconds - so it needs no pause button - for
 * anyone who hasn't asked for less motion (docs/adr/0066), and again each
 * time they press Replay (0072):
 *
 *   0s     "Who's playing this week?"
 *   1s     "What time's the game?"
 *   2.3s   "Where do you want me?", to stay
 *   3s     "You've been told!" lands across the pitch
 *   3.95s  a line goes through "been told", which drops away
 *   4.4s   for "bintold!", its whistle giving a toot
 *
 * Each question rises out, then the next rises in, never both at once. The
 * first is the page's heading, so it's only hidden from sight - faded and
 * clipped, not visibility: hidden - and screen readers still have it.
 * Without the motion: the first question, with "You've bintold!" on the
 * pitch.
 */
@media (prefers-reduced-motion: no-preference) {
  .home-hero__question:not(:first-child) {
    display: block;
  }

  .home-hero__question {
    animation: 5s ease-in-out both;
  }

  .home-hero__question:nth-child(1) {
    animation-name: home-question-1;
  }

  .home-hero__question:nth-child(2) {
    animation-name: home-question-2;
  }

  .home-hero__question:nth-child(3) {
    animation-name: home-question-3;
  }

  .home-hero__told {
    animation: home-told 0.35s cubic-bezier(0.3, 1.5, 0.5, 1) 3s both;
  }

  .home-hero__told-been {
    display: block;
    animation: home-told-been 0.15s ease-in 4.2s forwards;
  }

  .home-hero__told-been::after {
    animation: home-told-strike 0.25s ease-out 3.95s forwards;
  }

  .home-hero__told-bintold {
    animation: home-told-bintold 0.25s cubic-bezier(0.3, 1.5, 0.5, 1) 4.4s both;
  }

  /*
   * About the middle of its barrel. Filled both ways, though it starts and
   * ends straight, so it's kept once it's ended, like the rest, and Replay
   * can start it again (docs/adr/0072).
   */
  .home-hero__told .brand-whistle-o {
    transform-origin: 60% 60%;
    animation: home-whistle 0.3s ease-in-out 4.65s both;
  }
}

/*
 * Over the five seconds, 1% is 50ms: out takes 3% and in 4%. The first
 * question fades out, then is clipped away once it's gone.
 */
@keyframes home-question-1 {
  0%, 20% { opacity: 1; translate: 0 0; clip-path: inset(0); }
  22.9% { opacity: 0; translate: 0 -0.3em; clip-path: inset(0); }
  23%, 100% { opacity: 0; translate: 0 -0.3em; clip-path: inset(50%); }
}

@keyframes home-question-2 {
  0%, 23% { opacity: 0; translate: 0 0.3em; visibility: hidden; }
  27%, 43% { opacity: 1; translate: 0 0; visibility: visible; }
  46%, 100% { opacity: 0; translate: 0 -0.3em; visibility: hidden; }
}

@keyframes home-question-3 {
  0%, 46% { opacity: 0; translate: 0 0.3em; visibility: hidden; }
  50%, 100% { opacity: 1; translate: 0 0; visibility: visible; }
}

@keyframes home-told {
  from { opacity: 0; scale: 1.4; visibility: hidden; }
  to { opacity: 1; scale: 1; visibility: visible; }
}

@keyframes home-told-strike {
  to { scale: 1 1; }
}

@keyframes home-told-been {
  to { opacity: 0; translate: 0 0.3em; visibility: hidden; }
}

@keyframes home-told-bintold {
  from { opacity: 0; scale: 0.4; visibility: hidden; }
  to { opacity: 1; scale: 1; visibility: visible; }
}

@keyframes home-whistle {
  30% { rotate: -14deg; }
  65% { rotate: 10deg; }
}

/* What it does: a band each, white and light grey in turn, beside the page. */
.home-feature {
  padding-top: 3.5rem;
  padding-bottom: 3.5rem;
  background-color: var(--white);
  color: var(--black);
}

.home-feature:nth-child(even) {
  background-color: var(--row-stripe);
}

.home-feature__inner {
  display: grid;
  align-items: center;
  gap: 1.5rem;
}

.home-feature__name {
  margin-bottom: 0.75rem;
  font-size: 1.5rem;
  line-height: 1.25;
}

.home-feature__text p {
  max-width: 30rem;
  font-size: 1.125rem;
}

/* Words beside the picture, swapping sides each band; the words come first for screen readers either way. */
@media (min-width: 52rem) {
  .home-feature {
    padding-top: 4.5rem;
    padding-bottom: 4.5rem;
  }

  .home-feature__inner {
    grid-template-columns: minmax(14rem, 1fr) minmax(0, 2fr);
    gap: 3rem;
  }

  .home-feature:nth-child(even) .home-feature__inner {
    grid-template-columns: minmax(0, 2fr) minmax(14rem, 1fr);
  }

  .home-feature:nth-child(even) .home-feature__shot {
    grid-row: 1;
    grid-column: 1;
  }

  .home-feature__name {
    font-size: 1.75rem;
  }
}

/* A browser window, framed like the site's cards. */
.home-window {
  overflow: hidden;
  border: 0.25rem solid var(--black);
  border-radius: 0.5rem;
  background-color: var(--white);
  box-shadow: 0.375rem 0.375rem var(--black);
}

.home-window__bar {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 0.25rem solid var(--black);
  background-color: var(--tertiary);
}

.home-window__dot {
  width: 0.625rem;
  height: 0.625rem;
  border: 0.125rem solid var(--black);
  border-radius: 50%;
  background-color: var(--white);
}

.home-window__address {
  flex: 0 1 16rem;
  min-width: 0;
  margin-left: 0.75rem;
  padding: 0 0.75rem;
  border: 0.125rem solid var(--black);
  border-radius: 1rem;
  background-color: var(--white);
  color: var(--black);
  font-size: 0.75rem;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-window__screen {
  display: block;
  width: 100%;
  height: auto;
}

/*
 * Replies: the same match on a player's phone, standing in front of the
 * window's corner and tilted like the hero's pitch. The window leaves it
 * room on the right and below, so it covers only the window's edge.
 */
.home-feature__shot--phone {
  position: relative;
  padding-right: 18%;
  padding-bottom: 14%;
}

.home-feature__phone {
  position: absolute;
  right: 0.5rem;
  bottom: 0;
  width: 26%;
  height: auto;
  border: 0.25rem solid var(--black);
  border-radius: 1.25rem;
  box-shadow: 0.375rem 0.375rem var(--black);
  transform: rotate(3deg);
}

/* What's free: a yellow band between what it does and the form. */
.home-free {
  padding-top: 3rem;
  padding-bottom: 3rem;
  border-top: 0.25rem solid var(--black);
  background-color: var(--tertiary);
  color: var(--black);
}

.home-free__inner {
  display: grid;
  gap: 1rem 4rem;
}

.home-free__heading {
  font-size: 2rem;
  line-height: 1.2;
}

.home-free__text {
  max-width: 36rem;
  font-size: 1.125rem;
}

.home-free__text > * + * {
  margin-top: 0.75rem;
}

.home-free__list {
  padding-left: 1.25rem;
  list-style: disc;
}

@media (min-width: 48rem) {
  .home-free__inner {
    grid-template-columns: minmax(0, 1fr) minmax(0, 36rem);
  }
}

/* The way in: create an account, beside why. */
.home-signup {
  padding-top: 3.5rem;
  padding-bottom: 4rem;
}

.home-signup__inner {
  display: grid;
  align-items: center;
  gap: 2rem;
}

.home-signup__heading {
  font-size: 2rem;
  line-height: 1.2;
}

.home-signup__intro {
  max-width: 32rem;
  margin-top: 0.75rem;
  font-size: 1.125rem;
}

.home-signup__login {
  margin-top: 1.25rem;
}

.home-signup__login a {
  color: inherit;
}

@media (min-width: 48rem) {
  .home-signup__inner {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4rem;
  }
}
