/* ==========================================================================
   Intel Focus Newsletter
   The pop-up and the end-of-article sign-up, drawn from the theme's own
   tokens (--bg, --bg-card, --bg-elevated, --text, --text-dim, --border,
   --border-strong) so both follow its light/dark toggle with no script.

   Dossier world: a hairline card with a brand-blue top rule, a typed
   kicker, a small ledger of what the reader is signing up to, and one
   motion — a redaction bar lifting off a single word.

   Brand blue #5271ff is only 4.07:1 against white, so it draws rules and
   marks here but never sits behind white text: the button is #3d53e0
   (5.98:1), #2f43c9 on hover (7.59:1).
   ========================================================================== */

.ifn-dialog,
.ifn-inline {
  --ifn-blue: #5271ff;
  --ifn-fill: #3d53e0;
  --ifn-fill-hover: #2f43c9;
  --ifn-mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --ifn-error: #aa2726;
}
html:not([data-theme="light"]) .ifn-dialog,
html:not([data-theme="light"]) .ifn-inline { --ifn-error: #ff8f8a; }

/* --- Shared type ------------------------------------------------------ */

.ifn-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  font-family: var(--ifn-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.ifn-kicker::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--ifn-blue);
  flex: none;
}

.ifn-dialog .ifn-title,
.ifn-inline .ifn-title {
  margin: 0 0 10px;
  font-family: 'Neo Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 27px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text);
  text-wrap: balance;
}
.ifn-title:focus { outline: none; }

.ifn-dialog .ifn-dek,
.ifn-inline .ifn-dek {
  margin: 0 0 20px;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--text-dim);
  max-width: 46ch;
}

