/* The range. Each tin gets a full-width field in its own label colours:
   a name band set like the band on the label, then the tin and the cook's line. */

.range__intro {
  display: grid;
  gap: 0.75rem 4rem;
  align-items: baseline;
  padding-top: 1.75rem;
  padding-bottom: clamp(2rem, 4vw, 3.25rem);
  border-top: 2px solid var(--ink);
}

.range__title {
  font-size: clamp(2rem, 1.3rem + 2.6vw, 3.25rem);
}

.range__lede {
  max-width: 32em;
}

@media (min-width: 60em) {
  .range__intro {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  }
}

/* ---------- Colour fields ---------- */

.field {
  --focus: var(--field-ink);
  overflow: clip;
  background-color: var(--field-bg);
  background-image: var(--grain);
  color: var(--field-ink);
}

.field--mackerel {
  --field-bg: var(--label-yellow);
  --field-ink: var(--label-ink);
  --band-bg: var(--label-red);
  --band-ink: var(--on-colour);
  --ray: rgba(255, 244, 200, 0.26);
  --shape: url("../img/tin-mackerel-720.webp");
}

.field--sardines {
  --field-bg: #cb0f08;
  --field-ink: var(--on-colour);
  --band-bg: var(--label-cream);
  --band-ink: var(--label-ink);
  --ray: rgba(255, 150, 110, 0.17);
  --shape: url("../img/tin-sardines-720.webp");
}

.field--xiu-mai {
  --field-bg: var(--label-green);
  --field-ink: var(--on-colour);
  --band-bg: var(--label-cream);
  --band-ink: var(--label-ink);
  --ray: rgba(160, 220, 180, 0.13);
  --shape: url("../img/tin-xiu-mai-380.webp");
}

.field__band {
  position: relative;
  z-index: 1;
  background-color: var(--band-bg);
  background-image: var(--grain);
  color: var(--band-ink);
}

.field__band-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding-block: clamp(1.1rem, 2.4vw, 2rem);
}

/* Product names are lettered as they are on the tins. */
.field__name {
  font-family: var(--sans);
  font-style: italic;
  font-weight: 900;
  font-stretch: 125%;
  font-size: clamp(1.5rem, 5.7vw, 5.75rem);
  letter-spacing: -0.025em;
  line-height: 0.92;
  text-transform: uppercase;
}

.field--xiu-mai .field__name {
  font-style: normal;
  line-height: 1.08;
}

.field--xiu-mai .field__name b {
  color: var(--label-red);
  font-weight: inherit;
}

.field__release {
  font-size: clamp(1.375rem, 2.2vw, 2.125rem);
  line-height: 1;
  text-align: right;
}

.field__release span {
  display: block;
  margin-top: 0.35rem;
  font-size: clamp(0.875rem, 1.36vw, 1.3125rem);
  font-weight: 600;
}

.field__body {
  display: grid;
  gap: clamp(2.75rem, 6vw, 5.5rem);
  align-items: center;
  padding-block: clamp(3.5rem, 8vw, 7.5rem);
}

.field__copy {
  position: relative;
}

.field__cook {
  max-width: 21em;
  font-size: clamp(1.4rem, 1rem + 1.7vw, 2.25rem);
  font-weight: 500;
  letter-spacing: -0.012em;
  line-height: 1.3;
}

/* Her order for the tin, signed. */
.field__order {
  margin-top: clamp(1.5rem, 3vw, 2.25rem);
  padding-top: 1rem;
  border-top: 2px solid currentColor;
}

.field__order-title {
  font-size: clamp(1.375rem, 2vw, 1.75rem);
}

.field__order-text {
  max-width: 30em;
  margin-top: 0.5rem;
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.25rem);
  line-height: 1.45;
}

.field__order-sign {
  margin-top: 0.6rem;
  font-style: italic;
  font-weight: 600;
}

.spec {
  margin-top: clamp(1.25rem, 2.5vw, 1.75rem);
  border-top: 1px solid currentColor;
  border-top-color: color-mix(in srgb, currentColor 38%, transparent);
}

.spec > div {
  display: grid;
  grid-template-columns: minmax(6.5rem, 9rem) minmax(0, 1fr);
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid currentColor;
  border-bottom-color: color-mix(in srgb, currentColor 38%, transparent);
}

.spec dt {
  font-weight: 700;
}

.spec dd {
  text-wrap: pretty;
}

@media (min-width: 60em) {
  .field__body {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  }

  .field--flip .field__tin {
    order: 2;
  }
}

@media (max-width: 35.99em) {
  .field__release {
    text-align: left;
  }

  .field__release span {
    display: inline;
    margin-left: 0.5em;
  }
}

/* ---------- The tins ---------- */

.field__tin {
  position: relative;
  display: grid;
  place-items: center;
}

/* Rays behind each tin, as on old grocery labels. They turn once every three minutes. */
.field__tin::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(150%, 62rem);
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: repeating-conic-gradient(var(--ray) 0 6deg, transparent 6deg 12deg);
  -webkit-mask-image: radial-gradient(closest-side, #000 22%, transparent 96%);
  mask-image: radial-gradient(closest-side, #000 22%, transparent 96%);
  animation: rays 180s linear infinite;
  pointer-events: none;
}

@keyframes rays {
  to {
    rotate: 360deg;
  }
}

/* The pad keeps still and reads the pointer; the tin inside it does the moving. */
.tin-pad {
  position: relative;
  width: min(100%, 39rem);
}

.tin-pad--round {
  width: min(56%, 18.5rem);
}

.tin {
  --lean: -3deg;
  position: relative;
  transform: perspective(70rem) translateY(var(--drop, 0rem)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) rotate(var(--lean));
  transition: transform 0.7s cubic-bezier(0.2, 0.85, 0.25, 1), opacity 0.35s ease;
  filter: drop-shadow(0 1.3rem 0.9rem rgba(28, 26, 23, 0.4));
}

.field--flip .tin {
  --lean: 2.5deg;
}

.tin-pad--round .tin {
  --lean: 0deg;
}

.tin img {
  width: 100%;
}

/* Light travelling across the lid, clipped to the tin's own outline. */
.tin__sheen {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 38%, rgba(255, 255, 255, 0.55) 50%, transparent 62%) no-repeat;
  background-size: 220% 100%;
  background-position: var(--sheen, 91%) 0;
  -webkit-mask: var(--shape) center / 100% 100% no-repeat;
  mask: var(--shape) center / 100% 100% no-repeat;
  mix-blend-mode: soft-light;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.tin-pad.is-held .tin {
  transition-duration: 0.14s, 0.35s;
}

.tin-pad.is-held .tin__sheen {
  opacity: 1;
}

/* Until it has been seen, a tin waits just above its place; then it is set down.
   The waiting state only applies once tins.js is running. */
.tins-ready .tin-pad:not(.is-set) .tin {
  --drop: -2.75rem;
  --lean: -9deg;
  opacity: 0;
}

/* Reduced motion: the rays hold still and a tin fades in where it stands instead of being
   set down. It does not lean (see tins.js), but its lid still catches the light. */
@media (prefers-reduced-motion: reduce) {
  .field__tin::before {
    animation: none;
  }

  .tin,
  .tin-pad.is-held .tin {
    transition: opacity 0.5s ease;
  }
}
