/* OPRA Subscriber Agreement step (opra_agreement.html), rebuilt 2026-09-23 as a
   three-pane wizard inside the auth/onboarding shell (auth_base.html, wide card).
   Loads after style.css and content.css, scoped to the opra- prefix so it never
   leaks. Shared components used as-is and NOT restyled here: .btn/.btn-primary/
   .btn-ghost/.btn-sm, .auth-submit (+ its .is-loading spinner), .auth-field,
   .auth-status-msg, .auth-status-icon, .auth-status-actions, .onboard-steps,
   .callout-note, .eyebrow, .auth-brand-*. Where this file touches a shared
   class it does so only through an opra- prefixed parent selector, per the
   design-system hard rules. */

/* ===== Brand panel: "why this step" ===== */
.opra-why { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-4); }
.opra-why li {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  font-size: var(--fs-sm); line-height: 1.55; color: var(--text-muted);
}
.opra-why strong { color: var(--text); font-weight: var(--fw-strong); }
.opra-why-icon {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--voice-dim); color: var(--voice);
}
.opra-why-icon .icon { width: 16px; height: 16px; }
.opra-why-note {
  margin: 0; padding-top: var(--sp-4); border-top: 1px solid var(--border-hair);
  font-size: var(--fs-label); color: var(--text-faint); line-height: 1.55;
}

/* ===== State panes (loading / error / exempt / signed) ===== */
.opra-state { text-align: center; }
.opra-state .auth-status-icon { margin-inline: auto; }
.opra-state-icon--elite { background: var(--voice-dim); color: var(--ecosystem-elite); }

.opra-spinner {
  width: 24px; height: 24px; margin: var(--sp-7) auto var(--sp-4); display: block;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: opraSpin 0.8s linear infinite;
}
#opraLoading p { color: var(--text-muted); font-size: var(--fs-sm); margin: 0; }
@keyframes opraSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .opra-spinner { animation: none; } }

/* Signed receipt */
.opra-receipt {
  margin: 0; padding: var(--sp-3) var(--sp-5);
  background: var(--bg-sunken); border: 1px solid var(--border-hair); border-radius: var(--radius-md);
  text-align: left;
}
.opra-receipt-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-4);
  padding: var(--sp-2) 0;
}
.opra-receipt-row + .opra-receipt-row { border-top: 1px solid var(--border-hair); }
.opra-receipt dt { font-size: var(--fs-label); color: var(--text-faint); }
.opra-receipt dd {
  margin: 0; font-family: var(--font-mono); font-size: var(--fs-body-sm);
  letter-spacing: var(--ls-normal); color: var(--text); text-align: right;
}

.opra-fine { margin: var(--sp-4) 0 0; font-size: var(--fs-label); color: var(--text-faint); line-height: 1.55; text-align: center; }

/* ===== Wizard panes ===== */
.opra-recert-note { margin: 0 0 var(--sp-5); }
.opra-pane { display: flex; flex-direction: column; }
.opra-kicker {
  margin: 0 0 var(--sp-2);
  font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: var(--ls-wide);
  text-transform: uppercase; color: var(--voice);
}
.opra-pane .auth-form-sub { margin-bottom: var(--sp-5); }
.opra-pane-actions { display: flex; gap: var(--sp-3); margin-top: var(--sp-5); }
.opra-pane-actions .btn { justify-content: center; }
.opra-pane-actions .btn-primary { flex: 1; }
.opra-pane-actions .auth-submit { width: auto; margin-top: 0; }
.opra-pane .auth-status-msg:empty { margin-top: 0; min-height: 0; }

