/* ================================================================
   Products listing page (/products/)
   Individual Products | Packages toggle, size tiles drawn to scale
   (all-inclusive box, cards, EDDM), bento photo grids and the Direct
   Mail chooser. Data: src/_data/products.json, sizes.json, listmail.json.
   /assets/js/products-tabs.js adds .js to .products-page, which turns
   the stacked panels into tabs; without it everything simply stacks.
   /assets/js/products-sizes.js drives the quantity selects and the
   arrival lines.
   ================================================================ */

.products-page {
  padding-top: 3rem; padding-bottom: 3rem;
  /* Fallbacks only: the script measures the real sticky header and tab bar */
  --header-h: 71px;
  --tabbar-h: 0px;
}
.page-title {
  font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: clamp(2rem, 4vw, 2.8rem); line-height: 1.05; margin: .2rem 0 .6rem;
}

/* ---------------- Packages / Products toggle ---------------- */
.tabbar-anchor { height: 0; }
.tabbar { display: none; margin: 0 0 2rem; }
.products-page.js .tabbar { display: block; }
.tabs {
  display: inline-flex; max-width: 100%; gap: 3px; padding: 3px;
  background: #fff; border: 3px solid var(--navy); border-radius: 4px;
}
.tab {
  font-family: var(--display); font-weight: 600; font-size: .95rem; line-height: 1.2;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--navy); background: transparent; border: 0; border-radius: 2px;
  padding: .55rem 1.1rem .5rem; margin: 0; cursor: pointer; white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.tab:hover { background: var(--tint); }
.tab[aria-selected="true"] { background: var(--navy); color: #fff; }
.tab:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }

/* Panel titles are only needed while the panels are stacked (no script) */
.panel-title {
  font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: 1.5rem; border-bottom: 3px solid var(--red);
  display: inline-block; padding-bottom: .2rem; margin: 0 0 1.4rem;
}
.products-page.js .panel-title { display: none; }
.panel-lede { color: var(--slate); max-width: 44em; margin: 0 0 1.8rem; }

/* Anchor targets clear the sticky header (and the sticky tab bar on phones) */
.tabpanel, .products-page .category-block { scroll-margin-top: calc(var(--header-h) + 1.25rem); }
.tabpanel:focus, .products-page .category-block:focus { outline: none; }

/* ---------------- Packages tab ---------------- */
.pkg-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.8rem; }
.pkg-hero {
  grid-column: 1 / -1; position: relative;
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
}
.pkg-hero:hover, .mail-card:hover { transform: none; box-shadow: none; } /* the buttons inside are the links */
.pkg-hero .card-img { aspect-ratio: auto; min-height: 18rem; border-bottom: 0; border-right: 2px solid var(--line); }
.pkg-hero .card-body { padding: 1.8rem 2rem 2rem; gap: .7rem; justify-content: center; }
.pkg-hero h3 { font-size: clamp(1.7rem, 2.6vw, 2.2rem); }
.pkg-hero .card-body p { flex: 0 0 auto; font-size: 1rem; }
.card-badge {
  position: absolute; top: 1rem; left: -.55rem; z-index: 1;
  font-family: var(--display); font-weight: 600; font-size: .8rem;
  text-transform: uppercase; letter-spacing: .12em;
  background: var(--red); color: #fff; padding: .4rem .75rem .35rem;
  transform: rotate(-3deg); box-shadow: 3px 3px 0 var(--navy);
}
.pkg-includes { list-style: none; margin: .1rem 0 .3rem; padding: 0; font-size: .95rem; }
.pkg-includes li { position: relative; padding: .15rem 0 .15rem 1.4rem; }
.pkg-includes li::before { content: "★"; color: var(--red); position: absolute; left: 0; top: .35rem; font-size: .75rem; }
@supports (content: "x" / "y") { .pkg-includes li::before { content: "★" / ""; } }
.pkg-price { display: flex; align-items: baseline; gap: .9rem; flex-wrap: wrap; margin: .2rem 0 .5rem; }
.pkg-hero .bundle-now { font-size: 2.1rem; line-height: 1; }
.pkg-hero .btn { align-self: flex-start; }
.pkg-more { background: var(--tint); }
.pkg-more .card-body { justify-content: center; padding: 1.5rem 1.4rem; }
.pkg-more .card-body p { flex: 0 0 auto; }
.card-more { font-weight: 700; color: var(--red); font-size: .95rem; }

