/* Guided setup (Fix Mds/guided-setup-spec.md). The docked guide card, the
   welcome screen and the "Show me" tour. On a computer the tour's instruction is
   one square glass card in the bottom right corner (on a phone, a thin card that drags top or bottom); inside Settings it is a child of
   the Settings sheet, not a popup over it. The ring is a class on the real button. */

/* The ring on the real button. A style on the element itself, never a layer. */
.sg-ring {
  outline: 3px solid var(--ramp-5);
  outline-offset: 3px;
  border-radius: 10px;
  animation: sg-pulse 1.6s ease-in-out infinite;
  scroll-margin: 120px;
}
@keyframes sg-pulse {
  0%, 100% { outline-color: var(--ramp-5); box-shadow: 0 0 0 0 var(--f-active-bd); }
  50%      { outline-color: var(--ramp-6); box-shadow: 0 0 0 8px transparent; }
}
@media (prefers-reduced-motion: reduce) { .sg-ring { animation: none; } }
/* The tour's tip: always a square, in the bottom right corner, same frosted glass as the
   Inbox "Back to top" pill (the shared --glass-* tokens), so it follows light and dark.
   Firmer fill than the pill, because it sits over the page. On a phone it is a thin card instead (see the phone block below). */
#sg-coach {
  position: fixed; right: 24px; bottom: 24px; z-index: 960;
  width: 280px; height: 280px; aspect-ratio: 1 / 1;
  box-sizing: border-box; display: flex; flex-direction: column;
  padding: 22px 20px 18px; border-radius: 26px;
  background: var(--c-head-glass);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-edge), var(--glass-shadow);
  color: var(--text);
  animation: sg-coach-in .22s ease-out;
}
#page-settings > #sg-coach { z-index: 30; }
@keyframes sg-coach-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #sg-coach { animation: none; } }
.sg-coach-step { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.sg-coach-title { margin-top: 6px; font-size: 19px; font-weight: 700; line-height: 1.2; color: var(--text); }
.sg-coach-text { margin-top: 8px; flex: 1 1 auto; min-height: 0; overflow-y: auto; font-size: 14.5px; line-height: 1.45; color: var(--text2); }
.sg-coach-bar { flex: 0 0 auto; height: 5px; margin: 12px 0 14px; border-radius: 99px; background: var(--border2); overflow: hidden; }
.sg-coach-bar > span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.sg-coach-acts { flex: 0 0 auto; display: flex; gap: 8px; }
.sg-coach-acts .sg-btn { flex: 1 1 0; padding: 12px 10px; text-align: center; border-radius: 999px; }
#sg-coach .sg-btn-quiet { background: var(--glass-inner); color: var(--text); box-shadow: var(--glass-edge); }
#sg-coach .sg-btn-quiet:hover { background: var(--glass-inner); color: var(--text); text-decoration: none; filter: brightness(.97); }
#sg-coach .sg-btn-primary { background: var(--accent); color: var(--bg); }
#sg-coach .sg-btn-primary:hover { background: var(--accent); filter: brightness(1.08); }

/* Colors for the guide card, the welcome screen, the reopen row and the tip (Reuven, 26 Nov):
   light frosted glass in light mode, the navy only in dark mode. Every value is a shell
   token (CLAUDE.md design rule), so light and dark follow the app's own theme. */
#sg-dock, .sg-w-card, .sg-reopen, #sg-coach {
  --sg-bg: var(--f-menu-bg);
  --sg-fg: var(--text);
  --sg-muted: var(--text2);
  --sg-faint: var(--text3);
  --sg-line: var(--border);
  --sg-track: var(--border2);
  --sg-fill: var(--accent);
  --sg-dotline: var(--text3);
  --sg-btn: var(--f-pill-hover);
  --sg-btn-hover: var(--border2);
  --sg-link: var(--f-av-fg);
  --sg-tipbg: var(--f-pill-on-bg);
  --sg-numbg: var(--f-av-bg);
  --sg-edge: var(--glass-edge);
  --sg-shadow: var(--f-menu-sh);
  --sg-on: var(--bg);          /* text on a coloured dot: white in light mode */
}
[data-theme="dark"] #sg-dock, [data-theme="dark"] .sg-w-card, [data-theme="dark"] .sg-reopen, [data-theme="dark"] #sg-coach {
  --sg-btn: var(--gl-hover);
  --sg-btn-hover: var(--border2);
  --sg-on: var(--text);        /* near white on the dark theme */
}