/* The one motion: a redaction bar that lifts off the key word. */
.ifn-redact {
  position: relative;
  display: inline-block;
  white-space: nowrap;
}
.ifn-redact::after {
  content: "";
  position: absolute;
  inset: 0.12em -0.08em 0.02em;
  background: var(--text);
  transform-origin: right center;
  transform: scaleX(0);
}
.ifn-dialog[open] .ifn-redact::after {
  animation: ifn-unredact 0.7s cubic-bezier(0.65, 0, 0.35, 1) 0.35s both;
}
@keyframes ifn-unredact {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* --- Ledger --------------------------------------------------------- */

.ifn-ledger {
  margin: 0 0 22px;
  padding: 0;
  border-top: 1px solid var(--border-strong);
}
.ifn-ledger > div {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.ifn-ledger dt {
  font-family: var(--ifn-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding-top: 2px;
}
.ifn-ledger dd {
  margin: 0;
  font-size: 13.5px;
  color: var(--text);
}

/* --- Form ----------------------------------------------------------- */

.ifn-form { margin: 0; }

.ifn-label {
  display: block;
  margin: 0 0 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.ifn-row {
  display: flex;
  gap: 8px;
}

.ifn-dialog .ifn-input,
.ifn-inline .ifn-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 48px;
  margin: 0;
  padding: 0 14px;
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming the page on focus. */
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  box-shadow: none;
}
.ifn-input::placeholder { color: var(--text-dim); opacity: 0.8; }
.ifn-input:focus-visible {
  outline: 2px solid var(--ifn-blue);
  outline-offset: 1px;
  border-color: var(--ifn-blue);
}
.ifn-input[aria-invalid="true"] { border-color: var(--ifn-error); }

.ifn-dialog .ifn-btn,
.ifn-inline .ifn-btn {
  flex: none;
  height: 48px;
  margin: 0;
  padding: 0 22px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
  background: var(--ifn-fill);
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.ifn-btn:hover { background: var(--ifn-fill-hover); }
.ifn-btn:focus-visible { outline: 2px solid var(--ifn-blue); outline-offset: 2px; }
.ifn-btn:disabled { opacity: 0.6; cursor: progress; }

.ifn-dialog .ifn-btn-quiet {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.ifn-dialog .ifn-btn-quiet:hover { background: var(--bg-elevated); }

.ifn-dialog .ifn-status,
.ifn-inline .ifn-status {
  min-height: 1.4em;
  margin: 8px 0 0;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--text);
}
.ifn-input[aria-invalid="true"] ~ .ifn-status,
.ifn-form:has(.ifn-input[aria-invalid="true"]) .ifn-status { color: var(--ifn-error); }

.ifn-dialog .ifn-fine,
.ifn-inline .ifn-fine {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-dim);
}
.ifn-dialog .ifn-fine a,
.case-content .ifn-inline .ifn-fine a,
.ifn-inline .ifn-fine a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Honeypot: off-screen, not display:none, so naive bots still fill it. */
.ifn-hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* [hidden] loses to author display rules on this theme; restate it. */
.ifn-dialog [hidden],
.ifn-inline [hidden] { display: none !important; }

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

.ifn-dialog {
  width: min(520px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  overflow: visible;
}
.ifn-dialog::backdrop {
  background: rgba(12, 12, 16, 0.62);
}
.ifn-dialog[open] {
  animation: ifn-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.ifn-dialog[open]::backdrop {
  animation: ifn-fade 0.28s ease both;
}
@keyframes ifn-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@keyframes ifn-fade { from { opacity: 0; } to { opacity: 1; } }

.ifn-card {
  position: relative;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 30px 32px 26px;
  background: var(--bg-card, var(--bg));
  border: 1px solid var(--border-strong);
  border-top: 3px solid var(--ifn-blue);
  border-radius: 6px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.ifn-close-form { margin: 0; }
.ifn-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  color: var(--text-dim);
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}
.ifn-close:hover { color: var(--text); background: var(--bg-elevated); }
.ifn-close:focus-visible { outline: 2px solid var(--ifn-blue); outline-offset: 0; }

.ifn-dialog .ifn-kicker { padding-right: 44px; }

.ifn-dialog .ifn-done .ifn-dek { margin-bottom: 22px; }

html.ifn-open { overflow: hidden; }

/* Phones: a bottom sheet, thumb-reachable, not a box floating mid-screen. */
@media (max-width: 600px) {
  .ifn-dialog {
    width: 100vw;
    max-height: 92dvh;
    margin: auto 0 0;
  }
  .ifn-dialog[open] { animation-name: ifn-up; }
  @keyframes ifn-up {
    from { transform: translateY(100%); }
    to   { transform: none; }
  }
  .ifn-card {
    max-height: 92dvh;
    padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
    border-radius: 12px 12px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  .ifn-dialog .ifn-title { font-size: 23px; }
  .ifn-dialog .ifn-dek { font-size: 15px; margin-bottom: 16px; }
  .ifn-ledger { display: none; }
  .ifn-row { flex-direction: column; }
  .ifn-dialog .ifn-btn,
  .ifn-inline .ifn-btn { width: 100%; }
}

/* --- End-of-article sign-up ---------------------------------------- */

.ifn-inline {
  margin: 56px 0 8px;
  padding: 28px 30px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-top: 3px solid var(--ifn-blue);
  border-radius: 6px;
}
.case-content .ifn-inline p { margin-bottom: 0; }
.case-content .ifn-inline .ifn-kicker { margin-bottom: 18px; }
.case-content .ifn-inline .ifn-title { margin-bottom: 10px; }
.case-content .ifn-inline .ifn-dek { margin-bottom: 18px; }
.case-content .ifn-inline .ifn-status { margin-top: 8px; }
.case-content .ifn-inline .ifn-fine { margin-top: 4px; }
.ifn-inline .ifn-title { font-size: 24px; }
.ifn-inline .ifn-form { max-width: 560px; }

@media (max-width: 600px) {
  .ifn-inline { padding: 22px 18px 18px; margin-top: 40px; }
  .ifn-inline .ifn-title { font-size: 21px; }
}

/* --- Reduced motion ------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .ifn-dialog[open],
  .ifn-dialog[open]::backdrop,
  .ifn-dialog[open] .ifn-redact::after { animation: none; }
  .ifn-btn { transition: none; }
}

@media print {
  .ifn-inline, .ifn-dialog { display: none !important; }
}
