/* The newsletter card with the issue preview that leafs through: the sign up card of Slow Mondays, a slow travel
   letter, on white. Warm paper with a fine grain, a 1px edge and layered shadows; three past issues stacked like sheets
   on the left, the promise, the readers and the form on the right. One accent: terracotta. */
:root {
  --page: #ffffff;           /* the page */
  --paper: #fbf9f5;          /* the card, warm paper */
  --sheet: #fffdf9;          /* the issue sheets */
  --ink: #1f1c18;            /* the words */
  --muted: #8a8278;          /* the small words */
  --line: rgba(40, 30, 20, 0.1); /* the 1px edges */
  --accent: #c2532d;         /* the one accent: terracotta */
  --accent-ink: #fff8f2;     /* the words on the button */
  --sheet-w: 196px;          /* how wide an issue sheet is */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

/* the wrap is GSAP's (entrance), the card is CSS's */
.wrap {
  width: min(680px, 94vw);
  opacity: 0;
}

.card {
  position: relative;
  display: grid;
  grid-template-columns: calc(var(--sheet-w) + 36px) 1fr;
  grid-template-areas:
    'stack copy'
    'stack form';
  grid-template-rows: 1fr auto;
  column-gap: clamp(18px, 4vw, 34px);
  padding: clamp(18px, 4.2vh, 30px) clamp(18px, 4vw, 32px) clamp(18px, 4.2vh, 28px) clamp(14px, 3vw, 26px);
  border-radius: 22px;
  background:
    radial-gradient(120% 90% at 0% 0%, rgba(255, 255, 255, 0.9), transparent 55%),
    radial-gradient(90% 80% at 100% 100%, rgba(194, 83, 45, 0.045), transparent 60%),
    var(--paper);
  box-shadow:
    inset 0 0 0 1px var(--line),
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 1px 1px rgba(40, 28, 16, 0.04),
    0 4px 10px -4px rgba(40, 28, 16, 0.08),
    0 18px 36px -18px rgba(40, 28, 16, 0.16),
    0 42px 80px -40px rgba(40, 28, 16, 0.26);
  isolation: isolate;
}

/* the grain of the paper */
.card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: -1;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .38  0 0 0 0 .3  0 0 0 .16 0'/></filter><rect width='160' height='160' filter='url(%23g)'/></svg>");
}

/* ---------------------------------------------------------------- the stack of issues */
.stack {
  grid-area: stack;
  position: relative;
  align-self: center;
  height: calc(var(--sheet-w) * 1.14 + 30px);
  perspective: 900px;
  cursor: pointer;
  outline: none;
  border-radius: 14px;
}

.stack:focus-visible {
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent);
}

/* the sheet is GSAP's (place in the pile), the paper inside is CSS's */
.sheet {
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: var(--sheet-w);
  margin: 0 0 0 calc(var(--sheet-w) / -2);
  transform-origin: 50% 100%;
  will-change: transform;
}

.sheet__paper {
  position: relative;
  padding: 7px 7px 0;
  border-radius: 11px;
  background: var(--sheet);
  box-shadow:
    inset 0 0 0 1px var(--line),
    inset 0 1px 0 #ffffff,
    0 1px 1px rgba(40, 28, 16, 0.05),
    0 6px 12px -6px rgba(40, 28, 16, 0.14),
    0 20px 34px -20px rgba(40, 28, 16, 0.28);
  overflow: hidden;
}

.sheet__photo {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  overflow: hidden;
  background: #e9e2d8;
}

.sheet__photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* a thin ring and a soft vignette on the photo, as if printed */
.sheet__photo::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06), inset 0 -30px 40px -30px rgba(30, 18, 8, 0.25);
}

.sheet__cap {
  display: grid;
  gap: 3px;
  padding: 9px 3px 10px;
  margin: 0;
}

.sheet__meta {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 9.5px;
  font-weight: 560;
  font-variation-settings: 'wdth' 112;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.sheet__meta span:first-child {
  color: var(--accent);
}

.sheet__title {
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: 14.5px;
  line-height: 1.15;
  font-weight: 480;
  letter-spacing: -0.01em;
  font-variation-settings: 'opsz' 24, 'SOFT' 50;
}

.sheet__read {
  font-size: 9.5px;
  color: var(--muted);
}

/* the light on the bending paper: GSAP raises it as the sheet lifts */
.sheet__shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 38%, rgba(40, 24, 10, 0.12) 100%);
}

/* ---------------------------------------------------------------- the promise and the readers */
.copy {
  grid-area: copy;
  align-self: end;
  padding-top: 6px;
}

.copy__brand {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  font-size: 12px;
  font-weight: 620;
  font-variation-settings: 'wdth' 112;
  letter-spacing: 0.02em;
}

.copy__next {
  font-size: 11px;
  font-weight: 480;
  color: var(--muted);
  font-variation-settings: 'wdth' 100;
  letter-spacing: 0;
}

.copy__title {
  margin: clamp(8px, 1.8vh, 12px) 0 0;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: clamp(24px, min(5vw, 6vh), 34px);
  line-height: 1.04;
  font-weight: 440;
  letter-spacing: -0.025em;
  font-variation-settings: 'opsz' 72, 'SOFT' 100;
  text-wrap: balance;
}

