/* ==========================================================================
   Rowan — blocker overlay
   Scoped inside .stp-backdrop so styles + tokens never leak to the host page.
   Monospace used for: eyebrow, timer digits, insight chip, footnote.
   Sans: title, question, body, button labels.
   ========================================================================== */

.stp-backdrop,
.stp-backdrop * {
  box-sizing: border-box;
}

.stp-backdrop {
  /* tokens — scoped so host-page :root vars cannot bleed in.
     Notebook palette: warm cream paper, ink black, no colour accent.
     The "accent" tokens are ink-on-cream — primary actions are bold ink,
     not a brand colour. Backdrop is dark blur with a subtle warm glow
     (no green tint). */
  --stp-font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --stp-font-serif: "Instrument Serif", Georgia, "Iowan Old Style", "Times New Roman", serif;
  --stp-font-mono: "Inter", ui-sans-serif, system-ui, sans-serif;

  --stp-bg: #f8f6f1;
  --stp-bg-elevated: #fdfcf8;
  --stp-bg-muted: #efede6;
  --stp-border: #dedad0;
  --stp-border-strong: #c8c3b8;
  --stp-text: #1a1a18;
  --stp-text-muted: #5c5a54;
  --stp-text-subtle: #908c82;

  --stp-accent: #1a1a18;
  --stp-accent-hover: #333330;
  --stp-accent-soft: #efede6;
  --stp-accent-ink: #1a1a18;
  --stp-accent-contrast: #fdfcf8;

  --stp-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.5), 0 8px 20px rgba(0, 0, 0, 0.2);

  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: grid;
  place-items: center;
  padding: 24px;
  font-family: var(--stp-font-sans);
  color: var(--stp-text);
  background:
    radial-gradient(ellipse at 50% 20%, rgba(180, 170, 150, 0.08), transparent 50%),
    rgba(14, 13, 10, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: stp-fade 260ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Dark scheme (auto) — warm dark notebook, cream ink-on-dark */
@media (prefers-color-scheme: dark) {
  .stp-backdrop:not([data-color-scheme="light"]) {
    --stp-bg: #1a1916;
    --stp-bg-elevated: #232118;
    --stp-bg-muted: #2a2820;
    --stp-border: #3a382e;
    --stp-border-strong: #524f43;
    --stp-text: #f3eddc;
    --stp-text-muted: #a8a395;
    --stp-text-subtle: #7a7568;
    --stp-accent: #f3eddc;
    --stp-accent-hover: #ffffff;
    --stp-accent-soft: #2a2820;
    --stp-accent-ink: #f3eddc;
    --stp-accent-contrast: #1a1916;
  }
}

/* Dark scheme (manual) */
.stp-backdrop[data-color-scheme="dark"] {
  --stp-bg: #1a1916;
  --stp-bg-elevated: #232118;
  --stp-bg-muted: #2a2820;
  --stp-border: #3a382e;
  --stp-border-strong: #524f43;
  --stp-text: #f3eddc;
  --stp-text-muted: #a8a395;
  --stp-text-subtle: #7a7568;
  --stp-accent: #f3eddc;
  --stp-accent-hover: #ffffff;
  --stp-accent-soft: #2a2820;
  --stp-accent-ink: #f3eddc;
  --stp-accent-contrast: #1a1916;
}
/* ========== Card ========== */
.stp-card {
  width: min(520px, 100%);
  min-height: 320px;
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--stp-bg);
  color: var(--stp-text);
  border: 1px solid var(--stp-border);
  border-radius: 16px;
  padding: 44px 40px;
  box-shadow: var(--stp-shadow);
  animation: stp-rise 340ms cubic-bezier(0.2, 0.7, 0.2, 1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01" on, "cv11" on;
  display: flex;
  flex-direction: column;
  /* Every stage centres content vertically — short screens (confirm, timer)
     and long screens (urgent list) all feel balanced inside the card. */
  justify-content: center;
}

/* ========== Brand mark (top of every overlay card) ========== */
.stp-brand-mark {
  display: block;
  width: 32px;
  height: 32px;
  margin: 0 auto 20px;
  opacity: 0.95;
  user-select: none;
  animation: stp-brand-settle 440ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes stp-brand-settle {
  from { opacity: 0; transform: translateY(-4px) scale(0.9); }
  to { opacity: 0.95; transform: translateY(0) scale(1); }
}

/* ========== Typography ========== */
/* ========== Brand eyebrow ========== */
.stp-eyebrow-brand {
  display: block;
  margin: 0 0 14px;
  font-family: var(--stp-font-serif);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--stp-text-subtle);
  user-select: none;
}

.stp-title {
  margin: 0 0 16px;
  font-family: var(--stp-font-serif);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.18;
  color: var(--stp-text);
}

.stp-text {
  margin: 0 0 18px;
  font-family: var(--stp-font-sans);
  font-size: 17px;
  line-height: 1.6;
  color: var(--stp-text-muted);
}

/* ========== User note ========== */
.stp-note-display {
  margin: 0 0 18px;
  padding: 14px 16px;
  background: var(--stp-bg-muted);
  border-left: 2px solid var(--stp-border-strong);
  border-radius: 0 4px 4px 0;
  font-family: var(--stp-font-sans);
  font-size: 15px;
  font-style: italic;
  line-height: 1.55;
  color: var(--stp-text);
}

/* ========== Insight chip ========== */
.stp-insight {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 24px;
  padding: 12px 14px;
  background: var(--stp-accent-soft);
  border-radius: 10px;
  border: 1px solid transparent;
}
.stp-insight-label {
  flex-shrink: 0;
  font-family: var(--stp-font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stp-accent-ink);
  padding-top: 3px;
}
.stp-insight-body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--stp-accent-ink);
}

