/* ═══════════════════════════════════════════════════════════════
   NUDGEBEE — Personalized Briefing (/briefing)
   Page-specific styles. Relies on tokens from design-system.css.
   All classes are namespaced .brf-* to avoid clashing with styles.css.
   ═══════════════════════════════════════════════════════════════ */

/* ── Embed mode (iframed into the homepage popup) ──────────── */
/* Hide the site chrome so only the form shows inside the popup. */
.nb-embed #navbar,
.nb-embed #footer,
.nb-embed .brf-hero { display: none !important; }
.nb-embed .brf-form-section { padding: 24px 0 40px; }
.nb-embed body { background: var(--white); }
/* Tighter card rhythm inside the popup, where vertical space is scarce. */
.nb-embed .brf-block { padding: 22px; margin-bottom: 16px; }
.nb-embed .brf-block-head { margin-bottom: 18px; }

/* ── Hero ──────────────────────────────────────────────────── */
/* Quieter than the site-wide hero scale: the form is the star here,
   so the heading, kicker and lead are all shrunk proportionally. */
.brf-hero {
  padding: 80px 0 18px;
  text-align: center;
  background:
    radial-gradient(60% 90% at 50% -10%, rgba(56, 162, 255, .10), transparent 70%),
    var(--white);
}
.brf-hero .section-kicker { font-size: .64rem; margin-bottom: 14px; }
.brf-hero-h {
  font-family: var(--fh);
  font-size: clamp(1.55rem, 3.2vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.12;
  color: var(--ink);
  max-width: 720px;
  margin: 0 auto;
}
.brf-hero-h .acc { color: var(--purple); }
.brf-hero .section-lead { font-size: .95rem; max-width: 620px; margin: 12px auto 0; }

/* ── Form shell ────────────────────────────────────────────── */
.brf-form-section { padding: 22px 0 120px; }
.brf-form-wrap { max-width: 1040px; }

.brf-block {
  background: var(--white);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-lg);
  padding: 40px 44px;
  margin-bottom: 28px;
  box-shadow: 0 1px 3px rgba(15, 27, 45, .04);
}
.brf-block-head { display: flex; align-items: center; gap: 16px; margin-bottom: 30px; }
.brf-step {
  flex-shrink: 0;
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-pill);
  background: var(--navy); color: var(--yellow);
  font-family: var(--fh); font-weight: 800; font-size: .9rem;
}
.brf-block-h { font-family: var(--fh); font-size: 1.15rem; font-weight: 800; color: var(--ink); letter-spacing: -.02em; }
.brf-block-sub { font-size: .84rem; color: var(--muted); margin-top: 2px; }
.brf-block-sub .brf-optional { color: var(--yellow-deep); font-weight: 600; }

/* ── Question groups (compact custom selects) ──────────────── */
/* Two questions per row so the form stays short; stacks to 1-col when narrow. */
[data-groups] { display: grid; grid-template-columns: 1fr 1fr; gap: 26px 32px; }
.brf-q { min-width: 0; }
.brf-q-label { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.brf-q-title { font-size: .88rem; font-weight: 600; color: var(--text); }
.brf-req { color: var(--purple); font-weight: 700; }
.brf-q-help { font-size: .76rem; color: var(--muted); }
.brf-max-hint {
  font-size: .78rem; font-weight: 600; color: var(--yellow-deep);
  opacity: 0; transform: translateY(-2px); transition: opacity .2s, transform .2s;
}
.brf-max-hint.show { opacity: 1; transform: none; }

/* Collapsed control */
.brf-select { position: relative; }
.brf-select.is-open { z-index: 30; }
.brf-select.shake { animation: brf-shake .38s var(--ease-out-expo); }
.brf-select-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-family: var(--fb); font-size: .86rem; color: var(--ink); text-align: left;
  background: var(--white);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--r-md);
  padding: 12px 14px; cursor: pointer;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.brf-select-btn:hover { border-color: var(--purple-mid); }
