/* Commission estimator. Shared by /affiliate and /creator-dashboard.
   Uses only the token scale each page defines on :root. */

.est {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s5) var(--s6);
}

.est-controls {
  display: grid;
  gap: var(--s5);
  align-content: start;
}

.est-field {
  display: grid;
  gap: var(--s2);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.est-field[hidden] {
  display: none;
}

.est-field > label,
.est-field > legend {
  padding: 0;
  margin-bottom: var(--s2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: var(--fw-medium);
}

/* Subscribers you bring: one card per plan, side by side. */
.est-plans {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s3);
}

.est-plan {
  display: grid;
  gap: var(--s3);
  padding: var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
}

.est-plan-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2);
}

.est-plan-name {
  color: var(--text);
  font-size: 15px;
  font-weight: var(--fw-semibold);
}

.est-plan-price {
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
}

.est-stepper {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--bg);
  overflow: hidden;
}

.est-stepper button {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 18px;
  cursor: pointer;
}

.est-stepper button:hover {
  background: var(--surface-hover);
}

.est-stepper button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: -2px;
}

.est .est-stepper input[type="number"] {
  min-height: 40px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-variant-numeric: tabular-nums;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}

.est-stepper input::-webkit-outer-spin-button,
.est-stepper input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.est input[type="number"],
.est select {
  width: 100%;
  min-height: 40px;
  padding: 0 var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

/* White focus ring instead of the browser's default, which takes the
   system accent colour (yellow on some Macs). The stepper gets the ring as a
   whole, so it follows its rounded border. */
.est input[type="number"]:focus,
.est select:focus {
  outline: none;
}

.est select:focus-visible,
.est .est-stepper:has(input:focus-visible) {
  outline: 2px solid var(--text);
  outline-offset: -1px;
}

/* Our own chevron, set in from the edge like the other inputs' padding. */
.est select {
  padding-right: 36px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23ededee' stroke-opacity='.6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  cursor: pointer;
}

.est-seg {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--seg-count, 3), minmax(0, 1fr));
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  overflow: hidden;
}

.est-seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.est-seg label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 var(--s2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: var(--fw-medium);
  text-align: center;
  cursor: pointer;
}

.est-seg label + input + label {
  border-left: 1px solid var(--line-strong);
}

.est-seg input:checked + label {
  background: var(--text);
  color: var(--bg);
}

.est-seg input:focus-visible + label {
  outline: 2px solid var(--text);
  outline-offset: -4px;
}

/* Website benefit: a small panel under the Website half of the switch,
   joined to it by a short line, so the discount reads as website-only. */
.est-sub {
  position: relative;
  width: 50%;
  margin-top: var(--s3);
  padding: var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
}

.est-sub::before {
  content: '';
  position: absolute;
  top: calc(-1 * var(--s3) - 1px);
  left: 50%;
  width: 1px;
  height: var(--s3);
  background: var(--line-strong);
}

.est-field.est-sub > label {
  margin-bottom: 0;
}

.est-output {
  padding: var(--s5);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg);
}

.est-output p {
  margin: 0;
}

.est-kicker {
  color: var(--text-3);
  font-size: 12px;
  font-weight: var(--fw-medium);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.est-total {
  margin-top: var(--s2) !important;
  color: var(--text) !important;
  font-size: 40px;
  font-weight: var(--fw-semibold);
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.est-per {
  margin-top: var(--s1) !important;
  color: var(--text-2);
  font-size: 14px;
}

.est-breakdown {
  display: grid;
  gap: var(--s2);
  margin: var(--s5) 0 0;
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.est-breakdown div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px 84px;
  gap: var(--s3);
}

.est-breakdown dd {
  text-align: right;
}

/* Column titles: Plus and Pro. */
.est-breakdown .est-breakdown-head dt,
.est-breakdown .est-breakdown-head dd {
  color: var(--text-3);
  font-size: 12px;
  font-weight: var(--fw-medium);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.est-breakdown dt {
  color: var(--text-2);
}

.est-breakdown dd {
  margin: 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.est-breakdown div:last-child dt,
.est-breakdown div:last-child dd {
  color: var(--text);
  font-weight: var(--fw-semibold);
}

.est-result {
  position: relative;
  display: grid;
  gap: var(--s2);
  align-content: start;
}

/* Badge on the commission box's top edge, at the right. */
.est-badge {
  position: absolute;
  top: 0;
  right: var(--s5);
  transform: translateY(-50%);
  padding: 2px var(--s2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text-2);
  font-size: 12px;
  font-weight: var(--fw-medium);
  letter-spacing: 0.04em;
  line-height: 1.4;
  text-transform: uppercase;
}

.est-note {
  margin: 0;
  padding: 0 calc(var(--s5) + 1px);
  color: var(--text-3) !important;
  font-size: 11px;
  line-height: 1.5;
}

@media (max-width: 760px) {
  .est {
    grid-template-columns: 1fr;
  }

  .est-total {
    font-size: 34px;
  }
}

@media (max-width: 480px) {
  .est-breakdown div {
    grid-template-columns: minmax(0, 1fr) 64px 72px;
    gap: var(--s2);
  }

  .est-breakdown {
    font-size: 13px;
  }
}
