/* Keep one set of table values for both the desktop comparison and the small cards. */
.table-scroll { container-type: inline-size; }
.cell-label, .contents-toggle { display: none; }

@container (max-width: 42rem) {
  .table-scroll table {
    position: relative;
    display: block;
    min-width: 0;
    width: 100%;
    margin: 0;
    text-align: start;
  }
  .table-scroll caption {
    display: block;
    padding: .75rem 1rem;
    font-size: .875rem;
    line-height: 1.5;
  }
  .table-scroll thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .table-scroll tbody, .table-scroll tbody tr { display: block; }
  .table-scroll tbody tr { padding: 0 1rem .4rem; background: white; }
  .table-scroll tbody th, .table-scroll tbody td {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: .5rem;
    min-width: 0;
    padding: .65rem 0;
    border: 0;
    font-size: 1rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }
  .table-scroll tbody td + td { border-top: 1px solid var(--line); }
  .table-scroll tbody th[scope="row"] {
    display: block;
    margin-inline: -1rem;
    padding: .75rem 1rem;
    background: #e1efec;
  }
  .cell-label { display: block; color: var(--muted); font-weight: 600; }
  .table-scroll [data-price] { text-align: end; font-weight: bold; }
  .table-scroll td.long-value { grid-template-columns: minmax(0, 1fr); gap: .15rem; }
}

@media (max-width: 850px) {
  .reader > .section-jump {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    overflow: visible;
    gap: 0;
    padding: 0;
    margin-bottom: 1.5rem;
  }
  .reader > .section-jump a {
    min-width: 0;
    max-width: none;
    padding: .7rem .85rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }
  .contents-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    width: 100%;
    min-height: 46px;
    margin: 0 0 .6rem;
    padding: .7rem .85rem;
    border: 1px solid #abc7bf;
    border-radius: .5rem;
    background: #f1f6f1;
    color: #17494b;
    font: 600 1rem/1.45 Arial, sans-serif;
    text-align: start;
    cursor: pointer;
  }
  .contents-toggle::after {
    content: '';
    width: .52rem;
    height: .52rem;
    flex: none;
    margin-right: .2rem;
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    transform: translateY(-25%) rotate(45deg);
  }
  .contents-toggle[aria-expanded="true"]::after { transform: translateY(25%) rotate(225deg); }
  .contents-toggle[aria-expanded="false"] + .section-jump { display: none; }
  .reading-column > .planning, .reading-column > .discovery {
    padding: clamp(1rem, 4vw, 1.75rem);
  }
  .planning .steps { grid-template-columns: minmax(0, 1fr); gap: .7rem; }
  .steps > a {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: .25rem .65rem;
    padding: .9rem;
    border-radius: .9rem;
  }
  .steps > a > span { grid-area: 1 / 1; width: 2rem; height: 2rem; }
  .steps > a > div { grid-area: 1 / 2; min-width: 0; }
  .steps > a > b { grid-area: 1 / 3; }
  .steps h3 { margin: .15rem 0 .5rem; font-size: clamp(1.25rem, 4.4vw, 1.5rem); }
  .steps p { font-size: 1rem; line-height: 1.55; }
  .planning h2, .discovery h2 { font-size: clamp(1.65rem, 5.6vw, 2.25rem); line-height: 1.14; }
  .reading-column > .discovery { grid-template-columns: minmax(0, 1fr); gap: 1.2rem; }
  .discovery > div:last-child { grid-area: 1 / 1; min-width: 0; }
  .discovery-photo { grid-area: 2 / 1; }
  .discovery-photo img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; }
  .discovery-photo > span { left: .6rem; bottom: .6rem; padding: .4rem .65rem; }
  .small-feature { gap: .85rem; margin-top: 1.25rem; padding-top: 1rem; }
  .small-feature picture { flex: 0 0 4rem; }
  .small-feature img { width: 100%; height: 4rem; object-fit: cover; }
  .small-feature a { font-size: .875rem; }
}

@media (max-width: 760px) {
  main, main.article-layout, main.error-page, .site-header {
    width: calc(100% - 2rem);
    padding-inline: 0;
  }
  .reading-column, .new-hero { overflow-wrap: break-word; }
  .landing-page .reading-column > .guide-section { padding: 1.25rem 0; }
  .reading-column > .home-quick-plan { width: 100%; }
  .reader .section-jump a, .btn, .form-grid > *, .small-feature > div { min-width: 0; }
  .btn { max-width: 100%; white-space: normal; text-align: center; }
  .site-header .hamburger { min-height: 44px; font-size: .95rem; }
  .site-header .nav-links.open { align-items: stretch; gap: 0; }
  .site-header .nav-links.open a { padding: .75rem; }
  .new-hero.with-art { gap: 1rem; }
  .new-hero figure img { display: block; height: auto; aspect-ratio: 3 / 2; object-fit: cover; }
  .reading-column .home-index .index-item {
    grid-template-columns: minmax(0, 30%) minmax(0, 1fr);
    gap: .85rem;
  }
  .reading-column .index-item h2 { padding: .75rem .75rem .75rem 0; margin: 0; font-size: 1.2rem; }
  .reading-column .index-item picture { height: 100%; }
  .reading-column .index-item img { display: block; margin: 0; width: 100%; height: 100%; min-height: 5.5rem; object-fit: cover; }
  .form-grid, .provider-grid, .painting-grid, .info-grid { grid-template-columns: minmax(0, 1fr); }
  .cost-calculator, .provider-card { padding: 1rem; }
  .form-grid input, .form-grid select { max-width: 100%; min-width: 0; }
  .form-grid label, .calculation-result { overflow-wrap: anywhere; }
}

@media (max-width: 420px) {
  .steps > a { align-items: center; row-gap: .55rem; }
  .steps > a > div { display: contents; }
  .steps h3 { grid-area: 1 / 2; margin: 0; }
  .steps p { grid-column: 1 / -1; grid-row: 2; }
}
