/**
 * The one-time migration modal ("Things have changed" / "Welcome back") and
 * the long-gap re-orientation band, transcribed from the redesign reference
 * (docs/design-reference/extracted/state-returning-empty.html,
 * -returning-has-work.html and -back-6-weeks.html).
 *
 * Literal pixel sizes from the reference are written as
 * calc(Npx * var(--text-scale)) — identical at the default text size, while
 * keeping Settings -> text size working.
 */

/* The brand topography wash both surfaces carry: fixed-attachment texture at
   30%, faded out over the top 60% of the block. */
.guide-transition-topo,
.guide-gap-topo {
  position: absolute;
  inset: 0;
  background-image: var(--texture-topography);
  background-size: 900px;
  background-attachment: fixed;
  opacity: 0.3;
  pointer-events: none;
  z-index: 0;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 60%);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 60%);
}

/* ===== Migration modal ===== */
/* The welcome and transition overlays are native <dialog>s opened with
   showModal() (see hub/_welcome_modal, hub/_transition_modal), so the browser
   handles the top layer, the focus trap, the inert page and Escape. The
   element is still the scrim: it fills the viewport and centres the card, so
   the frosted blur stays where it was and nothing about the look changes.
   `display: flex` overrides the UA's `dialog:not([open]) { display: none }`,
   so a closed dialog is hidden explicitly below. */
.guide-transition-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1050;
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  border: 0;
  margin: 0;
  color: inherit;
  background: var(--overlay-scrim);
  /* Frosted scrim (owner, 2026-08-11): the page behind the welcome and
     transition modals blurs, keeping the focus fully on the modal. */
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overscroll-behavior: contain;
}

.guide-transition-backdrop:not([open]) { display: none; }

/* Entrance (motion & polish spec §5): the scrim fades and the card settles.
   showModal() flips the dialog from display:none, so this plays once per
   open; reduced motion pins it globally. */
.guide-transition-backdrop[open] {
  animation: motion-fade var(--motion-enter) var(--ease-out);
}

.guide-transition-backdrop[open] .guide-transition-modal {
  animation: motion-settle var(--motion-enter) var(--ease-out);
}

/* The dialog paints its own scrim, so the platform one would double it. */
.guide-transition-backdrop::backdrop { background: transparent; }

.guide-transition-modal {
  width: 720px;
  max-width: 100%;
  max-height: 88%;
  overflow-y: auto;
  background: var(--bg-primary);
  box-shadow: var(--shadow-modal);
  position: relative;
}

.guide-transition-head {
  background: var(--navy-primary);
  padding: 2rem 2.5rem 1.75rem;
  position: relative;
  overflow: hidden;
}

.guide-transition-head-inner {
  position: relative;
  z-index: 1;
}

.guide-transition-eyebrow-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
}

.guide-transition-close {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-size: calc(16.5px * var(--text-scale));
  padding: 0;
  line-height: 1;
}

.guide-transition-close:hover {
  color: #fff;
}

.guide-transition-eyebrow {
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: calc(12.5px * var(--text-scale));
  color: var(--teal-ink);
}

.guide-transition-headline {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(32.5px * var(--text-scale));
  line-height: 1.2;
  color: #fff;
  margin: 0.6rem 0 0.65rem;
}

.guide-transition-lede {
  font-family: var(--font-body);
  font-size: calc(17px * var(--text-scale));
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.72);
  margin: 0;
  max-width: 520px;
}

