/* ==========================================================================
   MEDSTAR · Base: reset, tipografia, utilitários, movimento
   ========================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
  overflow-x: clip;
}

body {
  min-height: 100dvh;
  overflow-x: clip;
  background-color: var(--creme);
  color: var(--marrom);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: var(--lh-body);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Grão de papel: um ladrilho SVG leve, sem imagem externa */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 40;           /* sobre as seções, sob o header e diálogos */
  pointer-events: none;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.23 0 0 0 0 0.14 0 0 0 0 0.09 0 0 0 1.4 -0.2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

img,
picture,
video,
svg,
iframe { display: block; max-width: 100%; }

img { height: auto; }

input,
button,
textarea,
select { font: inherit; color: inherit; }

button { cursor: pointer; background: none; border: 0; padding: 0; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }

p,
li,
h1,
h2,
h3,
h4,
blockquote { overflow-wrap: break-word; }

p { text-wrap: pretty; }

ul[role="list"],
ol[role="list"] { list-style: none; padding: 0; }

/* ---- Tipografia ------------------------------------------------------- */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 350;
  line-height: var(--lh-head);
  letter-spacing: -0.015em;
  text-wrap: balance;
  color: var(--fg);
}

em, i { font-style: italic; }

.display, .h2, .h3, .h4 {
  font-family: var(--font-display);
  font-weight: 350;
  color: var(--fg);
  text-wrap: balance;
}

/* Itálico da serifa como "voz" da frase: só em títulos */
.display em,
h1 em,
h2 em { font-weight: 300; color: var(--accent-text); }

.display {
  font-size: var(--step-6);
  line-height: var(--lh-tight);
  letter-spacing: -0.03em;
  font-variation-settings: "opsz" 72;
}

.h2 {
  font-size: var(--step-5);
  line-height: 1.04;
  letter-spacing: -0.025em;
  font-variation-settings: "opsz" 72;
}

.h3 {
  font-size: var(--step-3);
  line-height: 1.12;
}

.h4 {
  font-size: var(--step-2);
  line-height: 1.2;
}

.lede {
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--fg-soft);
  max-width: var(--measure);
}

.prose > * + * { margin-top: 1em; }
.prose { max-width: var(--measure); color: var(--fg-soft); }
.prose strong { color: var(--fg); font-weight: 600; }

.small { font-size: var(--step--1); }
.nw { white-space: nowrap; }

/* Link de texto com sublinhado que cresce */
.link {
  color: var(--accent-text);
  font-weight: 500;
  text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
  padding-bottom: 2px;
  transition: background-size var(--dur) var(--ease-out);
}
.link:hover { background-size: 0 1px; background-position: 100% 100%; }

/* ---- Foco ------------------------------------------------------------- */

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: 0.75rem;
  z-index: 200;
  padding: 0.75rem 1.25rem;
  background: var(--marrom);
  color: var(--creme);
  border-radius: var(--radius-s);
  transform: translateY(-160%);
  transition: transform var(--dur-fast) var(--ease-out);
}
.skip-link:focus-visible { transform: none; }

::selection { background: var(--terracota); color: #fff; }

/* ---- Layout ---------------------------------------------------------- */

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

.section {
  position: relative;
  background-color: var(--bg);
  color: var(--fg);
  padding-block: var(--section-pad);
}

/* Grade editorial de 12 colunas */
.grid-12 {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gutter);
}
.grid-12 > * { grid-column: 1 / -1; }

.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;
}

/* Marcação visível de pendências (some quando o dado é preenchido) */
.todo {
  font-family: var(--font-body);
  font-style: normal;
  font-size: 0.85em;
  color: var(--terracota-escuro);
  background: rgb(201 152 90 / 0.2);
  padding: 0.05em 0.4em;
  border-radius: 3px;
  outline: 1px dashed rgb(143 63 40 / 0.45);
}
.tone-marrom .todo { color: var(--creme); background: rgb(201 152 90 / 0.22); outline-color: rgb(201 152 90 / 0.6); }

/* ---- Revelar ao rolar ------------------------------------------------
   IntersectionObserver adiciona .is-in (ver main.js). A revelação é
   temporizada, e não ligada ao scroll, para o texto nunca ficar parado
   semitransparente na borda da tela. As scroll-driven animations
   (animation-timeline: view()) ficam para o parallax, em pages.css.
   O conteúdo só fica oculto quando o JS confirmou (.js no <html>).       */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity var(--dur-slow) var(--ease-out),
    transform var(--dur-slow) var(--ease-out);
  transition-delay: calc(var(--i, 0) * 90ms);
}
.js [data-reveal].is-in { opacity: 1; transform: none; }

/* ---- Movimento reduzido: tudo estático e legível --------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }
  .js [data-reveal] { opacity: 1 !important; transform: none !important; }
}
