/* craft.css · section 03, "The craft": marble tabling. Behaviour in assets/js/craft.js.
   A sticky stage: the instrument on the left (readout, curve, steps), the marble slab on the right. */

.craft { position: relative; height: 330vh; }

.craft__stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  width: 100%;
  max-width: calc(var(--max) + 2 * var(--gutter));
  margin-inline: auto;
  padding: clamp(84px, 11vh, 118px) var(--gutter) clamp(24px, 5vh, 52px);
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  align-items: center;
  gap: clamp(28px, 4.6vw, 88px);
}

/* ---- the instrument column ---- */
.craft__copy {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "label label"
    "title title"
    "temp  curve"
    "steps steps";
  column-gap: clamp(18px, 2.2vw, 36px);
  align-items: end;
}
.craft__copy > .label { grid-area: label; }
.craft__copy > .h2 {
  grid-area: title;
  margin-top: clamp(14px, 2.2vh, 24px);
  font-size: clamp(2.3rem, 4.3vw, 4.6rem);
  max-width: 10.5ch;
}

.craft__readout {
  --soft: 100;
  grid-area: temp;
  margin-top: clamp(24px, 4.4vh, 48px);
  display: flex;
  align-items: flex-start;
  font-family: var(--f-display);
  font-weight: 300;
  font-variant-numeric: lining-nums tabular-nums;
  font-variation-settings: "SOFT" var(--soft), "WONK" 0;
  line-height: 0.8;
  color: var(--chocolate);
  white-space: nowrap;
}
.craft__temp { font-size: clamp(4.2rem, 7.2vw, 8rem); letter-spacing: -0.055em; }
.craft__unit {
  margin: 0.14em 0 0 0.14em;
  font-size: clamp(1.15rem, 1.9vw, 1.9rem);
  letter-spacing: 0;
  color: var(--saffron);
}

.craft__curve {
  grid-area: curve;
  justify-self: start;
  width: 100%;
  max-width: 330px;
  height: auto;
  margin-bottom: 4px;
  overflow: visible;
}
.craft__curve-grid { fill: none; stroke: var(--line-2); stroke-width: 0.8; stroke-dasharray: 2 3; }
.craft__curve-divide { fill: none; stroke: var(--line); stroke-width: 0.8; }
.craft__curve-track { fill: none; stroke: var(--line-2); stroke-width: 1; stroke-linecap: round; stroke-linejoin: round; }
.craft__curve-path {
  fill: none;
  stroke: var(--saffron-ink);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.craft__curve-dot { fill: var(--saffron); stroke: var(--ivory); stroke-width: 2.4; }
.craft__curve-halo { fill: var(--saffron); opacity: 0.18; }
.craft__curve-text {
  font-family: var(--f-ui);
  font-weight: 500;
  font-size: 8.5px;
  letter-spacing: 0.14em;
  fill: var(--fg-2);
  user-select: none;
}
.craft__curve-text--phase { text-anchor: middle; }
.craft__curve-text.is-on { fill: var(--saffron-ink); }

.craft__steps {
  grid-area: steps;
  margin-top: clamp(22px, 4.2vh, 46px);
  border-top: 1px solid var(--line);
}
.craft__step {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 14px;
  padding: clamp(10px, 1.6vh, 15px) 0;
  border-bottom: 1px solid var(--line);
  opacity: 0.38;
  transition: opacity var(--t-base) var(--ease-snap);
}
.craft__step.is-active { opacity: 1; }
.craft__step-temp {
  font-family: var(--f-display);
  font-weight: 300;
  font-size: 1.55rem;
  line-height: 1.1;
  font-variant-numeric: lining-nums;
  color: var(--saffron-ink);
}
.craft__step h3 {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: 1.35rem;
  line-height: 1.2;
  letter-spacing: -0.012em;
  color: var(--fg);
}
.craft__step p {
  max-width: 42ch;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px);
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--fg-2);
  transition:
    max-height var(--t-base) var(--ease-set),
    margin var(--t-base) var(--ease-set),
    opacity var(--t-base) var(--ease-snap),
    transform var(--t-set) var(--ease-set);
}
.craft__step.is-active p { max-height: 7.5em; margin-top: 6px; opacity: 1; transform: none; }

