/* Componentes comuns a todas as páginas. Escrito a partir do celular; telas maiores só acrescentam. */
@layer base, components, pages, motion;

@layer base {
  *, *::before, *::after { box-sizing: border-box; }
  html { scroll-padding-top: 1.5rem; -webkit-text-size-adjust: 100%; }
  body { margin: 0; background: var(--surface-page); color: var(--c-ink); font: 400 1rem/var(--line-body) var(--font-body); overflow-wrap: break-word; }
  button, input, select, textarea { font: inherit; color: inherit; }
  button, a { touch-action: manipulation; }
  img, svg { display: block; max-width: 100%; }
  img { height: auto; }
  h1, h2, h3, h4, p, figure, blockquote { margin: 0; }
  ul, ol { margin: 0; padding: 0; }
  main:focus { outline: none; }

  /* Três papéis tipográficos fixos. */
  h1, h2 { font-family: var(--font-display); font-weight: var(--weight-display); line-height: 1.18; letter-spacing: -.01em; text-wrap: balance; }
  h2 { font-size: var(--text-section-title); }
  h3, h4 { font: var(--weight-subheading) var(--text-h3)/1.35 var(--font-subheading); text-wrap: balance; }
  p { max-width: 62ch; text-wrap: pretty; }
  .lead { font-size: var(--text-lead); line-height: 1.6; }
  .muted { color: var(--c-muted); }

  /* Foco sempre visível; em fundo escuro o anel fica claro. */
  :focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 3px; }
  .on-dark { background: var(--c-ink); color: var(--c-base); --focus-ring: var(--c-base); }
  .on-dark .muted { color: var(--on-dark-muted); }

  .container { width: calc(100% - 2 * var(--gutter)); max-width: var(--container); margin-inline: auto; }
  .section { padding-block: var(--space-8); }
  @media (min-width: 768px) { .section { padding-block: var(--space-9); } }

  .skip { position: fixed; left: 16px; top: -100px; z-index: 100; padding: 12px 16px; background: #fff; border-radius: var(--radius); }
  .skip:focus { top: 12px; }
  .sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  [hidden] { display: none !important; }
}