/* Buttons shared by the tip, the card and the welcome screen. */
.sg-btn {
  appearance: none; border: 0; cursor: pointer; font: inherit;
  font-size: 13.5px; font-weight: 600; line-height: 1;
  padding: 9px 13px; border-radius: 10px;
  background: var(--sg-btn); color: var(--sg-fg);
}
.sg-btn:hover { background: var(--sg-btn-hover); }
.sg-btn-primary, .sg-btn-primary:hover { background: var(--accent); color: var(--bg); }
.sg-btn-primary:hover { filter: brightness(1.08); }
.sg-btn-quiet { background: transparent; color: var(--sg-muted); padding-left: 6px; padding-right: 6px; }
.sg-btn-quiet:hover { background: transparent; color: var(--sg-fg); text-decoration: underline; }

/* The docked guide card (outside Settings only). */
#sg-dock {
  position: fixed; right: 20px; bottom: 20px; z-index: 950;
  width: 340px; max-width: calc(100vw - 24px);
  border-radius: 18px;
  background: var(--sg-bg);
  -webkit-backdrop-filter: var(--glass-blur, blur(18px)); backdrop-filter: var(--glass-blur, blur(18px));
  box-shadow: var(--sg-edge), var(--sg-shadow);
  color: var(--sg-fg); font-size: 14px;
}
#sg-dock[hidden] { display: none; }
.sg-head {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px 16px; cursor: pointer;
  appearance: none; border: 0; background: transparent; color: inherit; font: inherit; text-align: left;
  border-radius: 18px 18px 0 0;
}
.sg-head:focus-visible { outline: 2px solid var(--sg-link); outline-offset: -2px; }
.sg-head-text { display: block; }
.sg-title, .sg-sub { display: block; }
.sg-head-text { flex: 1 1 auto; min-width: 0; }
.sg-title { font-weight: 700; font-size: 14.5px; }
.sg-sub { margin-top: 2px; font-size: 12.5px; color: var(--sg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-chev { flex: 0 0 auto; color: var(--sg-muted); font-size: 18px; line-height: 1; transition: transform .2s; }
#sg-dock.sg-open .sg-chev { transform: rotate(180deg); }
.sg-bar { height: 6px; margin: 0 16px 14px; border-radius: 99px; background: var(--sg-track); overflow: hidden; }
.sg-bar > span { display: block; height: 100%; border-radius: 99px; background: var(--sg-fill); transition: width .4s; }
.sg-body { display: none; padding: 0 10px 12px; max-height: min(60vh, 520px); overflow-y: auto; }
#sg-dock.sg-open .sg-body { display: block; }
.sg-min { font-weight: 500; font-size: 12px; color: var(--sg-faint); margin-left: 4px; }
.sg-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sg-tip { margin: 0 6px 10px; padding: 12px; border-radius: 12px; background: var(--sg-tipbg); font-size: 13.5px; line-height: 1.45; }
.sg-step { display: flex; gap: 10px; padding: 10px 6px; border-top: 1px solid var(--sg-line); }
.sg-step:first-child { border-top: 0; }
.sg-dot {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--sg-dotline); margin-top: 1px;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800;
}
.sg-step.is-done .sg-dot { background: var(--c-won); border-color: var(--c-won); color: var(--sg-on); }
.sg-step.is-waiting .sg-dot { background: var(--note-send); border-color: var(--note-send); color: var(--sg-on); }
.sg-step.is-skipped .sg-dot { border-style: dashed; }
.sg-step-main { flex: 1 1 auto; min-width: 0; }
.sg-step-title { font-weight: 650; }
.sg-step.is-done .sg-step-title, .sg-step.is-skipped .sg-step-title { color: var(--sg-muted); }
.sg-step-line { margin-top: 2px; font-size: 12.5px; line-height: 1.4; color: var(--sg-muted); }
.sg-step-acts { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.sg-foot { display: flex; justify-content: space-between; gap: 8px; padding: 8px 6px 0; border-top: 1px solid var(--sg-line); }
.sg-video { color: var(--sg-link); font-weight: 600; text-decoration: none; }
.sg-video:hover { text-decoration: underline; }

/* Settings, Company: reopen a hidden guide (inline, no popup). */
.sg-reopen {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 0 0 16px; padding: 12px 16px; border-radius: 14px;
  background: var(--sg-bg); color: var(--sg-fg); font-size: 14px;
  box-shadow: var(--sg-edge);
}

/* While the tip sits in the Settings corner, the Weimark steps' own Next button moves to the left so the tip never covers it. */
#page-settings:has(> #sg-coach) #screening-root .scr-nav { justify-content: flex-start; }
/* Drag handle: only drawn on a phone. */
.sg-grab { display: none; }
/* Close and Show me on the guide card: only on a phone (the computer card opens into the step list). */
.sg-phone-acts { display: none; }

/* Phone (Reuven, 26 Nov): the same guide card and the same tip, as one thin full-width card
   above the bottom tab bar, with smaller text and buttons. Drag it by its top strip to the
   top of the screen or back to the bottom; it snaps to whichever half it is let go in. */
@media (max-width: 820px) {
  #sg-dock, #sg-coach {
    left: 10px; right: 10px; width: auto; max-width: none;
    bottom: calc(var(--tabbar-space, 12px) + 8px); top: auto;
  }
  #sg-dock.sg-top, #sg-coach.sg-top { top: calc(var(--safe-top, 0px) + 54px); bottom: auto; }
  /* Inside the Settings sheet (no tab bar there). */
  #page-settings > #sg-coach { bottom: calc(var(--safe-bottom, 0px) + 12px); }
  #page-settings > #sg-coach.sg-top { top: calc(var(--safe-top, 0px) + 54px); bottom: auto; }
  .sg-grab {
    display: block; height: 16px; margin: 0 auto -4px; width: 100%;
    touch-action: none; cursor: grab;
  }
  .sg-grab::before {
    content: ''; display: block; width: 36px; height: 4px; margin: 6px auto 0;
    border-radius: 99px; background: currentColor; opacity: .3;
  }
  .sg-dragging { transition: none !important; cursor: grabbing; }

  /* The guide card, thinner. */
  #sg-dock { border-radius: 16px; font-size: 13px; }
  #sg-dock .sg-head { padding: 4px 14px 8px; touch-action: none; }
  #sg-dock .sg-title { font-size: 13.5px; }
  #sg-dock .sg-sub { font-size: 11.5px; }
  #sg-dock .sg-chev { font-size: 15px; }
  #sg-dock .sg-bar { height: 4px; margin: 0 14px 10px; }
  #sg-dock .sg-body { max-height: 52vh; padding: 0 8px 10px; }
  #sg-dock .sg-step { padding: 8px 4px; gap: 8px; }
  #sg-dock .sg-dot { width: 18px; height: 18px; font-size: 10px; }
  #sg-dock .sg-step-line { font-size: 11.5px; }
  #sg-dock .sg-btn { font-size: 12.5px; padding: 7px 11px; }
  /* No big step list on a phone: the card stays thin, with Close and Show me like the tip. */
  #sg-dock:not(.sg-done) .sg-body { display: none !important; }
  #sg-dock .sg-chev { display: none; }
  #sg-dock .sg-phone-acts { display: flex; gap: 8px; padding: 0 14px 12px; }
  #sg-dock .sg-phone-acts .sg-btn { flex: 1 1 0; padding: 9px 10px; font-size: 13px; text-align: center; border-radius: 999px; }
  #sg-dock .sg-phone-acts .sg-btn-quiet { background: var(--sg-btn); color: var(--sg-fg); text-decoration: none; }

  /* The tip, thinner: no longer a square. */
  #sg-coach {
    width: auto; height: auto; aspect-ratio: auto;
    padding: 2px 14px 12px; border-radius: 18px;
    background: var(--f-menu-bg);   /* near solid: page text must not show through */
  }
  /* Room under the last row of a phone Settings screen, so a button at the very bottom
     can scroll up out from under the tip instead of hiding behind it. */
  #page-settings:has(> #sg-coach:not(.sg-top)) #msx .msx-body { padding-bottom: calc(220px + var(--msx-safe-bot, 0px)); }
  #sg-coach .sg-coach-head { touch-action: none; }
  .sg-coach-step { font-size: 10.5px; }
  .sg-coach-title { margin-top: 2px; font-size: 15px; }
  .sg-coach-text { margin-top: 4px; font-size: 13px; line-height: 1.4; max-height: 30vh; }
  .sg-coach-bar { height: 4px; margin: 8px 0 10px; }
  .sg-coach-acts .sg-btn { padding: 9px 10px; font-size: 13px; }
}

