/* Vintage surf-magazine intro: cover flips open across the spine into a
   double-page spread, like a real magazine on a table.
   Loaded after styles.css — overrides hero rules. */

:root {
  --cover-angle: 0deg;   /* 0 → -178deg as it opens */
  --book-shift: 1;       /* 1 = closed cover centered, 0 = spine centered   */
  --mag-scale: 1;        /* gentle zoom after the open */
  --cover-opacity: 1;
  --cover-shade: 0;      /* light on the turning cover, peaks mid-flip */
  --cast-opacity: 0;     /* cover's shadow cast on the page below */
  --page-h: min(82vh, 64vw);
  --page-w: calc(var(--page-h) * 0.71);  /* matches the cover scan ratio */
  --mag-paper: #fbf7ec;
}

.hero-scroll {
  height: 340vh;
  background: var(--ink);
}

.hero-sticky {
  background:
    radial-gradient(120% 90% at 50% 42%, rgb(255 255 255 / 0.35), transparent 65%),
    linear-gradient(#e2d5bc, #c9b995);
}

/* ink-black banner so it doesn't blend into the paper backdrop */
.site-header {
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.4);
}

/* dark logo → invert to paper-white on the black banner */
.site-wordmark img {
  filter: invert(1) brightness(1.04);
}

.cart-button {
  border-left-color: rgb(247 241 231 / 0.4);
}

.cart-count {
  background: var(--sun);
  color: var(--ink);
}

.mag-scene {
  position: absolute;
  inset: 0;
}

/* The whole book slides right as the cover opens, so the closed cover starts
   centered and the finished spread ends centered.
   NOTE: perspective lives here and ONLY the cover is 3D — putting the spread
   inside a preserve-3d subtree makes Chrome drop paints of filtered images. */
.mag-book {
  position: absolute;
  inset: 0;
  transform: translateX(calc(var(--book-shift) * var(--page-w) / -2)) scale(var(--mag-scale));
  perspective: 2400px;
  perspective-origin: 50% 42%;
  will-change: transform;
}

/* Double-page spread, anchored at its right edge. Its width grows from one
   page to two as the cover sweeps past the spine — no clip-path (Chrome
   paint bugs), just overflow on a fixed-size inner container. */
.mag-spread {
  position: absolute;
  top: 50%;
  right: calc(50% - var(--page-w));
  width: calc(var(--page-w) * (1 + var(--spread-reveal, 0)));
  height: var(--page-h);
  transform: translateY(-50%);
  overflow: hidden;
  box-shadow: 0 26px 70px rgb(0 0 0 / 0.5);
}

.mag-spread-inner {
  position: absolute;
  top: 0;
  right: 0;
  width: calc(var(--page-w) * 2);
  height: 100%;
  background:
    radial-gradient(rgb(17 16 13 / 0.035) 1px, transparent 1.3px) 0 0 / 7px 7px,
    var(--mag-paper);
}

/* Cover: one page wide, hinged on the spine (left edge sits at spread center) */
.mag-cover {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 5;
  width: var(--page-w);
  height: var(--page-h);
  transform-origin: left center;
  transform: translateY(-50%) rotateY(var(--cover-angle));
  transform-style: preserve-3d;
  opacity: var(--cover-opacity);
  will-change: transform, opacity;
}

.mag-cover.is-open {
  pointer-events: none;
}

/* backface-visibility breaks under blend modes, so the face swap is driven
   by JS toggling .is-past at the 90° mark */
.mag-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.mag-face--back {
  visibility: hidden;
}

.mag-cover.is-past .mag-face--front {
  visibility: hidden;
}

.mag-cover.is-past .mag-face--back {
  visibility: visible;
}

.mag-face--front {
  background: var(--mag-paper);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.45);
  color: var(--ink);
  cursor: pointer;
}

/* full-bleed scanned cover — already vintage, no extra filters */
.mag-cover-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

/* inside of the cover = plain aged paper, matches the spread so the
   final crossfade is invisible */
.mag-face--back {
  background:
    radial-gradient(rgb(17 16 13 / 0.035) 1px, transparent 1.3px) 0 0 / 7px 7px,
    var(--mag-paper);
  box-shadow: inset 0 0 46px rgb(92 62 20 / 0.18);
  transform: rotateY(180deg);
}

/* Cover contents — logo printed where a masthead would be */
.mag-masthead {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  padding: 4cqh 8cqw 0;
}

.mag-face--front {
  container-type: size;
}

.mag-logotype-img {
  display: block;
  width: 62cqw;
  opacity: 0.9;
}

.mag-issue {
  margin: 1.4cqh 0 0;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 2.6cqw;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #14120e;
  opacity: 0.85;
}

.mag-issue span {
  font-size: 1.9cqw;
  vertical-align: 12%;
  padding: 0 0.4cqw;
}

