/* ==========================================================================
   Stepwize First-Login Welcome (shared/_dashboard_welcome.html.erb)
   Own namespace (.dashboard-welcome-*). Colours come from the --guidance-*
   tokens contextual_guidance.css defines on :root, so the welcome and the
   Next Step card read as one product without sharing a single rule. Each
   token carries its literal as a fallback.

   Layout: the dialog itself never scrolls. It is a column of a body, which
   scrolls on its own when the screen is short, and a footer holding Get
   started, which does not. The close button is pinned to the dialog's corner,
   outside both. So the primary action and the close button stay in reach at
   any height, and the last line of the body can never sit behind the footer.
   ========================================================================== */

.dashboard-welcome {
  /* 16px side gutter, plus a landscape notch where there is one. */
  width: min(580px, calc(100vw - 32px));
  width: min(580px, calc(100vw - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  /* About 88% of the screen at most, and never into the phone's safe areas.
     The vh line is the fallback for browsers without dynamic viewport units. */
  max-height: 88vh;
  max-height: min(88dvh, calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  padding: 0;
  border: none;
  border-top: 4px solid var(--guidance-accent, #00008B);
  border-radius: 16px;
  background: var(--guidance-bg, #ffffff);
  color: var(--guidance-text-main, #0f172a);
  box-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.28);
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Only while open: a display on the closed dialog would override the
   browser's own display:none and show it on every page load. */
.dashboard-welcome[open] {
  display: flex;
  flex-direction: column;
  animation: dashboardWelcomeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.dashboard-welcome::backdrop {
  background: rgba(15, 23, 42, 0.55);
}

/* Keep the dashboard behind the dialog from scrolling while it is open. */
html:has(.dashboard-welcome[open]) {
  overflow: hidden;
}

/* Close: pinned to the corner, with a solid background so body text that
   scrolls beneath it stays out of sight. */
.dashboard-welcome-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--guidance-bg, #ffffff);
  border: none;
  border-radius: 10px;
  color: #64748b;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.dashboard-welcome-close:hover {
  background: #f1f5f9;
  color: #334155;
}

.dashboard-welcome-close:focus-visible,
.dashboard-welcome-continue:focus-visible {
  outline: none;
  box-shadow: var(--guidance-focus-ring, 0 0 0 2px #ffffff, 0 0 0 4px #00008B);
}

/* Body: the one scrolling region. */
.dashboard-welcome-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 28px 24px;
}

/* Browsers make an overflowing region keyboard-focusable; show it when it is. */
.dashboard-welcome-body:focus-visible {
  outline: 2px solid var(--guidance-accent, #00008B);
  outline-offset: -2px;
}

.dashboard-welcome-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.dashboard-welcome-role {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 9999px;
  background: var(--guidance-accent, #00008B);
  color: #ffffff;
}

.dashboard-welcome-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  text-wrap: balance;
  color: var(--guidance-text-main, #0f172a);
}

/* Focused by the controller so a screen reader starts at the title. It is not
   a control, so it takes no focus ring. */
.dashboard-welcome-title:focus {
  outline: none;
}

/* What Stepwize is: the one sentence every role reads first. */
.dashboard-welcome-intro {
  margin: 0;
  max-width: 62ch;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--guidance-text-main, #0f172a);
}

/* What it means for this role. */
.dashboard-welcome-lead {
  margin: 0;
  max-width: 62ch;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--guidance-text-muted, #475569);
}

/* How Stepwize helps you */
.dashboard-welcome-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dashboard-welcome-heading {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--guidance-text-muted, #475569);
}

.dashboard-welcome-benefits {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dashboard-welcome-benefit {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

.dashboard-welcome-benefit-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--guidance-primary-light, #eef0f9);
  color: var(--guidance-accent, #00008B);
}

.dashboard-welcome-benefit-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.dashboard-welcome-benefit-title {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--guidance-text-main, #0f172a);
}

.dashboard-welcome-benefit-text {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--guidance-text-muted, #475569);
}

/* Footer: never scrolls. */
.dashboard-welcome-footer {
  flex: none;
  display: flex;
  justify-content: flex-end;
  padding: 14px 28px 16px;
  border-top: 1px solid #e2e8f0;
  background: var(--guidance-bg, #ffffff);
}

.dashboard-welcome-continue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.625rem 1.25rem;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--guidance-accent, #00008B);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 10px -2px rgba(0, 0, 139, 0.18);
  transition: background 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dashboard-welcome-continue:hover {
  background: var(--guidance-accent-hover, #000070);
  transform: translateY(-1px);
}

.dashboard-welcome-continue:active {
  transform: scale(0.98);
}

@media (max-width: 480px) {
  .dashboard-welcome-body {
    gap: 18px;
    padding: 20px 20px 20px;
  }

  .dashboard-welcome-title {
    font-size: 1.25rem;
  }

  .dashboard-welcome-footer {
    padding: 12px 20px 14px;
  }

  .dashboard-welcome-continue {
    width: 100%;
  }
}

/* Phone in landscape, small laptop windows: tighten the spacing, never the
   text, so more of the body shows between the corner and the footer. */
@media (max-height: 520px) {
  .dashboard-welcome-body {
    gap: 14px;
    padding: 16px 24px 16px;
  }

  .dashboard-welcome-title {
    font-size: 1.25rem;
  }

  .dashboard-welcome-benefits {
    gap: 10px;
  }

  .dashboard-welcome-footer {
    padding: 10px 24px 12px;
  }

  .dashboard-welcome-close {
    top: 8px;
    right: 8px;
  }
}

/* ==========================================================================
   "Getting Started" capsule: reopens the welcome. It stacks 10px above the
   Need Help launcher and copies that launcher's corner offset, height, radius
   and type (need_help_launcher.css, which is not modified), following it
   through the same three positions: the default corner, above the Next Step
   pill, and the phone bottom nav. The outlined style keeps the two tellable
   apart: Need Help is the filled support button, this is the product guide.
   ========================================================================== */

.getting-started-button {
  position: fixed;
  right: calc(clamp(12px, 1.25vw, 24px) + env(safe-area-inset-right, 0px));
  /* Need Help's bottom + its 44px height + a 10px gap. */
  bottom: calc(clamp(12px, 1.25vw, 24px) + env(safe-area-inset-bottom, 0px) + 54px);
  z-index: 999;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--guidance-primary-border, #ccd1e8);
  border-radius: 9999px;
  background: var(--guidance-bg, #ffffff);
  color: var(--guidance-accent, #00008B);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.getting-started-button:hover {
  background: var(--guidance-primary-light, #eef0f9);
  border-color: var(--guidance-accent, #00008B);
}

.getting-started-button:focus-visible {
  outline: 3px solid rgba(0, 0, 139, 0.3);
  outline-offset: 2px;
}

/* Need Help climbs to 88px while the Next Step pill shows; stay above it. */
body:has(.guidance-floating-pill[style*="display: flex"]) .getting-started-button {
  bottom: calc(88px + 54px);
}

@media (max-width: 768px) {
  /* Phones: a 44px circle like Need Help, 12px above it (Need Help sits at
     nav 64 + 12; this one at nav 64 + 12 + 44 + 12). Label visually hidden,
     still read out. */
  .getting-started-button {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 68px);
    width: 44px;
    padding: 0;
    justify-content: center;
  }

  .getting-started-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  body:has(.guidance-floating-pill[style*="display: flex"]) .getting-started-button {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 120px);
  }

  /* Let content scroll clear of the taller stack: 56px more than the
     clearance need_help_launcher.css gives the launcher alone (132 / 184).
     One extra :has() makes these outrank those rules, which load later. The
     translation helper's 214px rule there still wins when it is larger. */
  .pwa-root:has([data-mobile-nav]):has(.need-help-button):has(.getting-started-button) .dashboard-main,
  .pwa-root:has([data-mobile-nav]):has(.need-help-button):has(.getting-started-button) .employee-dashboard-main {
    padding-bottom: calc(188px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .pwa-root:has([data-mobile-nav]):has(.need-help-button):has(.getting-started-button):has(.guidance-floating-pill[style*="display: flex"]) .dashboard-main,
  .pwa-root:has([data-mobile-nav]):has(.need-help-button):has(.getting-started-button):has(.guidance-floating-pill[style*="display: flex"]) .employee-dashboard-main {
    padding-bottom: calc(240px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

@keyframes dashboardWelcomeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-welcome[open] {
    animation: none;
  }

  .dashboard-welcome-continue,
  .dashboard-welcome-close,
  .getting-started-button {
    transition: none;
  }
}