/* ========== Note (textarea on reassurance screen) ========== */
.stp-note {
  width: 100%;
  min-height: 108px;
  margin: 0 0 20px;
  padding: 14px;
  border: 1px solid var(--stp-border-strong);
  border-radius: 10px;
  background: var(--stp-bg-elevated);
  color: var(--stp-text);
  font-family: var(--stp-font-sans);
  font-size: 16px;
  line-height: 1.55;
  resize: vertical;
  transition: border-color 140ms cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 140ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.stp-note::placeholder { color: var(--stp-text-subtle); }
.stp-note:focus {
  outline: none;
  border-color: var(--stp-accent);
  box-shadow: 0 0 0 3px var(--stp-accent-soft);
}

/* ========== Timer ========== */
.stp-timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 8px 0 14px;
  padding: 12px 0;
  border-top: 1px solid var(--stp-border);
  border-bottom: 1px solid var(--stp-border);
}
.stp-timer-digits {
  font-family: var(--stp-font-sans);
  font-size: 56px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--stp-text);
}
.stp-timer-label {
  font-family: var(--stp-font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--stp-text-subtle);
}
.stp-timer-track {
  width: 100%;
  height: 2px;
  margin-top: 4px;
  background: var(--stp-bg-muted);
  border-radius: 1px;
  overflow: hidden;
}
.stp-timer-fill {
  height: 100%;
  background: var(--stp-accent);
  border-radius: 1px;
  width: 0%;
  transition: width 1s linear;
}

/* ========== Timer context line ========== */
.stp-context {
  margin: 0 0 14px;
  font-family: var(--stp-font-sans);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--stp-text-muted);
}

/* ========== Continue link (post-timer, discouraged escape) ========== */
.stp-continue-link {
  display: block;
  margin: 12px auto 0;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--stp-text-subtle);
  font-family: var(--stp-font-sans);
  font-size: 13px;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  cursor: pointer;
  transition: color 140ms cubic-bezier(0.2, 0.7, 0.2, 1), text-decoration-color 140ms cubic-bezier(0.2, 0.7, 0.2, 1);
  animation: stp-fade 300ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.stp-continue-link[hidden] { display: none; }
.stp-continue-link:hover {
  color: var(--stp-text-muted);
  text-decoration-color: currentColor;
}

/* ========== Actions ========== */
.stp-actions {
  display: grid;
  gap: 10px;
}

.stp-button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  padding: 13px 18px;
  border: 1px solid var(--stp-border-strong);
  border-radius: 5px;
  background: var(--stp-bg-elevated);
  color: var(--stp-text);
  font-family: var(--stp-font-sans);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 160ms cubic-bezier(0.2, 0.7, 0.2, 1),
              border-color 160ms cubic-bezier(0.2, 0.7, 0.2, 1),
              color 160ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.stp-button::after { display: none; }
.stp-button:hover {
  border-color: var(--stp-accent);
  background: var(--stp-accent-soft);
}
.stp-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.stp-button:focus-visible {
  outline: 2px solid var(--stp-accent);
  outline-offset: 2px;
}

.stp-button-primary {
  border-color: var(--stp-accent);
  background: var(--stp-accent);
  color: var(--stp-accent-contrast);
}
.stp-button-primary:hover {
  border-color: var(--stp-accent-hover);
  background: var(--stp-accent-hover);
  color: var(--stp-accent-contrast);
}

