/* Styles for the billing area (src/routes/billing.ts) and the account extras
   on /app/settings (src/extras.ts). Linked on every page by src/layout.ts,
   after site.css. Uses only the tokens in site.css, so light and dark follow.
   Plan cards copy Mokxi's (web/src/site/site.css, "plans"), scoped under
   .billing so the marketing pricing page can style its own. */

/* ---------------- usage meters ---------------- */

.billing-usage {
  display: grid;
  gap: 18px;
  /* The dot grid from the brand texture, faint, so the panel reads like an instrument. */
  background-image: radial-gradient(var(--site-dot) 1px, transparent 1.2px);
  background-size: 14px 14px;
  background-color: var(--bg-panel);
}

.billing-usage-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
}

.billing-period {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.meters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.meter {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 14px 16px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.meter-head {
  display: grid;
  gap: 4px;
}

.meter-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.meter-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.meter-of {
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-dim);
}

.meter-track {
  display: block;
  height: 6px;
  overflow: hidden;
  background: var(--bg-active);
  border-radius: 999px;
}

.meter-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.15s ease;
}

/* 80% and up: amber. Past the limit: still amber, never red, since nothing stops. */
.meter-near .meter-fill,
.meter-over .meter-fill {
  background: var(--chip-warn-fg);
}

.meter-over {
  border-color: var(--chip-warn-line);
}

.meter-foot {
  font-size: 12.5px;
  color: var(--chip-warn-fg);
}

/* The one upgrade prompt for a Free account over its room. Calm: a panel, not a banner. */
.billing-prompt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text);
  background: var(--brand-band);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: var(--radius-sm);
}

.billing-prompt strong {
  font-weight: 650;
}

/* ---------------- plans ---------------- */

.billing-plans-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 14px;
}

.billing-plans-head .app-section-title {
  margin: 0;
}

.billing-plans-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* The Monthly / Yearly toggle: radios inside the form, so the choice posts with it. */
fieldset.billing-interval {
  margin: 0;
  min-width: 0;
}

.billing-interval .segment {
  min-height: 36px;
}

.billing-interval input:checked + .segment {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.billing-interval input:focus-visible + .segment {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.billing-interval .segment .pill {
  font-size: 10.5px;
  line-height: 16px;
  padding: 0 7px;
}

/* On the blue of the chosen tab the green pill turns to ink on a tint of it. */
.billing-interval input:checked + .segment .pill {
  color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent-ink) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent-ink) 35%, transparent);
}

/* Plans with a price: four across when there is room, two by two below 1280px, one column on phones. Custom sits under them. */
.billing .plan-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.billing .plan-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.12s ease;
}

.billing .plan-card.highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.billing .plan-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
}

.billing .plan-tagline {
  margin-top: 5px;
  font-size: 13.5px;
  color: var(--text-dim);
}

.billing .plan-price {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 14px;
}

.billing .plan-amount {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.billing .plan-period {
  font-size: 13.5px;
  color: var(--text-dim);
}

.billing .plan-billing {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-faint);
  white-space: nowrap;
}

.billing .plan-features {
  flex: 1 1 auto;
  margin: 16px 0 20px;
  padding: 16px 0 0;
  list-style: none;
  font-size: 14px;
  color: var(--text-dim);
  border-top: 1px solid var(--line);
}

.billing .plan-features li {
  position: relative;
  margin-bottom: 8px;
  padding-left: 22px;
}

/* A drawn tick in the ok green: 8.4:1 on the dark panel, 4.9:1 on the light one. */
.billing .plan-features li::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 0.55em;
  width: 8px;
  height: 4px;
  border-left: 2px solid var(--chip-ok-fg);
  border-bottom: 2px solid var(--chip-ok-fg);
  transform: rotate(-45deg);
}

.billing .plan-cta {
  width: 100%;
}

.billing .plan-foot-line {
  min-height: 1.5em;
  margin-top: 8px;
  font-size: 12.5px;
  text-align: center;
  color: var(--text-faint);
}

.billing-note {
  margin-top: 16px;
  max-width: 62ch;
  font-size: 13px;
  color: var(--text-faint);
}

/* Custom, priced per deal: one wide card under the grid, stacked below 900px. */
.billing .plan-wide {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(0, 2fr) minmax(200px, 1fr);
  gap: 16px 28px;
  align-items: center;
  margin-top: 16px;
}

.billing .plan-wide .plan-wide-head {
  align-self: start;
}