.brf-select.is-open .brf-select-btn,
.brf-select-btn:focus-visible { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(56, 162, 255, .14); }
.brf-select-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brf-select-val.is-placeholder { color: #9AA8B8; }
.brf-select-chev { flex-shrink: 0; width: 16px; height: 16px; color: var(--muted); transition: transform var(--dur-fast); }
.brf-select-chev svg { width: 100%; height: 100%; display: block; }
.brf-select.is-open .brf-select-chev { transform: rotate(180deg); }

/* Popover checklist */
.brf-select-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 31;
  background: var(--white);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--r-md);
  box-shadow: 0 12px 32px rgba(15, 27, 45, .16);
  padding: 6px; max-height: 240px; overflow-y: auto;
}
.brf-select.drop-up .brf-select-panel { top: auto; bottom: calc(100% + 6px); }
.brf-select-panel[hidden] { display: none; }
.brf-opt {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  font-family: var(--fb); font-size: .84rem; color: var(--mid);
  background: transparent; border: none; border-radius: 8px;
  padding: 8px 9px; cursor: pointer;
}
.brf-opt:hover { background: var(--off); color: var(--ink); }
.brf-opt[aria-selected="true"] { color: var(--ink); font-weight: 600; }
.brf-opt-check {
  flex-shrink: 0; width: 18px; height: 18px; border-radius: 5px;
  border: 1.5px solid var(--border-mid); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
.brf-opt-check svg { width: 13px; height: 13px; display: block; }
.brf-select.is-single .brf-opt-check { border-radius: 50%; }
.brf-opt[aria-selected="true"] .brf-opt-check { background: var(--navy); border-color: var(--navy); }

/* Error state on a group */
.brf-q.has-error .brf-select-btn { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, .12); }
.brf-q-error { font-size: .8rem; color: #dc2626; margin-top: 6px; font-weight: 500; }

/* ── Contact fields ────────────────────────────────────────── */
.brf-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 32px; }
.brf-field { margin-bottom: 16px; }
.brf-field:last-child { margin-bottom: 0; }
.brf-label { display: block; font-size: .85rem; font-weight: 600; color: var(--text); margin-bottom: 7px; }
.brf-label .brf-req { margin-left: 2px; }
.brf-input {
  width: 100%;
  font-family: var(--fb); font-size: .9rem; color: var(--ink);
  background: var(--white);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--r-md);
  padding: 12px 14px;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.brf-input::placeholder { color: #9AA8B8; }
.brf-input:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(56, 162, 255, .14); }
.brf-field.has-error .brf-input { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, .12); }

/* ── Actions ───────────────────────────────────────────────── */
.brf-actions { text-align: center; margin-top: 20px; }
.brf-submit { font-size: 1rem; }
.brf-submit.is-loading { opacity: .7; pointer-events: none; }
.brf-note { font-size: .82rem; color: var(--muted); margin-top: 14px; }
.brf-note a { color: var(--purple); font-weight: 600; }

/* ── Brief modal (popup) ───────────────────────────────────── */
.brf-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.brf-modal[hidden] { display: none; }
/* The `hidden` attribute must win over the modal parts' own display rules
   (author `display:flex/block` otherwise beats the UA `[hidden]` rule). */
.brf-modal [hidden] { display: none !important; }
.brf-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(13, 27, 46, .62);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  animation: brf-fade .2s var(--ease-out-expo);
}
.brf-modal-card {
  position: relative;
  width: min(940px, 100%); height: min(88vh, 100%);
  background: var(--white);
  border-radius: var(--r-lg); overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 80px rgba(13, 27, 46, .42);
  animation: brf-pop .28s var(--ease-out-expo);
}
.brf-modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 12px 20px;
  border-bottom: 1px solid var(--border-mid); background: var(--off);
}
.brf-modal-title { font-family: var(--fh); font-weight: 800; color: var(--ink); font-size: 1rem; }
.brf-modal-actions { display: flex; align-items: center; gap: 8px; }
.brf-modal-open, .brf-modal-pdf {
  font-size: .82rem; font-weight: 700; text-decoration: none;
  padding: 8px 14px; border-radius: var(--r-sm);
}
.brf-modal-open { color: var(--navy); border: 1.5px solid var(--border-mid); background: #fff; }
.brf-modal-open:hover { border-color: var(--yellow); }
.brf-modal-pdf { color: var(--navy); background: var(--yellow); }
.brf-modal-close {
  font-size: 1.5rem; line-height: 1; color: var(--muted);
  background: transparent; border: none;
  width: 36px; height: 36px; border-radius: 50%;
}
.brf-modal-close:hover { background: rgba(0, 0, 0, .06); color: var(--ink); }
.brf-modal-body { position: relative; flex: 1; overflow: hidden; }
.brf-modal-frame { width: 100%; height: 100%; border: 0; display: block; }
.brf-modal-preview {
  margin: 0; height: 100%; overflow: auto; padding: 18px;
  background: var(--navy-deep); color: #cfe3ff;
  font: .8rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre;
}
.brf-modal-loading {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  color: var(--muted); background: var(--white);
}
.brf-spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--border-mid); border-top-color: var(--blue);
  animation: brf-spin .8s linear infinite;
}
.brf-modal-error { padding: 32px; text-align: center; color: #dc2626; font-weight: 500; }
@keyframes brf-spin { to { transform: rotate(360deg); } }
@keyframes brf-fade { from { opacity: 0; } }
@keyframes brf-pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }

@keyframes brf-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .brf-hero { padding: 52px 0 16px; }
  .brf-block { padding: 22px 18px; }
  [data-groups] { grid-template-columns: 1fr; }
  .brf-field-row { grid-template-columns: 1fr; gap: 0; }
  .brf-modal { padding: 0; }
  .brf-modal-card { width: 100%; height: 100%; border-radius: 0; }
}
