/* New articles by email (subscribe.js). The box takes its colours from the page around it: light
   text on the night-blue pages, dark text on the white reading pages; the system's own light or
   dark colours on a page without them. */

.sub {
  --sub-ink: var(--ink, CanvasText);
  --sub-dim: var(--ink-dim, GrayText);
  --sub-line: var(--line, color-mix(in srgb, CanvasText 16%, transparent));
  --sub-tape: var(--tape, #c2323a);
  --sub-warn: color-mix(in srgb, var(--sub-tape) 70%, var(--sub-ink));
  color: var(--sub-ink);
  max-width: 36rem;
}
.sub .sub-form {
  margin: 0;
}
.sub .sub-label {
  display: block;
  margin: 0 0 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--sub-dim);
}
.sub-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.sub-input {
  flex: 999 1 15rem;
  min-width: 0;
  min-height: 48px;
  padding: 10px 16px;
  border: 1.5px solid var(--sub-line);
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 5%, transparent);
  color: inherit;
  font: inherit;
  font-size: 1rem;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}
.sub-input::placeholder {
  color: var(--sub-dim);
  opacity: 0.8;
}
.sub-input:focus {
  outline: none;
  border-color: var(--sub-tape);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sub-tape) 30%, transparent);
}
.sub-input[aria-invalid='true'] {
  border-color: var(--sub-warn);
}
.sub-btn {
  flex: 1 0 auto;
  min-height: 48px;
  padding: 10px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--sub-tape);
  color: #ffffff;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    filter 150ms ease,
    scale 120ms ease;
}
.sub-btn:hover {
  filter: brightness(1.08);
}
.sub-btn:active {
  scale: 0.97;
}
.sub-btn:focus-visible {
  outline: 3px solid var(--sub-ink);
  outline-offset: 3px;
}
.sub-btn:disabled {
  opacity: 0.6;
  cursor: progress;
}
.sub .sub-note {
  margin: 10px 0 0;
  font-size: 0.9rem;
  color: var(--sub-dim);
}
.sub .sub-msg {
  margin: 8px 0 0;
  font-size: 0.95rem;
  font-weight: 600;
}
.sub-msg:empty {
  display: none;
}
.sub-msg[data-kind='error'] {
  color: var(--sub-warn);
}
.sub.is-done .sub-row,
.sub.is-done .sub-label,
.sub.is-done .sub-note {
  display: none;
}
.sub.is-done .sub-msg {
  margin: 0;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1.5px solid var(--sub-line);
  font-weight: 500;
}
/* Only robots see this box (and fill it in). */
.sub-trap {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) {
  .sub-input,
  .sub-btn {
    transition: none;
  }
  .sub-btn:active {
    scale: none;
  }
}

/* ── The reading invitation (subscribe.js, on articles only) ──────────────────────────────────
   A warm paper card that matches the crocodile artwork: bottom right on a computer, a bottom sheet
   on a phone. It never covers the article and slides away when closed. */

.sub-pop {
  --pop-paper: #fbf8f3;
  --pop-art: #f9f3ed; /* the artwork's own paper colour */
  --pop-ink: #1b1d22;
  --pop-dim: #5b5f69;
  --pop-tape: #b3262d;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  width: min(340px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border-radius: 22px;
  background: var(--pop-paper);
  color: var(--pop-ink);
  box-shadow:
    0 30px 80px -20px rgba(10, 14, 30, 0.45),
    0 0 0 1px rgba(27, 29, 34, 0.08);
  opacity: 0;
  transform: translateY(24px) scale(0.98);
  transition:
    opacity 0.45s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sub-pop.is-in {
  opacity: 1;
  transform: none;
}
.sub-pop.is-out {
  opacity: 0;
  transform: translateY(24px) scale(0.98);
}
.sub-pop.is-dragging {
  transition: none;
}
.sub-pop-grip {
  display: none;
}
.sub-pop-x {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  color: var(--pop-ink);
  font:
    400 26px/1 system-ui,
    sans-serif;
  cursor: pointer;
}
.sub-pop-x:hover {
  background: #fff;
}
.sub-pop-art {
  background: var(--pop-art);
  border-radius: 22px 22px 0 0;
  overflow: hidden;
}
.sub-pop-art img {
  display: block;
  width: 100%;
  height: auto;
  animation: sub-pop-bob 3.2s ease-in-out infinite;
  transform-origin: 50% 90%;
}
.sub-pop.is-done .sub-pop-text {
  display: none;
}
.sub-pop.is-done .sub-pop-art img {
  animation: sub-pop-cheer 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes sub-pop-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}
@keyframes sub-pop-cheer {
  from {
    transform: scale(0.92);
  }
  60% {
    transform: scale(1.04);
  }
  to {
    transform: none;
  }
}
.sub-pop-body {
  padding: 18px 22px 18px;
}
.sub-pop-kicker {
  margin: 0 0 4px;
  color: var(--pop-tape);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sub-pop-title {
  margin: 0 0 8px;
  font-family: var(--display, Georgia, serif);
  font-size: 1.45rem;
  line-height: 1.15;
  color: var(--pop-ink);
}
.sub-pop-text {
  margin: 0 0 14px;
  color: var(--pop-dim);
  font-size: 0.95rem;
  line-height: 1.5;
}
.sub-pop .sub {
  --ink: var(--pop-ink);
  --ink-dim: var(--pop-dim);
  --line: rgba(27, 29, 34, 0.18);
  --tape: var(--pop-tape);
  max-width: none;
}
.sub-pop .sub-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.sub-pop .sub-btn {
  flex: 1 1 100%;
}
.sub-pop-later {
  display: block;
  margin: 10px auto 0;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  background: none;
  color: var(--pop-dim);
  font: inherit;
  font-size: 0.92rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.sub-pop-x:focus-visible,
.sub-pop-later:focus-visible {
  outline: 3px solid var(--pop-tape);
  outline-offset: 2px;
}

/* a phone: a bottom sheet that can be swiped down */
@media (max-width: 600px) {
  .sub-pop {
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    max-height: 88vh;
    border-radius: 22px 22px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(100%);
  }
  .sub-pop.is-out {
    transform: translateY(100%);
  }
  .sub-pop-grip {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 28px;
    z-index: 1;
    touch-action: none;
    cursor: grab;
  }
  .sub-pop-grip::after {
    content: '';
    position: absolute;
    top: 9px;
    left: 50%;
    width: 44px;
    height: 5px;
    margin-left: -22px;
    border-radius: 3px;
    background: rgba(27, 29, 34, 0.25);
  }
  .sub-pop-art {
    border-radius: 22px 22px 0 0;
    touch-action: none;
  }
  .sub-pop {
    max-height: 70vh;
  }
  .sub-pop-art img {
    max-height: 96px;
    width: auto;
    margin: 0 auto;
  }
  .sub-pop-body {
    padding: 12px 18px 8px;
  }
  .sub-pop-title {
    font-size: 1.2rem;
  }
  /* short on a phone: the article stays in view above the sheet */
  .sub-pop-text,
  .sub-pop .sub-note {
    display: none;
  }
  .sub-pop-later {
    margin-top: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sub-pop,
  .sub-pop.is-out {
    transition: opacity 0.2s linear;
    transform: none;
  }
  .sub-pop-art img,
  .sub-pop.is-done .sub-pop-art img {
    animation: none;
  }
}
@media (prefers-contrast: more) {
  .sub-pop {
    box-shadow: 0 0 0 2px var(--pop-ink);
  }
}
@media print {
  .sub-pop {
    display: none;
  }
}
