/* ============================================================
   LaiVox onboarding guide — layered on top of portal.css tokens
   (../assets/portal.css). No colors/fonts are redefined here;
   this file only adds the doc-site layout and components that
   portal.css (built for single-card login/billing pages) doesn't
   already provide.
   ============================================================ */

:root {
  --guide-header-h: 64px;
  --guide-sidebar-w: 272px;
  --guide-radius: 18px;
  --guide-radius-sm: 12px;
  --guide-transition: 200ms ease;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body { font-size: 15px; line-height: 1.6; }

/* ===== NOSCRIPT ===== */
.noscript {
  max-width: 640px;
  margin: 4rem auto;
  padding: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--guide-radius);
  box-shadow: var(--soft-shadow);
}
.noscript p { margin-top: 10px; color: var(--ink-mute); }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  top: calc(var(--guide-header-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 0.65rem 1.1rem;
  background: var(--bg-elevated);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.875rem;
  box-shadow: var(--soft-shadow);
  animation: fade-up 300ms cubic-bezier(.2,.8,.2,1) both;
}

/* ===== HEADER ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--guide-header-h);
  background: color-mix(in oklab, var(--bg-stage) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--signal), var(--signal-soft));
  color: var(--bg-stage);
  font-weight: 700;
  font-size: 1.05rem;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 1rem; letter-spacing: -0.01em; }
.brand-text span { font-size: 0.75rem; color: var(--ink-mute); }

.header-nav { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.header-link {
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink-mute);
  font-size: 0.875rem;
  transition: background var(--guide-transition), color var(--guide-transition);
}
.header-link:hover { background: color-mix(in oklab, var(--signal) 12%, transparent); color: var(--signal); }

/* header-scoped lang-switch: cancel portal.css's absolute positioning
   so it sits inline as the last flex item in the top bar */
.site-header .lang-switch { position: static; margin-left: auto; }

.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg-card-2);
  cursor: pointer;
}
.menu-toggle-bar { display: block; width: 16px; height: 2px; margin: 0 auto; background: var(--ink); border-radius: 1px; }

/* ===== LAYOUT ===== */
.layout {
  display: grid;
  grid-template-columns: var(--guide-sidebar-w) 1fr;
  max-width: 1280px;
  margin: 0 auto;
  min-height: calc(100vh - var(--guide-header-h) - 72px);
}
.sidebar {
  position: sticky;
  top: var(--guide-header-h);
  align-self: start;
  height: calc(100vh - var(--guide-header-h));
  overflow-y: auto;
  padding: 20px 16px 32px;
  border-right: 1px solid var(--line);
}
.sidebar-search { position: relative; margin-bottom: 16px; }
.sidebar-search input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  font: inherit;
  font-size: 0.875rem;
}
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--guide-radius-sm);
  box-shadow: var(--soft-shadow);
  overflow: hidden;
}
.search-hit {
  display: block;
  padding: 0.6rem 0.8rem;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  font-size: 0.875rem;
  transition: background var(--guide-transition);
}
.search-hit:last-child { border-bottom: 0; }
.search-hit:hover { background: color-mix(in oklab, var(--signal) 10%, transparent); }
.search-empty { margin: 0; padding: 0.8rem; font-size: 0.8125rem; color: var(--ink-mute); }

.sidebar-label {
  margin: 16px 0 6px;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.nav-link {
  display: block;
  padding: 0.4rem 0.6rem;
  margin-bottom: 2px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink-mute);
  font-size: 0.875rem;
  transition: background var(--guide-transition), color var(--guide-transition);
}
.nav-link:hover { background: var(--line); color: var(--ink); }
.nav-link.is-active { background: color-mix(in oklab, var(--signal) 14%, transparent); color: var(--signal); font-weight: 600; }

.sidebar-advanced { margin-top: 8px; border: 0; }
.sidebar-summary { cursor: pointer; list-style: none; user-select: none; }
.sidebar-summary::-webkit-details-marker { display: none; }
.sidebar-summary::after { content: " \25BE"; font-size: 0.75em; color: var(--ink-dim); }
.sidebar-advanced:not([open]) .sidebar-summary::after { content: " \25B8"; }
.sidebar-advanced-body { margin-top: 2px; }

