/* ============================================================
   Aportize - Preço médio
   Carregar depois de chrome.css e calculator.css.
   Requer <main class="wrap calculator-page pm-page">.
   ============================================================ */

.calculator-page.pm-page {
  --pm-column-gap: clamp(56px, 6vw, 96px);
  padding-top: clamp(36px, 5vw, 72px);
  padding-bottom: clamp(64px, 8vw, 112px);
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  color-scheme: dark;
}

.pm-page [hidden] {
  display: none !important;
}

.pm-page button,
.pm-page input,
.pm-page summary {
  -webkit-tap-highlight-color: transparent;
}

.pm-page button,
.pm-page input {
  margin: 0;
  font-family: var(--sans);
}

.pm-page button {
  appearance: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: color var(--t), background-color var(--t), border-color var(--t);
}

.pm-page button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pm-page button:focus-visible,
.pm-page summary:focus-visible,
.pm-page a:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 4px;
}

.pm-page input {
  caret-color: var(--green);
}
.pm-page input::placeholder {
  color: var(--muted);
  opacity: 1;
}

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

.pm-page .intro {
  margin: 0 0 clamp(36px, 4.5vw, 60px);
}

.pm-page .intro .eyebrow {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.pm-page .intro h1 {
  max-width: none;
  margin: 0;
  color: var(--text);
  font-size: clamp(2rem, 4.5vw, 4rem);
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -0.052em;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.pm-page .intro h1 span {
  color: var(--muted);
}

.pm-page .intro .intro__description {
  max-width: 52ch;
  margin: 22px 0 0;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.65;
  letter-spacing: -0.01em;
}

/* ---------- Estrutura ---------- */

.pm-page .calculator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 40px;
  padding-top: clamp(28px, 3vw, 40px);
  border-top: 1px solid var(--hairline);
  background: none;
}

.pm-page #calculator-form {
  display: grid;
  min-width: 0;
  gap: 28px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.pm-page .section-label,
.pm-page .section-header h2 {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -0.015em;
}

.pm-page .section-header {
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0;
}

.pm-page .section-description {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.pm-page .field-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.pm-page .field-label small {
  font-size: 0.6875rem;
}

/* ---------- Campos ---------- */

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

.pm-page .field-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.pm-page .input-shell {
  height: 48px;
  min-width: 0;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  transition: border-color var(--t), background-color var(--t);
}

.pm-page .input-shell:focus-within {
  border-color: var(--green);
}

.pm-page .input-shell input {
  min-width: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  color: var(--text);
  background: transparent;
  font-family: var(--mono);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.pm-page .input-shell__prefix {
  flex: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8125rem;
  pointer-events: none;
}

.pm-page .field--current {
  max-width: 15rem;
}

/* ---------- Linhas de compra ---------- */

.pm-page .rows {
  display: grid;
  gap: 18px;
  min-width: 0;
  margin-top: 20px;
}

.pm-page .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px;
  grid-template-areas:
    "quantity price remove"
    "fee fee fee";
  align-items: end;
  gap: 10px;
  min-width: 0;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--hairline);
}

.pm-page .field--quantity { grid-area: quantity; }
.pm-page .field--price { grid-area: price; }
.pm-page .field--fee { grid-area: fee; }

.pm-page .remove-button {
  grid-area: remove;
  align-self: end;
  display: grid;
  place-items: center;
  width: 44px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--muted);
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
}

.pm-page .add-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 8px 0 0;
  padding: 0 4px;
  border: 0;
  border-radius: 4px;
  color: var(--green);
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 500;
}

.pm-page .add-button__icon {
  font-size: 1.375rem;
  line-height: 1;
}

/* ---------- Resultado ---------- */

.pm-page .result,
.pm-page .result-empty {
  position: static;
  min-width: 0;
  width: 100%;
  margin: 0;
  padding: 32px 0 0;
  border: 0;
  border-top: 1px solid var(--hairline);
  border-radius: 0;
  color: var(--text);
  background: transparent;
  box-shadow: none;
}

.pm-page .result > .section-label {
  margin: 0;
  color: var(--green);
  font-size: 0.8125rem;
  font-weight: 500;
}

.pm-page .average-price {
  display: block;
  max-width: 100%;
  margin: 12px 0 0;
  padding-bottom: 3px;
  overflow-x: auto;
  color: var(--green);
  font-family: var(--mono);
  font-size: clamp(1.875rem, 2.7vw, 2.375rem);
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  scrollbar-width: thin;
}

.pm-page .average-price__note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.65;
}
.pm-page .average-price__note:empty {
  display: none;
}

.pm-page .statement {
  margin: 24px 0 0;
  border-top: 1px solid var(--hairline);
}

