/* Newsletter: a small "NEWS" tab on the left edge of the screen that opens a sign-up pop-up.
   Behaviour (when it shows, closing, remembering) is in js/features/newsletter.js. */

/* ---------- The tab ---------- */

/* A quiet tab in the panel colour that seems to melt out of the screen edge: the two
   ::before/::after corners curve inwards where it meets the edge. */
.news-tab {
  --tab-color: var(--color-frame);
  --tab-curve: 18px;

  position: fixed;
  left: 0;
  bottom: 40px;
  z-index: 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 16px 6px;
  border: 0;
  border-radius: 0 22px 22px 0;
  background: var(--tab-color);
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
  transform: translateX(-110%);
  transition: transform 700ms var(--ease-out); /* matches TAB_SLIDE_MS in newsletter.js */
}

.news-tab.is-visible {
  transform: translateX(0);
}

.news-tab::before,
.news-tab::after {
  content: "";
  position: absolute;
  left: 0;
  width: var(--tab-curve);
  height: var(--tab-curve);
}

.news-tab::before {
  bottom: 100%;
  background: radial-gradient(circle at 100% 0, transparent calc(var(--tab-curve) - 0.5px), var(--tab-color) var(--tab-curve));
}

.news-tab::after {
  top: 100%;
  background: radial-gradient(circle at 100% 100%, transparent calc(var(--tab-curve) - 0.5px), var(--tab-color) var(--tab-curve));
}

/* The envelope inside a thin ice-blue ring. */
.news-tab-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--color-accent);
  transition: transform 200ms var(--ease-in-out);
}

.news-tab-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* N E W S, one letter under the other. */
.news-tab-label {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
}

.news-tab:hover .news-tab-icon {
  transform: scale(1.06);
}

/* ---------- The pop-up ---------- */

.newsletter {
  width: min(460px, calc(100% - 32px));
  margin: auto;
  padding: 0;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-frame);
  background: var(--color-background);
  color: var(--color-text);
  box-shadow: 0 32px 80px -20px rgb(0 0 0 / 0.5);
}

/* Everything behind the pop-up gets blurred, wherever the visitor is on the page. */
.newsletter::backdrop {
  background: rgb(0 0 0 / 0.25);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

:root[data-theme="light"] .newsletter::backdrop {
  background: rgb(255 255 255 / 0.2);
}

/* No scrolling behind the open pop-up. */
:root:has(.newsletter[open]) {
  overflow: hidden;
}

.newsletter[open] {
  animation: newsletter-in 450ms var(--ease-out);
}

.newsletter[open]::backdrop {
  animation: newsletter-backdrop-in 450ms var(--ease-in-out);
}

@keyframes newsletter-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
}

@keyframes newsletter-backdrop-in {
  from {
    opacity: 0;
  }
}

.newsletter-body {
  position: relative;
  padding: 32px 28px 26px;
}

.newsletter-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}

.newsletter-close:hover {
  background: var(--color-hover);
  color: var(--color-text);
}

.newsletter-close svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.newsletter-title {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 500;
}

.newsletter-text {
  margin-top: 6px;
  color: var(--color-text-muted);
  font-size: 16px;
  line-height: 1.5;
}

.newsletter-form {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.newsletter-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--color-line);
  border-radius: 12px;
  background: var(--color-pill);
  color: var(--color-text);
  font: inherit;
  font-size: 16px;
}

.newsletter-input::placeholder {
  color: var(--color-text-muted);
}

.newsletter-input:focus {
  outline: none;
  border-color: var(--color-text-muted);
}

.newsletter-submit {
  padding: 12px 20px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--color-button);
  color: var(--color-button-text);
  font: inherit;
  cursor: pointer;
  /* premium look: small spaced capitals */
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.newsletter-consent {
  margin-top: 14px;
  color: var(--color-text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.newsletter-consent a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* After signing up the form makes way for a thank-you line. When sending failed, the form
   stays and the line under it says what went wrong. */
.newsletter-thanks {
  margin-top: 22px;
  font-size: 16px;
}

.newsletter.is-done .newsletter-form,
.newsletter.is-done .newsletter-consent,
.newsletter:not(.is-done, .is-failed) .newsletter-thanks {
  display: none;
}

.newsletter.is-failed .newsletter-thanks {
  margin-top: 14px;
  color: var(--color-fill-in);
  font-size: 14px;
}