.stp-button-link {
  justify-content: center;
  border-color: transparent;
  background: transparent;
  color: var(--stp-text-subtle);
  font-size: 13px;
  font-family: var(--stp-font-sans);
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 10px 12px;
}
.stp-button-link:hover {
  border-color: transparent;
  background: transparent;
  color: var(--stp-text-muted);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ========== Help screen (emergency numbers + GP reminder) ==========
 * Items here are intentionally NOT styled like buttons. They cannot be
 * actioned from inside the extension (a browser can't dial 999), so the
 * affordance would be misleading. Each row is plain typography with a
 * hairline separator, all rows weighted equally — no primary highlight,
 * no accent colour, no bold. The user reads, then leaves the browser
 * to act. */
.stp-urgent-list {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}
.stp-urgent-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 12px 0;
  color: var(--stp-text);
  font-family: var(--stp-font-sans);
  text-align: left;
  border-bottom: 1px solid var(--stp-border);
}
.stp-urgent-item:last-child {
  border-bottom: 0;
}
.stp-urgent-label {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.3;
}
.stp-urgent-note {
  font-size: 13px;
  opacity: 0.7;
  line-height: 1.45;
  font-weight: 400;
}
.stp-urgent-footer {
  margin: 4px 0 20px;
  font-size: 14px;
  color: var(--stp-text-muted);
}

.stp-divider {
  margin: 20px 0 16px;
  border: 0;
  border-top: 1px solid var(--stp-border);
}

.stp-back-row {
  margin-top: 4px;
  text-align: center;
}

/* ========== Footnote ========== */
.stp-footnote {
  margin: 28px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--stp-border);
  font-family: var(--stp-font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--stp-text-subtle);
  line-height: 1.6;
}
.stp-footnote-dot {
  display: inline-block;
  margin: 0 6px;
  opacity: 0.5;
}

/* ========== Animations ========== */
@keyframes stp-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes stp-rise {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==========================================================================
   Inline variant — overlay scoped to a container (onboarding sim browser)
   ========================================================================== */
.stp-backdrop[data-inline="1"] {
  position: absolute;
  inset: 0;
  padding: 14px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  background:
    radial-gradient(ellipse at 50% 18%, rgba(180, 170, 150, 0.06), transparent 50%),
    rgba(12, 13, 10, 0.58);
}
.stp-backdrop[data-inline="1"] .stp-card {
  width: 100%;
  max-width: 100%;
  min-height: 0;
  max-height: 100%;
  padding: 22px 22px;
  border-radius: 12px;
  box-shadow: 0 12px 36px -8px rgba(0, 0, 0, 0.4);
  font-size: 14px;
}
.stp-backdrop[data-inline="1"] .stp-brand-mark {
  width: 22px;
  height: 22px;
  margin-bottom: 12px;
}
.stp-backdrop[data-inline="1"] .stp-eyebrow-brand {
  font-size: 12px;
  margin-bottom: 8px;
}
.stp-backdrop[data-inline="1"] .stp-title {
  font-size: 19px;
  margin-bottom: 10px;
  line-height: 1.22;
}
.stp-backdrop[data-inline="1"] .stp-text {
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 16px;
}
.stp-backdrop[data-inline="1"] .stp-context {
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 18px;
}
.stp-backdrop[data-inline="1"] .stp-note-display {
  font-size: 13px;
  padding: 10px 12px;
  margin-bottom: 16px;
}
.stp-backdrop[data-inline="1"] .stp-actions {
  gap: 6px;
}
.stp-backdrop[data-inline="1"] .stp-button {
  padding: 10px 14px;
  font-size: 13px;
  border-radius: 5px;
}
.stp-backdrop[data-inline="1"] .stp-button-link {
  font-size: 11px;
  padding: 8px 10px;
}
.stp-backdrop[data-inline="1"] .stp-continue-link {
  font-size: 11px;
  margin-top: 12px;
}
.stp-backdrop[data-inline="1"] .stp-timer {
  margin: 12px 0;
  padding: 12px 0;
}
.stp-backdrop[data-inline="1"] .stp-timer-digits {
  font-size: 44px;
}
.stp-backdrop[data-inline="1"] .stp-timer-label {
  font-size: 10px;
}
.stp-backdrop[data-inline="1"] .stp-footnote {
  font-size: 9px;
  margin-top: 16px;
  padding-top: 12px;
  letter-spacing: 0.1em;
}
.stp-backdrop[data-inline="1"] .stp-urgent-list {
  margin-bottom: 12px;
}
.stp-backdrop[data-inline="1"] .stp-urgent-item {
  padding: 8px 0;
}
.stp-backdrop[data-inline="1"] .stp-urgent-label {
  font-size: 13px;
}
.stp-backdrop[data-inline="1"] .stp-urgent-note {
  font-size: 11px;
}
.stp-backdrop[data-inline="1"] .stp-divider {
  margin: 12px 0 10px;
}
.stp-backdrop[data-inline="1"] .stp-timer-track {
  margin-top: 4px;
}

/* ========== Responsive ========== */
@media (max-width: 640px) {
  .stp-backdrop { padding: 12px; }
  .stp-card {
    min-height: 0;
    padding: 28px 22px;
    border-radius: 14px;
  }
  .stp-title { font-size: 24px; }
  .stp-text { font-size: 15px; }
  .stp-button { font-size: 14px; padding: 12px 14px; }
  .stp-timer-digits { font-size: 48px; }
  .stp-note { font-size: 15px; }
  .stp-urgent-label { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .stp-backdrop, .stp-card, .stp-button, .stp-continue-link {
    animation: none !important;
    transition: none !important;
  }
  .stp-timer-fill { transition: none !important; }
}
