/* Not-Ship homepage additions: hero sign-up, "Start here" row, closing sign-up.
   Loaded on the homepage only (see default.hbs). Everything is prefixed "ns-" so
   nothing here affects the rest of the theme. */

/* (The shared colours and the sign-up form styles now live in ns-site.css, which loads on every page.) */

/* ---------- Hero ---------- */

.ns-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.125rem;
  box-sizing: border-box;
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem; /* the header above already provides the top spacing */
  text-align: center;
}

.ns-hero-title {
  margin: 0;
  font-size: clamp(1.75rem, 3.4vw, 2.75rem); /* 28px on phones (a step below article titles), 44px on desktop */
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.ns-hero-text {
  margin: 0;
  max-width: 48rem; /* wide enough for a one-line subhead on desktop */
  font-size: 1rem; /* same as body text on phones */
  line-height: 1.5;
  color: var(--color-gray-700);
  text-wrap: balance;
}

.dark-mode .ns-hero-text {
  color: var(--color-gray-300);
}

/* The sign-up sits in the same offset-frame card as the featured post and the closing sign-up */
.ns-hero-frame {
  box-sizing: border-box;
  width: 100%;
  max-width: 34rem;
  margin: 0.875rem 0.625rem 0 0; /* room for the card's offset */
  border: 3px solid var(--ns-frame);
}

.ns-hero-card {
  padding: 1rem;
  border: 2px solid var(--color-border-primary);
  background: var(--color-bg-primary);
  text-align: left;
  transform: translate(0.625rem, -0.625rem);
}

.ns-hero .ns-form {
  max-width: none;
}

.ns-hero .ns-form-success {
  text-align: center;
}

@media (min-width: 640px) {
  .ns-hero {
    padding: 0 1.5rem 3rem;
    gap: 1.25rem;
  }

  .ns-hero-text {
    font-size: 1.25rem;
  }

  .ns-hero-frame {
    margin-top: 1rem;
    margin-right: 0.75rem;
  }

  .ns-hero-card {
    padding: 1.125rem;
    transform: translate(0.75rem, -0.75rem);
  }
}

/* Phones: email field and button stacked, full width */
@media (max-width: 639px) {
  .ns-hero .ns-form-row {
    flex-direction: column;
  }

  .ns-hero .ns-form-input,
  .ns-hero .ns-form-button {
    flex-basis: auto;
    width: 100%;
  }
}

.ns-hero-proof {
  max-width: 34rem;
  margin: 0.25rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--ns-muted);
  text-wrap: balance;
}

/* Short blue divider (uses the theme's own <hr> style: 60px × 3px in the accent colour) */
.ns-hero .ns-rule {
  margin: 2.5rem auto 0;
}

.ns-start .ns-rule {
  margin: 3rem auto 0;
}

@media (min-width: 640px) {
  .ns-hero .ns-rule {
    margin-top: 3rem;
  }

  .ns-start .ns-rule {
    margin-top: 3.5rem;
  }
}

/* ---------- "Start here" row ---------- */

.ns-start {
  box-sizing: border-box;
  max-width: 900px;
  margin: 1rem auto 3rem;
  padding: 0 1rem;
}

.ns-start-title,
.ns-section-title {
  margin: 0 0 1.5rem;
  font-size: 1.5rem;
}

/* Heading above the list of earlier issues, lined up with the Start here heading */
.ns-section-heading {
  box-sizing: border-box;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem;
}

.ns-start-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.75rem;
}

.ns-start-link {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  color: var(--color-heading-primary);
  text-decoration: none;
}

.ns-start-image {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--color-gray-200);
}

.ns-start-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s ease-in-out;
}

.ns-start-link:hover .ns-start-image img,
.ns-start-link:focus .ns-start-image img {
  transform: scale(1.03);
}

.ns-start-card-title {
  margin: 0;
  font-size: 1.125rem;
  line-height: 1.25;
}

.ns-start-link:hover .ns-start-card-title,
.ns-start-link:focus .ns-start-card-title {
  text-decoration: underline;
  text-decoration-color: var(--ghost-accent-color);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.12em;
}

.ns-start-card-text {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--ns-muted);
}

@media (min-width: 640px) {
  .ns-start {
    margin-bottom: 3.5rem;
  }

  .ns-start-title,
  .ns-section-title {
    font-size: 1.75rem;
  }
}

