/* Limone con Amore — the forge
   One idea, carried through five states. The lemon is the anchor: it is
   sketched, framed, built, packaged, and finally shipped. Everything here
   animates with transform and opacity only, driven by scroll progress that
   js/studio.js writes onto custom properties.

   The scene is a container, and every detail inside it is sized in cqw, so
   the little product renders identically whether it is 200px or 460px wide. */

.forge {
  position: relative;
  padding: clamp(4.5rem, 9vw, 7.5rem) 0;
  background: color-mix(in srgb, var(--cream) 55%, var(--ivory));
  border-top: 1px solid color-mix(in srgb, var(--gold) 20%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--gold) 20%, transparent);
}

/* Scroll-driven mode. Added by script once the scene can be animated. */
.forge[data-forge-ready] {
  height: 520vh;
  padding: 0;
}

.forge__sticky {
  display: flex;
  align-items: center;
}

.forge[data-forge-ready] .forge__sticky {
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow: hidden;
}

.forge__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.92fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: center;
  width: min(calc(100% - 2.5rem), 1160px);
}

/* Copy side */

.forge__caps {
  display: grid;
  gap: 1.6rem;
}

.forge[data-forge-ready] .forge__caps {
  position: relative;
  display: block;
  min-height: 12rem;
}

.forge[data-forge-ready] .forge__cap {
  position: absolute;
  inset: 0 0 auto;
  opacity: var(--on, 0);
  transform: translate3d(0, calc(var(--d, 0) * -1.4rem), 0);
  will-change: transform, opacity;
}

.forge[data-forge-ready] .forge__cap[data-off] {
  visibility: hidden;
}

.forge__cap h2 {
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(2.8rem, 6.6vw, 5.4rem);
  line-height: 0.98;
  letter-spacing: -0.04em;
  color: var(--teal);
}

.forge__cap p {
  max-width: 24rem;
  margin-top: 1rem;
  font-size: 1.08rem;
  font-weight: 300;
  line-height: 1.6;
  color: var(--ink-soft);
}

.forge__rail {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.35rem;
  margin-top: 2.4rem;
  list-style: none;
}

.forge__rail-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ink-soft) 45%, var(--parchment));
  transition: color 0.45s var(--ease);
}

.forge__rail-dot {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 18%, transparent);
  transition: background 0.45s var(--ease), scale 0.45s var(--spring);
}

.forge__rail-item.is-done {
  color: var(--ink-soft);
}

.forge__rail-item.is-done .forge__rail-dot {
  background: color-mix(in srgb, var(--gold) 70%, transparent);
}

.forge__rail-item.is-on {
  color: var(--gold-deep);
}

.forge__rail-item.is-on .forge__rail-dot {
  background: var(--lemon);
  scale: 1.35;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--lemon) 24%, transparent);
}

/* Scene side */

.forge__scene {
  container-type: inline-size;
  position: relative;
  width: min(100%, 460px, 58vh);
  aspect-ratio: 1;
  justify-self: center;
}

.forge-halo {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 96%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--lemon) 26%, white) 0%, transparent 66%);
}

.forge-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
}

/* Without the script, the finished product is what you see. */
.forge-layer[data-forge-layer="4"] {
  opacity: 1;
}

.forge[data-forge-ready] .forge-layer {
  opacity: var(--on, 0);
  transform: translate3d(0, calc(var(--d, 0) * -2.5%), 0) scale(calc(1 - 0.05 * var(--ad, 0)));
  will-change: transform, opacity;
}

.forge[data-forge-ready] .forge-layer[data-off] {
  visibility: hidden;
}

/* The brand anchor that survives every stage. */

