/* ============================================================
   Dr. Ruimário Coelho · base.css
   Reset, tokens da marca, tipografia, botões, navbar, footer
   Paleta oficial: petróleo #0D252D / #183846, off-white #E0E4DF,
   cinzas #4C5156 / #5D6166, branco.
   ============================================================ */
@layer reset, tokens, base, components, utilities;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { -webkit-text-size-adjust: 100%; }
  body { min-height: 100dvh; line-height: 1.55; -webkit-font-smoothing: antialiased; }
  img, video, iframe { max-width: 100%; display: block; }
  input, button, textarea, select { font: inherit; }
  p, h1, h2, h3, h4 { overflow-wrap: break-word; }
  a { color: inherit; }
  ul[role="list"], ol[role="list"] { list-style: none; }
  button { background: none; border: none; cursor: pointer; color: inherit; }
}

@layer tokens {
  :root {
    /* Paleta da marca */
    --ink: #0D252D;
    --ink-deep: #081A20;
    --petrol: #183846;
    --petrol-soft: #1E4254;
    --slate: #4C5156;
    --gray: #5D6166;
    --paper: #E0E4DF;
    --paper-dim: #B9C2BD;
    --white: #FFFFFF;
    --accent: #6E9AA6;      /* petróleo claro, interações em fundo escuro */
    --accent-soft: #8FB3BC;
    --accent-deep: #2C5B6B; /* petróleo médio, interações em fundo claro */
    --wa: #25D366;

    /* Base clara (pedido 16/07: site estava escuro demais) */
    --light-bg: #EFF2EE;        /* off-white da paleta, clareado para page bg */
    --light-bg-2: #E0E4DF;      /* off-white oficial, para faixas alternadas */
    --light-card: #FFFFFF;
    --light-line: rgba(13, 37, 45, 0.1);
    --light-text: #3E464B;      /* cinza da paleta para corpo de texto */

    /* Tipografia fluida */
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --text-xs: clamp(0.72rem, 0.68rem + 0.2vw, 0.8rem);
    --text-sm: clamp(0.85rem, 0.8rem + 0.25vw, 0.95rem);
    --text-base: clamp(1rem, 0.94rem + 0.3vw, 1.125rem);
    --text-lg: clamp(1.125rem, 1rem + 0.6vw, 1.375rem);
    --text-xl: clamp(1.35rem, 1.1rem + 1.2vw, 1.9rem);
    --text-2xl: clamp(1.7rem, 1.2rem + 2.4vw, 2.7rem);
    --text-3xl: clamp(2.1rem, 1.4rem + 3.6vw, 3.6rem);
    --text-hero: clamp(2.5rem, 1.4rem + 5.6vw, 5.4rem);

    /* Espaçamento */
    --space-2: clamp(0.5rem, 0.4rem + 0.5vw, 0.75rem);
    --space-4: clamp(1rem, 0.8rem + 1vw, 1.5rem);
    --space-8: clamp(2rem, 1.5rem + 2.5vw, 3.5rem);
    --space-16: clamp(4.5rem, 3rem + 6vw, 8.5rem);

    --radius-sm: 6px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --radius-full: 100px;

    --shadow-md: 0 10px 30px -10px rgba(8, 26, 32, 0.5);
    --shadow-lg: 0 30px 80px -20px rgba(8, 26, 32, 0.65);

    --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    --nav-h: 76px;
  }
}

@layer base {
  html { scroll-behavior: smooth; }
  @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

  body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: 300;
    color: var(--paper);
    background: var(--ink);
  }

  ::selection { background: var(--accent); color: var(--ink-deep); }

  h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 400;
    line-height: 1.08;
    letter-spacing: -0.015em;
    text-wrap: balance;
    color: var(--white);
  }
  h4, h5 { color: var(--white); }
  p { text-wrap: pretty; max-width: 62ch; }
  em { font-style: italic; }
  strong { font-weight: 600; color: var(--white); }

  .container {
    width: 100%;
    max-width: 1320px;
    margin-inline: auto;
    padding-inline: clamp(1.25rem, 5vw, 4rem);
  }

  section { position: relative; }

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

  .skip-link {
    position: absolute; top: -60px; left: 1rem; z-index: 200;
    background: var(--white); color: var(--ink);
    padding: 0.6rem 1.2rem; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    font-weight: 600; text-decoration: none;
    transition: top 0.25s ease;
  }
  .skip-link:focus { top: 0; }

  .section-eyebrow {
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--accent-soft);
    margin-bottom: var(--space-2);
    display: flex; align-items: center; gap: 0.75rem;
  }
  .section-eyebrow::before {
    content: ''; width: 34px; height: 1px; background: var(--accent);
    display: inline-block; flex-shrink: 0;
  }

  .section-title {
    font-size: var(--text-3xl);
    margin-bottom: var(--space-4);
  }
  .section-title em { color: var(--accent-soft); }

  /* ---------- Contexto claro: seções sobre off-white ---------- */
  .light {
    background: var(--light-bg);
    color: var(--light-text);
  }
  .light h1, .light h2, .light h3, .light h4 { color: var(--ink); }
  .light strong { color: var(--ink); }
  .light .section-eyebrow { color: var(--accent-deep); }
  .light .section-eyebrow::before { background: var(--accent-deep); }
  .light .section-title em { color: var(--accent-deep); }
  .light ::selection { background: var(--petrol); color: var(--white); }
}