.guide-transition-points {
  padding: 1.9rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.guide-transition-point {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.guide-transition-point-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--teal-light);
  color: var(--teal-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(15px * var(--text-scale));
}

.guide-transition-point-head {
  display: block;
  font-family: var(--font-heading);
  font-size: calc(17px * var(--text-scale));
  font-weight: 500;
  color: var(--navy-primary);
}

.guide-transition-point-text {
  display: block;
  font-family: var(--font-body);
  font-size: calc(14.5px * var(--text-scale));
  line-height: 1.65;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* The grandfathered member's one line about chapter 1 (see
   Onboarding::Grandfather): sits under the three points, above the actions. */
.guide-transition-stage-note {
  margin: 0;
  padding: 0 2.5rem 1.6rem;
  font-family: var(--font-body);
  font-size: calc(14.5px * var(--text-scale));
  line-height: 1.65;
  color: var(--text-secondary);
}

/* The two-minute tour, above the actions: closed it is one quiet row, open it
   is the player. A native <details>, so the marker is ours to draw. */
.guide-transition-tour {
  border-top: 1px solid var(--border-light);
  padding: 0 2.5rem;
}

.guide-transition-tour-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.85rem 0;
  font-family: var(--font-ui);
  font-size: calc(14px * var(--text-scale));
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.guide-transition-tour-summary::-webkit-details-marker { display: none; }

.guide-transition-tour-summary:hover { color: var(--text-primary); }

.guide-transition-tour-summary i { color: var(--teal-accent); }

.guide-transition-tour[open] .guide-transition-tour-summary { color: var(--text-primary); }

/* Open, the player sits right below — a second copy of the same frame in the
   summary reads doubled, so the row collapses back to text. */
.guide-transition-tour[open] .video-thumb { display: none; }

.guide-transition-tour-video {
  display: block;
  width: 100%;
  margin: 0 0 1.4rem;
  background: #000;
}

.guide-transition-actions {
  padding: 1.2rem 2.5rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.guide-transition-actions form.button_to {
  display: contents;
}

.guide-transition-spring {
  flex: 1;
}

.guide-transition-foot {
  font-family: var(--font-body);
  font-size: calc(14px * var(--text-scale));
  color: var(--text-muted);
}

/* ===== First-run welcome modal =====
   Same head, same actions bar; the white section is Lloyd's video instead of
   the three points, so the modal runs a little wider to give it room. */
.guide-welcome-modal {
  width: 880px;
}

/* Lloyd's welcome uses the head's whole measure (the shared lede's 520px cap
   left it squished against the left edge), with air between paragraphs. */
.guide-welcome-lede {
  max-width: none;
}

.guide-welcome-lede + .guide-welcome-lede {
  margin-top: 0.9rem;
}

/* His signature. Caveat is loaded for this one element only. */
.guide-welcome-signature {
  font-family: "Caveat", cursive;
  font-size: calc(2.1rem * var(--text-scale, 1));
  line-height: 1;
  color: rgba(255, 255, 255, 0.88);
  margin: 1.1rem 0 0;
  transform: rotate(-2deg);
  transform-origin: left bottom;
}

/* Lloyd's portrait beside his signature (owner, 2026-08-13): a letter with a
   face on it. Round, teal-ringed, sized to the signature's presence. */
.guide-welcome-sign-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 1.1rem;
}

.guide-welcome-sign-row .guide-welcome-signature { margin-top: 0.4rem; }

.guide-welcome-portrait {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(72, 156, 184, 0.75);
  flex-shrink: 0;
}

.guide-welcome-video {
  padding: 1.6rem 2.5rem 1.5rem;
}

/* The shared embed sits inside .module-video-container (components.css), which
   already carries the 16:9 box; here it gets the modal's own framing. */
.guide-welcome-video .module-video-container {
  box-shadow: var(--shadow-md);
}

/* The roadmap explanation (hub/_welcome_modal, 2026-08-15): the migration
   modal's three-point shape, with more air between points because each of
   these is a paragraph rather than a line. */
.guide-welcome-explain {
  gap: 1.35rem;
}

.guide-welcome-example {
  margin: 0.15rem 0 0;
}

.guide-welcome-example-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-body);
  font-size: calc(15px * var(--text-scale));
  color: var(--teal-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.guide-welcome-example-link:hover {
  color: var(--navy-primary);
}

/* The quiet second action: a text link, not a second button. */
.guide-welcome-quiet {
  border: none;
  background: transparent;
  padding: 0.35rem 0.25rem;
  font-family: var(--font-body);
  font-size: calc(15px * var(--text-scale));
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.guide-welcome-quiet:hover {
  color: var(--teal-ink);
}

@media (max-width: 600px) {
  .guide-welcome-video {
    padding-left: var(--card-x);
    padding-right: var(--card-x);
  }
}

/* ===== Long-gap re-orientation band ===== */
.guide-gap-banner {
  background: var(--surface-inverse);
  color: #fff;
  padding: 1.35rem var(--card-x);
  margin-bottom: 0.9rem;
  position: relative;
  overflow: hidden;
}

.guide-gap-inner {
  position: relative;
  z-index: 1;
}

.guide-gap-eyebrow {
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: calc(11.5px * var(--text-scale));
  color: var(--teal-ink);
  margin-bottom: 0.45rem;
}

.guide-gap-headline {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(21px * var(--text-scale));
  line-height: 1.35;
  color: #fff;
  margin: 0 0 0.5rem;
}

.guide-gap-text {
  font-family: var(--font-body);
  font-size: calc(15px * var(--text-scale));
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.72);
  margin: 0;
}

.guide-gap-text strong {
  color: #fff;
  font-weight: 500;
}

@media (max-width: 600px) {
  .guide-transition-backdrop {
    padding: 0.75rem;
  }

  .guide-transition-head,
  .guide-transition-points,
  .guide-transition-actions {
    padding-left: var(--card-x);
    padding-right: var(--card-x);
  }
}

/* --navy-primary inverts to near-white in dark theme (that is the token
   system's rule for text, and the reference inherits it). These two blocks
   are dark surfaces carrying white text, so they hold a dark value. */
[data-theme="dark"] .guide-transition-head,
[data-theme="dark"] .guide-gap-banner {
  background: var(--surface-footer, #0f1a2e);
}

/* ── The welcome, to the owner's design (2026-08-15) ──────────────────────
   Two columns on a desktop or an iPad: Lloyd's own words on the dark half,
   what the roadmap is on the white half, the two ways forward along the foot.
   On a phone the halves stack and the actions stay put at the bottom, so the
   way in is reachable without scrolling the panel to its end. */
.guide-welcome-backdrop .guide-welcome-card {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1fr);
  width: min(920px, 94vw);
  max-height: min(660px, 92vh);
  background: var(--bg-primary);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.guide-welcome-aside {
  position: relative;
  background: var(--surface-inverse);
  color: #fff;
  overflow: hidden;
  display: flex;
}

.guide-welcome-aside-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 34px 32px 30px;
  width: 100%;
}

.guide-welcome-aside .guide-transition-headline {
  color: #fff;
  margin: 0;
}

.guide-welcome-aside .guide-transition-eyebrow { color: var(--teal-accent); }

.guide-welcome-lede {
  margin: 0;
  font-family: var(--font-body);
  font-size: calc(15px * var(--text-scale));
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.86);
}