/* Two flowing columns, so a long line never leaves a gap in the other one. */
.billing .plan-wide .plan-wide-features {
  columns: 2;
  column-gap: 24px;
  margin: 0;
  padding: 0 0 0 24px;
  border-top: none;
  border-left: 1px solid var(--line);
}

.billing .plan-wide .plan-wide-features li {
  break-inside: avoid;
}

.billing .plan-wide .plan-price {
  margin-top: 0;
}

.billing .plan-wide .plan-cta {
  margin-top: 14px;
}

@media (max-width: 1279px) {
  .billing .plan-wide {
    max-width: 760px;
  }
}

@media (max-width: 899px) {
  .billing .plan-wide {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }
  .billing .plan-wide .plan-wide-features {
    padding: 16px 0 0;
    border-left: none;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  .billing .plan-wide {
    max-width: 520px;
  }
  .billing .plan-wide .plan-wide-features {
    columns: 1;
  }
}

/* Prices follow the toggle. Without :has() the monthly prices stay, which is the default.
   Written after .plan-price and .plan-billing so these win at equal weight. */
.billing .plan-card .price-year {
  display: none;
}

.billing-plans:has(#iv-year:checked) .plan-card div.price-year {
  display: flex;
}

.billing-plans:has(#iv-year:checked) .plan-card p.price-year {
  display: block;
}

.billing-plans:has(#iv-year:checked) .plan-card .price-month {
  display: none;
}

@media (max-width: 1100px) {
  .meters {
    grid-template-columns: minmax(0, 1fr);
  }
  .meter {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1279px) {
  .billing .plan-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 760px;
  }
}

@media (max-width: 640px) {
  .billing .plan-grid {
    grid-template-columns: minmax(0, 1fr);
    max-width: 520px;
  }
}

@media (max-width: 480px) {
  .billing-plans-tools,
  .billing-plans-tools .segmented {
    width: 100%;
  }
  .billing-usage {
    padding: 16px;
  }
  .billing .plan-amount {
    font-size: 28px;
  }
}

/* ---------------- account extras (/app/settings) ---------------- */

.extras-logo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
}

.extras-logo .field {
  flex: 1 1 240px;
  min-width: 0;
}

/* A checkerboard-free neutral frame that shows a logo in either theme. */
.extras-logo-frame {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 180px;
  height: 84px;
  padding: 10px;
  background: var(--bg-raised);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.extras-logo-frame img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.extras-file {
  padding-block: 7px;
  height: auto;
}

.extras-domains {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.extras-domain {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.extras-host {
  min-width: 0;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* The DNS record, laid out like a registrar's row: type, name, target. */
.extras-dns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 10px 12px;
  font-size: 13px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.extras-dns code {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.extras-dns-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--accent);
  padding: 1px 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 999px;
}

.extras-dns-arrow {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
}

.extras-domain-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 480px) {
  .extras-add {
    flex-wrap: wrap;
  }
  .extras-add .btn {
    flex: 1 1 100%;
  }
  .extras-logo-frame {
    width: 100%;
  }
}

/* ---------------- admin billing ---------------- */

.admin-comp {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.admin-comp select.field-input {
  width: auto;
  min-width: 96px;
}

.admin-comp input.field-input {
  width: 72px;
}

/* No limit, no bar: an empty track would read as "nothing used of something". */
.meter-unlimited .meter-track {
  display: none;
}

/* The file picker's button, matched to .btn-secondary. */
.extras-file::file-selector-button {
  margin-right: 10px;
  padding: 5px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line-control);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ---------------- custom domain setup steps (src/extras.ts) ---------------- */

.extras-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  font-size: 14px;
}

.extras-steps li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: start;
  counter-increment: step;
}

.extras-steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 999px;
}

.extras-steps li > .extras-record {
  grid-column: 2;
}

.extras-steps code,
.extras-record code {
  font-family: var(--mono);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

/* The DNS record, laid out like a registrar's row: type, name, target. */
.extras-record {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  table-layout: auto;
}

.extras-record th,
.extras-record td {
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}

.extras-record th {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid var(--line);
}

.extras-record td code {
  color: var(--text);
}

/* ---------------- admin: the 30-day money back ---------------- */

.admin-refund > summary {
  list-style: none;
}

.admin-refund > summary::-webkit-details-marker {
  display: none;
}

.admin-refund form {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.admin-refund .field-check {
  font-size: 13px;
  white-space: nowrap;
}
