/* ==========================================================================
   Livelo do Zero — sistema de design
   CSS moderno puro: custom properties, nesting nativo, clamp(), :has()
   Sem nenhuma dependência externa.
   ========================================================================== */

@layer reset, tokens, base, layout, components, utils;

/* ---------- reset ---------- */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; }
  img, svg, video { display: block; max-width: 100%; height: auto; }
  input, button, textarea, select { font: inherit; color: inherit; }
  p, h1, h2, h3, h4, li { overflow-wrap: break-word; }
  :target { scroll-margin-top: 6rem; }
}

/* ---------- tokens ---------- */
@layer tokens {
  :root {
    color-scheme: light;

    /* marca */
    --ink:        #12123a;
    --ink-2:      #3a3a63;
    --ink-3:      #6b6b8f;
    --brand:      #d81b74;
    --brand-dark: #a8125a;
    --brand-soft: #fde8f2;
    --gold:       #f5a623;
    --gold-soft:  #fff5e2;
    --sky:        #2563eb;
    --green:      #0f9d58;

    /* superfícies */
    --bg:        #ffffff;
    --bg-alt:    #f8f7fc;
    --bg-deep:   #12123a;
    --line:      #e6e4f0;
    --line-soft: #f0eef7;

    /* tipografia fluida */
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --fs-hero:  clamp(2rem, 1.35rem + 3.1vw, 3.5rem);
    --fs-h2:    clamp(1.5rem, 1.24rem + 1.25vw, 2.25rem);
    --fs-h3:    clamp(1.19rem, 1.08rem + 0.5vw, 1.5rem);
    --fs-body:  clamp(1.0625rem, 1.03rem + 0.16vw, 1.1875rem);
    --fs-sm:    0.9375rem;
    --fs-xs:    0.8125rem;

    /* ritmo */
    --gap:      clamp(1rem, 0.7rem + 1.5vw, 2rem);
    --section:  clamp(3rem, 2.2rem + 4vw, 5.5rem);
    --measure:  68ch;
    --wrap:     1140px;

    --radius:    14px;
    --radius-lg: 22px;
    --shadow:    0 1px 2px rgb(18 18 58 / 0.06), 0 8px 24px -8px rgb(18 18 58 / 0.12);
    --shadow-lg: 0 2px 4px rgb(18 18 58 / 0.06), 0 24px 48px -16px rgb(18 18 58 / 0.22);
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      color-scheme: dark;
      --ink:        #f2f1f9;
      --ink-2:      #c6c4dd;
      --ink-3:      #9a97ba;
      --brand:      #ff5fa2;
      --brand-dark: #ff85b8;
      --brand-soft: #2c1327;
      --gold:       #ffc061;
      --gold-soft:  #2e2413;
      --sky:        #7fa6ff;
      --green:      #4ade80;
      --bg:        #0e0e26;
      --bg-alt:    #16163a;
      --bg-deep:   #08081a;
      --line:      #2a2a52;
      --line-soft: #1e1e44;
      --shadow:    0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px -8px rgb(0 0 0 / 0.6);
      --shadow-lg: 0 2px 4px rgb(0 0 0 / 0.4), 0 24px 48px -16px rgb(0 0 0 / 0.7);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }
}

/* ---------- base ---------- */
@layer base {
  html { scroll-behavior: smooth; }

  body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: var(--fs-body);
    line-height: 1.7;
    text-rendering: optimizeLegibility;
    padding-bottom: env(safe-area-inset-bottom);
  }

  h1, h2, h3, h4 {
    line-height: 1.18;
    letter-spacing: -0.02em;
    font-weight: 800;
    text-wrap: balance;
  }
  h1 { font-size: var(--fs-hero); }
  h2 { font-size: var(--fs-h2); }
  h3 { font-size: var(--fs-h3); font-weight: 700; }

  p { text-wrap: pretty; }

  a {
    color: var(--brand);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;

    &:hover { color: var(--brand-dark); }
  }

  strong { font-weight: 700; color: var(--ink); }

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

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

