/* Shared base: reset, accessibility helpers and behaviour-level styles.
   Each direction's tokens.css defines the variables used here; styles.css owns the look. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 6rem; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.icon { width: 1.25em; height: 1.25em; flex: none; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 2px; }

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  padding: .75rem 1rem; background: var(--text); color: var(--bg);
  border-radius: var(--radius-sm); text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

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

/* Client-supplied content placeholders: deliberately visible. */
.ph {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  border: 1.5px dashed color-mix(in srgb, var(--muted) 70%, transparent);
  color: var(--muted); background: color-mix(in srgb, var(--muted) 6%, transparent);
  border-radius: var(--radius-sm); padding: .1em .5em;
  font-size: .9em; font-weight: 500; letter-spacing: 0;
}
.ph-block { display: flex; width: 100%; min-height: 10rem; padding: 1rem; text-align: center; }

/* ---------- Header mechanics ---------- */
[data-header-sentinel] { position: absolute; top: 0; height: 1px; width: 1px; }
.site-header { position: sticky; top: 0; z-index: 40; }
.nav-list { list-style: none; margin: 0; padding: 0; }
.mega[hidden] { display: none; }
.nav-toggle { display: none; }

@media (max-width: 1023px) {
  .nav-toggle { display: inline-flex; }
  .primary-nav { display: none; }
  .nav-open .primary-nav { display: block; }
  .header-actions .btn-ghost { display: none; }
  .nav-open .header-actions .btn-ghost { display: none; }
}

/* ---------- Draft switcher (preview only) ---------- */
.draft-switcher {
  position: fixed; left: 1rem; bottom: 1rem; z-index: 45;
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem .85rem; border-radius: 999px;
  background: #1d232b; color: #f3f4f6; text-decoration: none;
  font: 500 13px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 6px 24px rgb(15 23 42 / .22);
}
.draft-switcher b { font-weight: 700; }
.draft-switcher:hover { background: #2b333d; }
@media (max-width: 600px) { .draft-switcher span { display: none; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 5.5rem; z-index: 60;
  transform: translate(-50%, 1rem); opacity: 0; pointer-events: none;
  max-width: min(92vw, 28rem); padding: .75rem 1rem; border-radius: var(--radius-sm);
  background: #1d232b; color: #f3f4f6; font-size: .9rem; text-align: center;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Chat mock mechanics ---------- */
.chat { position: fixed; right: 1rem; bottom: 1rem; z-index: 50; }
.chat-panel[hidden] { display: none; }
.chat-panel {
  position: absolute; right: 0; bottom: calc(100% + .75rem);
  width: min(23rem, calc(100vw - 2rem));
  max-height: min(34rem, calc(100dvh - 7rem));
  display: flex; flex-direction: column; overflow: hidden;
}
.chat-log { overflow-y: auto; flex: 1; }

/* ---------- Scribe demo mechanics (the one motion moment) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .js .scribe [data-line],
  .js .scribe [data-field] {
    opacity: 0; transform: translateY(8px);
    transition: opacity .5s var(--ease), transform .5s var(--ease);
    transition-delay: calc(var(--i, 0) * 420ms);
  }
  .js .scribe [data-field] { transition-delay: calc(var(--i, 0) * 420ms + 1500ms); }
  .js .scribe.is-playing [data-line],
  .js .scribe.is-playing [data-field] { opacity: 1; transform: none; }
}

.scribe.is-resetting [data-line], .scribe.is-resetting [data-field] { transition: none !important; }

/* Keep floating preview controls out of the way of the open mobile menu. */
.nav-open .chat, .nav-open .draft-switcher { display: none; }

/* ---------- Gentle entrance animations (Clinical Simple) ----------
   Hidden only when JS runs and the visitor has not asked for reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  .js [data-intro] > :not(h1),
  .js [data-reveal],
  .js [data-reveal-group] > * {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .7s var(--ease), transform .7s var(--ease);
  }
  .js [data-intro] > * { transition-delay: calc(var(--i, 0) * 90ms + 80ms); }
  .js [data-reveal-group] > * { transition-delay: calc(var(--i, 0) * 80ms); }
  .js.is-loaded [data-intro] > *,
  .js [data-reveal].is-visible,
  .js [data-reveal-group].is-visible > * { opacity: 1; transform: none; }
}

/* Chat "typing" bubble shown briefly before the assistant's reply. */
.chat-typing { display: flex; gap: .3rem; align-items: center; justify-self: start; min-height: 2.4rem; }
.chat-typing span { width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; opacity: .4; }
