/* Skeleton Files newsletter: the signup popup (built by /newsletter.js), the inline signup blocks (blog posts, the
   /newsletter/ pages) and their shared form. Loaded after /style.css (and /blog.css, /start/start.css), so it uses the
   site's tokens and follows <html data-theme>. Desktop: a centred card with a backdrop. Phones: a bottom sheet that
   leaves the top of the page in view. No inline styles anywhere: every state is a class or an attribute. */

/* ---------- the popup ---------- */
.nl-pop {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.nl-pop[hidden] { display: none; }
/* a tall enough desktop window: pin the card's top, so a message or the success state only grows or shrinks it
   downward instead of re-centring it (no jump under the pointer) */
@media (min-width: 768px) and (min-height: 601px) {
  .nl-pop { align-items: flex-start; padding-top: max(24px, 14vh); }
}
.nl-backdrop {
  position: absolute; inset: 0;
  background: rgba(5, 5, 8, 0.68);
  animation: nl-fade 0.18s ease-out;
}
html[data-theme="light"] .nl-backdrop { background: rgba(28, 26, 23, 0.42); }
.nl-panel {
  position: relative; width: 100%; max-width: 560px;
  margin-top: 30px; /* room for the folder tab, which sits outside the card */
  background: var(--ink-2); color: var(--bone);
  border: 1px solid var(--line); border-radius: 0 6px 6px 6px;
  padding: 38px 36px 26px;
  box-shadow: var(--device-shadow);
  animation: nl-rise 0.22s ease-out;
}
.nl-panel:focus { outline: none; }
/* on the dark theme the card needs a warmer edge to stand off the dimmed page */
html[data-theme="dark"] .nl-pop .nl-panel, html[data-theme="dark"] .nl-pop .nl-tab { border-color: #4a4337; }
html[data-theme="dark"] .nl-pop .nl-panel { box-shadow: 0 30px 80px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(212, 160, 23, 0.08); }
.nl-panel > .nl-title, .nl-panel > .nl-desc { position: relative; } /* above the dashed frame */
/* a short desktop window: the card scrolls inside itself, and the tab (which would be clipped) steps aside */
@media (max-height: 600px) and (min-width: 768px) {
  .nl-pop .nl-panel { margin-top: 0; max-height: calc(100vh - 32px); overflow-y: auto; overscroll-behavior: contain; border-radius: 6px; }
  .nl-pop .nl-tab { display: none; }
  .nl-pop .nl-panel::before { display: none; }
}

/* index-card edge + folder tab: the same dashed frame as the case files */
.nl-panel::before, .nl-inline::before {
  content: ""; position: absolute; inset: 8px;
  border: 1px dashed rgba(212, 160, 23, 0.28); pointer-events: none;
}
.nl-tab {
  position: absolute; left: -1px; top: -31px; height: 32px;
  display: flex; align-items: center;
  padding: 0 16px 1px; max-width: calc(100% - 60px);
  background: var(--ink-2); border: 1px solid var(--line); border-bottom: 0; border-radius: 6px 6px 0 0;
  color: var(--amber); font-size: 0.74rem; letter-spacing: 0.16em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nl-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; color: var(--bone-dim);
  font: 400 1.75rem/1 "Space Grotesk", system-ui, sans-serif; cursor: pointer;
}
.nl-close:hover { color: var(--amber); border-color: var(--line); }
.nl-close:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }

/* ---------- headline + copy (popup and inline) ---------- */
.nl-title {
  font-family: "Archivo Black", sans-serif; font-weight: normal;
  font-size: clamp(1.4rem, 2.6vw, 1.85rem); line-height: 1.08;
  text-transform: uppercase; letter-spacing: 0.01em;
  margin: 0 0 12px; max-width: none;
  text-wrap: balance;
}
.nl-title em { font-style: normal; color: var(--amber); }
.nl-pop .nl-title { margin-right: 40px; }
.nl-desc { color: var(--bone-dim); font-size: 1rem; line-height: 1.55; margin: 0 0 20px; max-width: 520px; text-wrap: pretty; }

/* ---------- the form (one markup everywhere: newsletter.js only flips data-nl-state and texts) ---------- */
.nl-form { max-width: none; position: relative; z-index: 1; }
.nl-label { margin-bottom: 8px; }
.nl-row { display: flex; gap: 10px; }
.nl-row .nl-email { flex: 1 1 auto; min-width: 0; min-height: 48px; padding: 12px 14px; }
/* the field's edge must reach 3:1 against the card (WCAG 1.4.11): --line is 1.4:1 light, 1.3:1 dark */
.nl-form { --nl-field-line: #8f8574; }                         /* 3.4:1 on --ink-2 light */
html[data-theme="dark"] .nl-form { --nl-field-line: #756d5c; } /* 3.6:1 on --ink-2 dark */
.nl-row .nl-email:not(:focus):not([aria-invalid="true"]) { border-color: var(--nl-field-line); }
.nl-row .nl-email::placeholder { color: var(--bone-dim); opacity: 0.9; } /* 5.7:1 light, 6.4:1 dark (was 3.7:1 dark) */
.nl-row .nl-email:focus { box-shadow: 0 0 0 1px var(--amber); }
.nl-row .nl-email[aria-invalid="true"] { border-color: var(--stamp); }
.nl-btn {
  flex: none; min-height: 48px; min-width: 104px; padding: 0 24px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.8rem; white-space: nowrap;
}
.nl-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.nl-btn[disabled], .nl-btn[aria-disabled="true"] { opacity: 0.72; cursor: progress; }
.nl-msg { min-height: 1.4em; margin: 8px 0 0; font-size: 0.92rem; line-height: 1.5; color: var(--bone-dim); }
.nl-form[data-nl-state="err"] .nl-msg { color: var(--err-text); }
.nl-done { display: none; align-items: center; gap: 16px; margin: 4px 0 0; }
.nl-done p { color: var(--bone); font-size: 1.02rem; font-weight: 500; }
.nl-done:focus { outline: none; }
.nl-done:focus-visible { outline: 2px solid var(--amber); outline-offset: 4px; }
.nl-form[data-nl-state="ok"] .nl-field, .nl-form[data-nl-state="ok"] .nl-msg { display: none; }
.nl-form[data-nl-state="ok"] .nl-done { display: flex; }
.nl-stamp {
  flex: none; color: var(--stamp-text); border: 2px solid var(--stamp);
  padding: 4px 10px; font-size: 0.82rem; letter-spacing: 0.18em; text-transform: uppercase;
  transform: rotate(-4deg); white-space: nowrap;
  animation: nl-stamp 0.32s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
.nl-fine { margin-top: 6px; font-size: 0.8rem; line-height: 1.5; color: var(--bone-dim); letter-spacing: 0.02em; }
.nl-form[data-nl-state="ok"] .nl-fine { margin-top: 16px; }
.nl-fine a { color: var(--bone); text-decoration: underline; text-decoration-color: rgba(212, 160, 23, 0.6); text-underline-offset: 3px; }
.nl-fine a:hover { color: var(--amber); }
/* a bigger tap area for the small link, without moving anything (the same trick as /start/'s toggles) */
.nl-fine a { position: relative; }
.nl-fine a::after { content: ""; position: absolute; inset: -14px -4px; }

/* ---------- inline block (end of each blog post; the card on /newsletter/) ---------- */
.nl-inline {
  position: relative; margin-top: 68px;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 0 6px 6px 6px;
  padding: 32px 30px 22px;
}
.nl-inline .nl-tab { max-width: calc(100% + 2px); }
.nl-inline > * { position: relative; }
.nl-inline > .nl-tab { position: absolute; }

/* ---------- the /newsletter/ pages ---------- */
.nl-page { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 56px; align-items: start; }
.nl-page .nl-inline { margin-top: 32px; }
.nl-about { color: var(--bone-dim); max-width: 520px; }
.nl-about h2 { font-size: clamp(1.05rem, 2vw, 1.3rem); margin: 0 0 12px; color: var(--bone); }
.nl-about h2 + p, .nl-about p + p { margin-top: 10px; }
.nl-about * + h2 { margin-top: 32px; }
.nl-about ul { margin: 12px 0 0 20px; }
.nl-about li { margin-bottom: 8px; }
.nl-about b { color: var(--bone); font-weight: 600; }
.nl-about a { color: var(--bone); text-decoration: underline; text-decoration-color: rgba(212, 160, 23, 0.6); text-underline-offset: 3px; }
.nl-about a:hover { color: var(--amber); }

@media (min-width: 861px) {
  .nl-page > .nl-inline { position: sticky; top: 104px; } /* the form stays in view beside the longer text */
}
@media (max-width: 860px) {
  .nl-page { grid-template-columns: 1fr; gap: 40px; }
}

/* ---------- phones: a bottom sheet, never the whole screen ---------- */
@media (max-width: 767px) {
  .nl-pop { align-items: flex-end; padding: 0; }
  .nl-backdrop { background: rgba(5, 5, 8, 0.5); }
  html[data-theme="light"] .nl-backdrop { background: rgba(28, 26, 23, 0.3); }
  .nl-pop .nl-panel {
    max-width: none; margin: 0; max-height: 72vh; max-height: 72svh; overflow-y: auto; overscroll-behavior: contain;
    border-width: 1px 0 0; border-radius: 0;
    padding: 24px 18px max(16px, env(safe-area-inset-bottom));
    animation-name: nl-sheet;
  }
  .nl-pop .nl-panel::before { inset: 6px 6px 0; border-bottom: 0; }
  /* the folder tab would be clipped by the scrolling sheet: it becomes a typewriter kicker inside it */
  .nl-pop .nl-tab { position: static; display: block; height: auto; max-width: calc(100% - 44px); padding: 0; margin: 0 0 8px;
    background: none; border: 0; border-radius: 0; font-size: 0.68rem; letter-spacing: 0.14em; }
  .nl-pop .nl-close { top: 6px; right: 6px; }
  .nl-pop .nl-title { font-size: 1.2rem; margin: 0 44px 8px 0; }
  .nl-pop .nl-desc { font-size: 0.92rem; margin-bottom: 14px; }
  .nl-pop .nl-label { font-size: 0.72rem; }
  .nl-inline { padding: 26px 18px 18px; margin-top: 60px; }
  .nl-inline .nl-tab { font-size: 0.68rem; letter-spacing: 0.12em; padding: 0 12px 1px; }
}
@media (max-width: 767px) {
  .nl-pop .nl-panel { box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.28); }
  html[data-theme="light"] .nl-pop .nl-panel { box-shadow: 0 -10px 30px rgba(60, 45, 20, 0.16); }
}
@media (max-width: 767px) and (max-height: 760px) {
  .nl-pop .nl-panel { padding-top: 18px; }
  .nl-pop .nl-tab { margin-bottom: 4px; }
  .nl-pop .nl-title { font-size: 1.08rem; margin-bottom: 12px; }
  .nl-pop .nl-desc { display: none; }
  .nl-pop .nl-msg { margin-top: 6px; }
}
/* a very short phone screen (320 × 568): the kicker steps aside too */
@media (max-width: 767px) and (max-height: 600px) {
  .nl-pop .nl-tab { display: none; }
}
/* narrow: the stamp sits above the confirmation instead of squeezing it into a thin column */
@media (max-width: 480px) {
  .nl-done { flex-direction: column; align-items: flex-start; gap: 12px; }
}
@media (max-width: 340px) {
  .nl-row { flex-direction: column; }
  .nl-btn { width: 100%; }
}

/* ---------- motion ---------- */
@keyframes nl-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes nl-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes nl-sheet { from { transform: translateY(100%); } to { transform: none; } }
@keyframes nl-stamp { from { opacity: 0; transform: rotate(-4deg) scale(1.5); } to { opacity: 1; transform: rotate(-4deg) scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .nl-backdrop, .nl-panel, .nl-pop .nl-panel, .nl-stamp { animation: none; }
}
html.motion-off .nl-backdrop, html.motion-off .nl-pop .nl-panel, html.motion-off .nl-stamp { animation: none; } /* /start/'s Motion: off */

/* the no-JS form lands on ?ok=1#join / ?err=…#join: keep the folder tab clear of the sticky header */
#join { scroll-margin-top: 56px; }
/* Windows High Contrast: .btn has no border, so the Join button would read as plain text */
@media (forced-colors: active) { .nl-btn { border: 1px solid ButtonText; } }