.pm-page .statement__row {
  align-items: baseline;
  gap: 6px 16px;
  min-width: 0;
  padding: 17px 0;
  border: 0;
  border-bottom: 1px solid var(--hairline);
}

.pm-page .statement__row dt {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.pm-page .statement__row dd {
  max-width: 100%;
  margin-left: auto;
  overflow-x: auto;
  color: var(--text-secondary);
  font-family: var(--mono);
  font-size: 1rem;
  line-height: 1.5;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  scrollbar-width: thin;
}

.pm-page #result-row.result-row--gain dd {
  color: var(--green);
}
.pm-page #result-row.result-row--loss dd {
  color: var(--red);
}

.pm-page #copy-result {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin-top: 18px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  background: var(--surface);
  font-size: 0.8125rem;
  font-weight: 500;
}

.pm-page .note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.pm-page .note strong {
  color: var(--text-secondary);
  font-weight: 500;
}

.pm-page .assumptions {
  margin-top: 20px;
  border-top: 1px solid var(--hairline);
}

.pm-page .assumptions summary {
  position: relative;
  display: block;
  min-height: 48px;
  padding: 15px 28px 15px 0;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.5;
  list-style: none;
  cursor: pointer;
}

.pm-page .assumptions summary::-webkit-details-marker {
  display: none;
}

.pm-page .assumptions summary::after {
  content: "+";
  position: absolute;
  top: 11px;
  right: 2px;
  color: var(--muted);
  font-size: 1.25rem;
}

.pm-page .assumptions[open] summary::after {
  content: "\2212";
}
.pm-page .assumptions__content {
  padding-bottom: 10px;
}
.pm-page .assumptions__content .note:first-child {
  margin-top: 0;
}

.pm-page .result:not([hidden]) + .result-empty {
  display: none;
}
.pm-page .result-empty {
  min-height: 220px;
}
.pm-page .result-empty > .section-label {
  color: var(--muted);
  font-size: 0.8125rem;
}
.pm-page .result-empty__title {
  margin: 20px 0 0;
  color: var(--text-secondary);
  font-size: clamp(1.75rem, 2.7vw, 2.375rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.04em;
}
.pm-page .result-empty__description {
  max-width: 34ch;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.65;
}

.pm-page .noscript {
  margin: 0 0 28px;
  padding: 16px 0;
  border-block: 1px solid var(--hairline);
  color: var(--text-secondary);
}

/* ---------- Interacao ---------- */

@media (hover: hover) {
  .pm-page .remove-button:not(:disabled):hover {
    color: var(--red);
    background: var(--surface);
  }
  .pm-page .add-button:hover {
    color: var(--text);
  }
  .pm-page .assumptions summary:hover,
  .pm-page .next-step a:hover,
  .pm-page #copy-result:hover {
    color: var(--text);
  }
}

/* ---------- Tablet e desktop ---------- */

@media (min-width: 620px) {
  .pm-page .row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.9fr) 44px;
    grid-template-areas: "quantity price fee remove";
    padding-bottom: 14px;
  }
  .pm-page .row:not(:first-child) .field-label {
    display: none;
  }
  .pm-page .rows {
    gap: 14px;
  }
}

@media (min-width: 1180px) {
  .pm-page .calculator-layout {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    column-gap: var(--pm-column-gap);
    background-image: linear-gradient(var(--hairline), var(--hairline));
    background-size: 1px 100%;
    background-repeat: no-repeat;
    background-position: calc(52.5% - var(--pm-column-gap) * 0.025) 0;
  }

  .pm-page .result,
  .pm-page .result-empty {
    padding: 0;
    border-top: 0;
  }
}

@media (min-width: 1180px) and (min-height: 860px) {
  .pm-page .result:not(:has(.assumptions[open])),
  .pm-page .result-empty {
    position: sticky;
    top: calc(var(--nav-h) + 28px);
  }
}

@media (max-width: 619px) {
  .pm-page .intro h1 {
    font-size: clamp(1.875rem, 8.5vw, 3rem);
    line-height: 1.08;
  }
  .pm-page .intro .intro__description {
    margin-top: 18px;
    font-size: 0.9375rem;
  }
  .pm-page .input-shell,
  .pm-page .remove-button {
    height: 52px;
  }
  .pm-page .field--current {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pm-page *,
  .pm-page *::before,
  .pm-page *::after {
    transition-duration: 1ms !important;
  }
}

@media (forced-colors: active) {
  .pm-page .input-shell,
  .pm-page #copy-result {
    border: 1px solid ButtonText;
  }
  .pm-page button:focus-visible,
  .pm-page summary:focus-visible,
  .pm-page a:focus-visible {
    outline-color: Highlight;
  }
  .pm-page .input-shell:focus-within {
    border-color: Highlight;
  }
}