/* ===== The agreement document, in its own scroller ===== */
.opra-doc-progress {
  height: 3px; border-radius: var(--radius-pill); background: var(--border);
  overflow: hidden; margin-bottom: var(--sp-3);
}
.opra-doc-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--voice));
  transition: width var(--dur-1) linear;
}
.opra-doc {
  /* Capped by viewport height too, so on a landscape phone the box never
     fills the whole screen and traps every swipe (overscroll: contain). */
  max-height: min(380px, 60vh); max-height: min(380px, 60dvh);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg-sunken); border: 1px solid var(--border-hair);
  border-radius: var(--radius-md); padding: var(--sp-5);
  /* A fade at the bottom edge that disappears once the end is reached,
     so "there is more below" is visible without a scrollbar hunt. */
  mask-image: linear-gradient(to bottom, currentColor calc(100% - 40px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, currentColor calc(100% - 40px), transparent 100%);
}
.opra-doc:focus-visible { outline: 2px solid var(--voice); outline-offset: 2px; }
.opra-doc.is-at-end { mask-image: none; -webkit-mask-image: none; }
@media (max-width: 560px) { .opra-doc { max-height: min(340px, 60vh); max-height: min(340px, 60dvh); padding: var(--sp-4); } }
.opra-doc-notice {
  font-size: var(--fs-body-sm); line-height: 1.7; color: var(--text-muted); margin: 0 0 var(--sp-4);
}
.opra-doc-notice:first-child {
  color: var(--text); font-weight: var(--fw-emphasis);
  background: var(--accent-soft); border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: var(--sp-4);
}
.opra-doc-heading {
  font-family: var(--font-display); font-weight: var(--fw-strong); font-size: var(--fs-h4);
  letter-spacing: var(--ls-tight); margin: var(--sp-6) 0 var(--sp-4); color: var(--text);
}
.opra-clause { display: flex; gap: var(--sp-4); margin-bottom: var(--sp-5); }
.opra-clause-num {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elevated); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: var(--ls-normal);
  color: var(--text-faint);
}
.opra-clause-body { min-width: 0; }
.opra-clause-body h4 {
  font-family: var(--font-body); font-weight: var(--fw-strong); font-size: var(--fs-body-sm);
  letter-spacing: var(--ls-tight); color: var(--text); margin: 3px 0 var(--sp-2);
}
.opra-clause-body p {
  font-size: var(--fs-body-sm); line-height: 1.7; color: var(--text-muted); margin: 0 0 var(--sp-3);
}
.opra-clause-body p:last-child { margin-bottom: 0; }
.opra-clause-emphatic {
  color: var(--text-faint) !important; font-size: var(--fs-xs) !important;
  letter-spacing: var(--ls-wide); line-height: 1.75 !important;
}
.opra-doc-end {
  font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: var(--ls-wide);
  text-transform: uppercase; color: var(--text-faint); text-align: center;
  padding-top: var(--sp-5); border-top: 1px dashed var(--border-strong); margin: 0;
}

.opra-doc-foot {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-3);
}
.opra-doc-status {
  display: flex; align-items: center; gap: var(--sp-2); margin: 0 auto 0 0;
  font-size: var(--fs-label); color: var(--text-faint);
}
.opra-doc-status-icon {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--border); color: transparent;
  transition: background var(--dur-2) ease, color var(--dur-2) ease;
}
.opra-doc-status-icon .icon { width: 11px; height: 11px; }
.opra-doc-status[data-read="true"] { color: var(--data); }
.opra-doc-status[data-read="true"] .opra-doc-status-icon { background: var(--data-dim); color: var(--data); }
.opra-version-tag {
  font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: var(--ls-normal);
  padding: 4px 10px; border-radius: var(--radius-pill);
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-faint);
  white-space: nowrap;
}

/* ===== Affirmation fieldsets + checkbox cards ===== */
.opra-affirm {
  margin: var(--sp-5) 0 0; padding: 0; border: 0; min-width: 0;
  display: flex; flex-direction: column; gap: var(--sp-3);
  transition: opacity var(--dur-2) ease;
}
/* Locked until the document has been read (opra.js unlocks it). A disabled
   <fieldset> disables every control inside it for free. */
.opra-affirm.opra-locked { opacity: 0.5; }
.opra-affirm.opra-locked .opra-check { cursor: not-allowed; }
.opra-legend {
  padding: 0; margin: 0 0 var(--sp-1);
  font-size: var(--fs-label); font-weight: var(--fw-emphasis); color: var(--text-muted);
}

.opra-check {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  /* Contains the visually-hidden real <input> below, which is absolutely
     positioned — without this it would resolve against some distant ancestor. */
  position: relative;
  padding: var(--sp-4); border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--bg-sunken);
  cursor: pointer;
  transition: border-color var(--dur-2) ease, background var(--dur-2) ease;
}
.opra-check:hover { border-color: var(--border-strong); }
/* The real input stays in the accessibility tree and keeps keyboard focus —
   it's visually replaced by .opra-check-box, not removed. */
.opra-check input[type="checkbox"] {
  position: absolute; opacity: 0; width: 18px; height: 18px; margin: 0; cursor: pointer;
}
.opra-check-box {
  width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px;
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: transparent; background: transparent;
  transition: background var(--dur-1) ease, border-color var(--dur-1) ease, color var(--dur-1) ease;
}
.opra-check-box .icon { width: 13px; height: 13px; stroke-width: 3; }
.opra-check input:checked ~ .opra-check-box {
  background: var(--data); border-color: var(--data); color: var(--text-on-data);
}
.opra-check input:focus-visible ~ .opra-check-box {
  outline: 2px solid var(--voice); outline-offset: 2px;
}
.opra-check:has(input:checked) { border-color: var(--data-dim); background: var(--data-dim); }
.opra-check-text { font-size: var(--fs-body-sm); line-height: 1.6; color: var(--text-muted); }
/* Step 2's cards lead with the plain-language summary, then the full legal
   wording underneath — the wording is what's affirmed, so it's never hidden. */