.copy__count {
  margin: clamp(10px, 2.2vh, 16px) 0 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

/* the readers on drums: each digit is a window one line tall over a column 0 to 9 */
.count {
  display: inline-flex;
  font-size: 15px;
  font-weight: 640;
  font-variation-settings: 'wdth' 100;
  color: var(--ink);
  line-height: 1.2;
}

.count__drum {
  position: relative;
  display: inline-block;
  height: 1.2em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
}

.count__col {
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.count__col span {
  height: 1.2em;
  text-align: center;
}

.count__sep {
  display: inline-block;
}

/* ---------------------------------------------------------------- the form */
.form {
  grid-area: form;
  margin: clamp(14px, 3vh, 22px) 0 0;
}

.form__field {
  position: relative;
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 6px 0 14px;
  border-radius: 14px;
  background: #ffffff;
  box-shadow:
    inset 0 0 0 1px var(--line),
    inset 0 1px 2px rgba(40, 28, 16, 0.06),
    0 1px 0 rgba(255, 255, 255, 0.9);
  transition: box-shadow 0.25s ease;
}

.form__field.is-focus {
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent),
    0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent),
    inset 0 1px 2px rgba(40, 28, 16, 0.06);
}

.form__icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.form__type {
  position: relative;
  flex: 1;
  min-width: 0;
  margin: 0 8px 0 9px;
}

.form__input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  padding: 0;
  caret-color: var(--accent);
}

.form__input::placeholder {
  color: #b3aba1;
}

/* the caret drawn while the field types itself */
.form__caret {
  position: absolute;
  left: 0;
  top: 50%;
  width: 1.5px;
  height: 17px;
  margin-top: -8.5px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0;
}

.form__measure {
  position: absolute;
  visibility: hidden;
  white-space: pre;
  font-size: 14px;
}

.form__note {
  margin: 10px 2px 0;
  font-size: 11.5px;
  color: var(--muted);
}

/* the button: GSAP owns its width (to grow over the field) and its scale (the press), the body inside is CSS's */
.btn {
  position: absolute;
  right: 5px;
  top: 5px;
  bottom: 5px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible {
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px var(--accent);
}

.btn__body {
  position: relative;
  display: block;
  height: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #ffffff) 0%, var(--accent) 55%, color-mix(in srgb, var(--accent) 86%, #000000) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 0 0 1px rgba(80, 20, 0, 0.18),
    0 1px 2px rgba(120, 40, 10, 0.25),
    0 6px 14px -6px rgba(160, 60, 20, 0.5);
  color: var(--accent-ink);
}

/* a soft sheen that crosses the button when the pointer comes in */
.btn__shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.26) 50%, transparent 65%);
  transform: translateX(-110%);
  pointer-events: none;
}

.btn__face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 600;
  font-variation-settings: 'wdth' 104;
  white-space: nowrap;
}

.btn__face--rest {
  position: relative;
  width: max-content;
  margin: 0 auto;
  height: 100%;
}

.btn__face--wait,
.btn__face--done {
  opacity: 0;
}

.btn__spin {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 30 44;
}

.btn__check {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn__check path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

@media (hover: hover) {
  .btn:hover .btn__body {
    filter: brightness(1.04);
  }
}

/* ---------------------------------------------------------------- phone: stack and promise side by side, the form under them */
@media (max-width: 560px) {
  :root {
    --sheet-w: min(112px, 31vw, 24vh);
  }

  .card {
    grid-template-columns: calc(var(--sheet-w) + 18px) 1fr;
    grid-template-areas:
      'stack copy'
      'form form';
    grid-template-rows: auto auto;
    column-gap: 14px;
    padding: 16px;
    border-radius: 18px;
  }

  .sheet__paper {
    padding: 4px 4px 0;
    border-radius: 8px;
  }

  .sheet__photo {
    border-radius: 4px;
  }

  .sheet__cap {
    gap: 2px;
    padding: 6px 2px 7px;
  }

  .sheet__meta,
  .sheet__read {
    font-size: 7px;
  }

  .sheet__meta span:last-child {
    display: none;
  }

  .sheet__title {
    font-size: 10px;
  }

  .stack {
    height: calc(var(--sheet-w) * 1.18 + 18px);
  }

  .copy {
    align-self: center;
    padding-top: 0;
  }

  .copy__brand {
    font-size: 11px;
  }

  .copy__next {
    font-size: 10px;
  }

  .copy__title {
    font-size: clamp(19px, 5.6vw, 23px);
    margin-top: 7px;
  }

  .copy__count {
    margin-top: 9px;
    font-size: 12.5px;
  }

  .count {
    font-size: 13.5px;
  }

  .form {
    margin-top: 14px;
  }

  .form__field {
    height: 44px;
    padding-left: 12px;
  }

  .form__input {
    font-size: 13px;
  }

  .form__measure {
    font-size: 13px;
  }

  .btn__face {
    padding: 0 14px;
    font-size: 13px;
  }

  .form__note {
    font-size: 10.5px;
    margin-top: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn__shine {
    display: none;
  }
}
