/* /vs/ (src/views/Compare.astro, public/vs.js): the comparison tables and the
   "What would you replace?" calculator, on top of styles.css (.doc, .faq,
   .mac-card). Loaded by that page only (Base's `styles`). A phone never scrolls
   sideways: under 640px each table row stacks, every cell named by its
   data-label, and the calculator's rows go to one column. */

/* A price never breaks inside itself ("1 790 000 IDR" stays on one line); the
   cell wraps around it instead. scripts/check-widths.mjs measures this with the
   longest prices. */
.vs-page [data-price],
.vs-page [data-price-monthly] {
  white-space: nowrap;
}

.vs-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 18px;
  font-size: 14.5px;
}

.doc .vs-jump a {
  color: var(--accent-light);
  text-decoration: none;
}

.doc .vs-jump a:hover {
  text-decoration: underline;
}

.vs-section {
  scroll-margin-top: 84px;
}

.vs-table {
  width: 100%;
  margin-top: 20px;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 15px;
  line-height: 1.5;
}

.vs-table th,
.vs-table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--hairline);
  overflow-wrap: anywhere;
}

.vs-table thead th,
.vs-table thead td {
  background: var(--pane);
  color: var(--ink);
  font-weight: 650;
}

.vs-table tbody th {
  width: 22%;
  color: var(--ink);
  font-weight: 600;
}

.vs-table td {
  color: var(--muted);
}

.vs-table td.vs-us {
  color: var(--ink);
  background: var(--accent-wash);
}

.vs-table tbody tr:last-child > * {
  border-bottom: 0;
}

.vs-line {
  display: block;
}

.vs-line + .vs-line {
  margin-top: 8px;
}

.doc .vs-table a {
  color: var(--accent-light);
}

/* ---- The calculator ---- */

.vs-calc {
  margin-top: 20px;
  padding: clamp(16px, 3vw, 24px);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-lg);
  background: var(--pane);
}

.doc .vs-calc > p:first-child {
  margin-top: 0;
}

.vs-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.vs-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 16px;
  align-items: center;
  /* A fieldset is min-content wide by default: let it shrink with the page. */
  min-width: 0;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--canvas-raised);
}

.vs-pick {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}

.vs-pick input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--accent);
}

.doc .vs-row .vs-instead {
  grid-column: 1;
  margin: 0 0 0 28px;
}

.vs-amount {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  align-items: center;
  gap: 8px;
}

.vs-sign {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.vs-amount input,
.vs-amount select {
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--pane-raised);
  border: 1px solid var(--hairline-strong);
  border-radius: 10px;
  padding: 8px 10px;
  max-width: 100%;
}

.vs-amount input {
  width: 7.5em;
  text-align: right;
}

.vs-amount input:focus,
.vs-amount select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.vs-amount input[aria-invalid="true"] {
  border-color: var(--danger);
}

.vs-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 18px 0 0;
}

.vs-totals > div {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--canvas-raised);
}

.vs-totals dt {
  font-size: 13.5px;
  color: var(--muted);
}

.vs-totals dd {
  margin: 4px 0 0;
}

.vs-totals output,
.vs-totals .vs-figure {
  font: 650 24px/1.2 var(--display);
  letter-spacing: -0.01em;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.vs-total-plus .vs-figure {
  color: var(--accent-light);
}

.doc .vs-totals .fine {
  margin-top: 6px;
}

@media (max-width: 640px) {
  .vs-table,
  .vs-table thead,
  .vs-table tbody,
  .vs-table tr,
  .vs-table th,
  .vs-table td {
    display: block;
    width: auto;
  }

  /* The column names move into each cell (its data-label). */
  .vs-table thead {
    display: none;
  }

  .vs-table tbody th {
    width: auto;
    background: var(--pane);
  }

  .vs-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font: 600 11.5px/1.4 var(--mono);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--faint);
  }

  .vs-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .vs-amount {
    grid-column: 1;
    grid-row: auto;
    margin-left: 28px;
  }

  .vs-amount input {
    flex: 1 1 5em;
    min-width: 0;
    width: auto;
  }

  .vs-amount select {
    flex: none;
  }
}