.forge-lemon {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.forge-lemon img {
  width: 46%;
  height: auto;
  opacity: var(--o, 1);
  /* translate first so the offset is not multiplied by the scale */
  transform: translate(0, var(--y, -14%)) scale(var(--s, 0.42)) rotate(var(--r, 0deg));
  filter: grayscale(var(--g, 0)) drop-shadow(0 14px 24px rgba(154, 122, 46, 0.2));
  will-change: transform, opacity;
}

/* 0 — Idea: a sketch on the page */

.forge-sketch {
  width: 86%;
  height: auto;
  color: color-mix(in srgb, var(--forest) 88%, var(--parchment));
}

.forge-sketch path {
  stroke-dasharray: 1;
  stroke-dashoffset: calc(1 - var(--draw, 1));
}

.forge-note {
  position: absolute;
  right: 6%;
  bottom: 8%;
  font-family: var(--serif);
  font-style: italic;
  font-size: 3.2cqw;
  color: color-mix(in srgb, var(--ink-soft) 70%, var(--parchment));
}

/* 1 — Design: the sketch finds its edges */

.forge-wire {
  position: relative;
  display: grid;
  /* bar, hero, line, line, row, cta — the hero row takes the slack so the
     lemon always has a block to sit in. */
  grid-template-rows: auto minmax(0, 1fr) auto auto auto auto;
  gap: 2.1cqw;
  width: 58%;
  height: 88%;
  padding: 3.8cqw;
  background: color-mix(in srgb, var(--white) 70%, transparent);
  border: 1.5px dashed color-mix(in srgb, var(--forest) 30%, transparent);
  border-radius: 4.3cqw;
}

.forge-wire__bar {
  height: 1.7cqw;
  width: 45%;
  border-radius: 0.7cqw;
  background: color-mix(in srgb, var(--forest) 24%, var(--parchment));
}

.forge-wire__hero {
  border-radius: 2.6cqw;
  background: color-mix(in srgb, var(--parchment) 60%, white);
  border: 1px solid color-mix(in srgb, var(--forest) 14%, transparent);
}

.forge-wire__line {
  height: 1.4cqw;
  border-radius: 0.7cqw;
  background: color-mix(in srgb, var(--forest) 18%, var(--parchment));
}

.forge-wire__line--short {
  width: 64%;
}

.forge-wire__row {
  display: flex;
  gap: 2.1cqw;
}

.forge-wire__row i {
  flex: 1;
  height: 5.6cqw;
  border-radius: 1.7cqw;
  background: color-mix(in srgb, var(--parchment) 70%, white);
}

.forge-wire__cta {
  height: 7.3cqw;
  border-radius: 2.2cqw;
  background: color-mix(in srgb, var(--forest) 22%, var(--parchment));
}

.forge-guide {
  position: absolute;
  background: color-mix(in srgb, var(--gold) 32%, transparent);
}

.forge-guide--v {
  left: 50%;
  top: 0;
  width: 1px;
  height: 100%;
}

.forge-guide--h {
  left: 0;
  top: 50%;
  width: 100%;
  height: 1px;
}

/* 2 — Build: working software */

.forge-ui {
  position: relative;
  display: grid;
  /* chrome, hero, kicker, title, line, line, button */
  grid-template-rows: auto minmax(0, 1fr) auto auto auto auto auto;
  gap: 1.6cqw;
  width: 58%;
  height: 88%;
  padding: 3.1cqw 3.8cqw 3.8cqw;
  background: var(--white);
  border: 1px solid color-mix(in srgb, var(--parchment) 70%, white);
  border-radius: 4.3cqw;
  box-shadow: 0 22px 48px rgba(28, 43, 38, 0.12);
}

.forge-ui__chrome {
  display: flex;
  gap: 1cqw;
  margin-bottom: 1cqw;
}

.forge-ui__chrome i {
  width: 1.25cqw;
  height: 1.25cqw;
  border-radius: 50%;
  background: color-mix(in srgb, var(--parchment) 72%, var(--sage));
}

.forge-ui__hero {
  border-radius: 2.6cqw;
  background:
    radial-gradient(70% 70% at 50% 40%, color-mix(in srgb, var(--lemon) 34%, white), transparent 70%),
    color-mix(in srgb, var(--beige) 70%, white);
}

.forge-ui__kicker {
  font-size: 2cqw;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-deep);
}

