/* AEKE .sg — the toggle-box card rows (the K1's machine and accessory rows).
 *
 * MEASURED ON aeke.com's K1 page at 1440, reading the rules the page itself applies:
 *
 *   .toggle-boxes--inner    grid, `padding: 0 50px`, `gap: 20px`, `align-items: end`,
 *                           `max-width: 1540px`, 4 columns of 316.2px
 *   .toggle-box             316x392 — `overflow: hidden`, `position: relative`, radius 4px,
 *                           `margin-bottom: 10px`
 *     image                 `padding-bottom` = the box's `--ratio-percent` (105.15% / 100%)
 *     button                60px, `padding: 10px 30px`, ground = the panel's ground,
 *                           label 17px/500, plus glyph 14x14 at `right: 25px`
 *     panel                 absolutely positioned at the bottom, radius `16px 16px 0 0`,
 *                           15px copy, 30px padding
 *   .section-header         `padding: 0 0 30px`, centred; title 34px/600, line-height 42px
 *
 * ## The one substitution
 *
 * Upstream opens the panel with `height: 97%`, and on the live page that resolves to **0px** —
 * the panel never appears, so all sixteen boxes carry copy nobody can read. The percentage asks
 * for a share of a containing block whose height comes from its own content, and upstream's inner
 * is `calc(100% - 60px)`, which has the same problem. Same box, expressed as `inset: 3% 0 0`,
 * which does resolve, and animated on `transform` because a height that was never definite is
 * not a height that can be transitioned. See the note in `sections/toggle_boxes.html`.
 */

/* The 70px of section spacing is a margin on `.toggle-boxes`, one level down, so the wrapper has
   to contain it — otherwise it collapses out and the section reports 825px where the live page
   reports 965. Same trap as the collapsed margins on the home page's rich-text blocks. */
.toggle-boxes-section {
  display: flow-root;
}

.toggle-boxes__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  max-width: var(--grid-width-row);
  margin: 0 auto;
  padding: 0 15px 30px;
  text-align: center;
}

.toggle-boxes__title {
  margin: 0;
  font-size: 34px;
  font-weight: 600;
  line-height: 42px;
  color: var(--color-heading);
}

.toggle-boxes__subtitle {
  margin: 0;
  color: var(--color-body);
}

.toggle-boxes__inner {
  display: grid;
  align-items: end;
  width: 100%;
  max-width: var(--grid-width-row);
  margin: 0 auto;
  padding: 0 15px;
  gap: 20px;
}

/* The palette lives on the row, so both the label bars and the panels take it from one place. */
.toggle-boxes__inner--light {
  --toggle-panel-surface: var(--toggle-light-surface);
  --toggle-panel-ink: var(--toggle-light-ink);
}

.toggle-boxes__inner--dark {
  --toggle-panel-surface: var(--toggle-dark-surface);
  --toggle-panel-ink: var(--toggle-dark-ink);
}

@media (min-width: 48em) {
  .toggle-boxes__header {
    padding: 0 50px 30px;
  }

  .toggle-boxes__inner {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0 50px;
  }
}

@media (min-width: 66.75em) {
  .toggle-boxes__inner {
    grid-template-columns: repeat(var(--toggle-columns, 4), minmax(0, 1fr));
  }
}

/* ------------------------------------------------------------------------ the card */

.toggle-box {
  position: relative;
  overflow: hidden;
  margin-bottom: 10px;
  border-radius: var(--block-border-radius);
  isolation: isolate;
}

.toggle-box__image {
  display: block;
  position: relative;
  margin: 0;
  padding-bottom: var(--ratio-percent, 100%);
}

.toggle-box__image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The label bar is the control. Its ground is the panel's, which is what makes the open card
   read as one surface rather than an image with a lid. */
.toggle-box__button {
  position: relative;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 60px;
  padding: 10px 30px;
  border: 0;
  background: var(--toggle-panel-surface);
  color: var(--toggle-panel-ink);
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}

.toggle-box__marker {
  position: absolute;
  right: 25px;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  transition: transform var(--duration-theme) var(--ease-theme);
}

.toggle-box__marker::before,
.toggle-box__marker::after {
  content: "";
  position: absolute;
  background: currentColor;
  border-radius: 1px;
}

.toggle-box__marker::before {
  top: 6px;
  left: 0;
  width: 100%;
  height: 2px;
}

.toggle-box__marker::after {
  top: 0;
  left: 6px;
  width: 2px;
  height: 100%;
}

.toggle-box.is-open .toggle-box__marker {
  transform: translateY(-50%) rotate(135deg);
}

.toggle-box__panel {
  position: absolute;
  inset: 3% 0 0;
  z-index: 11;
  overflow-y: auto;
  padding: 30px 30px 90px;
  border-radius: var(--block-border-radius) var(--block-border-radius) 0 0;
  background: var(--toggle-panel-surface);
  color: var(--toggle-panel-ink);
  font-size: 0.9375rem;
  transform: translateY(101%);
  visibility: hidden;
  transition: transform var(--duration-theme) var(--ease-theme),
    visibility 0s linear var(--duration-theme);
}

/* The 90px of bottom padding is the label bar's 60px plus the panel's own 30: the copy has to
   stop above the control that is covering the bottom of the card. */
.toggle-box.is-open .toggle-box__panel {
  transform: translateY(0);
  visibility: visible;
  transition: transform var(--duration-theme) var(--ease-theme), visibility 0s;
}

.toggle-box__panel > :first-child {
  margin-top: 0;
}

.toggle-box__panel > :last-child {
  margin-bottom: 0;
}

.toggle-box__button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -3px;
}

/* --------------------------------------------------------------- narrow screens */

@media (max-width: 47.99em) {
  .toggle-boxes__inner {
    gap: 10px;
  }

  /* Upstream's `swipe-on-mobile`: the row becomes a snap strip rather than four stacked
     columns, so a phone shows the shape of the row instead of an endless list. */
  .toggle-boxes__inner--swipe {
    grid-auto-flow: column;
    grid-auto-columns: minmax(75%, 1fr);
    grid-template-columns: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .toggle-boxes__inner--swipe::-webkit-scrollbar {
    display: none;
  }

  .toggle-boxes__inner--swipe .toggle-box {
    scroll-snap-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toggle-box__panel,
  .toggle-box__marker {
    transition: none;
  }
}
