/* Product comparison — CodyHouse pattern + Sony TW design language
   - Fixed left "features" column with spec labels
   - Horizontally scrolling right "products" area (3 product columns)
   - Prev / next navigation arrows for product columns
   - Fixed row heights so labels & values stay aligned
   - Sony palette: white surface, gold accent (#c89544/#b88a4f), soft gray dividers */

.c5-compare {
  position: relative;
  padding: 100px 24px 120px;
  isolation: isolate; /* contain ::before z-index inside .c5-compare's stacking context */
  color: #1d1d1f;
  font-family:
    "SST", "Helvetica Neue", "Microsoft JhengHei", "微軟正黑體", Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
/* Background image lives on a pseudo-element so it can be flipped per
   breakpoint via `transform`. The #fff fallback above stays visible if
   the asset fails to load. */
.c5-compare::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url(../new-images/compare/background.png) no-repeat center top /
    cover;
  z-index: -1;
  pointer-events: none;
}

.c5-compare__inner {
  max-width: 1180px;
  margin: 0 auto;
  position: relative;
}

/* ───────── Heading ───────── */

.c5-compare__tag {
  position: absolute;
  top: -56px;
  left: 0;
  background: #ff7a3d;
  color: #fff;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.18em;
  line-height: 1;
}

.c5-compare__heading {
  text-align: center;
  margin-bottom: 20px;
  /* shift the centering origin past the fixed left features column so the
     eyebrow + title visually center over .c5-compare__products instead of
     the full .c5-compare__inner. Reset to 0 on mobile (see ≤720px block). */
  padding-left: var(--feat-w);
}

.c5-compare__eyebrow {
  display: block;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #1d1d1f;
}

.c5-compare__title {
  font-size: clamp(28px, 3.6vw, 56px);
  font-weight: 700;
  line-height: 1.45;
  margin: 0;
  color: #1d1d1f;
}

/* ───────── Table shell ───────── */

.c5-compare__table {
  position: relative;
}

/* CSS custom props centralize all row heights so left + right always align */
.c5-compare {
  --top-h: 734px; /* +90 to absorb the desktop image bump (200 → 290) */
  --section-h: 56px;
  --row-h: 100px;
  --feat-w: 160px;
  --nav-top: 382px; /* color-label row (top-pad 28 + img 290 + img-mb 18 + swatches 32 + swatches-mb 8 + ~½ label) */
  --sticky-name-top: 70px; /* offset from viewport top (clears fixed header) */
}

/* ───────── Left: fixed features column ───────── */

.c5-compare__features {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--feat-w);
  z-index: 2;
}

.c5-compare__features-top {
  height: var(--top-h);
  border-bottom: 1px solid #e5e5e5;
}

.c5-compare__feature-section {
  height: var(--section-h);
  margin: 0;
  padding: 0 18px 14px;
  font-size: 14px;
  font-weight: 700;
  color: #000;
  background: #fafafa;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  align-items: flex-end;
  letter-spacing: 0.06em;
}

.c5-compare__feature-list {
  list-style: none;
  margin: 0;
  padding: 0;
  /* horizontal-only design: keep the bottom divider, no side frame */
  border-bottom: 1px solid #e5e5e5;
}

.c5-compare__feature-list li {
  height: var(--row-h);
  padding: 0 20px;
  /* match the table-content (value cell) typography */
  font-size: 15px;
  color: #1d1d1f;
  line-height: 1.65;
  background: #ededed;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  border-bottom: 1px solid #ececec;
}

.c5-compare__feature-list li:last-child {
  border-bottom: none;
}

/* ───────── Right: scrollable products area ───────── */

.c5-compare__products-wrap {
  margin-left: var(--feat-w);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: thin;
}

.c5-compare__products-wrap::-webkit-scrollbar {
  height: 6px;
}

.c5-compare__products-wrap::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

.c5-compare__products {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
}

.c5-compare__product {
  flex: 0 0 auto;
  width: calc((100% - 0px) / 3); /* 3 columns by default on desktop */
  min-width: 260px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
}