.opra-check-title {
  display: block; margin-bottom: var(--sp-1);
  font-weight: var(--fw-strong); color: var(--text);
}
.opra-check-body { display: block; font-size: var(--fs-xs); line-height: 1.6; color: var(--text-faint); }
.opra-check-marker {
  font-family: var(--font-mono); font-size: var(--fs-2xs); color: var(--text-faint);
  margin-right: var(--sp-2); letter-spacing: var(--ls-normal);
}
.opra-check-text a { color: var(--voice); text-decoration: underline; text-decoration-color: var(--voice-dim); }
.opra-check-text a:hover { text-decoration-color: var(--voice); }
.opra-check--terms { margin-top: var(--sp-5); }
.opra-check.is-invalid { border-color: var(--data-down); background: var(--data-down-dim); }

.opra-pro-note { margin: var(--sp-4) 0 0; }

/* ===== Details ===== */
.opra-fields { display: flex; flex-direction: column; gap: var(--sp-4); }
.opra-field-grid { display: grid; grid-template-columns: 1fr; gap: var(--sp-4); }
@media (min-width: 640px) { .opra-field-grid { grid-template-columns: 1fr 1fr; } }
/* style.css's .auth-field only styles `input`; this page is the first to put a
   textarea in one. Scoped to the pane so no other page's .auth-field changes. */
.opra-pane .auth-field textarea {
  width: 100%; font-family: var(--font-body); font-size: var(--fs-sm);
  letter-spacing: var(--ls-normal); line-height: 1.55; resize: vertical; min-height: 84px;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  color: var(--text); border-radius: var(--radius-md); padding: var(--sp-3) var(--sp-4);
  transition: border-color var(--dur-1) ease, box-shadow var(--dur-1) ease, background var(--dur-1) ease;
}

/* 16px on touch-size screens: iOS zooms into anything smaller on focus. */
@media (max-width: 860px) { .opra-pane .auth-field textarea { font-size: var(--fs-body); } }
.opra-pane .auth-field textarea:focus {
  outline: none; border-color: var(--accent); background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.opra-pane .auth-field textarea::placeholder { color: var(--text-faint); }
.opra-pane .auth-field.is-invalid textarea {
  border-color: var(--data-down); box-shadow: 0 0 0 3px var(--data-down-dim);
}

/* ===== Signature pad ===== */
.opra-signature { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-5); }
.opra-signature-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.opra-signature-label {
  font-size: var(--fs-label); font-weight: var(--fw-emphasis); color: var(--text-muted);
}
.opra-signature-pad {
  position: relative; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-md);
  background: var(--bg-sunken); overflow: hidden;
  transition: border-color var(--dur-2) ease, background var(--dur-2) ease;
}
.opra-signature-pad:hover { border-color: var(--accent-dim); }
.opra-signature-pad.is-signed { border-style: solid; border-color: var(--data-dim); background: var(--bg-elevated); }
.opra-signature-pad.is-invalid { border-color: var(--data-down); }
.opra-signature-pad canvas {
  display: block; width: 100%; height: 160px;
  touch-action: none; /* the pad handles pointer events itself; without this a
                         finger drag scrolls the page instead of drawing */
  cursor: crosshair; position: relative; z-index: 1;
}
.opra-signature-placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  margin: 0; pointer-events: none; z-index: 0;
  font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: var(--ls-wide);
  text-transform: uppercase; color: var(--text-faint);
}
.opra-signature-baseline {
  position: absolute; left: 10%; right: 10%; bottom: 38px; height: 1px;
  background: var(--border-strong); pointer-events: none; z-index: 0;
}
.opra-signature-hint { margin: 0; font-size: var(--fs-label); color: var(--text-faint); line-height: 1.5; }
.opra-signature-hint.is-signed { color: var(--data); }
.opra-signature-buttons { display: flex; gap: var(--sp-2); }
.opra-signature-buttons .btn .icon { width: 13px; height: 13px; }
.opra-signature-buttons .btn:disabled { opacity: 0.45; cursor: not-allowed; }

@media (prefers-reduced-motion: reduce) {
  .opra-affirm, .opra-check, .opra-signature-pad,
  .opra-doc-progress-fill, .opra-doc-status-icon {
    transition: none;
  }
}
