/*
 * Services comparison block (wpta/services-comparison), as in the Services wireframe: every service against every
 * plan, showing a tick, the plan's wording, or a dash, grouped under headings, with "View plan" under each column.
 *
 * - Key services show first; "Show all N services" (a checkbox, so no script is needed) opens the rest in place. The
 *   other rows are folded away rather than removed, so the columns keep the same widths when it opens.
 * - On laptops and up the table is only as wide as its content: the service column fits the longest service name and
 *   each plan has the same width. A line divides the services from the plans.
 * - The plan a visitor came from is highlighted down its column.
 * - On tablets and phones, tabs show one plan at a time (the script adds .has-tabs). Without the script, the table scrolls
 *   sideways instead.
 */

/* Land clear of the sticky site header when a link jumps to #compare-plans */

.services-comparison {
  scroll-margin-top: clamp(96px, 12vw, 132px);
}

/* "Showing key services. Show all N services", above the table on the right */

.services-comparison__toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* The checkbox itself is hidden; its label reads and works as a link */

.services-comparison__show-all {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.services-comparison__show-all-label {
  color: var(--teal-darker);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.services-comparison__show-all-label:hover {
  color: #0d3d39;
}

.services-comparison__show-all:focus-visible ~ .services-comparison__show-all-label {
  outline: 2px solid var(--teal-dark);
  outline-offset: 2px;
}

/* "Show key services only" stays hidden until "Show all" is chosen */

.services-comparison__show-less {
  display: none;
}

/*
 * Until "Show all" is chosen: only the key services, and only the groups that have one. The other rows fold to no
 * height and can't be seen or read, but stay in the table, so every column is already as wide as it will be.
 */

.services-comparison:has(.services-comparison__show-all:not(:checked)) .services-comparison__extra,
.services-comparison:has(.services-comparison__show-all:not(:checked)) .services-comparison__extra-group tr {
  border-top: 0;
}

.services-comparison:has(.services-comparison__show-all:not(:checked)) .services-comparison__extra :is(th, td),
.services-comparison:has(.services-comparison__show-all:not(:checked)) .services-comparison__extra-group :is(th, td) {
  padding-top: 0;
  padding-bottom: 0;
  border-top: 0;
  border-bottom: 0;
  line-height: 0;
  visibility: hidden;
}

.services-comparison__show-all:checked ~ .services-comparison__showing {
  display: none;
}

.services-comparison__show-all:checked ~ .services-comparison__show-all-label .services-comparison__show-more {
  display: none;
}

.services-comparison__show-all:checked ~ .services-comparison__show-all-label .services-comparison__show-less {
  display: inline;
}

/* The table's frame: a fine teal border with rounded corners, scrolling sideways when it can't fit */

.services-comparison__scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--white);
}

.services-comparison__scroll:focus-visible {
  outline: 3px solid var(--teal-dark);
  outline-offset: 4px;
}

.services-comparison__table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 15px;
}

/* Plan names across the top, in serif on the darkest teal; "Service" on the left */

.services-comparison__table thead tr {
  background: #0d3d39;
  color: var(--white);
}

.services-comparison__table thead th {
  padding: 18px 12px;
  border: 0;
  color: var(--white);
  font-family: "DM Serif Display", Georgia, serif;
  font-size: 22px;
  font-weight: 400;
  text-transform: none;
}

.services-comparison__table thead th:first-child {
  padding: 18px 20px;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
}

/*
 * Each plan's name links to its plan page. On hover or keyboard focus it glows softly and lifts a little, so it
 * reads as something to press.
 */

.services-comparison__plan-link {
  display: inline-block;
  border-radius: 4px;
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease, text-shadow 0.2s ease, transform 0.2s ease;
}

.services-comparison__plan-link:hover,
.services-comparison__plan-link:focus-visible {
  color: var(--teal-light);
  text-shadow: 0 0 12px rgba(79, 185, 175, 0.85), 0 0 2px rgba(223, 245, 242, 0.6);
  transform: translateY(-2px);
}

.services-comparison__plan-link:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 4px;
}