/* The last product also snaps at its end edge so the scroll container can
   rest at the natural max-scroll position. Without this, "start" snap on a
   card wider than the remaining slack leaves an unreachable gap past the
   last snap point, and the next arrow can't hide cleanly. */
.c5-compare__product:last-child {
  border-right: none;
  scroll-snap-align: start end;
}

/* ── Product top-info ── */

.c5-compare__top {
  height: var(--top-h);
  /* horizontal padding gives the image / button / text breathing room from the edges */
  padding: 28px 24px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-bottom: 2px solid #e5e5e5;
}

.c5-compare__new {
  /* sit below-left, hugging the divider above; fixed, non-shrinking height
     (matches the 30px tag image) so every column reserves the same space */
  align-self: flex-start;
  height: 30px;
  flex-shrink: 0;
  margin: -2px 0px 0px -5px;
}

.c5-compare__new img {
  display: block;
  height: 30px;
  width: auto;
}

.c5-compare__img {
  position: relative;
  width: 100%;
  height: 290px;
  flex-shrink: 0; /* keep image height constant so swatches/labels align across columns */
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 45px;
}

/* Colour variants are stacked as layers and cross-fade on swatch select,
   mirroring the Apple AirPods Max overview bento colour transition. */
.c5-compare__img img {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.6s ease-out,
    visibility 0.6s ease-out;
}

.c5-compare__img img.is-active {
  opacity: 1;
  visibility: visible;
}

.c5-compare__name {
  font-size: 23px;
  font-weight: 700;
  line-height: 1.3;
  color: #1d1d1f;
  /* reserve 2 lines so a wrapping title doesn't shift the description / button below */
  min-height: calc(19px * 1.3 * 2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-wrap: nowrap;
}

.c5-compare__desc {
  font-size: 18px;
  color: #1d1d1f;
  /* fill the padded column width; card padding provides the edge inset */
  align-self: stretch;
  text-align: left;
  box-sizing: border-box;
  /* reserve 3 lines so 2- and 3-line copy keep the buy button aligned */
  min-height: calc(18px * 1.75 * 3);
  flex-shrink: 0;
}

.c5-compare__swatches {
  list-style: none;
  display: flex;
  gap: 8px;
  padding: 0;
  margin: 0 0 8px;
  justify-content: center;
  /* fixed row height + centering so the divider below aligns across all columns
     regardless of swatch count */
  align-items: center;
  height: 32px;
  flex-shrink: 0;
}

.c5-compare__swatches button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--swatch, #1a1a1a);
  padding: 0;
  cursor: pointer;
  outline: none;
  transition: box-shadow 0.15s ease;
}

.c5-compare__swatches button.is-active {
  box-shadow:
    0 0 0 1.5px #fff,
    0 0 0 3px #5b68ec;
}

.c5-compare__color-name {
  align-self: stretch; /* span full column width so the divider isn't text-width */
  flex-shrink: 0; /* never compress, so the divider stays aligned across columns */
  margin: 0; /* no gap so the NEW tag below can hug the divider */
  padding-bottom: 16px;
  border-bottom: 2px solid #d8d8d8;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: #666666;
  text-align: center;
  min-height: 1em;
}

.c5-compare__color-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 0;
  background-color: #c8b9a4; /* 砂岩 */
  color: #fff;
  font-size: 11px;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

/* no badge text → no pill (keeps the divider clean for other colors) */
.c5-compare__color-badge:empty {
  display: none;
}

.c5-compare__buy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  flex-shrink: 0;
  vertical-align: middle;
  margin: 0px 0 14px;
  padding: 0.85em 1em;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 0;
  -webkit-transition:
    background-color 0.25s ease-out,
    color 0.25s ease-out;
  transition:
    background-color 0.25s ease-out,
    color 0.25s ease-out;
  font-family: inherit;
  font-size: 1rem;
  -webkit-appearance: none;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  background-color: #5b68ec;
  color: #fff;
}

