:root {
  --cal: #fbfaf7;
  --stone: #f2ebdc;
  --albero: #d9a64e;
  --verde: #1c4a33;
  --verde-soft: #4a6456;
  --line: #e6dfcf;
  --guindilla: #b3261e;

  --font-display: "Bodoni Moda", Georgia, serif;
  --font-body: "Hanken Grotesk", system-ui, sans-serif;

  --page-width: 1240px;
  --gutter: clamp(20px, 5vw, 64px);
  --header-height: 76px;
  /* A photo is on screen for one interval of app.js (6s) plus its fade; the drift outlasts both. */
  --photo-fade: 1.6s;
  --photo-drift: 12s;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-height);
}

body {
  margin: 0;
  background: var(--cal);
  color: var(--verde);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 400;
  line-height: 1.05;
}

p {
  margin: 0;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a,
button {
  color: inherit;
  font: inherit;
}

:focus-visible {
  outline: 1.5px solid var(--verde);
  outline-offset: 4px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Kept this faint so --verde-soft text stays above 4.5:1 even over a black pixel.
   100lvh keeps the layer still while a phone's address bar collapses. */
.page-photos {
  position: fixed;
  z-index: -1;
  inset: 0 0 auto;
  height: 100lvh;
  overflow: hidden;
  opacity: 0.12;
}

.page-photos img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
}

/* The leaving photo stays opaque and keeps drifting under the new one until it is covered. */
.page-photos .is-leaving {
  opacity: 1;
}

.page-photos .is-visible {
  z-index: 1;
  opacity: 1;
  transition: opacity var(--photo-fade) cubic-bezier(0.45, 0, 0.55, 1);
}

.page-photos .is-visible,
.page-photos .is-leaving {
  animation: photo-drift var(--photo-drift) linear both;
  will-change: transform;
}

/* Four slow camera moves in turn. Each scale leaves enough margin for its shift. */
.page-photos img:nth-child(4n + 1) {
  --drift-from: scale(1.04) translate(-1.5%, 1%);
  --drift-to: scale(1.14) translate(1.5%, -1%);
}

.page-photos img:nth-child(4n + 2) {
  --drift-from: scale(1.16) translate(1.5%, 1.5%);
  --drift-to: scale(1.05) translate(-1%, -1%);
}

.page-photos img:nth-child(4n + 3) {
  --drift-from: scale(1.06) translate(2%, -1%);
  --drift-to: scale(1.14) translate(-2%, 1%);
}

.page-photos img:nth-child(4n) {
  --drift-from: scale(1.15) translate(-2%, -1%);
  --drift-to: scale(1.05) translate(1.5%, 1%);
}

/* Shared page frame: content width plus gutters, centered. */
.nav,
.hero,
.catalog,
.shipping {
  width: 100%;
  max-width: calc(var(--page-width) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 1.6em;
  border: 1px solid var(--verde);
  border-radius: 999px;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.button:hover,
.button-solid {
  background: var(--verde);
  color: var(--cal);
}

.button-solid:hover {
  background: #133624;
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgb(251 250 247 / 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
}

.nav {
  display: flex;
  align-items: center;
  gap: 40px;
  height: var(--header-height);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: auto;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 500;
  text-decoration: none;
}

.brand img {
  border-radius: 50%;
}

.nav-links {
  display: flex;
  gap: 32px;
}

.nav-links a {
  padding-block: 10px;
  font-size: 0.95rem;
  text-decoration: none;
  text-underline-offset: 6px;
}

.nav-links a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

.cart-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 0.95rem;
  cursor: pointer;
}

.cart-count {
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border: 1px solid var(--verde);
  border-radius: 999px;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.cart-count.has-items {
  border-color: var(--guindilla);
  background: var(--guindilla);
  color: var(--cal);
}

.cart-count.bump {
  animation: bump 0.35s ease-out;
}

/* Hero */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(24px, 4vw, 64px);
  min-height: min(calc(100vh - var(--header-height)), 820px);
  padding-block: clamp(32px, 5vw, 64px);
}

.hero h1 {
  max-width: 9ch;
  font-size: clamp(3.2rem, 8vw, 7rem);
  line-height: 0.95;
  letter-spacing: -0.025em;
}

.hero-copy p {
  max-width: 38ch;
  margin: clamp(24px, 3vw, 36px) 0 clamp(32px, 4vw, 44px);
  color: var(--verde-soft);
  font-size: 1.15rem;
}

/* An albero disc with a hairline outer ring, echoing the double circle of the logo. */
.hero-art {
  position: relative;
  width: min(100%, 70svh);
  aspect-ratio: 1;
  justify-self: center;
}

.hero-art::before,
.hero-art::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.hero-art::before {
  inset: 6%;
  background: var(--albero);
}

.hero-art::after {
  inset: 2%;
  border: 1px solid var(--verde);
  opacity: 0.35;
}

.hero-seal {
  position: absolute;
  z-index: 1;
  inset: 14%;
  width: 72%;
  height: 72%;
  animation: seal-in 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s both;
}

/* Catalog */

/* A nearly solid veil over the photos. The shadow and clip-path bleed it to both screen edges
   without widening the page. */
.catalog {
  --veil: rgb(251 250 247 / 0.82);

  padding-block: clamp(32px, 5vw, 72px) clamp(72px, 10vw, 140px);
  background: var(--veil);
  box-shadow: 0 0 0 100vmax var(--veil);
  clip-path: inset(0 -100vmax);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 32px;
  margin-bottom: clamp(36px, 5vw, 64px);
}

.section-head h2 {
  font-size: clamp(2.4rem, 4.5vw, 3.6rem);
  letter-spacing: -0.015em;
}

.section-head p {
  color: var(--verde-soft);
}

.products {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(48px, 6vw, 88px) clamp(20px, 3vw, 40px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.product-stage {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  background: var(--stone);
}

.product-stage svg {
  width: 82%;
}

.product-info {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 6px 24px;
  padding-top: 24px;
}

.product-info h3 {
  font-size: clamp(1.6rem, 2.4vw, 2rem);
}

.product-price {
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

.product-ingredients {
  grid-column: 1 / -1;
  max-width: 46ch;
  color: var(--verde-soft);
}

.product-info .button {
  grid-column: 1 / -1;
  justify-self: start;
  margin-top: 18px;
}

/* Shipping */

.shipping {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 40px clamp(24px, 4vw, 64px);
  padding-bottom: clamp(80px, 10vw, 140px);
}

.shipping-item {
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.shipping-item h3 {
  margin-bottom: 10px;
  font-size: 1.4rem;
}

.shipping-item p {
  max-width: 34ch;
  color: var(--verde-soft);
}

/* Footer */

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
  padding: 40px max(var(--gutter), (100% - var(--page-width)) / 2);
  background: var(--verde);
  color: var(--cal);
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 20px;
  line-height: 1.5;
}

.footer-brand img {
  border-radius: 50%;
}

.footer-note {
  color: rgb(251 250 247 / 0.65);
  font-size: 0.9rem;
}

.footer-credits {
  flex-basis: 100%;
  padding-top: 24px;
  border-top: 1px solid rgb(251 250 247 / 0.2);
  color: rgb(251 250 247 / 0.65);
  font-size: 0.85rem;
}

.footer-credits h2 {
  margin-bottom: 8px;
  font-family: var(--font-body);
  font-size: inherit;
  font-weight: 500;
  line-height: inherit;
}

.footer-credits ul {
  columns: 3 280px;
  column-gap: 32px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-credits a {
  text-underline-offset: 3px;
}

/* Cart drawer */

.cart {
  inset: 0 0 0 auto;
  width: min(440px, 100vw);
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--cal);
  color: var(--verde);
}

.cart[open] {
  animation: drawer-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.cart::backdrop {
  background: rgb(28 74 51 / 0.32);
  backdrop-filter: blur(2px);
}

.cart-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.cart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 28px 20px;
}

.cart-head h2 {
  font-size: 2rem;
}

.cart-close {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 0.95rem;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  cursor: pointer;
}

.cart-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding: 0 28px 28px;
}

.cart-empty {
  margin: auto 0;
  text-align: center;
}

.cart-empty p {
  margin-bottom: 24px;
  color: var(--verde-soft);
}

.cart-lines {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.cart-line {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 4px 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.cart-thumb {
  grid-row: span 2;
  aspect-ratio: 4 / 3;
  background: var(--stone);
}

.cart-line-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.cart-line-total {
  font-variant-numeric: tabular-nums;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stepper button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  line-height: 1;
  cursor: pointer;
}

.stepper button:hover {
  border-color: var(--verde);
}

.stepper output {
  min-width: 2ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.cart-summary {
  margin-top: auto;
  padding-top: 28px;
}

.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  font-family: var(--font-display);
  font-size: 1.6rem;
}

.cart-shipping {
  margin-bottom: 24px;
  color: var(--verde-soft);
  font-size: 0.9rem;
}

.cart-summary .button {
  width: 100%;
}

.cart-notice {
  margin-top: 16px;
  color: var(--verde-soft);
  font-size: 0.9rem;
  text-align: center;
}

/* Motion */

@keyframes seal-in {
  from {
    opacity: 0;
    transform: scale(0.96) rotate(-12deg);
  }
}

@keyframes photo-drift {
  from {
    transform: var(--drift-from);
  }

  to {
    transform: var(--drift-to);
  }
}

@keyframes drawer-in {
  from {
    transform: translateX(100%);
  }
}

@keyframes bump {
  50% {
    transform: scale(1.2);
  }
}

@keyframes seal-roll {
  to {
    rotate: 32deg;
    scale: 0.72;
  }
}

@keyframes product-rise {
  from {
    opacity: 0;
    translate: 0 48px;
  }
}

@keyframes shipping-appear {
  from {
    opacity: 0;
  }
}

/* Tied to the scroll position, not to time. Browsers without support show the page at rest. */
@supports (animation-timeline: view()) {
  /* On the disc, not the seal: the seal's own entrance already animates its transform. */
  .hero-art {
    animation: seal-roll linear both;
    animation-timeline: scroll(root);
    animation-range: 0 100vh;
  }

  .product {
    animation: product-rise linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 55%;
  }

  .product:nth-child(even) {
    animation-range: entry 12% entry 67%;
  }

  .shipping-item {
    animation: shipping-appear linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Responsive */

/* Stacks only in portrait: a phone on its side keeps two columns and the disc fits its height. */
@media (max-width: 860px) and (orientation: portrait) {
  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  /* Capped by height so the button stays on the first screen of short phones. */
  .hero-art {
    order: -1;
    width: min(440px, 100%, 34svh);
  }
}

@media (max-width: 860px) {
  .shipping {
    grid-template-columns: 1fr;
  }
}

@media (pointer: coarse) {
  .stepper button {
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 640px) {
  .nav-links,
  .brand span {
    display: none;
  }

  .products {
    grid-template-columns: 1fr;
  }

  .footer-credits li {
    padding-block: 4px;
  }
}