.forge-ui__title {
  font-family: var(--serif);
  font-size: 4cqw;
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--teal);
}

.forge-ui__line {
  height: 1cqw;
  border-radius: 0.6cqw;
  background: color-mix(in srgb, var(--parchment) 78%, var(--sage));
}

.forge-ui__line--short {
  width: 58%;
}

.forge-ui__btn {
  display: grid;
  place-items: center;
  height: 6.8cqw;
  margin-top: 1cqw;
  font-size: 2.4cqw;
  font-weight: 500;
  color: var(--ivory);
  background: var(--teal);
  border-radius: 2cqw;
}

.forge-code {
  position: absolute;
  z-index: 4;
  left: -2%;
  bottom: 9%;
  display: grid;
  gap: 0.7cqw;
  padding: 2.1cqw 2.6cqw;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 2.4cqw;
  line-height: 1.4;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--white) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--parchment) 78%, white);
  border-radius: 2.6cqw;
  box-shadow: 0 14px 32px rgba(28, 43, 38, 0.1);
}

.forge-code b {
  font-weight: 600;
  color: var(--moss);
}

.forge-code em {
  font-style: normal;
  color: var(--gold-deep);
}

.forge-code__row--ok {
  color: #5f9a68;
}

/* 3 — Launch: it becomes a package */

.forge-icon {
  width: 38%;
  aspect-ratio: 1;
  translate: 0 -8%;
  background:
    radial-gradient(80% 80% at 50% 25%, color-mix(in srgb, var(--lemon) 46%, white), transparent 72%),
    color-mix(in srgb, var(--beige) 82%, white);
  border: 1px solid color-mix(in srgb, var(--gold) 34%, transparent);
  border-radius: 24%;
  box-shadow: 0 26px 52px rgba(154, 122, 46, 0.26);
}

.forge-store {
  position: absolute;
  z-index: 4;
  left: 10%;
  right: 10%;
  bottom: 11%;
  display: flex;
  align-items: center;
  gap: 2.6cqw;
  padding: 2.4cqw 2.8cqw;
  background: var(--white);
  border: 1px solid color-mix(in srgb, var(--parchment) 72%, white);
  border-radius: 3cqw;
  box-shadow: 0 16px 36px rgba(28, 43, 38, 0.1);
}

.forge-store__text {
  display: grid;
  gap: 0.4cqw;
  min-width: 0;
}

.forge-store__text b {
  font-family: var(--serif);
  font-size: 3.3cqw;
  font-weight: 560;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: var(--teal);
}

.forge-store__text i {
  font-style: normal;
  font-size: 2.4cqw;
  letter-spacing: 0.08em;
  white-space: nowrap;
  color: var(--ink-soft);
}

.forge-store__get {
  margin-left: auto;
  padding: 1cqw 3.3cqw;
  font-size: 2.5cqw;
  font-weight: 500;
  color: var(--ivory);
  background: var(--teal);
  border-radius: 999px;
}

/* 4 — Live: in someone's hand */

.forge-phone {
  width: 34%;
  aspect-ratio: 9 / 19;
  padding: 1.4cqw;
  background: var(--teal);
  border-radius: 13%/6.2%;
  box-shadow: 0 30px 60px rgba(22, 56, 51, 0.3);
}

.forge-phone__screen {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.4cqw;
  height: 100%;
  padding: 3.8cqw 2.6cqw 2.6cqw;
  background: color-mix(in srgb, var(--beige) 46%, var(--white));
  border-radius: 11%/5.4%;
  overflow: hidden;
}

/* Reserves the top half of the screen for the lemon. */
.forge-phone__art {
  flex: 0 0 52%;
}

.forge-phone__bar {
  position: absolute;
  left: 50%;
  top: 1.6cqw;
  width: 28%;
  height: 0.8cqw;
  translate: -50% 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--teal) 28%, transparent);
}