/* His encouragement, over a hairline, above his own name. */
.guide-welcome-sign {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.guide-welcome-quote {
  margin: 0 0 16px;
  font-family: var(--font-body);
  font-style: italic;
  font-size: calc(14.5px * var(--text-scale));
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.9);
}

.guide-welcome-sign-row { display: flex; align-items: center; gap: 16px; }
.guide-welcome-sign-row .guide-welcome-quote { margin-bottom: 6px; }

.guide-welcome-portrait {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--teal-accent);
}

.guide-welcome-signature {
  margin: 0;
  font-family: "Caveat", cursive;
  font-size: calc(23px * var(--text-scale));
  line-height: 1;
  color: #fff;
}

/* ── The explaining half ─────────────────────────────────────────────────── */
.guide-welcome-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.guide-welcome-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 30px 32px 22px;
}

.guide-welcome-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 22px;
}

.guide-welcome-point { display: flex; gap: 14px; align-items: flex-start; }

.guide-welcome-point-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--teal-light);
  color: var(--teal-ink);
  font-size: 15px;
}

.guide-welcome-point-head {
  display: block;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(16.5px * var(--text-scale));
  color: var(--text-dark);
  margin-bottom: 4px;
}

.guide-welcome-point-text {
  display: block;
  font-family: var(--font-body);
  font-size: calc(14.5px * var(--text-scale));
  line-height: 1.6;
  color: var(--text-secondary);
}

.guide-welcome-example { margin: 24px 0 0; }

.guide-welcome-example-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: calc(14.5px * var(--text-scale));
  color: var(--teal-ink);
}

.guide-welcome-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 32px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

.guide-welcome-actions form { display: contents; }

/* The one-time returning-member question, in the same foot slot as the two
   ways forward: the question leads, the yes/no pair follows. */
.guide-welcome-returning { flex-wrap: wrap; }

/* Answering swaps the foot in place (a Turbo frame inside the open dialog):
   the incoming region eases in on the app's motion tokens instead of the
   dialog tearing down and reopening. The global prefers-reduced-motion block
   in base.css collapses this like every other animation. */
#welcome_modal_actions .guide-welcome-actions {
  animation: guide-welcome-foot-in var(--motion-enter) var(--ease-smooth) both;
}

@keyframes guide-welcome-foot-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.guide-welcome-returning-q {
  margin: 0;
  margin-right: auto;
  font-family: var(--font-heading);
  font-size: calc(16px * var(--text-scale));
  color: var(--text-primary);
}

@media (max-width: 760px) {
  .guide-welcome-returning-q { margin-right: 0; }
}

.guide-welcome-returning-hint {
  margin: 0;
  flex-basis: 100%;
  font-size: calc(13px * var(--text-scale));
  color: var(--text-secondary);
}


/* ── A phone: stacked, with the way in always reachable ──────────────────── */
@media (max-width: 760px) {
  .guide-welcome-backdrop .guide-welcome-card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    width: 100vw;
    max-height: 100vh;
    height: 100vh;
  }

  .guide-welcome-aside-inner { padding: 26px 22px 22px; }

  /* On a phone his encouragement follows the points rather than sitting in a
     dark block above the fold. */
  .guide-welcome-sign { display: none; }

  .guide-welcome-scroll { padding: 22px 22px 18px; }

  .guide-welcome-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 22px calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .guide-welcome-actions .btn-primary { width: 100%; justify-content: center; }
  .guide-welcome-actions .guide-welcome-quiet { text-align: center; }
}
