/* The method of a recipe with steps that tick off. One card on a warm page: the step in hand is lit with its timer,
   the done ones are struck through and greyed, the rail beside the ticks fills down to the step in hand. Every size
   is in em of the card, and the card's font size follows both the width and the height of the window. */
:root {
  --page: #f1ece3;          /* the page */
  --card: #fffdf9;          /* the card */
  --ink: #1f1b16;           /* the words */
  --muted: #9a9184;         /* small words and done steps */
  --line: #ebe4d8;          /* hairlines */
  --accent: #c4701f;        /* brown butter amber: the step in hand, the ticks, the timer */
  --accent-soft: #fbefe0;   /* the lit timer's ground */
  --accent-ink: #8a4a10;    /* words on the lit timer */
}

* { box-sizing: border-box; }
html { touch-action: manipulation; }
html, body { margin: 0; overflow-x: clip; }
body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.stage {
  position: relative;
  min-height: 100svh;
  max-height: 100vh;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
  background:
    radial-gradient(60% 55% at 50% 38%, rgba(255, 250, 240, 0.95), rgba(255, 250, 240, 0) 70%),
    radial-gradient(40% 40% at 80% 90%, rgba(196, 112, 31, 0.07), rgba(196, 112, 31, 0) 70%),
    var(--page);
}
.stage::after {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- the card ---------- */
.method {
  --fs: clamp(10.5px, min(3.55vw, 3.05vh), 15px);
  position: relative;
  z-index: 1;
  font-size: var(--fs);
  width: min(28.5em, 92vw);
  padding: 1.55em 1.6em 1.15em;
  border-radius: 1.6em;
  background: linear-gradient(180deg, #fffefb 0%, var(--card) 60%, #fcf9f3 100%);
  box-shadow:
    0 0 0 1px rgba(60, 42, 20, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 2px rgba(60, 42, 20, 0.05),
    0 6px 14px -4px rgba(60, 42, 20, 0.08),
    0 26px 48px -18px rgba(60, 42, 20, 0.2);
}
.method::before {
  /* a soft amber glow that sits behind the step in hand, moved by script.js */
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: var(--glow-y, 40%);
  height: 7em;
  transform: translateY(-50%);
  background: radial-gradient(55% 50% at 30% 50%, rgba(196, 112, 31, 0.07), rgba(196, 112, 31, 0) 72%);
  pointer-events: none;
  transition: top 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.brand { display: flex; align-items: center; gap: 0.45em; font-size: 0.82em; color: var(--muted); }
.brand__mark { width: 1.35em; height: 1.35em; fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.brand__name { color: var(--ink); font-weight: 620; letter-spacing: -0.005em; font-variation-settings: 'wdth' 108; }
.brand__tag {
  margin-left: auto;
  padding: 0.28em 0.7em 0.3em;
  border-radius: 99em;
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 0.92em;
  letter-spacing: 0.02em;
}
.method__title {
  margin: 0.55em 0 0.35em;
  font-size: 1.62em;
  line-height: 1.05;
  font-weight: 640;
  letter-spacing: -0.025em;
  font-variation-settings: 'wdth' 112;
}
.meta { display: flex; align-items: center; gap: 0.7em; font-size: 0.82em; color: var(--muted); }
.meta__item { display: inline-flex; align-items: center; gap: 0.4em; white-space: nowrap; }
.meta__rule { width: 1px; height: 0.95em; background: var(--line); }
.clock--meta { color: var(--ink); font-weight: 560; }

/* ---------- the rolling clock ---------- */
.clock {
  display: inline-flex;
  line-height: 1.2;
  height: 1.2em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 22%, #000 78%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 22%, #000 78%, transparent 100%);
}
.reel { display: block; width: 0.62em; height: 1.2em; overflow: hidden; }
.reel__col { display: flex; flex-direction: column; will-change: transform; }
.reel__col span { display: block; height: 1.2em; text-align: center; }
.clock__colon { display: block; padding: 0 0.04em; }

/* ---------- the steps ---------- */
.steps { position: relative; margin-top: 1.15em; }
.steps__list { list-style: none; margin: 0; padding: 0; position: relative; }
.rail {
  position: absolute;
  left: 0.95em;
  width: 1px;
  top: var(--rail-top, 1.5em);
  height: var(--rail-h, 10em);
  background: repeating-linear-gradient(180deg, var(--line) 0 3px, transparent 3px 6px);
  transform: translateX(-50%);
}
.rail__fill {
  position: absolute; left: 0; top: 0; width: 1px; height: 100%;
  background: var(--accent);
  transform-origin: 50% 0;
  transform: scaleY(0);
}

.step {
  position: relative;
  display: grid;
  grid-template-columns: 1.9em 1fr auto;
  column-gap: 0.75em;
  align-items: start;
  padding: 0.62em 0;
}
.step + .step { border-top: 1px solid transparent; }

.tick {
  position: relative;
  width: 1.9em; height: 1.9em;
  margin-top: -0.18em;
  border-radius: 50%;
  background: var(--card);
}
.tick svg { width: 100%; height: 100%; display: block; overflow: visible; }
.tick__ring { fill: var(--card); stroke: #ddd5c8; stroke-width: 1.3; transition: stroke 0.3s; }
.tick__fill { fill: var(--accent); }
.tick__ghost { fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0; }
.tick__mark { fill: none; stroke: #fff; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.step.is-active .tick__ring { stroke: var(--accent); }

.step__main { min-width: 0; }
.step__name {
  --w: 100;
  position: relative;
  display: inline-block;
  margin: 0;
  font-size: 1.06em;
  line-height: 1.3;
  font-weight: 560;
  letter-spacing: -0.012em;
  white-space: nowrap;
  color: var(--muted);
  font-variation-settings: 'wdth' var(--w);
}
.step__name { transition: color 0.4s; }
.step.is-active .step__name { color: var(--ink); }
.step.is-done .step__name { color: var(--muted); }
.strike {
  position: absolute;
  left: -0.12em; right: -0.12em; top: 0.12em;
  width: calc(100% + 0.24em); height: 1.1em;
  overflow: visible;
  pointer-events: none;
}
.strike path { fill: none; stroke: var(--ink); stroke-width: 0.95; stroke-linecap: round; stroke-dasharray: 1 1; stroke-dashoffset: 1; opacity: 0; }

.step__body { height: 0; overflow: hidden; }
.step__body p {
  margin: 0;
  padding: 0.3em 0 0.15em;
  font-size: 0.86em;
  line-height: 1.45;
  color: #6f675c;
  max-width: 21em;
}
.step__body .w { display: inline-block; }

/* ---------- the timer ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.36em;
  margin-top: -0.06em;
  padding: 0.24em 0.62em 0.24em 0.46em;
  border-radius: 99em;
  font-size: 0.84em;
  font-weight: 560;
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line);
  background: rgba(255, 255, 255, 0);
  transition: color 0.35s, box-shadow 0.35s, background-color 0.35s;
}
.chip__ring { width: 1.05em; height: 1.05em; transform: rotate(-90deg); overflow: visible; }
.chip__ring circle { fill: none; stroke: currentColor; stroke-width: 1.5; opacity: 0.3; }
.chip__ring .chip__left { opacity: 1; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 0; }
.chip__face { position: relative; display: block; height: 1.2em; min-width: 2.75em; overflow: hidden; }
.chip__face .clock { -webkit-mask-image: none; mask-image: none; }
.chip__done { position: absolute; left: 0; right: 0; top: 0; line-height: 1.2; text-align: center; }
.step.is-active .chip {
  color: var(--accent-ink);
  background-color: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(196, 112, 31, 0.22), 0 4px 10px -6px rgba(196, 112, 31, 0.45);
}
.step.is-active .chip__ring .chip__left { stroke: var(--accent); }
.step.is-done .chip { opacity: 0.75; }

/* ---------- the foot ---------- */
.method__foot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  margin-top: 0.75em;
  padding-top: 0.95em;
  border-top: 1px solid var(--line);
  font-size: 0.84em;
  min-height: 3.1em;
}
.next { display: inline-flex; align-items: baseline; gap: 0.5em; min-width: 0; }
.next__label { color: var(--muted); white-space: nowrap; }
.next__win { display: block; height: 1.3em; overflow: hidden; }
.next__text { display: block; line-height: 1.3; font-weight: 560; white-space: nowrap; }
.again {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.55em 1em 0.55em 0.85em;
  border-radius: 99em;
  background: var(--ink);
  color: #fffaf2;
  font-weight: 560;
  font-variation-settings: 'wdth' 100;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 6px 14px -6px rgba(31, 27, 22, 0.5);
  opacity: 0;
  visibility: hidden;
}
.again svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

@media (hover: hover) {
  .chip:hover { box-shadow: inset 0 0 0 1px #d9d0c2; }
  .step.is-active .chip:hover { box-shadow: inset 0 0 0 1px rgba(196, 112, 31, 0.4), 0 4px 10px -6px rgba(196, 112, 31, 0.5); }
  .again:hover { font-variation-settings: 'wdth' 112; }
}
.again { transition: font-variation-settings 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }

.tick:focus, .chip:focus, .again:focus { outline: none; }
.tick:focus-visible, .chip:focus-visible, .again:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.pointer {
  position: absolute; left: 0; top: 0;
  width: 22px; height: 22px; margin: -3px 0 0 -4px;
  fill: #1f1b16; stroke: #fff; stroke-width: 1.4; stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.22));
  pointer-events: none;
  opacity: 0;
  z-index: 20;
}