.forge-phone__title {
  font-family: var(--serif);
  font-size: 3.1cqw;
  font-weight: 560;
  letter-spacing: -0.02em;
  text-align: center;
  color: var(--teal);
}

.forge-phone__line {
  height: 0.9cqw;
  border-radius: 0.6cqw;
  background: color-mix(in srgb, var(--parchment) 74%, var(--sage));
}

.forge-phone__line--short {
  width: 62%;
  margin-inline: auto;
}

.forge-phone__tabs {
  display: flex;
  gap: 1cqw;
  margin-top: auto;
}

.forge-phone__tabs i {
  flex: 1;
  height: 1.5cqw;
  border-radius: 999px;
  background: color-mix(in srgb, var(--parchment) 72%, var(--sage));
}

.forge-phone__tabs i:first-child {
  background: var(--lemon);
}

.forge-badge {
  position: absolute;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 1.4cqw;
  padding: 1.5cqw 2.4cqw;
  font-size: 2.4cqw;
  font-weight: 500;
  white-space: nowrap;
  background: color-mix(in srgb, var(--white) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--parchment) 76%, white);
  border-radius: 999px;
  box-shadow: 0 14px 30px rgba(28, 43, 38, 0.1);
}

.forge-badge svg {
  width: 3.6cqw;
  height: 3.6cqw;
  color: var(--teal);
}

/* Both stores, on opposite corners so the phone stays the centre of attention. */
.forge-badge--a {
  left: 1%;
  top: 22%;
}

.forge-badge--b {
  right: 1%;
  bottom: 24%;
}

/* Responsive */

@media (max-width: 980px) {
  .forge[data-forge-ready] {
    height: 420vh;
  }

  .forge__grid {
    grid-template-columns: 1fr;
    gap: 1.3rem;
  }

  /* Scene first on narrow screens: the picture leads, the words follow. */
  .forge__scene {
    order: -1;
    width: min(100%, 300px, 38vh);
  }

  /* Keep the scene clear of the fixed header. */
  .forge[data-forge-ready] .forge__sticky {
    padding-top: 4.5rem;
  }

  .forge__cap h2 {
    font-size: clamp(2.4rem, 11vw, 3.4rem);
  }

  .forge__cap p {
    font-size: 1rem;
  }

  .forge[data-forge-ready] .forge__caps {
    min-height: 10rem;
  }

  .forge__rail {
    margin-top: 1.4rem;
    gap: 0.4rem 1rem;
  }

  .forge__rail-item {
    font-size: 0.6rem;
    letter-spacing: 0.12em;
  }
}

@media (max-width: 600px) {
  .forge[data-forge-ready] {
    height: 360vh;
  }
}

/* A short but wide window has no room to stack. Keep the scene beside the
   copy so it can use the height instead of shrinking to a thumbnail. */
@media (max-width: 980px) and (min-aspect-ratio: 1/1) {
  .forge__grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
  }

  .forge__scene {
    order: 0;
    width: min(100%, 320px, 62vh);
  }

  .forge[data-forge-ready] .forge__sticky {
    padding-top: 0;
  }
}

/* Short, narrow viewports: the stacked layout has to hold the scene, the
   caption and the rail inside one screen, so give the scene less room. */
@media (max-width: 980px) and (max-height: 720px) and (max-aspect-ratio: 1/1) {
  .forge__scene {
    width: min(100%, 240px, 30vh);
  }

  .forge[data-forge-ready] .forge__caps {
    min-height: 8rem;
  }

  .forge__cap h2 {
    font-size: clamp(2.1rem, 9vw, 2.8rem);
  }

  .forge__cap p {
    margin-top: 0.7rem;
    font-size: 0.95rem;
  }
}

/* With reduced motion the script never enables the scene, so the section
   stays a plain list of stages and the rail does not animate. */
@media (prefers-reduced-motion: reduce) {
  .forge__rail-item,
  .forge__rail-dot {
    transition: none;
  }
}