.main { padding: 24px 32px 48px; min-width: 0; }

/* ===== VIEWS ===== */
.page-enter { animation: fade-up 380ms cubic-bezier(.2,.8,.2,1) both; }

.view-header h1, .hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.75rem, 3.4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.view-subtitle, .hero-tagline { margin: 0; font-size: 1rem; color: var(--ink-mute); max-width: 42ch; }

/* ===== HERO ===== */
.hero { padding: 16px 0 40px; }
.hero-quick { max-width: 40rem; }

.success-goal {
  margin: 12px 0 0;
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: color-mix(in oklab, var(--signal) 14%, transparent);
  color: var(--signal);
  font-size: 0.875rem;
  font-weight: 600;
}

.path-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 0;
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  counter-reset: path;
}
.path-preview li { display: flex; align-items: center; gap: 6px; font-size: 0.875rem; color: var(--ink-mute); }
.path-preview li::before {
  counter-increment: path;
  content: counter(path);
  display: grid;
  place-items: center;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: var(--signal);
  color: var(--bg-stage);
  font-size: 0.7rem;
  font-weight: 700;
}
.path-preview li:not(:last-child)::after { content: "\2192"; margin: 0 10px 0 6px; color: var(--ink-dim); }

.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 20px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 220ms ease, background var(--guide-transition), color var(--guide-transition), border-color var(--guide-transition);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(145deg, var(--signal), var(--signal-soft));
  color: var(--bg-stage);
  box-shadow: 0 10px 26px -12px color-mix(in oklab, var(--signal) 55%, transparent);
}
.btn-secondary { background: var(--bg-card-2); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost { background: transparent; color: var(--ink-mute); border-color: var(--line); }
.btn-ghost:hover { color: var(--ink); background: var(--line); }
.btn-lg { height: 48px; padding: 0 24px; font-size: 1rem; }

.btn:focus-visible,
.nav-link:focus-visible,
.mode-card:focus-visible,
.tour-progress-item:focus-visible,
.menu-toggle:focus-visible,
.sidebar-search input:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

/* ===== HOME PANELS ===== */
.home-panels { display: grid; gap: 20px; }
.panel { padding: 20px 22px; background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--guide-radius); box-shadow: var(--soft-shadow); }
.panel h2 { margin: 0 0 10px; font-size: 1.15rem; }
.panel-hint { margin: -4px 0 14px; font-size: 0.8125rem; color: var(--ink-dim); }
.mode-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mode-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 16px;
  border-radius: var(--guide-radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-card-2);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--guide-transition), transform var(--guide-transition), box-shadow var(--guide-transition);
}
.mode-card:hover { border-color: color-mix(in oklab, var(--signal) 45%, var(--line)); transform: translateY(-2px); box-shadow: 0 12px 26px -18px color-mix(in oklab, var(--signal) 40%, transparent); }
.mode-card strong { font-size: 0.9375rem; }
.mode-card span { font-size: 0.8125rem; color: var(--ink-mute); }

/* ===== DOCS CONTENT ===== */
.doc-content { display: grid; gap: 20px; }
.lead { margin: 0; font-size: 1.0625rem; color: var(--ink-mute); }

.block-steps h3, .block-table h3, .block-diagram h3, .block-checklist h3, .block-paragraph h3 {
  margin: 0 0 10px; font-size: 1rem;
}
.block-steps ol { margin: 0; padding-left: 1.2rem; }
.block-steps li + li { margin-top: 6px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--guide-radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.6rem 0.8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg-card-2); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

.callout { padding: 0.85rem 1rem; border-radius: var(--guide-radius-sm); border: 1px solid var(--line); }
.callout strong { display: block; margin-bottom: 4px; }
.callout p { margin: 0; font-size: 0.9rem; }
.callout-info {
  background: color-mix(in oklab, var(--signal-soft) 12%, transparent);
  border-color: color-mix(in oklab, var(--signal-soft) 30%, transparent);
  color: var(--signal-soft);
}
.callout-warn {
  background: color-mix(in oklab, var(--signal-warm) 12%, transparent);
  border-color: color-mix(in oklab, var(--signal-warm) 30%, transparent);
  color: var(--signal-warm);
}
.callout p, .callout strong { color: inherit; }