/* Visitors who ask for reduced motion get the glow without the lift */

@media (prefers-reduced-motion: reduce) {
  .services-comparison__plan-link {
    transition: none;
  }

  .services-comparison__plan-link:hover,
  .services-comparison__plan-link:focus-visible {
    transform: none;
  }
}

/* A group's heading row: small capitals on pale teal */

.services-comparison__group th {
  padding: 12px 20px;
  border-right: 1px solid var(--border);
  background: #f2fbfa;
  color: var(--teal-darker);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}

/* Each service: its name on the left, what each plan gives centred under the plan */

.services-comparison__table tbody tr:not(.services-comparison__group) {
  border-top: 1px solid #e8ebe5;
}

.services-comparison__group td {
  background: #f2fbfa;
}

/* The service names, with the line that divides them from the plans */

.services-comparison__table tbody th[scope="row"],
.services-comparison__table tfoot td:first-child {
  border-right: 1px solid var(--border);
}

.services-comparison__table tbody th[scope="row"] {
  padding: 14px 20px;
  color: var(--text);
  font-weight: 500;
  text-align: left;
}

.services-comparison__table tbody td {
  padding: 14px 12px;
  color: var(--text-muted);
  text-align: center;
  overflow-wrap: break-word;
}

/* "View plan" under each plan's column */

.services-comparison__table tfoot tr {
  border-top: 1px solid var(--border);
}

.services-comparison__table tfoot td {
  padding: 16px 8px;
  text-align: center;
}

.services-comparison__view {
  color: var(--teal-darker);
  font-weight: 600;
}

.services-comparison__view:hover,
.services-comparison__view:focus-visible {
  color: #0d3d39;
}

/* The plan the visitor came from: a pale column and a "You were viewing" label */

.services-comparison__table td.is-highlighted {
  background: rgba(79, 185, 175, 0.12);
}

.services-comparison__table thead th.is-highlighted {
  background: var(--teal-darker);
  box-shadow: inset 0 4px 0 var(--teal);
}

.services-comparison__badge {
  display: block;
  width: max-content;
  margin: 0 auto 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #f4f3ee;
  color: var(--teal-darker);
  font-family: Inter, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Plan tabs: hidden until the script shows them, and only used on phones */

.services-comparison__tabs {
  display: none;
}

/* Shown until there is at least one plan and one service */

.services-comparison__empty {
  color: var(--text-muted);
}

/*
 * Laptops and up: the table wraps around its content instead of filling the page. Each plan column has the same
 * width, so the headings never change size, and the service column takes what its names need.
 */

@media (min-width: 900px) {
  .services-comparison__scroll {
    width: fit-content;
    max-width: 100%;
  }

  .services-comparison__table {
    width: auto;
  }

  .services-comparison__plan {
    width: 160px;
  }
}

/* Wide enough for every service name on one line */

@media (min-width: 1200px) {
  .services-comparison__table tbody th[scope="row"] {
    white-space: nowrap;
  }
}

/* Tablets and phones: a tab per plan, and one plan's column at a time so the table fits the screen */

@media (max-width: 899px) {
  .services-comparison__toolbar {
    justify-content: flex-start;
  }

  .services-comparison__table tbody th[scope="row"],
  .services-comparison__table thead th:first-child {
    padding-right: 14px;
    padding-left: 14px;
  }

  .services-comparison.has-tabs .services-comparison__tabs:not([hidden]) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 16px;
  }

  .services-comparison__tab {
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--white);
    color: var(--teal-darker);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
  }

  .services-comparison__tab[aria-selected="true"] {
    border-color: #0d3d39;
    background: #0d3d39;
    color: var(--white);
  }

  .services-comparison__tab:focus-visible {
    outline: 3px solid var(--teal);
    outline-offset: 2px;
  }

  .services-comparison.has-tabs .services-comparison__table {
    min-width: 0;
  }

  .services-comparison.has-tabs .services-comparison__table [data-plan]:not(.is-shown) {
    display: none;
  }

  .services-comparison.has-tabs .services-comparison__table thead th.services-comparison__plan {
    width: 45%;
  }
}