/* ---------------- Individual products tab ---------------- */
.cat-chips { display: flex; flex-wrap: wrap; gap: .6rem; margin: 0 0 2.2rem; }
.chip {
  font-family: var(--display); font-weight: 600; font-size: .85rem;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--navy); background: #fff; text-decoration: none;
  border: 2px solid var(--navy); border-radius: 99px; padding: .4rem .95rem .35rem;
  transition: background .15s ease, color .15s ease;
}
.chip:hover { background: var(--navy); color: #fff; }
.cat-head { margin-bottom: 1.4rem; }
.products-page .cat-head h2 { margin-bottom: .5rem; }
.cat-sub { margin: 0; color: var(--slate); }

/* Bento lead card: two columns of the grid, image beside the text */
.card-lead { grid-column: span 2; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.card-lead .card-img { aspect-ratio: auto; min-height: 15rem; border-bottom: 0; border-right: 2px solid var(--line); }
.card-lead .card-body { padding: 1.4rem 1.5rem 1.5rem; justify-content: center; gap: .55rem; }
.card-lead h3 { font-size: 1.7rem; }
.card-lead .card-body p { flex: 0 0 auto; font-size: .98rem; }
.card-full { margin: 0 0 1.8rem; } /* wide card on its own row (Direct Mail postcards) */

/* Direct Mail: EDDM vs. targeted list */
.mail-q {
  font-family: var(--display); font-weight: 600; font-size: 1.15rem;
  text-transform: uppercase; letter-spacing: .05em; margin: 0 0 1rem;
}
.mail-ways { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.8rem; }
.mail-card .card-body { padding: 1.4rem 1.5rem 1.5rem; gap: .5rem; }
.mail-card h3 { font-size: 1.5rem; }
.mail-card .card-body .mail-sub {
  flex: 0 0 auto; margin: -.2rem 0 .2rem;
  font-family: var(--display); font-weight: 500; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .14em; color: var(--red);
}
.mail-postage { font-size: .85rem; color: var(--slate); margin-top: -.3rem; }
.mail-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: .6rem; }

.mail-compare-wrap { margin-top: 1.8rem; background: #fff; border: 2px solid var(--navy); border-radius: 4px; overflow: hidden; }
.mail-compare { width: 100%; border-collapse: collapse; font-size: .93rem; }
.mail-compare caption {
  caption-side: top; text-align: left; padding: .8rem 1rem .65rem;
  font-family: var(--display); font-weight: 700; font-size: 1.1rem;
  text-transform: uppercase; letter-spacing: .04em;
  background: var(--tint); border-bottom: 2px solid var(--navy);
}
.mail-compare th, .mail-compare td { padding: .7rem 1rem; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
.mail-compare thead th {
  background: var(--navy); color: #fff; border-top: 0;
  font-family: var(--display); font-weight: 600; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .1em;
}
.mail-compare tbody th { font-weight: 700; width: 24%; }
.mail-compare td { color: var(--slate); }
.mail-compare tbody tr:first-child th, .mail-compare tbody tr:first-child td { border-top: 0; }

/* Arrival line on photo cards ("In your hands Oct 15 – Oct 21"), from products-sizes.js */
.card-arrive { font-size: .82rem; color: var(--slate); }
.card-arrive::before { content: "→ "; color: var(--red); }
.pkg-hero .card-arrive { margin: -.2rem 0 .2rem; }
.panel-foot { margin: 1.6rem 0 0; color: var(--slate); max-width: 50em; }

/* ---------------- Size tiles (drawn to scale) ---------------- */
.size-section { margin: 0 0 2.6rem; }
.size-head {
  display: flex; flex-wrap: wrap; gap: .8rem 2rem; align-items: flex-end; justify-content: space-between;
  margin: 0 0 1.3rem;
}
.size-head-text { flex: 1 1 28rem; min-width: 0; }
.size-kicker {
  font-family: var(--display); font-weight: 600; font-size: .78rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--red); margin: 0 0 .35rem;
}
.products-page .size-section h2, .size-title {
  font-family: var(--display); font-weight: 700; text-transform: uppercase; line-height: 1.1;
  font-size: 1.6rem; margin: 0 0 .45rem; border: 0; padding: 0; display: block;
}
.size-sub { margin: 0; color: var(--slate); max-width: 52em; line-height: 1.5; }
.size-sub .arrive { color: var(--navy); }
.qty-pick { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; white-space: nowrap; flex: 0 0 auto; }
.qty-pick select {
  font: inherit; font-weight: 700; color: var(--navy); background: #fff;
  border: 2px solid var(--navy); border-radius: 3px; padding: .35rem .5rem; min-height: 2.4rem; cursor: pointer;
}
.tile-row + .tile-row { margin-top: 1.5rem; }
.tile-row-h {
  display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .7rem; margin: 0 0 .7rem;
  font-family: var(--display); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; font-size: 1.05rem;
}
.tile-row-h img { width: 48px; height: 36px; object-fit: cover; border: 2px solid var(--line); border-radius: 3px; background: #fff; }
.tile-row-h img + img { margin-left: -.5rem; }
.tile-row-h small { font-family: inherit; font-weight: 400; text-transform: none; letter-spacing: 0; font-size: .86rem; color: var(--slate); }
.tile-row-h small { font-family: "Public Sans", system-ui, sans-serif; }
.tiles { --in: 12px; display: flex; flex-wrap: wrap; gap: .8rem; align-items: stretch; }
.tile {
  position: relative; flex: 0 0 10.5rem; max-width: 100%;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .12rem;
  padding: .9rem .6rem 1rem; background: #fff; border: 2px solid var(--line); border-radius: 4px;
  color: var(--navy); text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.tile-wide { flex-basis: 15.5rem; } /* flat brochures are wider than they are tall */
.tile:hover { border-color: var(--navy); transform: translate(-2px, -2px); box-shadow: var(--shadow-sign-sm); }
.tile:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.tile-badge {
  position: absolute; top: .45rem; right: .45rem;
  font-family: var(--display); font-weight: 600; font-size: .62rem; letter-spacing: .1em; text-transform: uppercase;
  color: #fff; background: var(--red); border-radius: 2px; padding: .18rem .4rem .14rem;
}
.tile-stage {
  display: flex; align-items: flex-end; justify-content: center; width: 100%;
  height: calc(var(--stage, 11) * var(--in)); margin: .2rem 0 .7rem;
}
.paper {
  position: relative; display: block; box-sizing: border-box;
  width: calc(var(--w) * var(--in)); height: calc(var(--h) * var(--in));
  background: #fff; border: 2px solid var(--navy); box-shadow: 3px 3px 0 var(--tint);
}
/* Fold lines (brochures are drawn flat, landscape) */
.paper.fold-tri::before, .paper.fold-tri::after, .paper.fold-half::before {
  content: ""; position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--slate);
}
.paper.fold-tri::before { left: 33.33%; }
.paper.fold-tri::after { left: 66.67%; }
.paper.fold-half::before { left: 50%; }
/* Door hanger hole */
.paper-hanger::before {
  content: ""; position: absolute; left: 50%; top: calc(.6 * var(--in));
  width: calc(1.3 * var(--in)); height: calc(1.3 * var(--in)); transform: translateX(-50%);
  border: 2px solid var(--navy); border-radius: 50%; background: var(--paper);
}
/* EDDM indicia box */
.paper-mail::after {
  content: ""; position: absolute; top: calc(.5 * var(--in)); right: calc(.5 * var(--in));
  width: calc(1.3 * var(--in)); height: calc(.95 * var(--in)); border: 1px solid var(--slate);
}
.tile-size { font-family: var(--display); font-weight: 700; font-size: 1.25rem; line-height: 1.1; }
.tile-name { font-size: .78rem; color: var(--slate); line-height: 1.3; }
.tile-price { margin-top: .4rem; font-size: 1.02rem; line-height: 1.2; }
.tile-price strong { font-weight: 700; }
.tile-price span { color: var(--slate); font-size: .85rem; }
.tile-nearest .tile-price span { text-decoration: underline dotted; text-underline-offset: .15em; } /* nearest listed quantity */
.tile-per { font-size: .78rem; color: var(--slate); }
.tile-extra { font-size: .74rem; color: var(--slate); line-height: 1.3; margin-top: .1rem; }
.size-foot { margin: 1.3rem 0 0; font-size: .92rem; line-height: 1.5; color: var(--slate); max-width: 60em; }

/* The all-inclusive box: navy, so the 2-day pieces read as their own thing */
.ai-box { background: var(--navy); color: #fff; border-radius: 6px; padding: 1.6rem 1.6rem 1.5rem; }
.ai-box .size-kicker { color: #F2B8C6; }
.products-page .ai-box h2 { color: #fff; }
.ai-box .size-sub { color: #C9D6E8; }
.ai-box .size-sub .arrive, .ai-box .size-sub [data-arrive-date] { color: #fff; }
.ai-box .qty-pick { color: #fff; }
.ai-box .tile-row-h { color: #fff; }
.ai-box .tile-row-h small { color: #C9D6E8; }
.ai-box .tile-row-h img { border-color: rgba(255,255,255,.35); }
.ai-box .tile { border-color: #fff; }
.ai-box .tile:hover { border-color: #fff; box-shadow: 4px 4px 0 var(--red); }
.ai-box .size-foot { color: #C9D6E8; }
.ai-box .size-foot strong { color: #fff; }
.ai-box a:not(.tile) { color: #fff; }

/* EDDM box inside Direct Mail */
.mail-box { background: #fff; border: 2px solid var(--navy); border-radius: 4px; padding: 1.3rem 1.4rem 1.4rem; margin: 0 0 1.6rem; }
.mail-box .tiles { margin-bottom: 1.1rem; }
.mail-box .tile { border-color: var(--line); }
.mail-card-full { margin: 0 0 1.6rem; }
.mail-card-full .card-body { padding: 1.4rem 1.5rem 1.5rem; gap: .5rem; max-width: 60em; }

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  .products-page { --header-h: 126px; } /* nav drops to its own row under the logo */
  .products-page.js .tabbar {
    position: sticky; top: var(--header-h); z-index: 40;
    background: var(--paper); padding: .6rem 0; margin: 0 0 1.4rem;
  }
  .tabpanel, .products-page .category-block { scroll-margin-top: calc(var(--header-h) + var(--tabbar-h) + .75rem); }
  .pkg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; }
  .pkg-hero { grid-template-columns: 1fr; }
  .pkg-hero .card-img { min-height: 0; aspect-ratio: 2 / 1; border-right: 0; border-bottom: 2px solid var(--line); }
  .pkg-hero .card-body { padding: 1.4rem 1.4rem 1.6rem; }
  .pkg-more { grid-column: 1 / -1; }
  .card-lead .card-img { min-height: 13rem; }
  .card-lead .card-body { padding: 1.2rem 1.3rem 1.3rem; }
  .card-full { margin-bottom: 1.2rem; }
  .mail-ways { gap: 1.2rem; }
  .mail-card .card-body { padding: 1.2rem 1.3rem 1.3rem; }
}
@media (max-width: 640px) {
  .mail-ways { grid-template-columns: 1fr; }
  .size-head { align-items: flex-start; }
  .tiles { --in: 7.5px; gap: .5rem; }
  .tile { flex: 1 1 7.4rem; padding: .7rem .4rem .8rem; }
  .tile-wide { flex-basis: 9rem; }
  .tiles-three .tile { flex-basis: 5.6rem; padding-left: .3rem; padding-right: .3rem; } /* three small cards fit one row */
  .tile-size { font-size: 1.05rem; }
  .tile-badge { font-size: .56rem; top: .35rem; right: .35rem; }
  .ai-box { padding: 1.1rem 1rem 1.1rem; }
  .mail-box { padding: 1rem .9rem 1rem; }
  .tile-row-h img { width: 40px; height: 30px; }
}
@media (max-width: 540px) {
  .products-page { --header-h: 185px; } /* nav wraps to two rows on phones */
  .products-page.js .tabbar { padding: .45rem 0; }
  .tabs { display: flex; width: 100%; }
  .tab { flex: 1 1 0; min-width: 0; white-space: normal; text-align: center; padding: .5rem .3rem .45rem; font-size: .85rem; letter-spacing: .04em; }
  .pkg-grid { grid-template-columns: 1fr; }
  .card-badge { left: .6rem; top: .6rem; }
  .pkg-hero .card-body { padding: 1.3rem 1.2rem 1.4rem; }
  .card-lead { grid-column: auto; display: flex; flex-direction: column; }
  .card-lead .card-img { aspect-ratio: 4 / 3; min-height: 0; border-right: 0; border-bottom: 2px solid var(--line); }
  .card-lead h3 { font-size: 1.45rem; }
  .card-lead .card-body { padding: 1.1rem 1.2rem 1.3rem; }

  /* Comparison table stacks into labelled rows */
  .mail-compare thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .mail-compare, .mail-compare tbody, .mail-compare tr, .mail-compare th, .mail-compare td { display: block; }
  .mail-compare caption { display: block; }
  .mail-compare tr { padding: .75rem 1rem .85rem; border-top: 2px solid var(--line); }
  .mail-compare tbody tr:first-child { border-top: 0; }
  .mail-compare th, .mail-compare td { padding: 0; border-top: 0; width: auto; }
  .mail-compare tbody th { width: auto; margin-bottom: .35rem; }
  .mail-compare td { margin-top: .35rem; }
  .mail-compare td::before {
    content: attr(data-label); display: block;
    font-family: var(--display); font-weight: 500; font-size: .7rem;
    text-transform: uppercase; letter-spacing: .14em; color: var(--red);
  }
}
@media (prefers-reduced-motion: reduce) {
  .tab, .chip, .tile { transition: none; }
}

/* Larger runs on the size tiles (sizes.json largeOptions): label the tile, explain in the box head */
.tile-run {
  display: inline-block; margin-top: .3rem; padding: .1rem .45rem; border-radius: 3px;
  align-self: flex-start; background: var(--navy); color: #fff; font-size: .72rem; font-weight: 600; letter-spacing: .02em;
}
.tile-run[hidden] { display: none; }
.size-sub.size-large { margin-top: .4rem; }
.size-sub.size-large[hidden] { display: none; }
