/* Guided input: the workspace-bar switch and the per-step guide card.
   Sized for readability first -- large type, large tap targets, high
   contrast -- since it is meant for people who find the plain form hard. */

/* ---------- Workspace-bar switch ---------- */

.guide-toggle {
  /* Stays at the end of the workspace bar even when the save indicator
     before it is hidden (no case open). */
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface-alt);
  color: var(--color-text);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  flex: 0 0 auto;
}

/* Switched off for everyone by an administrator (js/guide/settings.js): no switch to show. */
html[data-guide-allowed="off"] .guide-toggle {
  display: none;
}

.guide-toggle[aria-checked="true"] {
  border-color: var(--color-guide-action);
  background: var(--color-guide-action);
  color: var(--color-guide-action-text);
}

.guide-toggle:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.guide-toggle__state {
  font-weight: 700;
}

/* ---------- Guide card ---------- */

.guide {
  margin-block-end: 1rem;
  padding: 1rem 1.125rem 1.125rem;
  border: 1px solid var(--color-border);
  border-inline-start: 5px solid var(--color-guide-action);
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  font-size: 1.125rem;
  line-height: 1.5;
}

.guide[hidden] {
  display: none;
}

.guide__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-block-end: 0.5rem;
}

.guide__badge {
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.guide__off,
.guide__link {
  font: inherit;
  font-size: 1rem;
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  text-decoration: underline;
  cursor: pointer;
  padding: 0.5rem 0.25rem;
  min-height: 2.75rem;
}

.guide__off {
  font-size: 0.9375rem;
}

.guide__off:hover,
.guide__link:hover {
  color: var(--color-text);
}

.guide__title {
  margin-block: 0 0.375rem;
  font-size: 1.375rem;
  line-height: 1.35;
  font-weight: 700;
}

.guide__title:focus {
  outline: none;
}

.guide__hint {
  margin-block: 0 0.75rem;
  color: var(--color-text-muted);
  font-size: 1.0625rem;
}

.guide__lines {
  margin-block: 0 1rem;
  padding: 0.5rem 0.875rem;
  list-style: none;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.guide__line {
  padding-block: 0.1875rem;
  font-size: 1.0625rem;
}

.guide__line[data-depth="1"] { padding-inline-start: 1.25rem; }
.guide__line[data-depth="2"] { padding-inline-start: 2.5rem; }
.guide__line[data-depth="3"] { padding-inline-start: 3.75rem; }

.guide__choices {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-block-end: 0.5rem;
}

.guide__choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.125rem;
  width: 100%;
  min-height: 3.5rem;
  padding: 0.625rem 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: 1.1875rem;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.guide__choice:hover {
  border-color: var(--color-guide-action);
}

.guide__choice--primary {
  border-color: var(--color-guide-action);
  background: var(--color-guide-action);
  color: var(--color-guide-action-text);
}

.guide__choice--primary:hover {
  filter: brightness(0.92);
}

.guide__choice:focus-visible,
.guide__link:focus-visible,
.guide__off:focus-visible,
.guide__input:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.guide__choice:disabled,
.guide__input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.guide__choice-sub {
  font-size: 1rem;
  font-weight: 400;
  opacity: 0.85;
}

.guide__form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-block-end: 0.5rem;
}

.guide__field-label {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  font-size: 1rem;
  font-weight: 600;
}

.guide__input {
  width: 100%;
  min-height: 3.5rem;
  padding: 0.5rem 0.875rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: 1.1875rem;
  font-weight: 400;
}

.guide__secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}

.guide__busy {
  display: none;
  margin-block: 0.5rem 0;
  color: var(--color-text-muted);
  font-weight: 600;
}

.guide[data-busy="true"] .guide__busy {
  display: block;
}

/* ---------- Focused (modal) presentation ----------
   Same .guide__* parts as the inline card, on a centered dialog over a
   dimmed app. Used for Step 1's interview (see guide/index.js). */

html[data-guide-modal="open"] body {
  overflow: hidden;
}

.guide-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--color-scrim);
  backdrop-filter: blur(3px);
  animation: guide-fade-in 180ms ease-out;
}

.guide--modal {
  width: 100%;
  max-width: 36rem;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  margin: 0;
  padding: 1.5rem 1.5rem 1.25rem;
  border: 1px solid var(--color-border);
  border-inline-start-width: 1px;
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  animation: guide-rise-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.guide--modal .guide__title {
  font-size: 1.5rem;
}

.guide--modal .guide__choice,
.guide--modal .guide__input,
.guide--modal .guide__lines {
  background: var(--color-surface-alt);
}

.guide--modal .guide__choice--primary {
  background: var(--color-guide-action);
}

.guide__close {
  min-height: 2.75rem;
  padding: 0.25rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.guide__close:hover {
  background: var(--color-surface-alt);
}

.guide__close:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.guide__off--footer {
  display: block;
  margin-block-start: 0.5rem;
  margin-inline: auto;
}

/* Progress strip: About them -> Family -> Family tree */

.guide__stages {
  display: flex;
  gap: 0.5rem;
  margin-block: 0 1.25rem;
  padding: 0;
  list-style: none;
}

.guide__stage {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding-block-start: 0.625rem;
  border-block-start: 4px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  text-align: center;
}

.guide__stage[data-state="done"],
.guide__stage[data-state="current"] {
  border-block-start-color: var(--color-guide-action);
}

.guide__stage[data-state="current"] {
  color: var(--color-text);
  font-weight: 700;
}

.guide__stage-dot {
  display: none;
}

.guide__error {
  margin-block: 0 0.75rem;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-sm);
  color: var(--color-danger);
  font-weight: 600;
}

.guide__recap {
  margin-block-start: 0.75rem;
  border-block-start: 1px solid var(--color-border);
  padding-block-start: 0.5rem;
}

.guide__recap-summary {
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  color: var(--color-text-muted);
  font-size: 1rem;
  cursor: pointer;
}

.guide__recap-summary:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.guide__recap .guide__lines {
  margin-block: 0.25rem 0;
}

@keyframes guide-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes guide-rise-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .guide-modal,
  .guide--modal {
    animation: none;
  }
}

@media (max-width: 480px) {
  .guide-modal {
    align-items: flex-end;
    padding: 0;
  }

  .guide--modal {
    max-width: none;
    max-height: 92dvh;
    border-end-start-radius: 0;
    border-end-end-radius: 0;
  }
}
