/**
 * Limits page: the plan comparison table (limits.html)
 *
 * Shared look of data tables: header row of plan cards, one column per plan, a label column that stays
 * visible while the table scrolls sideways on a narrow screen. Colours come from the tokens in variables.css,
 * so the dark theme needs nothing here.
 */

/* The page opens straight with the table: the section takes the space a page hero would have used */
.limits-table-section {
  padding-top: calc(var(--nav-h) + clamp(12px, 2.4vh, 40px));

  /* The table is the page, so its height follows the window instead of a breakpoint. 520px is every part
     that does not scale — nav, title, header text, group labels, row text — plus the gap that should stay
     under the table; whatever is left over is handed to the padding. A tall window reaches the comfortable
     values and looks unchanged, a short one keeps the frame and the last row above the fold. The header
     row gives up its padding fastest, the rows slowest. */
  --limits-cell-y: clamp(7px, calc((100vh - 520px) / 14), 14px);
  --limits-group-y: clamp(12px, calc((100vh - 520px) / 7), 26px);
  --limits-head-top: clamp(8px, calc((100vh - 520px) / 20), 18px);
  --limits-head-bottom: clamp(9px, calc((100vh - 520px) / 18), 20px);
}

/* Same type as a page hero title: this heading is the page's h1. A display line does not need the body
   leading, and the space above and below it is what the table below can least spare on a short window. */
.limits-title {
  text-align: center;
  font-size: var(--font-size-4xl);
  line-height: 1.2;
  margin-bottom: clamp(10px, 1.8vh, var(--spacing-xl));
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.limits-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  -webkit-overflow-scrolling: touch;
}

/* Header row and the corner cell sit one surface level above the card. In dark mode --background-alt
   equals --card-bg, so they would vanish; --ccn-surface-raised is the step up. */
.limits-scroll {
  --limits-band: var(--background-alt);
  --limits-cross: color-mix(in srgb, var(--primary) 8%, var(--card-bg));
}

:root[data-theme="dark"] .limits-scroll {
  --limits-band: var(--ccn-surface-raised);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .limits-scroll {
    --limits-band: var(--ccn-surface-raised);
  }
}

.limits-table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.limits-table th,
.limits-table td {
  padding: var(--limits-cell-y) 16px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
}

.limits-table tbody tr:last-child th,
.limits-table tbody tr:last-child td {
  border-bottom: 0;
}

/* Header: the plan name stays quiet, the price is what the column is about */

.limits-table thead th {
  padding: var(--limits-head-top) 16px var(--limits-head-bottom);
  vertical-align: bottom;
  background: var(--limits-band);
  border-bottom: 1px solid var(--border);
}

.limits-tier-name {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-secondary);
}

.limits-tier-amount {
  display: block;
  margin-top: 6px;
  font-size: var(--font-size-2xl);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

/* The recommended plan says so with a rule along the top of its header cell only */
.limits-table thead th.limits-tier-featured {
  box-shadow: inset 0 3px 0 var(--primary);
}

/* Group rows: spacing and type say "new section" */

.limits-table tbody tr.limits-group th {
  padding: var(--limits-group-y) 16px 6px;
  background: transparent;
  border-bottom: 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}

.limits-table tbody tr.limits-group:first-child th {
  padding-top: 14px;
}

/* Body: the label column anchors each row, values line up in a numeric grid */

.limits-table tbody th[scope="row"] {
  width: 24%;
  min-width: 180px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.limits-table tbody td {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* "—" and the fixed values are the quiet states; a full column of bold text would read as a wall */
.limits-val-muted {
  color: var(--text-muted);
  font-weight: 500;
}

/* The label column follows the reader to the right edge on a narrow screen */
.limits-table tbody th[scope="row"],
.limits-corner {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--card-bg);
  box-shadow: inset -1px 0 0 var(--border);
}

.limits-corner {
  background: var(--limits-band);
}

/* The crosshair: js/limits-table.js marks the row and the column under the pointer.
   Declared after the sticky column so its tint wins on the cells that carry their own background. */
.limits-table tbody tr > .limits-cross,
.limits-table thead .limits-cross {
  background: var(--limits-cross);
  transition: background-color var(--ccn-dur-2) var(--ccn-ease-out);
}

/* Notes under the table: a hairline replaces the table border, then two even columns so four short
   points do not turn into a full-width wall of text */

.limits-notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--spacing-2xl);
  row-gap: var(--spacing-sm);
  margin: clamp(16px, 2.6vh, var(--spacing-xl)) 0 0;
  padding: var(--spacing-md) 0 0;
  border-top: 1px solid var(--border);
  list-style: none;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.55;
}

.limits-notes li {
  position: relative;
  padding-left: 16px;
}

.limits-notes li::before {
  content: "";
  position: absolute;
  top: 0.65em;
  left: 2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
}

.limits-notes a {
  color: var(--primary-text);
  text-decoration: underline;
}

/* Call to action */

.limits-cta .container {
  text-align: center;
}

.limits-cta-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  line-height: 1.3;
}

.limits-cta-text {
  max-width: 640px;
  margin: var(--spacing-sm) auto 0;
  color: var(--text-secondary);
}

.limits-cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  justify-content: center;
  margin-top: var(--spacing-lg);
}

@media (max-width: 768px) {
  .limits-title {
    font-size: var(--font-size-2xl);
  }

  .limits-table {
    min-width: 680px;
    font-size: var(--font-size-xs);
  }

  .limits-table th,
  .limits-table td {
    padding: 11px 10px;
  }

  .limits-table thead th {
    padding: 14px 10px 16px;
  }

  .limits-table tbody th[scope="row"] {
    min-width: 150px;
    width: auto;
    white-space: normal;
  }

  .limits-tier-amount {
    font-size: var(--font-size-lg);
  }

  .limits-notes {
    grid-template-columns: 1fr;
  }

  .limits-scroll {
    scrollbar-width: thin;
  }
}

/* Short windows: the heading and the prices step down a size so the rows above the fold are not the
   only thing the clamps can take */
@media (max-height: 680px) {
  .limits-title {
    font-size: var(--font-size-2xl);
  }

  .limits-tier-amount {
    font-size: var(--font-size-lg);
  }
}
