/* ==========================================================================
   Dr.FiGo — shared structure and components.
   Loaded after tokens.css, before each site's own style.css.

   Logical-property first throughout: margin-inline, padding-block, inset-inline,
   text-align:start. Two direction overrides exist in this file and each carries
   the reason it cannot be expressed logically.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, p, figure, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }

:where(a) { color: inherit; text-underline-offset: 3px; }

:where(a, button, input, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

img, svg { max-inline-size: 100%; }

.wrap {
  width: min(var(--wrap), 100% - (var(--gutter) * 2));
  margin-inline: auto;
}

.narrow { max-inline-size: 46em; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Scroll progress hairline — the only persistent animated element on a page.
   -------------------------------------------------------------------------- */

.progress {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  block-size: 2px;
  z-index: 60;
  pointer-events: none;
}

.progress__bar {
  block-size: 100%;
  background: var(--accent);
  transform: scaleX(var(--progress, 0));
  transform-origin: left;
  will-change: transform;
}

/* OVERRIDE 1 of 2. The bar must grow from the edge the reader starts at.
   transform-origin accepts no logical keyword in any shipping browser, so the
   direction switch cannot be written logically here. */
[dir="rtl"] .progress__bar { transform-origin: right; }

@supports (animation-timeline: scroll()) {
  .progress__bar {
    animation: progress-grow linear both;
    animation-timeline: scroll(root block);
  }
  @keyframes progress-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
}

/* --------------------------------------------------------------------------
   Header — wordmark + language toggle. No hamburger anywhere on the platform.
   -------------------------------------------------------------------------- */

.site-header {
  padding-block: var(--sp-4);
  border-block-end: 1px solid var(--rule);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.wordmark {
  display: block;
  color: var(--brand);
  --logo-accent: var(--accent);
}

.wordmark svg { display: block; block-size: 20px; inline-size: auto; }

.lang-toggle {
  font-family: var(--font-en);      /* the toggle always names the other language */
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-label);
  color: var(--ink);
  background: none;
  border: 1px solid var(--rule-strong);
  padding-inline: var(--sp-3);
  min-block-size: var(--tap);
  min-inline-size: var(--tap);
  cursor: pointer;
  transition: background var(--dur-ui) var(--ease-out),
              color var(--dur-ui) var(--ease-out);
}

.lang-toggle:hover { background: var(--brand); color: var(--on-brand); }

/* The toggle is script-driven; with scripting off it would be a dead control. */
html:not(.js) .lang-toggle { display: none; }

/* --------------------------------------------------------------------------
   Sticky section header — pins under the progress hairline, swaps on entry,
   underline resizes to the new word.
   -------------------------------------------------------------------------- */

.sticky-head {
  position: fixed;
  inset-block-start: 2px;
  inset-inline: 0;
  z-index: 50;
  background: var(--ground);
  border-block-end: 1px solid var(--rule);
  padding-block: var(--sp-3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity var(--dur-ui) var(--ease-out),
              transform var(--dur-ui) var(--ease-out),
              visibility 0s linear var(--dur-ui);
}

.sticky-head.is-on {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

.sticky-head__label {
  display: inline-block;
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.3;
  color: var(--brand);
}

.sticky-head__rule {
  display: block;
  block-size: 2px;
  inline-size: 0;
  margin-block-start: var(--sp-1);
  background: var(--brand);
  transition: inline-size var(--dur-swap) var(--ease-out);
}

html:not(.js) .sticky-head { display: none; }

/* --------------------------------------------------------------------------
   Sections
   -------------------------------------------------------------------------- */

.section { padding-block: var(--sp-8); }
.section + .section { border-block-start: 1px solid var(--rule); }

.section__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-xl);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-display);
  color: var(--brand);
  text-wrap: balance;
}

.section__intro {
  margin-block-start: var(--sp-4);
  font-size: var(--fs-md);
  line-height: var(--lh-snug);
  color: var(--ink-quiet);
  max-inline-size: var(--measure);
}

/* Hero — sits large and alone; every section after it steps down the scale
   and tightens. That rhythm is layout, not script. */
.hero { padding-block: var(--sp-8) var(--sp-7); }

.hero__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-display);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-display);
  color: var(--brand);
  text-wrap: balance;
  max-inline-size: 16ch;
}

.hero__sub {
  margin-block-start: var(--sp-5);
  font-size: var(--fs-md);
  line-height: var(--lh-snug);
  color: var(--ink-quiet);
  max-inline-size: var(--measure);
}

/* --------------------------------------------------------------------------
   Card list and the swipeable strip
   -------------------------------------------------------------------------- */

.cards {
  display: grid;
  gap: var(--sp-4);
  margin-block-start: var(--sp-6);
}

.card {
  background: var(--surface);
  padding: var(--sp-5);
  border-inline-start: 2px solid var(--brand);
}

.card__title {
  font-size: var(--fs-md);
  font-weight: 700;
  line-height: var(--lh-tight);
  color: var(--brand);
}

.card__body {
  margin-block-start: var(--sp-2);
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
  color: var(--ink-quiet);
}