.diagram-pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  background: var(--bg-card-2);
  border: 1px solid var(--line);
  border-radius: var(--guide-radius-sm);
  color: var(--ink-mute);
}

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.checklist li:last-child { border-bottom: 0; }
.check-box { flex-shrink: 0; width: 1rem; height: 1rem; margin-top: 3px; border: 2px solid var(--signal); border-radius: 3px; }

/* ===== FIGURE / IMAGE PLACEHOLDER ===== */
.figure { margin: 0; }
.figure + .figure { margin-top: 14px; }
.figure-caption {
  margin-top: 8px;
  font-size: 0.8125rem;
  color: var(--ink-dim);
  text-align: center;
}

/* Side-panel shots are tall; never let them fill the card width or
   they dominate the viewport. Cap height for reading comfort. */
.figure-img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, 420px);
  max-height: min(62vh, 560px);
  margin-inline: auto;
  object-fit: contain;
  border-radius: var(--guide-radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-card);
}

/* placeholder box reserves the real image's footprint via aspect-ratio,
   with a padding-top fallback for browsers that predate it.
   display:flex must not win over [hidden] — otherwise a loaded image
   still shows a fake "load failed" strip underneath. */
.figure-placeholder {
  position: relative;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  aspect-ratio: var(--figure-ratio, 16/9);
  padding-top: 42%;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--guide-radius-sm);
  background: var(--bg-card-2);
  color: var(--ink-dim);
  font-size: 0.8125rem;
  text-align: center;
}
.figure-placeholder:not([hidden]) { display: flex; }
.figure-placeholder[hidden] { display: none !important; }
@supports (aspect-ratio: 1) {
  .figure-placeholder { padding-top: 0; }
}
.figure-placeholder > * { position: relative; }
.figure-placeholder-icon {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  border: 1.5px dashed var(--line-strong);
  font-size: 1rem;
  color: var(--ink-dim);
}
.figure-placeholder--error {
  border-style: solid;
  border-color: color-mix(in oklab, var(--danger) 40%, var(--line-strong));
  color: var(--danger);
}
.figure-placeholder--error .figure-placeholder-icon {
  border-color: color-mix(in oklab, var(--danger) 50%, var(--line-strong));
  color: var(--danger);
}
.figure--broken .figure-img { display: none; }

.figure--zoomable .figure-zoom-btn {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  position: relative;
  border-radius: var(--guide-radius-sm);
}
.figure--zoomable .figure-zoom-btn:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 3px;
}
.figure--zoomable .figure-zoom-btn:disabled {
  cursor: default;
}
.figure-zoom-hint {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: color-mix(in oklab, var(--bg-stage) 72%, transparent);
  color: var(--ink);
  font-size: 0.75rem;
  line-height: 1.2;
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.figure--broken .figure-zoom-hint { display: none; }

/* ===== IMAGE LIGHTBOX ===== */
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 20px;
}
.image-lightbox[hidden] { display: none !important; }

body.image-lightbox-open { overflow: hidden; }

.image-lightbox-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: color-mix(in oklab, var(--bg-stage) 55%, black);
  cursor: zoom-out;
}

.image-lightbox-panel {
  position: relative;
  z-index: 1;
  width: min(96vw, 1200px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fade-up 220ms cubic-bezier(.2,.8,.2,1) both;
}

.image-lightbox-close {
  position: absolute;
  top: -6px;
  right: -6px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--soft-shadow);
  transition: background var(--guide-transition), transform 120ms ease;
}
.image-lightbox-close:hover {
  background: var(--bg-card-2);
  transform: scale(1.04);
}
.image-lightbox-close:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

.image-lightbox-figure {
  margin: 0;
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.image-lightbox-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 96vw;
  max-height: min(86vh, 900px);
  object-fit: contain;
  border-radius: var(--guide-radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-card);
  box-shadow: var(--soft-shadow);
}