@layer components {
  /* ---------- Botões ---------- */
  .btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.6rem;
    padding: 0.8rem 1.9rem;
    font-size: var(--text-sm);
    font-weight: 500;
    letter-spacing: 0.02em;
    line-height: 1;
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    min-height: 46px;
    position: relative;
    transition: transform 0.25s var(--ease-spring), box-shadow 0.25s ease,
                background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  }
  .btn:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 3px; }
  .btn:active { transform: scale(0.97); }

  .btn--primary {
    background: var(--wa); color: #06281a;
    font-weight: 600;
    box-shadow: 0 6px 22px -6px rgba(37, 211, 102, 0.45);
  }
  .btn--primary:hover {
    background: #2fe273;
    transform: translateY(-2px);
    box-shadow: 0 12px 30px -8px rgba(37, 211, 102, 0.55);
  }

  .btn--outline {
    background: transparent; color: var(--paper);
    border-color: rgba(224, 228, 223, 0.35);
  }
  .btn--outline:hover {
    border-color: var(--accent-soft); color: var(--white);
    background: rgba(110, 154, 166, 0.1);
    transform: translateY(-2px);
  }

  .btn--ghost { background: transparent; color: var(--paper-dim); }
  .btn--ghost:hover { color: var(--white); transform: translateY(-2px); }
  .btn--ghost::after {
    content: ''; position: absolute; left: 1.9rem; right: 1.9rem; bottom: 0.55rem;
    height: 1px; background: currentColor; opacity: 0.4;
    transform: scaleX(0.6); transform-origin: left;
    transition: transform 0.3s var(--ease-smooth), opacity 0.3s ease;
  }
  .btn--ghost:hover::after { transform: scaleX(1); opacity: 0.9; }

  .btn--light {
    background: var(--paper); color: var(--ink);
    font-weight: 600;
  }
  .btn--light:hover { background: var(--white); transform: translateY(-2px); box-shadow: var(--shadow-md); }

  .btn--sm { padding: 0.55rem 1.3rem; min-height: 38px; font-size: var(--text-xs); }
  .btn--lg { padding: 1rem 2.3rem; min-height: 54px; font-size: var(--text-base); }
  .btn--xl { padding: 1.15rem 2.8rem; min-height: 60px; font-size: var(--text-lg); }
  .btn--full { width: 100%; }

  /* ---------- Navbar ---------- */
  .navbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    transition: background-color 0.3s ease, border-color 0.3s ease, backdrop-filter 0.3s ease;
    border-bottom: 1px solid transparent;
  }
  .navbar.scrolled {
    background: rgba(8, 26, 32, 0.82);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border-bottom-color: rgba(224, 228, 223, 0.08);
  }
  /* Páginas internas (fundo claro): navbar escura sempre, mesmo no topo */
  body.light .navbar {
    background: rgba(8, 26, 32, 0.92);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border-bottom-color: rgba(224, 228, 223, 0.08);
  }

  .navbar__inner {
    max-width: 1320px; margin-inline: auto;
    padding: 0.9rem clamp(1.25rem, 5vw, 4rem);
    display: flex; align-items: center; gap: 2rem;
    min-height: var(--nav-h);
  }

  .navbar__brand {
    display: flex; align-items: center; gap: 0.9rem;
    text-decoration: none; margin-right: auto;
  }
  .navbar__brand img { width: 44px; height: 44px; }
  .navbar__name {
    font-family: var(--font-display);
    font-size: 1.05rem; color: var(--white); line-height: 1.15;
    display: flex; flex-direction: column;
  }
  .navbar__name em { color: var(--accent-soft); font-style: italic; display: inline; }
  .navbar__name small {
    font-family: var(--font-body); font-size: 0.62rem; font-weight: 400;
    letter-spacing: 0.14em; text-transform: uppercase; color: var(--gray);
    margin-top: 2px;
  }

  .navbar__links { display: flex; gap: 1.8rem; }
  .navbar__links a {
    font-size: var(--text-sm); font-weight: 400; color: var(--paper-dim);
    text-decoration: none; position: relative; padding-block: 0.3rem;
    transition: color 0.2s ease;
  }
  .navbar__links a::after {
    content: ''; position: absolute; left: 0; bottom: 0;
    width: 100%; height: 1px; background: var(--accent-soft);
    transform: scaleX(0); transform-origin: right;
    transition: transform 0.35s var(--ease-smooth);
  }
  .navbar__links a:hover { color: var(--white); }
  .navbar__links a:hover::after { transform: scaleX(1); transform-origin: left; }

  .navbar__burger {
    display: none; flex-direction: column; gap: 6px;
    padding: 10px; margin: -10px;
  }
  .navbar__burger span {
    width: 26px; height: 1.5px; background: var(--paper);
    transition: transform 0.3s var(--ease-smooth), opacity 0.3s ease;
  }
  .navbar__burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(3.75px) rotate(45deg); }
  .navbar__burger[aria-expanded="true"] span:nth-child(2) { transform: translateY(-3.75px) rotate(-45deg); }

  .navbar__mobile {
    display: none;
    background: rgba(8, 26, 32, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(224, 228, 223, 0.08);
    max-height: 0; overflow: hidden;
    transition: max-height 0.45s var(--ease-smooth);
  }
  .navbar__mobile.open { max-height: 420px; }
  .navbar__mobile ul { padding: 1rem clamp(1.25rem, 5vw, 4rem) 1.5rem; display: grid; gap: 0.4rem; }
  .navbar__mobile a:not(.btn) {
    display: block; padding: 0.7rem 0; text-decoration: none;
    color: var(--paper); font-size: var(--text-lg);
    font-family: var(--font-display);
    border-bottom: 1px solid rgba(224, 228, 223, 0.07);
  }
  .navbar__mobile .btn { margin-top: 0.9rem; }

  /* ---------- Footer ---------- */
  .footer {
    background: var(--ink-deep);
    border-top: 1px solid rgba(224, 228, 223, 0.07);
    padding-block: var(--space-8) var(--space-4);
  }
  .footer__grid {
    display: grid; gap: var(--space-8);
    grid-template-columns: 1.2fr 0.8fr 1fr;
    padding-bottom: var(--space-8);
  }
  .footer__brand img { margin-bottom: 1rem; opacity: 0.9; }
  .footer__brand p { font-size: var(--text-sm); color: var(--paper-dim); }
  .footer__nav ul { display: grid; gap: 0.5rem; }
  .footer__nav a, .footer__contact a {
    color: var(--paper-dim); text-decoration: none; font-size: var(--text-sm);
    transition: color 0.2s ease;
  }
  .footer__nav a:hover, .footer__contact a:hover { color: var(--white); }
  .footer__contact { display: grid; gap: 0.5rem; align-content: start; }
  .footer__contact address {
    font-style: normal; font-size: var(--text-xs); color: var(--gray);
    margin-top: 0.75rem; line-height: 1.7;
  }
  .footer__legal {
    border-top: 1px solid rgba(224, 228, 223, 0.07);
    padding-top: var(--space-4);
    display: flex; flex-wrap: wrap; gap: 0.5rem 2rem;
    justify-content: space-between;
  }
  .footer__legal p { font-size: var(--text-xs); color: var(--gray); }

  /* ---------- WhatsApp float ---------- */
  .whatsapp-float {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    width: 58px; height: 58px;
    background: var(--wa); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4);
    z-index: 90;
    transition: transform 0.3s var(--ease-spring), box-shadow 0.3s ease;
  }
  .whatsapp-float:hover { transform: scale(1.1); }
  /* Pulse por transform/opacity num anel próprio: roda no compositor,
     sem repintar box-shadow a cada frame */
  .whatsapp-float::after {
    content: ''; position: absolute; inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(37, 211, 102, 0.55);
    animation: whatsapp-ring 2.6s ease-out infinite;
    pointer-events: none;
  }
  @keyframes whatsapp-ring {
    0% { transform: scale(1); opacity: 0.8; }
    70%, 100% { transform: scale(1.55); opacity: 0; }
  }
  @media (prefers-reduced-motion: reduce) { .whatsapp-float::after { animation: none; } }

  /* ---------- Sticky CTA mobile ---------- */
  .sticky-cta {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 80;
    background: rgba(8, 26, 32, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(224, 228, 223, 0.1);
    padding: 0.7rem 1.25rem calc(0.7rem + env(safe-area-inset-bottom));
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    transform: translateY(110%);
    transition: transform 0.4s var(--ease-smooth);
  }
  .sticky-cta.visible { transform: translateY(0); }
  .sticky-cta p { font-size: var(--text-sm); color: var(--paper); font-weight: 500; }
  @media (min-width: 64em) { .sticky-cta { display: none; } }

  /* ---------- Reading progress ---------- */
  .reading-progress {
    position: fixed; top: 0; left: 0; z-index: 110;
    height: 2px; width: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-soft));
  }

  /* ---------- Preloader ---------- */
  .preloader {
    position: fixed; inset: 0; z-index: 300;
    background: var(--ink-deep);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.6rem;
    transition: opacity 0.6s ease, visibility 0.6s ease;
  }
  .preloader.done { opacity: 0; visibility: hidden; }
  .preloader__logo { width: 72px; height: auto; animation: preloader-breathe 1.6s ease-in-out infinite; }
  .preloader__bar {
    width: 132px; height: 1px; background: rgba(224, 228, 223, 0.15);
    overflow: hidden; border-radius: 2px;
  }
  .preloader__bar span {
    display: block; height: 100%; width: 40%;
    background: var(--accent-soft);
    animation: preloader-slide 1.1s var(--ease-smooth) infinite;
  }
  @keyframes preloader-breathe { 0%,100% { opacity: 0.75; transform: scale(1); } 50% { opacity: 1; transform: scale(1.04); } }
  @keyframes preloader-slide { from { transform: translateX(-140%); } to { transform: translateX(340%); } }

  /* ---------- Cursor customizado (desktop) ---------- */
  @media (hover: hover) and (pointer: fine) {
    .cursor { position: fixed; top: 0; left: 0; z-index: 9999; pointer-events: none; }
    .cursor__dot {
      width: 7px; height: 7px; background: var(--accent-soft); border-radius: 50%;
      position: absolute; transform: translate(-50%, -50%);
    }
    .cursor__ring {
      width: 34px; height: 34px;
      border: 1px solid rgba(143, 179, 188, 0.6);
      border-radius: 50%; position: absolute;
      transform: translate(-50%, -50%);
      transition: width 0.3s var(--ease-smooth), height 0.3s var(--ease-smooth), opacity 0.3s ease;
      opacity: 0.55;
    }
    .cursor.hovering .cursor__ring { width: 52px; height: 52px; opacity: 0.9; }
  }
  @media (hover: none), (pointer: coarse) { .cursor { display: none; } }
}