/* Horizontal strip. The last card is deliberately left part-visible so the
   row reads as swipeable without any arrow or dot affordance.

   Flex rather than grid: an auto-column sized minmax(0, N%) takes that zero as
   its minimum and compresses to fit the scroller instead of overflowing it, so
   the row silently stops being swipeable. A flex basis that cannot shrink
   actually overflows. */
.strip {
  display: flex;
  gap: var(--sp-3);
  margin-block-start: var(--sp-6);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline-start: var(--gutter);
  padding-block-end: var(--sp-3);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.strip::-webkit-scrollbar { block-size: 0; }
.strip > * { flex: 0 0 78%; scroll-snap-align: start; }

@media (min-width: 700px) {
  .strip > * { flex-basis: 42%; }
  .cards { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1000px) {
  .strip > * { flex-basis: 30%; }
}

/* --------------------------------------------------------------------------
   Numbered steps — the numbering is real sequence, so it is a real <ol>.
   -------------------------------------------------------------------------- */

.steps {
  counter-reset: step;
  display: grid;
  gap: var(--sp-5);
  margin-block-start: var(--sp-6);
}

.steps > li {
  counter-increment: step;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-4);
  align-items: start;
}

.steps > li::before {
  content: counter(step);
  font-family: var(--font-en);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1;
  color: var(--brand);
  border: 1px solid var(--rule-strong);
  inline-size: 34px;
  block-size: 34px;
  display: grid;
  place-items: center;
}

.steps p { font-size: var(--fs-sm); line-height: var(--lh-snug); }

/* Checked lines */
.checks { display: grid; gap: var(--sp-4); margin-block-start: var(--sp-6); }

.checks > li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-3);
  align-items: start;
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
}

.checks > li::before {
  content: "";
  inline-size: 9px;
  block-size: 9px;
  margin-block-start: .55em;
  background: var(--accent);
  transform: rotate(45deg);      /* the Datum square, reused as the marker */
}

/* --------------------------------------------------------------------------
   Buttons and fields
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-block-size: var(--tap);
  padding-inline: var(--sp-5);
  padding-block: var(--sp-3);
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: var(--on-brand);
  transition: background var(--dur-ui) var(--ease-out),
              color var(--dur-ui) var(--ease-out);
}

.btn:hover { background: transparent; color: var(--brand); }

.btn[aria-disabled="true"] {
  background: transparent;
  color: var(--ink-quiet);
  border-color: var(--rule);
  cursor: not-allowed;
  pointer-events: none;
}

.field { display: grid; gap: var(--sp-3); }

.field__label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--brand);
}

.input {
  font-family: inherit;
  font-size: var(--fs-base);
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--rule-strong);
  padding-inline: var(--sp-4);
  padding-block: var(--sp-3);
  min-block-size: var(--tap);
  inline-size: 100%;
  text-align: start;
}

.input::placeholder { color: var(--ink-quiet); opacity: .8; }

/* Pills. A pill row that scrolls is the specialty picker; scroll-snap and a
   part-visible final pill make it read as swipeable. */
.pills {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding-block-end: var(--sp-2);
  scrollbar-width: none;
}

.pills::-webkit-scrollbar { block-size: 0; }

.pill {
  scroll-snap-align: start;
  flex: 0 0 auto;
  font-family: inherit;
  font-size: var(--fs-sm);
  line-height: 1;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-pill);
  padding-inline: var(--sp-4);
  min-block-size: var(--tap);
  cursor: pointer;
  transition: background var(--dur-ui) var(--ease-out),
              color var(--dur-ui) var(--ease-out);
}

.pill[aria-pressed="true"] {
  background: var(--brand);
  color: var(--on-brand);
  border-color: var(--brand);
}

/* --------------------------------------------------------------------------
   Persistent WhatsApp bar. Appears past the hero, retreats whenever the
   in-page call to action is on screen. A bar, not a circle over the copy.
   -------------------------------------------------------------------------- */

.wa-bar {
  position: fixed;
  inset-inline: 0;
  inset-block-end: 0;
  z-index: 55;
  background: var(--brand);
  border-block-start: 1px solid var(--brand);
  padding: var(--sp-3) var(--gutter);
  padding-block-end: max(var(--sp-3), env(safe-area-inset-bottom));
  transform: translateY(110%);
  transition: transform var(--dur-swap) var(--ease-out);
}

.wa-bar.is-on { transform: none; }

.wa-bar__link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-block-size: var(--tap);
  color: var(--on-brand);
  font-size: var(--fs-base);
  font-weight: 700;
  text-decoration: none;
}

html:not(.js) .wa-bar { display: none; }

@media (min-width: 700px) {
  .wa-bar { display: none; }      /* the in-page CTA is always reachable here */
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
  padding-block: var(--sp-7) var(--sp-9);
  border-block-start: 1px solid var(--rule);
  font-size: var(--fs-xs);
  color: var(--ink-quiet);
}

/* --------------------------------------------------------------------------
   Reveal on entry. Scoped to .js so that with scripting off everything is
   simply visible and every graphic is fully drawn.
   -------------------------------------------------------------------------- */

.js .reveal { opacity: 0; transform: translateY(14px); }

.js .reveal.is-in {
  opacity: 1;
  transform: none;
  transition: opacity var(--dur-reveal) var(--ease-out),
              transform var(--dur-reveal) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; }
  .sticky-head { transition: none; }
}