/* ---------- layout ---------- */
@layer layout {
  .wrap {
    width: min(100% - 2 * var(--gap), var(--wrap));
    margin-inline: auto;
  }

  .prose {
    width: min(100%, var(--measure));

    & > * + * { margin-block-start: 1.15em; }
    & > h2 { margin-block-start: 2.2em; }
    & > h3 { margin-block-start: 1.8em; }

    & ul, & ol {
      padding-inline-start: 1.35em;
      display: grid;
      gap: 0.6em;
    }
    & li::marker { color: var(--brand); font-weight: 700; }
  }

  section[id] { scroll-margin-top: 5rem; }

  .section { padding-block: var(--section); }
  .section--alt { background: var(--bg-alt); }
  .section--deep {
    background: var(--bg-deep);
    color: #fff;

    & h2, & h3, & strong { color: #fff; }
    & p { color: #cfceea; }
  }
}

/* ---------- componentes ---------- */
@layer components {

  /* ---- skip link ---- */
  .skip {
    position: absolute;
    inset-inline-start: -9999px;
    top: 0;
    z-index: 100;
    background: var(--ink);
    color: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: 0 0 var(--radius) 0;

    &:focus { inset-inline-start: 0; color: #fff; }
  }

  /* ---- cabeçalho ---- */
  .site-head {
    position: sticky;
    top: 0;
    z-index: 40;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-block-end: 1px solid var(--line);

    & > .wrap {
      display: flex;
      align-items: center;
      gap: var(--gap);
      min-height: 4rem;
    }
  }

  .brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--ink);
    text-decoration: none;
    font-size: 1.0625rem;

    & .brand__mark {
      display: grid;
      place-items: center;
      inline-size: 2rem;
      block-size: 2rem;
      border-radius: 9px;
      background: linear-gradient(135deg, var(--brand), var(--gold));
      color: #fff;
      flex: none;
    }
    & em { font-style: normal; color: var(--brand); }
  }

  .nav {
    margin-inline-start: auto;
    display: flex;
    align-items: center;
    gap: 1.25rem;

    /* :not(.btn) para não sobrescrever a cor do botão de CTA */
    & a:not(.btn) {
      color: var(--ink-2);
      text-decoration: none;
      font-size: var(--fs-sm);
      font-weight: 600;

      &:hover { color: var(--brand); }
    }

    & .btn {
      margin-inline-start: 0.5rem;
      padding: 0.62rem 1.25rem;
      font-size: var(--fs-sm);
    }

    @media (width < 900px) { display: none; }
  }

  /* ---- botões ---- */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 0.95rem 1.6rem;
    border: 0;
    border-radius: 999px;
    font-weight: 700;
    font-size: 1.0625rem;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;

    &:hover { transform: translateY(-2px); }
    &:active { transform: translateY(0); }
  }

  .btn--cta {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    box-shadow: 0 8px 20px -6px color-mix(in srgb, var(--brand) 70%, transparent);

    &:hover { color: #fff; box-shadow: 0 14px 28px -8px color-mix(in srgb, var(--brand) 80%, transparent); }
  }

  .btn--ghost {
    background: transparent;
    color: var(--ink);
    box-shadow: inset 0 0 0 2px var(--line);

    &:hover { color: var(--brand); box-shadow: inset 0 0 0 2px var(--brand); }
  }

  .btn--lg { padding: 1.1rem 2.1rem; font-size: 1.125rem; }
  .btn--block { inline-size: 100%; }

  /* ---- hero ---- */
  .hero {
    position: relative;
    padding-block: clamp(2.5rem, 1.6rem + 4.5vw, 5rem) var(--section);
    background:
      radial-gradient(60rem 30rem at 15% -10%, var(--brand-soft), transparent 60%),
      radial-gradient(50rem 26rem at 95% 0%, var(--gold-soft), transparent 55%);

    & > .wrap {
      display: grid;
      gap: clamp(2rem, 1rem + 4vw, 3.5rem);
      align-items: center;
      grid-template-columns: 1fr;

      @media (width >= 960px) { grid-template-columns: 1.15fr 0.85fr; }
    }
  }

  .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg);
    color: var(--brand);
    border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .hero__lead {
    font-size: clamp(1.125rem, 1.05rem + 0.35vw, 1.3125rem);
    color: var(--ink-2);
    margin-block-start: 1.15rem;
    max-inline-size: 56ch;
  }

  .hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    margin-block-start: 2rem;
  }

  .hero__trust {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-block-start: 1.5rem;
    font-size: var(--fs-sm);
    color: var(--ink-3);

    & span {
      display: inline-flex;
      align-items: center;
      gap: 0.4rem;
    }
    & svg { color: var(--green); flex: none; }
  }

  /* ---- card de oferta ---- */
  .offer {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem);
    box-shadow: var(--shadow-lg);
    text-align: center;
    position: relative;
    overflow: hidden;

    &::before {
      content: "";
      position: absolute;
      inset-block-start: 0;
      inset-inline: 0;
      block-size: 5px;
      background: linear-gradient(90deg, var(--brand), var(--gold));
    }
  }

  .offer__title {
    font-size: var(--fs-h3);
    margin-block-end: 0.75rem;
  }

  .offer__price {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.4rem;
    margin-block: 1rem;

    & b {
      font-size: clamp(2.25rem, 1.8rem + 2vw, 3rem);
      font-weight: 800;
      letter-spacing: -0.04em;
      color: var(--ink);
      line-height: 1;
    }
    & small { color: var(--ink-3); font-size: var(--fs-sm); }
  }

  .offer__list {
    text-align: start;
    display: grid;
    gap: 0.65rem;
    margin-block: 1.35rem;
    padding: 0;
    list-style: none;
    font-size: var(--fs-sm);

    & li {
      display: grid;
      grid-template-columns: 1.15rem 1fr;
      gap: 0.6rem;
      align-items: start;
      color: var(--ink-2);
    }
    & svg { color: var(--green); margin-block-start: 0.28rem; }
  }

  .offer__note {
    font-size: var(--fs-xs);
    color: var(--ink-3);
    margin-block-start: 0.9rem;
  }

  /* ---- caixas de conteúdo ---- */
  .cards {
    display: grid;
    gap: var(--gap);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
    margin-block-start: 2.5rem;
  }

  .card {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);

    & h3 { margin-block-end: 0.55rem; }
    & p { color: var(--ink-2); font-size: var(--fs-sm); }
  }

  .card__icon {
    display: grid;
    place-items: center;
    inline-size: 2.75rem;
    block-size: 2.75rem;
    border-radius: 12px;
    background: var(--brand-soft);
    color: var(--brand);
    margin-block-end: 1rem;
  }

  /* passos numerados */
  .steps {
    counter-reset: step;
    display: grid;
    gap: 1rem;
    margin-block-start: 2.5rem;
    padding: 0;
    list-style: none;
  }

  .steps li {
    counter-increment: step;
    display: grid;
    grid-template-columns: 2.75rem 1fr;
    gap: 1rem;
    align-items: start;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem;

    &::before {
      content: counter(step);
      display: grid;
      place-items: center;
      inline-size: 2.75rem;
      block-size: 2.75rem;
      border-radius: 50%;
      background: linear-gradient(135deg, var(--brand), var(--brand-dark));
      color: #fff;
      font-weight: 800;
    }
    & strong { display: block; margin-block-end: 0.2rem; }
    & p { color: var(--ink-2); font-size: var(--fs-sm); }
  }

  /* destaque / aviso */
  .callout {
    border-inline-start: 4px solid var(--gold);
    background: var(--gold-soft);
    padding: 1.15rem 1.35rem;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: var(--fs-sm);
    color: var(--ink-2);

    & strong { color: var(--ink); }
  }

  /* tabela responsiva */
  .table-scroll {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-block-start: 1.5rem;
  }

  table {
    inline-size: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
    min-inline-size: 34rem;

    & th, & td {
      text-align: start;
      padding: 0.85rem 1rem;
      border-block-end: 1px solid var(--line-soft);
    }
    & th {
      background: var(--bg-alt);
      font-weight: 700;
      color: var(--ink);
      white-space: nowrap;
    }
    & td { color: var(--ink-2); }
    & tr:last-child td { border-block-end: 0; }
  }

  /* ---- FAQ ---- */
  .faq {
    display: grid;
    gap: 0.75rem;
    margin-block-start: 2rem;
  }

  .faq details {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg);
    overflow: hidden;

    &[open] {
      border-color: color-mix(in srgb, var(--brand) 40%, transparent);
      box-shadow: var(--shadow);
    }
  }

  .faq summary {
    cursor: pointer;
    padding: 1.1rem 1.35rem;
    font-weight: 700;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 0.9rem;
    list-style: none;

    &::-webkit-details-marker { display: none; }

    &::after {
      content: "";
      margin-inline-start: auto;
      inline-size: 0.6rem;
      block-size: 0.6rem;
      border-inline-end: 2.5px solid var(--brand);
      border-block-end: 2.5px solid var(--brand);
      rotate: 45deg;
      transition: rotate 0.2s ease;
      flex: none;
    }
    &:hover { color: var(--brand); }
  }

  .faq details[open] summary::after { rotate: -135deg; }

  .faq .faq__body {
    padding: 0 1.35rem 1.25rem;
    color: var(--ink-2);
    font-size: var(--fs-sm);

    & > * + * { margin-block-start: 0.8em; }
  }

  /* ---- bloco CTA ---- */
  .cta-band {
    background: linear-gradient(135deg, var(--bg-deep), #2a1a45 60%, #4a1338);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: clamp(1.75rem, 1.2rem + 2.6vw, 3rem);
    text-align: center;
    box-shadow: var(--shadow-lg);

    & h2 { color: #fff; }
    & p {
      color: #d3d1ee;
      margin-block: 0.85rem 1.75rem;
      max-inline-size: 56ch;
      margin-inline: auto;
    }
    & .btn--cta {
      background: #fff;
      color: var(--bg-deep);
      box-shadow: 0 10px 26px -8px rgb(0 0 0 / 0.5);

      &:hover { color: var(--brand-dark); }
    }
    & .cta-band__note {
      font-size: var(--fs-xs);
      color: #a9a6cf;
      margin-block-start: 1.1rem;
    }
  }

  /* ---- índice do artigo ---- */
  .toc {
    background: var(--bg-alt);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem;
    margin-block: 2rem;

    & h2 {
      font-size: 1rem;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: var(--ink-3);
      margin-block-end: 0.85rem;
    }
    & ol {
      display: grid;
      gap: 0.5rem;
      padding-inline-start: 1.2rem;
      font-size: var(--fs-sm);
    }
    & a { color: var(--ink-2); text-decoration: none; font-weight: 600; }
    & a:hover { color: var(--brand); text-decoration: underline; }
  }

  /* ---- breadcrumb ---- */
  .crumbs {
    font-size: var(--fs-xs);
    color: var(--ink-3);
    padding-block: 1rem 0;

    & ol {
      display: flex;
      flex-wrap: wrap;
      gap: 0.4rem;
      list-style: none;
      padding: 0;
      align-items: center;
    }
    & li:not(:last-child)::after {
      content: "›";
      margin-inline-start: 0.4rem;
      color: var(--line);
    }
    & a { color: var(--ink-3); text-decoration: none; }
    & a:hover { color: var(--brand); }
    & [aria-current] { color: var(--ink-2); font-weight: 600; }
  }

  /* ---- links relacionados ---- */
  .related {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
    margin-block-start: 1.75rem;
    padding: 0;
    list-style: none;

    & a {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      background: var(--bg);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      padding: 1rem 1.15rem;
      text-decoration: none;
      color: var(--ink);
      font-weight: 600;
      font-size: var(--fs-sm);
      transition: border-color 0.16s ease, transform 0.16s ease;

      &:hover {
        border-color: var(--brand);
        color: var(--brand);
        transform: translateY(-2px);
      }
      &::after { content: "→"; margin-inline-start: auto; color: var(--brand); }
    }
  }

  /* ---- barra fixa mobile ---- */
  .sticky-cta {
    position: fixed;
    inset-inline: 0;
    inset-block-end: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(12px);
    border-block-start: 1px solid var(--line);
    padding: 0.7rem var(--gap) calc(0.7rem + env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    gap: 0.85rem;
    translate: 0 110%;
    transition: translate 0.28s ease;

    &[data-visible="true"] { translate: 0 0; }

    & .sticky-cta__info {
      display: grid;
      line-height: 1.3;

      & b { font-size: var(--fs-sm); }
      & small { color: var(--ink-3); font-size: var(--fs-xs); }
    }
    & .btn {
      margin-inline-start: auto;
      padding: 0.8rem 1.35rem;
      font-size: var(--fs-sm);
      white-space: nowrap;
    }

    @media (width >= 900px) { display: none; }
  }

  /* ---- barra de progresso de leitura ---- */
  .progress {
    position: fixed;
    inset-block-start: 0;
    inset-inline-start: 0;
    block-size: 3px;
    inline-size: 100%;
    transform-origin: 0 50%;
    scale: var(--p, 0) 1;
    background: linear-gradient(90deg, var(--brand), var(--gold));
    z-index: 60;
  }

  /* ---- rodapé ---- */
  .site-foot {
    background: var(--bg-deep);
    color: #b8b6d8;
    padding-block: var(--section) 2.5rem;
    font-size: var(--fs-sm);
    margin-block-end: 4.5rem;

    @media (width >= 900px) { margin-block-end: 0; }

    & a { color: #e6e4f5; text-decoration: none; }
    & a:hover { color: #fff; text-decoration: underline; }
    & h3 { color: #fff; font-size: 1rem; margin-block-end: 0.9rem; }
  }

  .foot-grid {
    display: grid;
    gap: var(--gap);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));

    & ul { list-style: none; padding: 0; display: grid; gap: 0.5rem; }
  }

  .foot-legal {
    margin-block-start: 2.5rem;
    padding-block-start: 1.75rem;
    border-block-start: 1px solid #2a2a52;
    font-size: var(--fs-xs);
    color: #8d8ab3;
    display: grid;
    gap: 0.75rem;
  }

  .disclosure {
    background: var(--bg-alt);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.9rem 1.15rem;
    font-size: var(--fs-xs);
    color: var(--ink-3);
    margin-block-start: 1.5rem;
  }
}

/* ---------- utilitários ---------- */
@layer utils {
  .center { text-align: center; }
  .stack > * + * { margin-block-start: 1.15rem; }
  .lead { font-size: 1.1875rem; color: var(--ink-2); }
  .mt-lg { margin-block-start: 2.5rem; }
  .visually-hidden {
    position: absolute;
    inline-size: 1px; block-size: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .section-head {
    max-inline-size: 60ch;
    margin-inline: auto;
    text-align: center;

    & p { color: var(--ink-2); margin-block-start: 0.85rem; }
  }
}