/* Phones: one swipeable row, with the next card peeking in from the edge */
@media (max-width: 767px) {
  .ns-start {
    padding: 0;
  }

  .ns-start-header,
  .ns-section-heading {
    padding: 0 1.25rem;
  }

  .ns-start-row {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 1.25rem;
    padding: 0 1.25rem 0.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .ns-start-row::-webkit-scrollbar {
    display: none;
  }

  .ns-start-card {
    flex: 0 0 72%;
    max-width: 18rem;
    scroll-snap-align: start;
  }
}

/* ---------- Closing sign-up ---------- */

.ns-closing {
  box-sizing: border-box;
  max-width: 44rem;
  margin: 4rem auto 1rem;
  padding: 0 2rem 0 1.25rem;
}

.ns-closing-frame {
  border: 4px solid var(--ns-frame);
}

.ns-closing-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.875rem;
  padding: 2.5rem 2rem;
  border: 2px solid var(--color-border-primary);
  background: var(--color-bg-primary);
  text-align: center;
  transform: translate(1rem, -1rem);
}

.ns-closing-title {
  margin: 0;
  font-size: 1.875rem;
}

.ns-closing-text {
  margin: 0;
  font-size: 1rem;
}

.ns-closing .ns-form {
  margin-top: 0.375rem;
}

.ns-closing .ns-form-row {
  justify-content: center;
}

@media (max-width: 639px) {
  .ns-closing-frame {
    border-width: 3px;
  }

  .ns-closing-card {
    align-items: stretch;
    padding: 1.75rem 1.375rem;
    text-align: left;
    transform: translate(0.75rem, -0.75rem);
  }

  .ns-closing-title {
    font-size: 1.5rem;
  }

  .ns-closing .ns-form-row {
    flex-direction: column;
  }

  .ns-closing .ns-form-input,
  .ns-closing .ns-form-button {
    flex-basis: auto;
    width: 100%;
  }
}

/* Hero sign-up: just the white card, without the blue offset frame behind it */
.ns-hero-frame,
.ns-hero-frame:is(*) {
  margin: 1.25rem 0 0;
  border: 0;
}

.ns-hero-card,
.ns-hero-card:is(*) {
  transform: none;
}

/* Start here, desktop: line up the three cards row by row (images, titles, then the short texts),
   so a two-line title doesn't push its text lower than the others */
@media (min-width: 768px) {
  @supports (grid-template-rows: subgrid) {
    .ns-start-row {
      grid-template-rows: auto auto;
      row-gap: 0.75rem;
    }

    .ns-start-card,
    .ns-start-link {
      display: grid;
      grid-row: span 2;
      grid-template-rows: subgrid;
      gap: 0;
      row-gap: inherit;
    }

    .ns-start-card {
      row-gap: 0.75rem;
    }

    .ns-start-link {
      row-gap: 0.75rem;
    }
  }
}

/* Closing sign-up: same blue offset frame as everywhere else (see ns-site.css) */
.ns-closing {
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.ns-closing-frame,
.ns-closing-frame:is(*) {
  position: relative;
  isolation: isolate;
  border: 0;
}

.ns-closing-frame::before {
  content: "";
  position: absolute;
  top: 20px;
  left: -15px;
  right: 20px;
  bottom: -15px;
  border: 4px solid var(--ghost-accent-color, #5478ea);
  z-index: -1;
  pointer-events: none;
}

.ns-closing-card,
.ns-closing-card:is(*) {
  transform: none;
}

/* Closing box: same width as the other sign-up boxes (see "Sign-up boxes" in ns-site.css) */
main .ns-closing {
  max-width: 42.5rem;
}

/* ---------- Hero, calmer version ----------
   No box around the form, so the headline and the blue button lead. */
.ns-hero-card,
.ns-hero-card:is(*) {
  padding: 0;
  border: 0;
  background: transparent;
}

.ns-hero-title {
  font-size: 2.5rem; /* 40px on desktop */
}

/* Phones: headline on two lines ("There's a story behind / every statistic.") */
@media (max-width: 639px) {
  .ns-hero-title {
    font-size: min(1.75rem, 7.8vw); /* 28px on nearly all phones; a touch smaller on very narrow ones so it stays on two lines */
    letter-spacing: -0.025em;
  }
}

/* Phones: the featured issue's title matches the headline above it (28px), so the page has one clear top size:
   28px headlines, 24px section headings ("New here?", "Recent issues"), 19px issue titles */
@media (max-width: 639px) {
  .slide-item-title {
    font-size: 1.75rem;
    line-height: 1.15;
  }
}
