/* Onboarding system styles. All onboarding elements use position:fixed and
   never cover the board or intercept canvas interaction (checklist/tips/hint
   stay out of the canvas area or are pointer-events:none where appropriate). */

:root {
  --onboarding-blue: #0677bb;
  --onboarding-dark: #293144;
}

/* ── Getting started checklist ───────────────────────────────────────────── */
#onboarding-checklist {
  position: fixed;
  right: 64px;   /* clear of the zoom controls */
  bottom: 96px;  /* clear of the HELP button and the playback bar */
  width: 300px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(20, 30, 50, 0.18), 0 0 0 1px rgba(20, 30, 50, 0.06);
  font-family: Rubik, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  z-index: 500; /* below modals/tooltips, above the board */
  overflow: hidden;
  color: var(--onboarding-dark);
}

#onboarding-checklist.collapsed { width: 220px; }

.onboarding-checklist-header {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 10px 8px 8px 14px;
}

.onboarding-checklist-title {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.onboarding-checklist-heading {
  font-size: 0.95em;
  font-weight: 700;
}

.onboarding-checklist-count {
  font-size: 0.8em;
  color: #8a93a6;
}

.onboarding-checklist-collapse,
.onboarding-checklist-dismiss {
  background: none;
  border: none;
  color: #8a93a6;
  cursor: pointer;
  font-size: 1em;
  width: 26px;
  height: 26px;
  border-radius: 8px;
}

.onboarding-checklist-collapse:hover,
.onboarding-checklist-dismiss:hover {
  background: #f0f2f6;
  color: var(--onboarding-dark);
}

.onboarding-checklist-progress-bar {
  height: 4px;
  margin: 0 14px 4px 14px;
  background: #edf0f4;
  border-radius: 2px;
  overflow: hidden;
}

#onboarding-checklist.collapsed .onboarding-checklist-progress-bar { margin-bottom: 12px; }

.onboarding-checklist-progress-fill {
  height: 100%;
  background: var(--onboarding-blue);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.onboarding-checklist-body {
  padding: 6px 8px 12px 8px;
}

.onboarding-checklist-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.onboarding-checklist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 6px;
  background: none;
  border: none;
  border-radius: 10px;
  font: inherit;
  color: inherit;
  text-align: left;
}

button.onboarding-checklist-row { cursor: pointer; }
button.onboarding-checklist-row:hover { background: #f3f7fb; }

.onboarding-checklist-check {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid #cdd3dd;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.onboarding-checklist-list li.next .onboarding-checklist-check { border-color: var(--onboarding-blue); }

.onboarding-checklist-list li.done .onboarding-checklist-check {
  background: #1f9d63;
  border-color: #1f9d63;
}

.onboarding-checklist-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.onboarding-checklist-label {
  font-size: 0.88em;
  font-weight: 500;
}

.onboarding-checklist-list li.done .onboarding-checklist-label { color: #9aa2b1; }

.onboarding-checklist-hint {
  font-size: 0.75em;
  color: #8a93a6;
  margin-top: 1px;
}

.onboarding-checklist-go {
  flex-shrink: 0;
  font-size: 0.72em;
  font-weight: 600;
  color: var(--onboarding-blue);
  opacity: 0;
  transition: opacity 0.15s ease;
}

button.onboarding-checklist-row:hover .onboarding-checklist-go,
button.onboarding-checklist-row:focus-visible .onboarding-checklist-go,
.onboarding-checklist-list li.next .onboarding-checklist-go { opacity: 1; }

.onboarding-checklist-celebrate {
  margin: 0 6px 8px 6px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #eaf7f0;
  color: #1a7a4c;
  font-size: 0.82em;
  font-weight: 600;
}

.onboarding-checklist-more {
  display: block;
  width: calc(100% - 12px);
  margin: 8px 6px 0 6px;
  padding: 9px 12px;
  background: #eef5fb;
  border: none;
  border-radius: 10px;
  color: var(--onboarding-blue);
  font: inherit;
  font-size: 0.85em;
  font-weight: 600;
  cursor: pointer;
}

.onboarding-checklist-more:hover { background: #e1eef8; }

.onboarding-checklist-foot {
  margin-top: 6px;
  text-align: center;
  font-size: 0.72em;
  color: #9aa2b1;
}

/* ── Highlight used by "Show me" guides and tours ───────────────────────── */
.onboarding-highlight {
  outline: 3px solid var(--onboarding-blue) !important;
  outline-offset: 2px !important;
  border-radius: 4px !important;
  animation: onboardingPulse 1.4s infinite;
}

@keyframes onboardingPulse {
  0%, 100% { outline-color: var(--onboarding-blue); }
  50% { outline-color: #3cb9d8; }
}

/* ── Empty-canvas hint ────────────────────────────────────────────────────── */
#onboarding-empty-hint {
  position: fixed;
  top: 50%;
  left: 55%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: rgba(41, 49, 68, 0.35);
  font-family: Rubik, sans-serif;
  pointer-events: none;
  z-index: 1;
  user-select: none;
}

.onboarding-empty-hint-arrow {
  font-size: 2.4em;
  animation: onboardingArrowBob 1.6s ease-in-out infinite;
}

.onboarding-empty-hint-text {
  font-size: 1.1em;
  font-weight: 600;
  margin-top: 4px;
}

@keyframes onboardingArrowBob {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-6px, -6px); }
}

/* ── Welcome modal (replaces auto-starting tour) ─────────────────────────── */
.onboarding-welcome-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.onboarding-welcome-modal {
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 32px;
  max-width: 440px;
  width: 90%;
  font-family: Rubik, sans-serif;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.onboarding-welcome-modal h2 {
  margin: 0 0 12px 0;
  color: var(--onboarding-dark);
}

.onboarding-welcome-modal p {
  margin: 0 0 24px 0;
  color: #555;
  line-height: 1.5;
}

.onboarding-welcome-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  font-size: 22px;
  color: #999;
  cursor: pointer;
}

/* Language flags on the welcome popup (flag images come from flag-icons) */
.onboarding-welcome-langs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 14px 0;
}

.onboarding-welcome-lang {
  width: 34px;
  height: 25px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  background: none;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

.onboarding-welcome-lang .fi {
  display: block;
  width: 100%;
  height: 100%;
  background-size: cover;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); /* keeps white flags (Japan) visible */
}

.onboarding-welcome-lang:hover,
.onboarding-welcome-lang:focus-visible { opacity: 1; }

.onboarding-welcome-lang.active {
  opacity: 1;
  border-color: var(--onboarding-blue);
}

.onboarding-welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.onboarding-welcome-option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  border: 1px solid #e3e7ee;
  border-radius: 12px;
  background: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.onboarding-welcome-option:hover {
  border-color: var(--onboarding-blue);
  background: #f5f9fd;
}

.onboarding-welcome-option.primary {
  background: var(--onboarding-blue);
  border-color: var(--onboarding-blue);
  color: #fff;
}

.onboarding-welcome-option.primary:hover { background: #055d99; }

.onboarding-welcome-option-title {
  font-weight: 700;
  font-size: 0.98em;
  color: var(--onboarding-dark);
}

.onboarding-welcome-option-sub {
  font-size: 0.82em;
  color: #6b7486;
}

.onboarding-welcome-option.primary .onboarding-welcome-option-title,
.onboarding-welcome-option.primary .onboarding-welcome-option-sub { color: #fff; }

.onboarding-welcome-option.primary .onboarding-welcome-option-sub { opacity: 0.85; }

.onboarding-welcome-foot {
  margin-top: 18px;
  font-size: 0.8em;
  color: #8a93a6;
}

.onboarding-welcome-skip {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--onboarding-blue);
  cursor: pointer;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #onboarding-checklist {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 12px;
  }
}

/* Keep the checklist out of the way of the welcome popup, the properties
   sidebar and tours */
body:has(.onboarding-welcome-overlay) #onboarding-checklist { display: none; }

@media (min-width: 769px) {
  body.sidebar-open #onboarding-checklist { right: 356px; } /* clear of the shifted zoom controls */
}

body.onboarding-tour-active #onboarding-checklist { display: none; }

/* ── Guided coach marks ("Show me") ──────────────────────────────────────── */
.onboarding-coach {
  position: fixed;
  z-index: 700; /* above the checklist, below modals */
  width: 260px;
  max-width: calc(100vw - 20px);
  background: var(--onboarding-dark);
  color: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  font-family: Rubik, sans-serif;
  font-size: 0.9em;
  line-height: 1.4;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  --arrow: 50%;
}

/* Arrow pointing back at the target; --arrow is set from JS */
.onboarding-coach::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  background: inherit;
  transform: translate(-50%, -50%) rotate(45deg);
}

.onboarding-coach-below::after { top: 0; left: var(--arrow); }
.onboarding-coach-above::after { top: 100%; left: var(--arrow); }
.onboarding-coach-right::after { left: 0; top: var(--arrow); }
.onboarding-coach-left::after { left: 100%; top: var(--arrow); }

.onboarding-coach-step {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.65;
  margin-bottom: 4px;
}

.onboarding-coach-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.onboarding-coach-actions button {
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
}

.onboarding-coach-next {
  background: var(--onboarding-blue);
  color: #fff;
}

.onboarding-coach-skip {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.onboarding-coach-skip:hover { background: rgba(255, 255, 255, 0.22); }

.onboarding-coach-success {
  background: #1f7a4d;
}

/* ── "Looks stuck" nudge toast (also used for tour offers) ───────────────── */
.onboarding-stuck {
  position: fixed;
  left: 50%;
  top: 72px;
  transform: translateX(-50%);
  z-index: 650;
  width: 380px;
  max-width: calc(100vw - 32px);
  background: #fff;
  color: var(--onboarding-dark);
  border-left: 4px solid var(--onboarding-blue);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 12px 14px;
  font-family: Rubik, sans-serif;
  font-size: 0.9em;
  animation: onboardingSlideIn 0.25s ease-out;
}

.onboarding-stuck-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.onboarding-stuck-show {
  background: var(--onboarding-blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.onboarding-stuck-link,
.onboarding-stuck-off {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.85em;
  color: var(--onboarding-blue);
  cursor: pointer;
  text-decoration: none;
}

.onboarding-stuck-off { color: #888; }

.onboarding-stuck-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.2em;
  color: #999;
  cursor: pointer;
}

@keyframes onboardingSlideIn {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .onboarding-highlight,
  .onboarding-empty-hint-arrow,
  .onboarding-stuck { animation: none; }
}

/* ── Feature tours (reuse the coach bubble) ──────────────────────────────── */
.onboarding-tour {
  z-index: 10010; /* above menus, the sidebar and dialogs a tour opens (Share) */
  width: 290px;
}

.onboarding-tour-title {
  font-weight: 700;
  font-size: 1.05em;
  margin-bottom: 4px;
}

.onboarding-tour-spacer { flex: 1; }

.onboarding-tour .onboarding-coach-actions { align-items: center; }

.onboarding-coach-actions .onboarding-tour-skip {
  background: none;
  padding: 6px 0;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 500;
}

.onboarding-coach-actions .onboarding-tour-skip:hover { color: #fff; }

.onboarding-offer-hint {
  margin-top: 6px;
  font-size: 0.75em;
  color: #888;
}

.onboarding-offer-never {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.85em;
  color: #888;
  cursor: pointer;
}


/* ── Floating Tutorials button (bottom left, between TOOLS and LOGIN) ────── */
#onboarding-launcher {
  position: fixed;
  left: 5px;
  bottom: 140px;
  z-index: 400; /* under the checklist, menus and modals */
  display: flex;
  align-items: center;
  font-family: Rubik, sans-serif;
  filter: drop-shadow(0 4px 10px rgba(20, 30, 50, 0.18));
}

.onboarding-launcher-open {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 8px 12px;
  background: #fff;
  border: 1px solid #dfe4ec;
  border-right: none;
  border-radius: 999px 0 0 999px;
  color: var(--onboarding-dark);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.onboarding-launcher-open:hover { background: #f3f7fb; }

.onboarding-launcher-badge {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--onboarding-blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.onboarding-launcher-hide {
  align-self: stretch;
  padding: 0 9px 0 6px;
  background: #fff;
  border: 1px solid #dfe4ec;
  border-left: 1px solid #eef1f5;
  border-radius: 0 999px 999px 0;
  color: #9aa2b1;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.onboarding-launcher-hide:hover { color: var(--onboarding-dark); background: #f3f7fb; }

/* One thing at a time: out of the way of the welcome popup and running tours */
body:has(.onboarding-welcome-overlay) #onboarding-launcher,
body.onboarding-tour-active #onboarding-launcher { display: none; }

.onboarding-hub-toggles {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Tutorials hub ───────────────────────────────────────────────────────── */
.onboarding-hub-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
}

.onboarding-hub {
  background: #fff;
  border-radius: 14px;
  width: 560px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  font-family: Rubik, sans-serif;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.onboarding-hub-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 22px 8px 22px;
}

.onboarding-hub-header h2 {
  margin: 0;
  font-size: 1.3em;
  color: var(--onboarding-dark);
}

.onboarding-hub-progress {
  font-size: 0.85em;
  color: #777;
  margin-top: 2px;
}

.onboarding-hub-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  line-height: 1;
}

.onboarding-hub-search {
  margin: 8px 22px 12px 22px;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font: inherit;
  font-size: 0.95em;
}

.onboarding-hub-search:focus {
  outline: 2px solid var(--onboarding-blue);
  border-color: transparent;
}

.onboarding-hub-list {
  overflow-y: auto;
  padding: 0 22px 12px 22px;
}

.onboarding-hub-group { margin-bottom: 14px; }

.onboarding-hub-group-title {
  font-size: 0.75em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #999;
  margin-bottom: 6px;
}

.onboarding-hub-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #eee;
  border-radius: 10px;
  margin-bottom: 6px;
}

.onboarding-hub-card:hover { border-color: #cfe3f1; background: #f8fbfe; }

.onboarding-hub-card-main { flex: 1; min-width: 0; }

.onboarding-hub-card-title {
  font-weight: 600;
  color: var(--onboarding-dark);
}

.onboarding-hub-check {
  color: #1f7a4d;
  margin-right: 6px;
}

.onboarding-hub-card-summary {
  font-size: 0.85em;
  color: #666;
  margin-top: 2px;
}

.onboarding-hub-card-meta {
  font-size: 0.75em;
  color: #aaa;
  margin-top: 2px;
}

.onboarding-hub-start {
  flex-shrink: 0;
  background: var(--onboarding-blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font: inherit;
  font-size: 0.85em;
  font-weight: 600;
  cursor: pointer;
}

.onboarding-hub-card.done .onboarding-hub-start {
  background: #eef3f7;
  color: var(--onboarding-dark);
}

.onboarding-hub-empty {
  padding: 20px 0;
  color: #777;
  text-align: center;
}

.onboarding-hub-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 22px;
  border-top: 1px solid #eee;
  font-size: 0.85em;
}

.onboarding-hub-footer a {
  color: var(--onboarding-blue);
  text-decoration: none;
  font-weight: 600;
}

.onboarding-hub-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #555;
  cursor: pointer;
}


/* ── Icons (ui-icons.js) inside onboarding UI ─────────────────────────── */
.onboarding-launcher-icon { display: inline-flex; color: var(--onboarding-blue); }

.onboarding-checklist-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.onboarding-checklist-celebrate {
  display: flex;
  align-items: center;
  gap: 8px;
}

.onboarding-coach-text .st-icon {
  display: inline-block;
  vertical-align: -3px;
  margin-right: 4px;
}

.onboarding-hub-check { display: inline-flex; vertical-align: -3px; }

.onboarding-hub-links {
  display: flex;
  align-items: center;
  gap: 14px;
}

.onboarding-hub-examples {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--onboarding-blue);
  cursor: pointer;
}

/* ── Example boards picker ───────────────────────────────────────────────── */
.onboarding-examples-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The guided basics point at the picker: keep the bubble above it. */
body:has(.onboarding-examples-overlay) .onboarding-coach { z-index: 10011; }

.onboarding-examples {
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 26px 26px 20px;
  width: 640px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  font-family: Rubik, sans-serif;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.onboarding-examples h2 {
  margin: 0 0 6px 0;
  color: var(--onboarding-dark);
}

.onboarding-examples-sub {
  margin: 0 0 18px 0;
  font-size: 0.9em;
  color: #6b7486;
}

.onboarding-examples-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.onboarding-example {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 8px 12px;
  border: 1px solid #e3e7ee;
  border-radius: 12px;
  background: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.onboarding-example:hover:not(:disabled) {
  border-color: var(--onboarding-blue);
  background: #f5f9fd;
}

.onboarding-example:disabled { cursor: default; opacity: 0.55; }
.onboarding-example.loading { opacity: 1; border-color: var(--onboarding-blue); }

.onboarding-example img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: #eef2f7;
  margin-bottom: 4px;
}

.onboarding-example-title {
  font-weight: 700;
  font-size: 0.95em;
  color: var(--onboarding-dark);
}

.onboarding-example-sub {
  font-size: 0.8em;
  line-height: 1.35;
  color: #6b7486;
}

.onboarding-examples-note {
  margin: 14px 0 0 0;
  font-size: 0.8em;
  color: #8a93a6;
}

@media (max-width: 600px) {
  .onboarding-examples-grid { grid-template-columns: 1fr; }
  .onboarding-example { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .onboarding-example img { width: 96px; margin: 0 8px 0 0; }
  .onboarding-example-title { flex: 1; }
  .onboarding-example-sub { flex-basis: 100%; }
}