@layer utilities {
  /* Grain sutil */
  .grain::before {
    content: ''; position: absolute; inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    opacity: 0.028;
    pointer-events: none;
    z-index: 1;
  }

  /* Reveal padrão (fallback JS via IntersectionObserver) */
  [data-animate] {
    opacity: 0; transform: translateY(26px);
    transition: opacity 0.85s var(--ease-smooth), transform 0.85s var(--ease-smooth);
  }
  [data-animate].visible { opacity: 1; transform: none; }

  [data-animate-stagger] > * {
    opacity: 0; transform: translateY(22px);
    transition: opacity 0.65s var(--ease-smooth), transform 0.65s var(--ease-smooth);
  }
  [data-animate-stagger].visible > * { opacity: 1; transform: none; }
  [data-animate-stagger].visible > *:nth-child(1) { transition-delay: 0.05s; }
  [data-animate-stagger].visible > *:nth-child(2) { transition-delay: 0.13s; }
  [data-animate-stagger].visible > *:nth-child(3) { transition-delay: 0.21s; }
  [data-animate-stagger].visible > *:nth-child(4) { transition-delay: 0.29s; }
  [data-animate-stagger].visible > *:nth-child(5) { transition-delay: 0.37s; }
  [data-animate-stagger].visible > *:nth-child(6) { transition-delay: 0.45s; }
  [data-animate-stagger].visible > *:nth-child(7) { transition-delay: 0.53s; }
  [data-animate-stagger].visible > *:nth-child(8) { transition-delay: 0.61s; }

  @media (prefers-reduced-motion: reduce) {
    [data-animate], [data-animate-stagger] > * {
      opacity: 1 !important; transform: none !important; transition: none !important;
    }
    .whatsapp-float, .preloader__logo, .preloader__bar span { animation: none !important; }
  }

  /* Modo sem animação (reduced motion, GSAP ausente ou ?static=1) */
  html.no-motion { scroll-behavior: auto; }
  html.no-motion [data-animate],
  html.no-motion [data-animate-stagger] > * {
    opacity: 1 !important; transform: none !important; transition: none !important;
  }
  html.no-motion .ticker__track { animation: none !important; }
  html.no-motion .hero__glow, html.no-motion .hero__scrollhint svg { animation: none !important; }
}