/* Dynamic light while the cover turns */
.mag-shade {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.mag-shade--front {
  background: linear-gradient(90deg, rgb(8 6 2 / 0.62), rgb(8 6 2 / 0.18) 45%, transparent 78%);
  opacity: calc(var(--cover-shade) * 0.9);
}

.mag-shade--back {
  background: radial-gradient(130% 110% at 20% 50%, transparent 55%, rgb(8 6 2 / 0.3));
  opacity: calc(var(--cover-shade) * 0.85);
}

/* shadow the cover casts on the left page as it lands */
.mag-cast {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 50%;
  z-index: 4;
  width: 50%;
  background: linear-gradient(270deg, rgb(20 12 4 / 0.45), rgb(20 12 4 / 0.12) 55%, transparent);
  opacity: var(--cast-opacity);
  pointer-events: none;
}

/* ---- The spread is the catalog ---- */

.product-stage {
  position: absolute;
  inset: 0;
  padding: clamp(18px, 3.4vh, 34px) clamp(18px, 2.2vw, 36px) clamp(30px, 4.5vh, 44px);
}

/* center gutter shadow between the two pages */
.product-stage::before {
  inset: 0;
  border: 0;
  border-radius: 0;
  background: linear-gradient(
    90deg,
    transparent 46%,
    rgb(17 16 13 / 0.07) 49.3%,
    rgb(60 40 15 / 0.26) 50%,
    rgb(17 16 13 / 0.07) 50.7%,
    transparent 54%
  );
  opacity: var(--frame-opacity, 0);
}

.product-stage::after {
  content: none;
}

.product-index-header {
  width: 100%;
  border-bottom: 3px double rgb(17 16 13 / 0.75);
  padding: 0 4px clamp(7px, 1.1vh, 12px);
  margin-bottom: clamp(9px, 1.6vh, 16px);
}

.product-heading {
  font-family: "Chango", "Titan One", "Arial Black", "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(1.3rem, 2.4vw, 2.4rem);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 0.9;
  text-transform: lowercase;
  transform: scaleY(1.12);
  transform-origin: bottom left;
}

/* Editorial catalog layout: featured item fills the left page,
   the other three run as horizontal entries down the right page. */
.product-row {
  display: grid;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 1.8vh, 20px) clamp(26px, 3.4vw, 58px);
  counter-reset: catalog-item;
}

.product-card {
  flex: none;
  width: auto;
  height: auto;
}

.product-card:first-child {
  grid-row: 1 / -1;
}

/* horizontal entries on the right page: image left, details right */
.product-card:not(:first-child) {
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  grid-template-rows: none;
  align-items: center;
}

.product-card:not(:first-child) img {
  width: 100%;
  height: 100%;
  padding: 5%;
}

.product-card:not(:first-child) .product-card__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 7px;
  align-self: center;
  height: 72%;
  width: auto;
  margin: 0 12px 0 0;
  border-top: 0;
  border-left: 1px solid rgb(17 16 13 / 0.55);
  padding: 4px 0 4px 14px;
}

.product-card:not(:first-child) .product-card__meta strong {
  white-space: normal;
  overflow: visible;
  line-height: 1.1;
}

.product-card {
  counter-increment: catalog-item;
}

/* printed ink frames, each item on its own muted print-color field */
.product-card::before {
  opacity: 1;
  background: var(--card-field, transparent);
  border: 2px solid rgb(17 16 13 / 0.82);
  box-shadow: none;
  transition: box-shadow 180ms ease;
}

.product-card {
  --card-field: #f2ecdb; /* faint warm wash, just off the page tone */
}

.product-card:hover::before,
.product-card:focus-visible::before {
  box-shadow: inset 0 0 0 999px rgb(255 255 255 / 0.28);
}

/* no filters on images — they make Chrome drop paints inside the 3D scene */
.product-card {
  will-change: auto;
  /* cap the implicit grid column so long names ellipsize instead of
     stretching the meta row past the card edge */
  grid-template-columns: minmax(0, 1fr);
}

.product-card img {
  padding: 6% 6% 0;
  filter: none;
}

.product-card__meta {
  border-top: 1px solid rgb(17 16 13 / 0.75);
  margin: 0 8px;
  width: calc(100% - 16px);
  padding: 7px 2px 10px;
}

.product-card__meta strong::before {
  content: "No.0" counter(catalog-item) " ";
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.6em;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: rgb(17 16 13 / 0.55);
  vertical-align: 18%;
  padding-right: 2px;
}

.product-card__meta strong {
  font-size: clamp(0.72rem, 0.95vw, 0.95rem);
}

.product-card__meta > span {
  font-size: clamp(0.66rem, 0.8vw, 0.8rem);
}

.product-card__flag {
  top: 11px;
  left: 11px;
  border-width: 1.5px;
  box-shadow: 1px 1px 0 rgb(17 16 13 / 0.35);
  transform: rotate(-5deg);
}

/* page folios in the bottom corners of the spread */
.mag-folio {
  position: absolute;
  bottom: clamp(7px, 1.3vh, 13px);
  z-index: 4;
  margin: 0;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: lowercase;
  color: rgb(17 16 13 / 0.6);
  opacity: var(--products-label-opacity, 0);
  pointer-events: none;
}

.mag-folio--left {
  left: clamp(14px, 1.8vw, 30px);
}

.mag-folio--right {
  right: clamp(14px, 1.8vw, 30px);
}

@media (max-width: 760px) {
  :root {
    --page-h: min(62vh, 118vw);
    --page-w: min(calc(var(--page-h) * 0.71), 46vw);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mag-book,
  .mag-cover {
    transition: none;
    will-change: auto;
  }
}