.image-lightbox-caption {
  margin: 12px 0 0;
  max-width: 56ch;
  font-size: 0.9rem;
  color: var(--ink-mute);
  text-align: center;
}
.image-lightbox-caption[hidden] { display: none !important; }

@media (max-width: 900px) {
  .image-lightbox { padding: 12px; }
  .image-lightbox-close {
    top: 4px;
    right: 4px;
  }
  .figure-zoom-hint {
    right: 6px;
    bottom: 6px;
    font-size: 0.6875rem;
  }
}

/* ===== FAQ ===== */
.faq-list { display: grid; gap: 8px; margin-top: 8px; }
.faq-item { border: 1px solid var(--line); border-radius: var(--guide-radius-sm); background: var(--bg-card); overflow: hidden; }
.faq-item summary { padding: 0.8rem 1rem; cursor: pointer; font-weight: 600; list-style: none; transition: background var(--guide-transition); }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; float: right; color: var(--signal); font-weight: 700; }
.faq-item[open] summary::after { content: "\2212"; }
.faq-item summary:hover { background: color-mix(in oklab, var(--signal) 8%, transparent); }
.faq-answer { padding: 0 1rem 0.85rem; color: var(--ink-mute); font-size: 0.9rem; }
.faq-answer p { margin: 0; }

/* ===== TOUR ===== */
.tour-progress { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.tour-progress-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-card);
  cursor: pointer;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--ink-mute);
  transition: border-color var(--guide-transition), background var(--guide-transition), transform var(--guide-transition);
}
.tour-progress-item:hover { border-color: color-mix(in oklab, var(--signal) 45%, var(--line)); }
.tour-progress-item.is-active {
  border-color: var(--signal);
  background: color-mix(in oklab, var(--signal) 14%, transparent);
  color: var(--signal);
  font-weight: 600;
  transform: scale(1.02);
}
.tour-progress-item.is-done .tour-progress-num { background: var(--signal); color: var(--bg-stage); }
.tour-progress-num {
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background: var(--line-strong);
  font-size: 0.72rem;
  font-weight: 700;
}
.tour-progress-label { max-width: 10rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tour-step-card { padding: 22px 24px; background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--guide-radius); box-shadow: var(--soft-shadow); }
.tour-step-meta { margin: 0 0 6px; font-size: 0.8125rem; color: var(--ink-dim); }
.tour-step-card h2 { margin: 0 0 14px; font-size: 1.3rem; }
.tour-body-list { margin: 0; padding-left: 1.15rem; }
.tour-body-list li + li { margin-top: 8px; }
.tour-tip { margin-top: 16px; }
.tour-more { margin: 16px 0 0; font-size: 0.875rem; }
.tour-more a { color: var(--signal-soft); }
.figure + .tour-more, .figure + .callout { margin-top: 16px; }
.tour-step-card .figure { margin-top: 16px; }

.tour-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; align-items: center; }
.tour-actions .btn-primary { margin-left: auto; }

.doc-back { margin-top: 32px; }

/* ===== FOOTER ===== */
.site-footer {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 24px 32px;
  border-top: 1px solid var(--line);
  font-size: 0.8125rem;
  color: var(--ink-dim);
}
.site-footer p { margin: 4px 0; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .menu-toggle { display: flex; }
  .header-nav { display: none; }
  .site-header .lang-switch { margin-left: auto; }

  .sidebar {
    position: fixed;
    top: var(--guide-header-h);
    left: 0;
    z-index: 90;
    width: min(88vw, var(--guide-sidebar-w));
    transform: translateX(-105%);
    transition: transform 0.28s ease;
    box-shadow: var(--soft-shadow);
    background: var(--bg-stage);
  }
  .sidebar.is-open { transform: translateX(0); }

  .main { padding: 16px 18px 32px; }
  .mode-cards { grid-template-columns: 1fr; }
  .tour-progress-label { display: none; }
  .tour-actions .btn-primary { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .page-enter, .toast, .btn:hover, .mode-card:hover, .tour-progress-item.is-active {
    animation: none !important;
    transform: none !important;
  }
}
