/* ============================================================
   Aportize — base das calculadoras
   Depende dos tokens e do reset de chrome.css.
   Carregada antes da folha específica de cada calculadora.

   Aqui mora só o que três calculadoras usaram sem variação:
   a grade de duas colunas com o fio, o campo em destaque,
   os fields preenchidos e os rótulos. O que é de uma só
   continua na folha dela.

   Regras herdadas: um único elemento alto por página, nenhuma
   caixa, raio de canto só no que é clicável, monoespaçada só
   em algarismo.
   ============================================================ */

.calculator-page {
  padding-top: clamp(32px, 5.5vw, 60px);
  padding-bottom: clamp(64px, 10vw, 112px);
}

/* ---------- Abertura ---------- */

.intro { margin-bottom: clamp(36px, 6vw, 60px); }

.intro h1 {
  margin: 0;
  max-width: 32ch;
  /* O piso precisa caber a palavra mais longa numa tela de 320px. */
  font-size: clamp(1.5rem, 3.6vw, 1.9rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.026em;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.intro p {
  margin: 10px 0 0;
  max-width: 54ch;
  font-size: .9375rem;
  line-height: 1.55;
  color: var(--muted);
}

/* ---------- Duas colunas separadas por um fio ---------- */

.calculator-layout { display: block; }

/* ---------- Rótulos ---------- */

.section-label {
  display: block;
  font-size: .9375rem;
  font-weight: 500;
  color: var(--muted);
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-header h2 {
  margin: 0;
  font-size: .9375rem;
  font-weight: 500;
  color: var(--muted);
}

.field-label {
  display: block;
  font-size: .8125rem;
  font-weight: 400;
  color: var(--muted);
}

/* ---------- O elemento alto da página ---------- */

.primary-input { margin-bottom: clamp(40px, 6vw, 60px); }

.primary-input .section-label { margin-bottom: 14px; }

.primary-input__field {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--hairline);
  transition: border-color var(--t);
}

.primary-input__field:hover { border-color: rgba(245, 247, 250, .2); }
.primary-input__field:focus-within { border-color: var(--green); }

.primary-input__currency {
  flex: none;
  font-family: var(--mono);
  font-size: 1.125rem;
  color: var(--muted);
}

.primary-input__field input {
  flex: 1;
  min-width: 0;
  width: 100%;
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  color: var(--text);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.25rem, 9.5vw, 4rem);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -.04em;
}

.primary-input__field input:focus { outline: none; }
.primary-input__field input::placeholder { color: #363E48; }

/* ---------- Campos: a única camada com preenchimento ---------- */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.input-shell {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 13px 14px;
  transition: box-shadow var(--t);
}

.input-shell:focus-within { box-shadow: inset 0 0 0 1.5px var(--green); }

.input-shell input {
  flex: 1;
  min-width: 0;
  width: 100%;
  appearance: none;
  -moz-appearance: textfield;
  background: none;
  border: 0;
  padding: 0;
  color: var(--text);
  font-family: var(--sans);
  font-size: .9375rem;
  font-weight: 500;
  letter-spacing: -.01em;
}

.input-shell input:focus { outline: none; }
.input-shell input::placeholder { color: #545C67; }
.input-shell input::-webkit-outer-spin-button,
.input-shell input::-webkit-inner-spin-button { appearance: none; margin: 0; }

/* Algarismo é sempre mono, arowdo à direita, sem quebrar. */
.input-shell--numeric input {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.input-shell__prefix, .input-shell__suffix {
  flex: none;
  font-family: var(--mono);
  font-size: .8125rem;
  color: var(--muted);
}

/* ---------- Controles secundários ---------- */

.link-button {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: var(--sans);
  font-size: .875rem;
  color: var(--muted);
  transition: color var(--t);
}

.link-button:hover { color: var(--green); }

.warning {
  margin: 16px 0 0;
  font-size: .875rem;
  line-height: 1.5;
  color: var(--red);
}

.warning:empty { display: none; }

/* ---------- A resposta ---------- */

.result {
  margin-top: 44px;
  padding-top: 36px;
  border-top: 1px solid var(--hairline);
}

.result[hidden] { display: none; }

.result .section-label { margin-bottom: 4px; }

.note {
  margin: 22px 0 0;
  font-size: .8125rem;
  line-height: 1.55;
  color: var(--muted);
}

.note[hidden] { display: none; }

/* ---------- Fecho em forma de extrato: rótulo à esquerda, número à direita ---------- */

.statement { margin: 26px 0 0; }
.statement[hidden] { display: none; }

.statement__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 15px 0;
  border-top: 1px solid var(--hairline);
}

.statement__row[hidden] { display: none; }

.statement__row dt {
  font-size: .9375rem;
  color: var(--text-secondary);
}

.statement__row dd {
  margin: 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

/* ---------- noscript ---------- */

.noscript {
  margin: 0 0 32px;
  padding: 16px 0;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  color: var(--text-secondary);
  font-size: .9375rem;
}

/* ---------- Próximo passo: link para outra ferramenta ---------- */

.calculator-page .next-step {
  margin: 18px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
  color: var(--text-secondary);
  font-size: .875rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.calculator-page .next-step a {
  color: var(--green);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: color var(--t);
}

/* ---------- Perguntas frequentes ---------- */

.calculator-page .faq {
  margin-top: clamp(48px, 7vw, 80px);
  padding-top: clamp(28px, 3vw, 40px);
  border-top: 1px solid var(--hairline);
}

.calculator-page .faq__title {
  margin: 0 0 6px;
  font-size: .9375rem;
  font-weight: 500;
  color: var(--muted);
}

.calculator-page .faq__item {
  border-bottom: 1px solid var(--hairline);
}

.calculator-page .faq__item summary {
  position: relative;
  display: block;
  padding: 18px 34px 18px 0;
  font-size: .9375rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
}

.calculator-page .faq__item summary::-webkit-details-marker { display: none; }

.calculator-page .faq__item summary::after {
  content: "+";
  position: absolute;
  top: 15px;
  right: 4px;
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--muted);
}

.calculator-page .faq__item[open] summary { color: var(--text); }
.calculator-page .faq__item[open] summary::after { content: "\2212"; }

.calculator-page .faq__item p {
  margin: 0;
  padding: 0 0 20px;
  max-width: 68ch;
  font-size: .875rem;
  line-height: 1.7;
  color: var(--muted);
}

.calculator-page .faq__item summary:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

@media (hover: hover) {
  .calculator-page .faq__item summary:hover { color: var(--text); }
  .calculator-page .next-step a:hover { color: var(--text); }
}

/* ---------- Gráficos: legenda própria e tema do ApexCharts ---------- */

.calculator-page .section-description {
  margin: 8px 0 0;
  font-size: .8125rem;
  line-height: 1.5;
  color: var(--muted);
}

.calculator-page .chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.calculator-page .chart-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: .8125rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.calculator-page .chart-legend__dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

.calculator-page .chart-legend__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* O ApexCharts injeta o próprio CSS; aqui só encostamos no tema. */
.calculator-page .apexcharts-canvas { margin: 0 auto; }

.calculator-page .apexcharts-tooltip.apexcharts-theme-dark {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .42);
}

.calculator-page .apexcharts-tooltip-title {
  background: var(--surface-2);
  border-bottom: 1px solid var(--hairline);
  font-family: var(--sans);
}

.calculator-page .apexcharts-xaxistooltip,
.calculator-page .apexcharts-yaxistooltip { display: none; }

/* ---------- Desktop: o fio vertical ---------- */

@media (min-width: 940px) {
  .calculator-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: clamp(48px, 7vw, 88px);
    /* O fio vive no container, então acompanha a coluna mais alta
       mesmo com a resposta em position:sticky. */
    background-image: linear-gradient(var(--hairline), var(--hairline));
    background-repeat: no-repeat;
    background-size: 1px 100%;
    background-position: 50% 0;
  }

  .result {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
    position: sticky;
    top: calc(var(--nav-h) + 32px);
    align-self: start;
  }
}