/* The welcome screen (first sign-in only, outside Settings). */
#onboarding-overlay.sg-welcome {
  display: flex; position: fixed; inset: 0; z-index: 9000;
  align-items: center; justify-content: center; padding: 20px;
  background: transparent;
}
/* The dark scrim behind the welcome card: the shell's navy, faded (no hard-coded colour). */
#onboarding-overlay.sg-welcome::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: var(--navy); opacity: .6;
}
.sg-w-card {
  width: 100%; max-width: 520px; max-height: calc(100dvh - 40px); overflow-y: auto;
  border-radius: 20px; background: var(--sg-bg); color: var(--sg-fg);
  -webkit-backdrop-filter: var(--glass-blur, blur(18px)); backdrop-filter: var(--glass-blur, blur(18px));
  box-shadow: var(--sg-edge), var(--sg-shadow);
  padding: 34px 32px 26px;
}
.sg-w-acts .sg-btn:focus:not(:focus-visible) { outline: none; }
.sg-w-acts .sg-btn:focus-visible { outline: 2px solid var(--sg-link); outline-offset: 3px; }
.sg-w-kicker { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--sg-link); }
.sg-w-title { margin-top: 8px; font-family: Georgia, 'Times New Roman', serif; font-size: 28px; line-height: 1.2; font-weight: 700; }
.sg-w-sub { margin-top: 8px; font-size: 15px; line-height: 1.5; color: var(--sg-muted); }
.sg-w-steps { margin: 20px 0 6px; padding: 0; list-style: none; counter-reset: sgw; }
.sg-w-steps li {
  counter-increment: sgw; display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--sg-line); font-size: 14.5px;
}
.sg-w-steps li:first-child { border-top: 0; }
.sg-w-steps li::before {
  content: counter(sgw); flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  background: var(--sg-numbg); color: var(--sg-link); font-weight: 800; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.sg-w-steps .sg-w-min { margin-left: auto; color: var(--sg-faint); font-size: 13px; white-space: nowrap; }
.sg-w-acts { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.sg-w-acts .sg-btn { width: 100%; padding: 14px; font-size: 15px; text-align: center; }
.sg-w-video { display: block; margin-top: 14px; text-align: center; }
@media (max-width: 520px) {
  .sg-w-card { padding: 26px 20px 20px; border-radius: 18px; }
  .sg-w-title { font-size: 24px; }
}
