/* Instinct Sells: the newsletter sign-up
   Sale-sticker yellow and signage black. One family (Archivo).
   Doc stands behind the email box and does the talking, in comic balloons.
   Motion: he rises and the balloons pop when the page loads; he blinks;
   he leans in while the email box is in use; the balloons change once
   someone has signed up. */

@font-face {
  font-family: "Archivo IS";
  src: url("/assets/fonts/archivo-variable.woff2") format("woff2-variations"),
       url("/assets/fonts/archivo-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}

:root {
  --sticker: #ffd23f;   /* the page */
  --dot: #f2be1c;       /* the print dots behind Doc */
  --ink: #000;          /* type, borders, the button */
  --paper: #fff;        /* balloons, fields and long reads */
  --display: "Archivo IS", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --gutter: clamp(1.1rem, 4.5vw, 3rem);
  --edge: 3px solid var(--ink);
  --radius: 0.5rem;
  --phone: 27.5rem;     /* the phone layout never grows wider than this */
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* the hidden attribute must win over any display rule below */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
  color-scheme: only light;
}

body {
  display: flex;
  flex-direction: column;
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--sticker);
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.0625rem;
  font-weight: 430;
  font-stretch: 100%;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 0.16em;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- page furniture ---------- */

.masthead,
.stage,
.document,
.colophon {
  width: min(100% - 2 * var(--gutter), 66rem);
  margin-inline: auto;
}

.masthead {
  padding-top: 1.05rem;
}

.wordmark {
  font-size: 1.15rem;
  font-weight: 860;
  font-stretch: 66%;
  text-decoration: none;
}

.colophon {
  margin-top: auto;
  padding-block: 1.1rem 1.6rem;
}

.colophon__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.45rem 1.5rem;
  padding-top: 0.85rem;
  border-top: var(--edge);
  font-size: 0.92rem;
}

.byline {
  margin: 0;
}

.byline a {
  font-weight: 750;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---------- the stage: Doc, his balloons and the counter he stands behind ---------- */

.masthead--stage,
.stage,
.colophon--stage {
  max-width: var(--phone);
}

.stage {
  position: relative;
  z-index: 0;
  display: grid;
  grid-template-columns: 44% minmax(0, 1fr);
  column-gap: 0.85rem;
  padding-block: 0.8rem 1.4rem;
}

/* comic-print dots, fading out around him */
.stage::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: -22%;
  top: 17%;
  width: 92%;
  height: 0;
  padding-bottom: 92%;
  background-image: radial-gradient(circle, var(--dot) 0, var(--dot) 1.7px, transparent 2.1px);
  background-size: 10px 10px;
  -webkit-mask-image: radial-gradient(closest-side, #000 30%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 30%, transparent 100%);
  pointer-events: none;
}

@supports not ((mask-image: radial-gradient(#000, transparent)) or (-webkit-mask-image: radial-gradient(#000, transparent))) {
  .stage::before {
    display: none;
  }
}

.balloon {
  position: relative;
  border: var(--edge);
  border-radius: 1.35rem;
  background: var(--paper);
}

/* each tail is a black triangle with a white one laid over it */
.balloon::before,
.balloon::after {
  content: "";
  position: absolute;
}

.balloon--ask {
  grid-column: 1 / -1;
  padding: 0.95rem 1.05rem;
  transform-origin: 18% 100%;
  animation: pop 0.28s cubic-bezier(0.3, 1.45, 0.5, 1) 0.1s backwards;
}

.balloon--ask::before {
  left: 2.6rem;
  top: 100%;
  width: 1.9rem;
  height: 1.75rem;
  background: var(--ink);
  clip-path: polygon(0 0, 100% 0, 18% 100%);
}

.balloon--ask::after {
  left: calc(2.6rem + 4.5px);
  top: calc(100% - 3px);
  width: calc(1.9rem - 10px);
  height: calc(1.75rem - 9px);
  background: var(--paper);
  clip-path: polygon(0 0, 100% 0, 18% 100%);
}

.balloon--ask h1 {
  margin: 0;
  font-size: clamp(1.75rem, 8.9vw, 2.35rem);
  font-weight: 860;
  font-stretch: 66%;
  line-height: 0.97;
  text-wrap: balance;
}

.balloon--ask p {
  margin: 0.55rem 0 0;
  font-size: 1.06rem;
  font-weight: 470;
  line-height: 1.34;
  text-wrap: pretty;
}

.doc {
  position: relative;
  grid-column: 1;
  grid-row: 2;
  align-self: end;
  margin-top: 1.05rem;
  /* open on three sides, shut along the counter's top edge, so he rises from
     behind it and never shows through its rounded corners */
  clip-path: inset(-4rem -4rem 0.6rem -4rem);
}

.doc__figure {
  position: relative;
  display: block;
  transform-origin: 50% 100%;
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.25);
  animation: rise 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) 0.2s backwards;
}

.doc__figure img {
  display: block;
  width: 100%;
  height: auto;
}

/* answers the person's action: he leans in while the email box is in use */
.stage:focus-within .doc__figure {
  transform: rotate(-2.5deg) scale(1.035);
}

.doc__blink {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  animation: blink 5.4s steps(1, end) 2.6s infinite;
}

.balloon--tell {
  grid-column: 2;
  grid-row: 2;
  align-self: center;
  justify-self: start;
  margin: 1.5rem 0 1.3rem;
  padding: 0.6rem 0.8rem;
  font-size: clamp(1.02rem, 5vw, 1.4rem);
  font-weight: 840;
  font-stretch: 68%;
  line-height: 1.04;
  rotate: 1.5deg;
  transform-origin: 0 40%;
  animation: pop 0.28s cubic-bezier(0.3, 1.45, 0.5, 1) 0.95s backwards;
}

.balloon--tell::before {
  right: 100%;
  top: 0.95rem;
  width: 1.15rem;
  height: 1.35rem;
  background: var(--ink);
  clip-path: polygon(100% 0, 100% 100%, 0 62%);
}

.balloon--tell::after {
  right: calc(100% - 3px);
  top: calc(0.95rem + 5px);
  width: calc(1.15rem - 5px);
  height: calc(1.35rem - 10px);
  background: var(--paper);
  clip-path: polygon(100% 0, 100% 100%, 0 62%);
}

.balloon--tell p {
  margin: 0;
}

.balloon--tell span {
  display: block;
}

.balloon--tell span + span {
  margin-top: 0.14em;
}

/* a balloon pops again whenever what Doc says changes */
.balloon.is-popping {
  animation: pop 0.28s cubic-bezier(0.3, 1.45, 0.5, 1) both;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.72);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes rise {
  from {
    transform: translateY(45%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes blink {
  0% {
    opacity: 1;
  }
  2.6%,
  100% {
    opacity: 0;
  }
}

/* ---------- the counter: the sign-up, and what replaces it ---------- */

.signup,
.signup-done,
.counter {
  position: relative;
  z-index: 1;
  grid-column: 1 / -1;
  margin-top: -0.6rem; /* overlaps the bottom of the portrait */
}

.signup,
.signup-done {
  display: grid;
  gap: 0.55rem;
}

.signup__row {
  display: grid;
  gap: 0.55rem;
}

.signup__input,
.signup__button,
.signup-done__sent,
.counter {
  min-height: 3.35rem;
  border: var(--edge);
  border-radius: var(--radius);
}

.signup__input,
.signup__button {
  margin: 0;
  font-family: var(--display);
  -webkit-appearance: none;
  appearance: none;
}

.signup__input {
  width: 100%;
  padding: 0 1rem;
  background: var(--paper);
  color: var(--ink);
  font-size: 1.0625rem; /* 17px keeps iPhones from zooming in */
  font-weight: 450;
}

.signup__input::placeholder {
  color: #6f6f6f;
  opacity: 1;
}

.signup__button {
  padding: 0 1.35rem;
  background: var(--ink);
  color: var(--sticker);
  font-size: 1.25rem;
  font-weight: 820;
  font-stretch: 82%;
  white-space: nowrap;
  cursor: pointer;
}

.signup__button:hover {
  background: #262626;
}

.signup__button:active {
  transform: translateY(1px);
}

.signup__button[disabled] {
  opacity: 0.75;
  cursor: progress;
}

.signup__small {
  margin: 0.1rem 0 0;
  font-size: 0.9rem;
  line-height: 1.4;
}

.signup__small a {
  white-space: nowrap;
}

.signup__status {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 750;
  line-height: 1.35;
}

.signup__status:empty {
  display: none;
}

.signup__trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.signup-done:focus {
  outline: none;
}

.signup-done__sent {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 0.35em;
  margin: 0;
  padding: 0.55rem 1rem;
  background: var(--paper);
  overflow-wrap: anywhere;
}

.signup-done__sent strong {
  font-weight: 800;
}

.signup-done__again {
  justify-self: start;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.95rem;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
}

/* on the other pages, links take the place of the form */
.counter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.2rem 1.5rem;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--sticker);
  font-size: 1.2rem;
  font-weight: 820;
  font-stretch: 82%;
  list-style: none;
}

.counter a {
  display: inline-block;
  padding: 0.3rem 0;
}

.counter :focus-visible {
  outline-color: var(--sticker);
}

/* ---------- long reads: the privacy notice ---------- */

.document {
  padding-block: clamp(1.75rem, 6vw, 3.5rem) 3.5rem;
}

.paper {
  max-width: 46rem;
  padding: clamp(1.5rem, 5vw, 3.25rem);
  border: var(--edge);
  border-radius: 0.6rem;
  background: var(--paper);
  box-shadow: 0.55rem 0.55rem 0 var(--ink);
}

.paper h1 {
  margin: 0 0 0.8rem;
  font-size: clamp(2.75rem, 11vw, 4.75rem);
  font-weight: 860;
  font-stretch: 62%;
  line-height: 0.9;
}

.paper h2 {
  margin: 2.2rem 0 0.5rem;
  font-size: 1.3rem;
  font-weight: 800;
  font-stretch: 85%;
  line-height: 1.2;
}

.paper h3 {
  margin: 1.3rem 0 0.35rem;
  font-size: 1.0625rem;
  font-weight: 750;
}

.paper p,
.paper li {
  max-width: 66ch;
  line-height: 1.62;
}

.paper p {
  margin: 0 0 0.85rem;
}

.paper ul {
  margin: 0 0 0.85rem;
  padding-left: 1.2rem;
}

.paper__meta {
  color: #555;
}

/* ---------- laptops and bigger: one wide comic panel ---------- */

@media (min-width: 60rem) {
  /* on big monitors the whole panel grows a little with the screen */
  html {
    font-size: clamp(100%, 0.5rem + 0.55vw, 125%);
  }

  .masthead--stage,
  .stage,
  .colophon--stage {
    max-width: 66rem;
  }

  /* the panel sits in the middle of the screen, so the footer stops pushing */
  .colophon--stage {
    margin-top: 0;
  }

  .stage {
    grid-template-columns: clamp(18rem, 28vw, 25rem) minmax(0, 1fr);
    column-gap: clamp(1.9rem, 3vw, 2.8rem);
    margin-block: auto;
    padding-block: 1.6rem 2.2rem;
  }

  .stage::before {
    left: -9%;
    top: 4%;
    width: 52%;
    padding-bottom: 52%;
    background-size: 12px 12px;
  }

  .doc {
    grid-row: 1 / span 2;
    margin-top: 0;
  }

  .balloon--ask {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    padding: 1.45rem 1.7rem 1.4rem;
    border-radius: 1.8rem;
    transform-origin: 0 80%;
  }

  /* the tail turns to point left, at him */
  .balloon--ask::before {
    left: auto;
    right: 100%;
    top: auto;
    bottom: 2.3rem;
    width: 2.3rem;
    height: 1.9rem;
    clip-path: polygon(100% 0, 100% 100%, 0 88%);
  }

  .balloon--ask::after {
    left: auto;
    right: calc(100% - 3px);
    top: auto;
    bottom: calc(2.3rem + 4.5px);
    width: calc(2.3rem - 9px);
    height: calc(1.9rem - 10.5px);
    clip-path: polygon(100% 0, 100% 100%, 0 88%);
  }

  .balloon--ask h1 {
    font-size: clamp(2.5rem, 4.1vw, 3.9rem);
  }

  .balloon--ask p {
    max-width: 42ch;
    margin-top: 0.8rem;
    font-size: 1.3rem;
    text-wrap: balance;
  }

  /* the second balloon is joined to the first, the way comics link one speaker's balloons */
  .balloon--tell {
    align-self: start;
    margin: 1.3rem 0 2.7rem 2.6rem;
    padding: 0.85rem 1.2rem 0.8rem;
    font-size: clamp(1.6rem, 2.3vw, 2rem);
    rotate: 1deg;
  }

  .balloon--tell::before {
    left: 2.6rem;
    right: auto;
    top: auto;
    bottom: 100%;
    width: 1.8rem;
    height: calc(1.3rem + 9px);
    margin-bottom: -4.5px;
    border-inline: var(--edge);
    background: var(--paper);
    clip-path: none;
  }

  .balloon--tell::after {
    display: none;
  }

  .signup__row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .signup__input,
  .signup__button,
  .signup-done__sent,
  .counter {
    min-height: 3.9rem;
  }

  .signup__input,
  .signup-done__sent {
    padding-inline: 1.3rem;
    font-size: 1.2rem;
  }

  .signup__button {
    padding-inline: 2.2rem;
    font-size: 1.4rem;
  }

  .counter {
    font-size: 1.35rem;
  }

  .signup__small {
    font-size: 0.95rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .balloon,
  .balloon.is-popping,
  .doc__figure,
  .doc__blink {
    animation: none;
    transition: none;
  }
}
