@font-face {
  font-family: "EB Garamond";
  src: url("assets/eb-garamond.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

@font-face {
  font-family: Inter;
  src: url("assets/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --cream: #f5efe1;
  --paper: #fffbf3;
  --linen: #eadcc7;
  --crimson: #a11d21;
  --burgundy: #7e000e;
  --onyx: #1d1d1b;
  --muted: #60554b;
  --line: #d8c9b7;
  --display: "EB Garamond", Georgia, serif;
  --body: Inter, system-ui, sans-serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --gutter: clamp(16px, 5.6vw, 28px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-height: 100svh;
  margin: 0;
  color: var(--onyx);
  background: radial-gradient(ellipse at 55% 1%, var(--paper), var(--cream) 68%);
  font-family: var(--body);
  line-height: 1.5;
}

.masthead, .guide {
  width: min(100%, 40rem);
  margin-inline: auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}

.masthead { padding-top: max(8px, env(safe-area-inset-top)); }

.masthead-inner {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.emblem {
  display: block;
  width: 43px;
  height: 43px;
  object-fit: contain;
  border-radius: 50%;
  mix-blend-mode: multiply;
}

.masthead-label {
  margin: 0;
  font-size: .6875rem;
  font-weight: 720;
  line-height: 1.25;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.masthead-label { color: var(--muted); }
.guide { padding-block: clamp(18px, 3.4svh, 32px) max(18px, env(safe-area-inset-bottom)); }
.intro { margin-bottom: 19px; }
h1 {
  margin: 0 0 6px;
  font: 500 clamp(2.35rem, 10vw, 4.6rem)/.96 var(--display);
  letter-spacing: -.042em;
  text-wrap: balance;
}

.intro > p:last-child {
  max-width: 39ch;
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.45;
  text-wrap: pretty;
}

.scene {
  display: grid;
  place-items: center;
  width: 100%;
  height: clamp(180px, min(69vw, 40svh), 340px);
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #dfcdb5;
  border-radius: 19px;
  background: radial-gradient(ellipse at 52% 35%, #fffaf1 8%, #f4e8d9 64%, #eadbc6);
  box-shadow: 0 13px 26px -26px #6a382698, inset 0 1px 0 #fffaf3;
}

.scene > svg { display: block; width: 100%; height: 100%; }

button { font: inherit; }
:focus-visible { outline: 2px solid var(--crimson); outline-offset: 4px; }

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

.model-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  gap: 12px;
  color: var(--muted);
  font-size: .75rem;
}

.storyboard { margin-top: 14px; }
.model-tools:not([hidden]) + .storyboard { margin-top: 4px; }

/* A single navigation row ties the swipe prompt to the cards it controls. */
.storyboard-header {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 7px;
  margin-block: 1px 9px;
}
.swipe-prompt {
  min-height: 3.25rem;
  display: grid;
  place-content: center;
  gap: 1px;
  text-align: center;
}
#swipe-direction {
  margin: 0;
  color: var(--onyx);
  font-size: .825rem;
  font-weight: 645;
  line-height: 1.22;
  text-wrap: balance;
}
#step-count {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 610;
  font-variant-numeric: tabular-nums;
}
.step-arrow {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 1px solid #c6a48e;
  border-radius: 50%;
  color: var(--crimson);
  background: var(--paper);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 180ms var(--ease), border-color 180ms var(--ease);
}
.step-arrow:disabled { visibility: hidden; }
.step-arrow::before {
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: translateX(-2px) rotate(-45deg);
}
.step-back::before { transform: translateX(2px) rotate(135deg); }
.step-arrow:active { background: var(--linen); }
@media (hover: hover) { .step-arrow:hover { border-color: var(--crimson); background: var(--linen); } }

.storyboard-rail {
  --step-gap: 9px;
  --peek: clamp(54px, 16%, 72px);
  position: relative;
  display: grid;
  gap: var(--step-gap);
  padding: 0;
  margin: 0;
  list-style: none;
}

.storyboard-rail.is-interactive {
  display: flex;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  touch-action: pan-x pan-y pinch-zoom;
}

.storyboard-rail::-webkit-scrollbar { display: none; }
.step-card {
  position: relative;
  min-width: 0;
  min-height: 112px;
  padding: 13px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: #f0e5d5;
  transition: background 240ms var(--ease), border-color 240ms var(--ease), color 240ms var(--ease);
}
.is-interactive .step-card {
  flex: 0 0 calc(100% - var(--peek));
  scroll-snap-align: center;
  scroll-snap-stop: always;
}
.is-interactive .step-card:first-child { scroll-snap-align: start; }
.is-interactive .step-card:last-child { scroll-snap-align: end; }
.step-card.is-current, .storyboard-rail:not(.is-interactive) .step-card {
  color: var(--onyx);
  background: var(--paper);
}
.step-card.is-current { border-color: #bc8c78; }

.step-card h2 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 4px;
  font: 600 1.4rem/1.05 var(--display);
}
.step-card h2 span {
  padding: 1px 0;
  color: var(--crimson);
  font: 690 .72rem/1.1 var(--body);
  font-variant-numeric: tabular-nums;
}
.step-card p {
  margin: 0;
  font-size: .94rem;
  line-height: 1.4;
}
.is-interactive .step-card:not(.is-current) { cursor: pointer; }
.storyboard-rail:focus-visible { outline-offset: 2px; border-radius: 14px; }

/* An illustrated fallback stays visible until the local WebGL scene is ready. */
.scene { position: relative; }
.scene[data-model="3d"] { touch-action: pinch-zoom; cursor: grab; }
.scene[data-dragging="true"] { cursor: grabbing; }
.scene > canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  visibility: hidden;
}
.scene[data-model="3d"] > canvas { visibility: visible; }
.scene[data-model="3d"] > svg { visibility: hidden; }
.cut-scene .cut-board { transform: translateY(9px); }
.cut-scene :is(.serve, .knife, .guide-depth) { opacity: 0; }
.cut-scene .knife { transform: translateY(86px); }
.cut-scene .slab { transform-origin: 232px 241px; transform: translateY(8px) scaleY(-.6); }
.cut-scene:is([data-stage="1"], [data-stage="2"]) .cut-board { transform: none; }
.cut-scene[data-stage="1"] :is(.knife, .guide-depth), .cut-scene[data-stage="2"] .serve { opacity: 1; }
.cut-scene[data-stage="2"] :is(.uncut, .cut-guide) { opacity: 0; }
.cut-scene :is(.portion-scene, .portion-plate, .portion-strips, .lengthwise-guides, .crosswise-guide) { display: none; }
.cut-scene:is([data-stage="3"], [data-stage="4"], [data-stage="5"]) > g:not(.portion-scene) { display: none; }
.cut-scene:is([data-stage="3"], [data-stage="4"], [data-stage="5"]) .portion-scene,
.cut-scene[data-stage="3"] .portion-strips,
.cut-scene[data-stage="3"] .lengthwise-guides,
.cut-scene[data-stage="4"] .crosswise-guide,
.cut-scene[data-stage="5"] .portion-plate { display: inline; }
.cut-scene:is([data-stage="4"], [data-stage="5"]) .portion-row-back { transform: translateY(-6px); }
.cut-scene:is([data-stage="4"], [data-stage="5"]) .portion-row-front { transform: translateY(6px); }
.cut-scene[data-stage="3"] .portion-rows, .cut-scene[data-stage="5"] .portion-board { display: none; }

@media (max-height: 640px) and (orientation: portrait) {
  .guide { padding-top: 14px; }
  .intro { margin-bottom: 14px; }
  h1 { font-size: clamp(2.3rem, 10vw, 3.5rem); }
  .scene { height: clamp(160px, 34svh, 218px); }
  .model-tools { min-height: 34px; }
  .step-card { min-height: 102px; padding-block: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