.c5-compare__buy:hover,
.c5-compare__buy:focus,
.c5-compare__buy:visited,
.c5-compare__buy:active {
  color: #fff;
}

.c5-compare__buy:hover {
  background-color: #4653e8;
}

.c5-compare__buy-icon {
  width: 18px;
  height: auto;
  flex-shrink: 0;
  display: block;
}

.c5-compare__more {
  color: #5b68ec; /* match the buy button colour */
  font-size: 16px;
  letter-spacing: 0.04em;
  text-decoration: none;
  flex-shrink: 0;
}

.c5-compare__more::after {
  content: "˃";
  margin-left: 2px;
}

.c5-compare__more:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Product values ── */

.c5-compare__values {
  display: flex;
  flex-direction: column;
  border-bottom: 2px solid #e5e5e5;
}

/* Floating banner — pinned at the top of the viewport while user is reading
   the spec rows. Driven by JS (script.js initCompareStickyName). */
.c5-compare__floating-name {
  position: fixed;
  top: var(--sticky-name-top);
  left: 0;
  right: 0;
  z-index: 6;
  pointer-events: none;
  display: flex;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.c5-compare__floating-name.is-visible {
  opacity: 1;
}
@media screen and (min-width: 750px) {
  .c5-compare__floating-name {
    display: none;
  }
}
.c5-compare__floating-name-inner {
  background: #fff;
  border: 1px solid #d2d2d7;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #1d1d1f;
  border-radius: 20px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.c5-compare__value-section {
  height: var(--section-h);
  background: #fafafa;
  border-bottom: 1px solid #e5e5e5;
}

.c5-compare__value-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.c5-compare__value-list li {
  height: var(--row-h);
  padding: 0 20px;
  font-size: 16px;
  color: #1d1d1f;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: left;
  border-bottom: 2px solid #e5e5e5;
  line-height: 1.65;
  text-wrap: pretty;
}

.c5-compare__value-list li:last-child {
  border-bottom: none;
}

/* ───────── Nav arrows ───────── */

.c5-compare__nav {
  position: absolute;
  top: var(--nav-top);
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #d2d2d7;
  color: #1d1d1f;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  transition:
    opacity 0.25s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
  padding: 0;
  line-height: 0;
}

.c5-compare__nav svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.c5-compare__nav:hover {
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}

.c5-compare__nav:hover:not(.is-hidden) {
  transform: translateY(calc(-50% - 1px));
}

.c5-compare__nav--prev {
  left: calc(var(--feat-w) + 12px);
}

.c5-compare__nav--next {
  right: 12px;
}

.c5-compare__nav.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* ───────── Tablet (≤ 1024px) ───────── */

@media (max-width: 1024px) {
  .c5-compare {
    padding: 80px 20px 100px;
    --top-h: 600px;
    --feat-w: 140px;
    --nav-top: 230px; /* on the color-label row (img-bottom 168 + spacing) */
  }

  .c5-compare__product {
    width: calc((100% - 0px) / 2.2); /* show ~2 products + glimpse of next */
  }

  .c5-compare__img {
    height: 140px;
  }

  .c5-compare__name {
    font-size: 20px;
  }

  .c5-compare__desc {
    font-size: 16px;
  }
}

/* ───────── Mobile (≤ 720px) ───────── */

@media (max-width: 720px) {
  .c5-compare {
    padding: 56px 16px 72px;
    --top-h: 600px;
    --section-h: 50px;
    --row-h: 180px;
    --feat-w: 120px;
    --nav-top: 285px; /* on the color-label row (img-bottom 190 + img-mb 14 + swatches 32 + swatches-mb 8 ≈ centerline) */
  }
  /* On phones anchor the bg image to its right edge so it reveals
     right-to-left as the viewport narrows (instead of cropping equally
     from both sides with `center top`). */
  .c5-compare::before {
    background-position: right top;
  }

  /* reserve 4 lines: the longest copy wraps past 3 lines in the narrow mobile column */
  .c5-compare__desc {
    min-height: calc(11.5px * 1.75 * 4);
  }

  .c5-compare__tag {
    position: static;
    display: inline-block;
    margin-bottom: 22px;
    font-size: 13px;
    padding: 10px 18px;
  }

  .c5-compare__heading {
    text-align: center;
    margin-bottom: 14px;
    padding-left: 0; /* drop the features-column offset on mobile */
  }

  .c5-compare__eyebrow,
  .c5-compare__title {
    text-align: center;
  }

  .c5-compare__eyebrow {
    font-size: calc(20 / var(--root-font-size) * var(--font-ratio) * 1rem);
  }

  .c5-compare__title {
    font-size: calc(22 / var(--root-font-size) * var(--font-ratio) * 1rem);
    text-wrap: nowrap;
  }

  /* Features column compact */
  .c5-compare__feature-section {
    height: var(--section-h);
    padding: 0 12px 10px;
    font-size: 13px;
    letter-spacing: 0.04em;
  }

  .c5-compare__feature-list li {
    height: var(--row-h);
    padding: 0 4px;
    font-size: 14px;
  }

  /* Mobile-only layout shift: let the product .c5-compare__top span the full
     viewport width while keeping the spec rows aligned with the left features
     labels. Achieved by (1) hiding the empty features-top spacer, (2) shifting
     the absolutely-positioned features column down to where values start,
     (3) escaping the section's horizontal padding so the table reaches the
     viewport edges, (4) dropping the products-wrap's left offset, (5) widening
     each product to 100vw, and (6) pushing each product's .c5-compare__values
     right by --feat-w so its rows still line up against the features labels. */
  .c5-compare__features-top {
    display: none;
  }
  .c5-compare__features {
    top: var(--top-h);
  }
  .c5-compare__table {
    /* escape the .c5-compare horizontal padding (16px each side on mobile)
       so the table runs edge-to-edge and 100vw children fit without clipping */
    margin-left: -16px;
    margin-right: -16px;
  }
  .c5-compare__products-wrap {
    margin-left: 0;
  }
  .c5-compare__product {
    width: 100vw;
    min-width: 0;
    max-width: none;
  }
  .c5-compare__values {
    margin-left: var(--feat-w);
  }

  .c5-compare__top {
    height: var(--top-h);
    padding: 22px 16px 24px;
  }

  .c5-compare__img {
    height: 190px;
    margin-bottom: 14px;
  }

  .c5-compare__name {
    font-size: 24px;
  }

  .c5-compare__desc {
    font-size: 14px;
    line-height: 1.75;
  }

  .c5-compare__swatches {
    margin-bottom: 16px;
  }

  .c5-compare__buy {
    width: 100%;
    font-size: 0.875rem;
    padding: 0.85em 1em;
  }

  .c5-compare__more {
    font-size: 14px;
  }

  .c5-compare__value-list li {
    padding: 14px;
    font-size: 14px;
    /* Center wrapped multi-line values. The base rule uses text-align:left,
       which left-aligns the wrapped lines (only single-line values looked
       centred via the flex align-items:center). */
    align-items: baseline;
  }

  .c5-compare__nav {
    width: 42px;
    height: 42px;
  }

  .c5-compare__nav svg {
    width: 18px;
    height: 18px;
  }

  /* Top section is now full-viewport-width on mobile, so the arrows hug the
     viewport edges (negative inset escapes the .c5-compare 16px gutter) rather
     than clearing the features column. */
  .c5-compare__nav--prev {
    left: 8px;
  }

  .c5-compare__nav--next {
    right: 8px;
  }

  /* While the floating product-name overlay is pinned at the top of the
     viewport, also pin the prev/next arrows so users can flip products
     without scrolling back up to the product images. */
  .c5-compare.is-floating-name .c5-compare__nav {
    position: fixed;
    top: var(--sticky-name-top);
    transform: translateY(0);
    z-index: 7;
  }
  .c5-compare.is-floating-name .c5-compare__nav--prev {
    left: 8px;
  }
  .c5-compare.is-floating-name .c5-compare__nav:hover:not(.is-hidden) {
    transform: translateY(-1px);
  }
}