/* ---- the marble slab ---- */
.craft__slab {
  position: relative;
  isolation: isolate;
  height: min(76vh, 790px);
  min-height: 360px;
  border-radius: var(--radius-stage);
  overflow: hidden;
  /* Calacatta before WebGL paints (and if it never does): soft, broad veins on one diagonal */
  background:
    linear-gradient(145deg, transparent 0 20%, rgb(150 141 131 / 0.07) 25%, rgb(150 141 131 / 0.17) 27.5%, rgb(150 141 131 / 0.06) 30%, transparent 35%),
    linear-gradient(145deg, transparent 0 47%, rgb(150 141 131 / 0.08) 52%, rgb(150 141 131 / 0.22) 54.5%, rgb(150 141 131 / 0.07) 57%, transparent 62%),
    linear-gradient(145deg, transparent 0 74%, rgb(150 141 131 / 0.06) 78%, rgb(150 141 131 / 0.14) 80%, transparent 85%),
    radial-gradient(120% 90% at 18% 8%, #FBF8F2 0%, #F3EDE3 70%, #EDE6DB 100%);
  box-shadow:
    0 60px 100px -60px rgb(60 33 18 / 0.5),
    0 22px 44px -28px rgb(60 33 18 / 0.28);
}
.craft__slab::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgb(43 26 17 / 0.07), inset 0 1px 0 rgb(255 255 255 / 0.55);
  pointer-events: none;
}
.craft--no-gl .craft__canvas { display: none; }

/* The waiting pool (built by craft.js): the same lobed pour, in SVG, until the first WebGL frame. */
.craft__pool {
  position: absolute;
  z-index: 0;
  left: 47%;
  top: 47%;
  height: var(--pool-h, 32%);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: opacity 600ms var(--ease-flow);
}
.craft__pool svg { display: block; width: 100%; height: 100%; overflow: visible; }
.craft--gl .craft__pool { opacity: 0; }

.craft__canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* The CSS marble holds the frame until the first WebGL frame exists, then the canvas fades in. */
  opacity: 0;
  transition: opacity 600ms var(--ease-flow);
}
.craft__canvas.is-ready { opacity: 1; }

.craft__slab-ui {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  padding: clamp(14px, 1.6vw, 22px);
  pointer-events: none;
}
.craft__slab-ui .label {
  padding: 9px 14px;
  border-radius: 999px;
  background: rgb(250 246 239 / 0.86);
  color: var(--ink);
  box-shadow: 0 6px 18px -10px rgb(60 33 18 / 0.35);
}
.craft__phase { order: -1; align-self: flex-end; gap: 0.7em; }
.craft__phase::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--saffron);
}
.craft__hint { transition: opacity var(--t-base) var(--ease-flow), transform var(--t-base) var(--ease-set); }
.craft--touched .craft__hint { opacity: 0; transform: translateY(6px); }
.craft--no-gl .craft__hint { display: none; }

/* ---- short laptops ---- */
@media (min-width: 901px) and (max-height: 780px) {
  .craft__stage { padding-top: 80px; }
  .craft__copy > .h2 { font-size: clamp(2.1rem, 3.6vw, 3.6rem); }
  .craft__readout { margin-top: 18px; }
  .craft__temp { font-size: clamp(3.6rem, 6vw, 6rem); }
  .craft__curve { max-width: 280px; }
  .craft__steps { margin-top: 18px; }
  .craft__step { padding: 9px 0; }
  .craft__step p { font-size: 0.9rem; }
}

/* ---- phones and tablets: stack, the slab takes what is left ---- */
@media (max-width: 900px) {
  .craft { height: 300vh; }
  .craft__stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    align-items: stretch;
    gap: 16px;
    padding-top: 76px;
    padding-bottom: 18px;
  }
  .craft__copy > .h2 { margin-top: 10px; font-size: clamp(1.9rem, 8.2vw, 2.8rem); max-width: 14ch; }
  .craft__readout { margin-top: 14px; }
  .craft__temp { font-size: clamp(2.9rem, 14vw, 4.4rem); }
  .craft__unit { font-size: 1.05rem; }
  .craft__curve { max-width: 360px; margin-bottom: 2px; }
  .craft__steps { margin-top: 12px; border-top: 0; }
  .craft__step { display: none; padding: 0; border-bottom: 0; grid-template-columns: 46px minmax(0, 1fr); gap: 10px; }
  .craft__step.is-active { display: grid; }
  .craft__step-temp { font-size: 1.3rem; }
  .craft__step h3 { font-size: 1.15rem; }
  .craft__step p { font-size: 0.9rem; }
  .craft__step.is-active p { margin-top: 2px; }
  .craft__slab { height: auto; min-height: 0; border-radius: 22px; }
}