@layer components {
  /* Cabeçalho: divide a capa com a foto e sai com a rolagem. */
  .site-header { position: absolute; inset: 0 0 auto; z-index: 10; color: var(--c-base); --focus-ring: var(--c-base); }
  .header-inner { position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); min-height: 76px; border-bottom: 1px solid color-mix(in srgb, var(--c-base) 35%, transparent); }
  /* Marca: símbolo da Videira num círculo claro, como na versão circular do logo, e o nome ao lado. */
  .brand { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; color: inherit; text-decoration: none; }
  .brand-mark { display: grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 7px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px color-mix(in srgb, var(--c-base) 30%, transparent); }
  .brand-mark img { width: 100%; height: 100%; object-fit: contain; }
  .brand-name { display: flex; flex-direction: column; font: var(--weight-display) 1.25rem/1 var(--font-display); letter-spacing: -.01em; }
  .brand-name small { margin-top: 4px; font: var(--weight-subheading) .5625rem/1 var(--font-display); letter-spacing: .2em; text-transform: uppercase; opacity: .85; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; padding: 0; border: 0; border-radius: var(--radius); background: transparent; color: inherit; cursor: pointer; }
  .menu-toggle svg { width: 26px; height: 26px; }

  /* Menu no celular: painel escuro abaixo do cabeçalho. Sem JS, os links ficam visíveis. */
  .main-nav { display: flex; flex-wrap: wrap; gap: 0 var(--space-5); }
  .main-nav a { position: relative; display: inline-flex; align-items: center; min-height: 48px; color: inherit; text-decoration: none; font-weight: 600; }
  html:not(.js) .header-inner { flex-wrap: wrap; padding-bottom: var(--space-2); }
  .js .main-nav { display: none; position: absolute; inset: calc(100% + 1px) calc(-1 * var(--gutter)) auto; flex-direction: column; padding: var(--space-3) var(--gutter) var(--space-5); background: var(--c-ink); box-shadow: 0 18px 30px color-mix(in srgb, var(--c-ink) 30%, transparent); }
  .js .main-nav.is-open { display: flex; }
  .main-nav a::after { content: ""; position: absolute; left: 0; bottom: 8px; width: 32px; height: 3px; background: var(--c-1-bright); border-radius: 100% 15% 80% 20%; transform: scaleX(0); transform-origin: left; }
  .main-nav a:hover::after, .main-nav a:focus-visible::after, .main-nav a[aria-current]::after { transform: scaleX(1); }

  @media (min-width: 1024px) {
    .header-inner { min-height: 92px; }
    .brand-mark { width: 50px; height: 50px; }
    .brand-name { font-size: 1.375rem; }
    .js .menu-toggle { display: none; }
    .js .main-nav, .main-nav { position: static; display: flex; flex-direction: row; gap: clamp(1.25rem, 2.5vw, 2.5rem); padding: 0; background: transparent; box-shadow: none; }
    .main-nav a::after { bottom: 6px; width: 100%; }
  }

  /* Botão: contorno degradê comum; preenchimento e texto por contexto. */
  .button {
    --button-rest: var(--c-ink); --button-ink: var(--c-base); --button-hover: var(--c-ink-hover);
    display: inline-flex; align-items: center; justify-content: center; gap: .625rem;
    min-height: 48px; padding: 12px 20px;
    border: 2px solid transparent; border-radius: var(--radius);
    background: linear-gradient(var(--button-fill, var(--button-rest)), var(--button-fill, var(--button-rest))) padding-box, var(--brand-gradient) border-box;
    color: var(--button-ink); font: 600 1rem/1.3 var(--font-body); text-align: center; text-decoration: none; cursor: pointer;
  }
  .button.light { --button-rest: var(--c-base); --button-ink: var(--c-ink); --button-hover: #fff; }
  .button:hover { --button-fill: var(--button-hover); }
  .button[aria-disabled="true"], .button:disabled { --button-fill: #e7e4ec; color: var(--c-muted); cursor: not-allowed; }
  .button svg { width: 20px; height: 20px; flex: none; }
  .actions { display: flex; flex-direction: column; align-items: stretch; gap: var(--space-3); }
  @media (min-width: 560px) { .actions { flex-direction: row; flex-wrap: wrap; align-items: center; } }

  .text-link { display: inline-flex; align-items: center; gap: .375rem; min-height: 44px; font-weight: 600; color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }
  .text-link:hover { text-decoration-thickness: 2px; }
  .text-link svg { width: 20px; height: 20px; flex: none; }

  /* Espaço reservado: informação que a igreja ainda vai confirmar. */
  .pending { display: inline-block; min-width: 7rem; min-height: 1.5em; border-bottom: 1px solid currentColor; opacity: .6; }

  /* Lugar de foto enquanto as imagens não chegam: mesma proporção e moldura da foto final. */
  .media-slot { position: relative; display: grid; place-items: center; overflow: hidden; aspect-ratio: var(--ratio, 4 / 3); border: 2px solid transparent; border-radius: var(--radius); background: linear-gradient(140deg, var(--surface-1-mix), var(--surface-2-mix) 55%, var(--surface-3-mix)) padding-box, var(--brand-gradient) border-box; color: color-mix(in srgb, var(--c-ink) 45%, transparent); }
  .media-slot svg { width: 30%; max-width: 120px; opacity: .55; }
  .editorial-photo { width: 100%; aspect-ratio: var(--ratio, 4 / 3); object-fit: cover; border: 2px solid transparent; border-radius: var(--radius); background: var(--brand-gradient) border-box; }

  /* Card: fundo quase branco, linha fina e sombra quase invisível. */
  .card { min-width: 0; padding: var(--space-5); background: var(--surface-card); border: 1px solid var(--line-ink); border-radius: var(--radius); box-shadow: var(--shadow-soft); }
  .card.has-accent { border-top: 4px solid var(--accent, var(--c-1)); }
  .card > * + * { margin-top: var(--space-3); }

  /* Tríade em sequência: folha, uva, luz. */
  .triad > :nth-child(3n + 1) { --accent: var(--c-1); --accent-soft: var(--c-1-soft); }
  .triad > :nth-child(3n + 2) { --accent: var(--c-2); --accent-soft: var(--c-2-soft); }
  .triad > :nth-child(3n + 3) { --accent: var(--c-3); --accent-soft: var(--c-3-soft); }

  /* Texto e imagem: uma coluna no celular, colunas desiguais a partir do tablet. */
  .split { display: grid; gap: var(--space-6); align-items: center; }
  .split > * { min-width: 0; }
  @media (min-width: 900px) {
    .split { grid-template-columns: .9fr 1.1fr; gap: clamp(48px, 6vw, 96px); }
    .split.is-reversed > :first-child { order: 2; }
    .split:not(:has(figure)) { display: block; }
    .split:not(:has(figure)) > * { max-width: 780px; }
  }

  /* Ornamento: o símbolo da Videira recortado em máscara, com o degradê da marca, pequeno e girado. */
  .ornament { position: absolute; z-index: 2; pointer-events: none; aspect-ratio: 313 / 346; background: var(--tint, var(--brand-gradient)); -webkit-mask: url('../img/marca/videira-simbolo.png') center / contain no-repeat; mask: url('../img/marca/videira-simbolo.png') center / contain no-repeat; transform: rotate(var(--turn, -8deg)); }
  /* Ornamento com arte própria (por exemplo, o R do Radicais Kids), sem máscara. */
  .ornament-art { background: none; -webkit-mask: none; mask: none; height: auto; aspect-ratio: auto; }

  /* Curvas entre seções: o preenchimento é a cor da seção seguinte. */
  .wave { display: block; width: 100%; height: clamp(48px, 7vw, 96px); pointer-events: none; }

  /* Capa interna: faixa escura com título; recebe a foto quando ela chegar. */
  .page-hero { position: relative; isolation: isolate; overflow: clip; padding: 140px 0 clamp(96px, 14vw, 170px); background: radial-gradient(120% 90% at 85% 10%, var(--hero-glow) 0, var(--c-ink) 60%); color: var(--c-base); --focus-ring: var(--c-base); }
  .page-hero > .hero-photo { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; filter: brightness(.7); }
  /* Com foto, o véu escurece o lado do texto e deixa o resto respirar. */
  .page-hero:has(.hero-photo)::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, #1b2134e6 0, #1b2134b8 60%, #1b213499 100%); }
  @media (min-width: 900px) { .page-hero:has(.hero-photo)::after { background: linear-gradient(90deg, #1b2134f0 0, #1b2134c2 40%, #1b213459 100%); } }
  .page-hero h1 { font-size: var(--text-page-title); max-width: 16ch; }
  .page-hero .lead { margin-top: var(--space-4); max-width: 46ch; color: var(--on-dark-muted); }
  .page-hero .wave { position: absolute; bottom: -1px; left: 0; z-index: 1; fill: var(--surface-page); }
  .page-hero .ornament { right: var(--gutter); bottom: 40px; width: clamp(72px, 14vw, 150px); }
  @media (min-width: 1024px) { .page-hero { padding-top: 180px; } }

  /* Cabeçalho de seção: título com uma frase curta abaixo. */
  .section-heading { margin-bottom: var(--space-6); }
  .section-heading p { margin-top: var(--space-3); }

  /* Rodapé escuro e compacto. */
  /* Sobreposição de 1px esconde a emenda entre a curva e o rodapé. */
  .site-footer { margin-top: -1px; padding-top: var(--space-7); }
  .footer-main { display: grid; gap: var(--space-6); padding-bottom: var(--space-6); }
  .footer-main p { margin-top: var(--space-3); color: var(--on-dark-muted); font-size: var(--text-small); }
  .footer-label { display: block; margin-bottom: var(--space-2); color: var(--on-dark-muted); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
  .footer-nav ul, .footer-contact ul { list-style: none; }
  .footer-nav a, .footer-contact a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: inherit; text-decoration: none; }
  .footer-nav a:hover, .footer-contact a:hover { color: var(--c-1-soft); }
  .footer-contact svg { width: 20px; height: 20px; flex: none; }
  /* Várias redes na mesma linha do rodapé, quebrando quando faltar espaço. */
  .footer-contact li:last-child { display: flex; flex-wrap: wrap; column-gap: var(--space-5); }
  .footer-contact li:last-child .footer-label { flex-basis: 100%; }
  .footer-bottom { display: flex; flex-direction: column; gap: var(--space-2); padding-block: var(--space-4) var(--space-6); border-top: 1px solid color-mix(in srgb, var(--c-base) 22%, transparent); color: var(--on-dark-muted); font-size: .8125rem; }
  .footer-bottom a { color: var(--c-base); font-weight: 600; text-underline-offset: 3px; }
  @media (min-width: 768px) {
    .footer-main { grid-template-columns: 1.2fr 1fr 1fr; align-items: start; }
    .footer-bottom { flex-direction: row; justify-content: space-between; }
  }

  /* Voltar ao topo: círculo fixo, aparece depois de rolar. */
  .back-to-top { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 20; width: 48px; height: 48px; min-height: 48px; padding: 0; border-radius: 50%; box-shadow: 0 4px 16px color-mix(in srgb, var(--c-ink) 18%, transparent); }
  @media (min-width: 768px) { .back-to-top { right: 24px; bottom: 24px; width: 52px; height: 52px; } }
}

@layer motion {
  /* Movimento liberado peça por peça. */
  .button { transition: box-shadow var(--duration) ease, translate var(--duration) ease; }
  .button:not(:disabled):not([aria-disabled="true"]):hover { translate: 0 -2px; box-shadow: var(--shadow-lift); }
  .button:not(:disabled):active { translate: 0 0; box-shadow: none; }
  .main-nav a::after { transition: transform 240ms ease; }

  /* Entrada breve na rolagem, uma vez, só abaixo da dobra. */
  .reveal { opacity: 0; translate: 0 20px; transition: opacity .6s ease var(--reveal-delay, 0ms), translate .6s var(--ease-reveal) var(--reveal-delay, 0ms); }
  .reveal.is-revealed { opacity: 1; translate: 0 0; }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
    .button:hover { translate: none; }
    .reveal { opacity: 1; translate: none; }
  }
  @media print { .reveal { opacity: 1; translate: none; } }
}
