/* Brewing simulator (/brew/). Builds on site.css: same palette, type and buttons. */

.brew-page .lede { max-width: 46rem; }

/* Tea picker */
.brew-pick h2 { margin-top: 1.5rem; }
.brew-cards { margin-top: 1rem; }
.brew-card h3 button {
  padding: 0;
  color: var(--text);
  background: none;
  border: 0;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  cursor: pointer;
}
.brew-card h3 button::after { position: absolute; inset: 0; content: ""; border-radius: inherit; }
.brew-card:focus-within { border-color: var(--peach); }
.brew-card h3 button:focus-visible { outline: none; }
.brew-card:has(button:focus-visible) { outline: 2px solid var(--peach); outline-offset: 3px; }
.brew-card .brew-meta { margin-top: auto; padding-top: .9rem; color: var(--amber); font-size: .85rem; }
.brew-card .brew-meta:empty { display: none; }
.brew-card .brew-meta.is-unlocked::before { content: "✓ "; }
.brew-unlock-hint { margin: 1.25rem 0 0; }

/* Simulator layout: the step card sits beside the kitchen on wide screens and above it on narrow
   ones. It comes first in the page, so Tab goes from the step straight into the kitchen. */
.brew-sim {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(19rem, 25rem);
  grid-template-rows: auto 1fr;
  grid-template-areas: "stage panel" "stage more";
  gap: 1rem 1.25rem;
  align-items: start;
  margin: 1.5rem 0 0;
  scroll-margin-top: 4.5rem;
}
.brew-sim[hidden], .brew-result[hidden] { display: none; }
.brew-stage {
  grid-area: stage;
  position: sticky;
  top: 4.25rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  background: #2c1a12;
}
.brew-more { grid-area: more; display: grid; gap: 1rem; min-width: 0; }
.scene { aspect-ratio: 800 / 386; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.scene svg { display: block; width: 100%; height: 100%; }

.stage-toast {
  position: absolute;
  top: .75rem;
  left: 50%;
  max-width: calc(100% - 1.5rem);
  margin: 0;
  padding: .45rem .9rem;
  transform: translateX(-50%);
  color: var(--bg);
  background: var(--peach);
  border-radius: 2rem;
  box-shadow: 0 .4rem 1.2rem #0007;
  font-size: .9rem;
  font-weight: 650;
  text-align: center;
  pointer-events: none;
}
.stage-toast[hidden] { display: none; }

.readouts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  border-top: 1px solid var(--line);
  background: var(--line);
}
.readout { display: flex; flex-direction: column; padding: .55rem .8rem .65rem; background: var(--panel); }
.readout span { color: var(--amber); font-size: .7rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.readout strong { font: 600 1.35rem/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.readout small { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.readout.is-live strong { color: var(--peach); }

/* Panel */
.brew-panel { grid-area: panel; display: grid; gap: 1rem; min-width: 0; }
.panel-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem 1rem; }
.panel-top .kicker { margin: 0; }
.panel-links { display: flex; gap: 1rem; }
.text-button {
  padding: .3rem 0;
  color: var(--peach);
  background: none;
  border: 0;
  font: inherit;
  font-size: .9rem;
  text-decoration: underline;
  text-underline-offset: .18em;
  cursor: pointer;
}
.text-button:hover { color: var(--text); }
.step-progress { height: .35rem; overflow: hidden; border-radius: 1rem; background: var(--panel-2); }
.step-progress span { display: block; width: 0; height: 100%; background: var(--peach); transition: width .3s; }

.step-list { border: 1px solid var(--line); border-radius: .9rem; background: var(--panel); }
.step-list summary { padding: .6rem .9rem; color: var(--muted); font-size: .9rem; cursor: pointer; }
.step-list ol { margin: 0; padding: 0 .9rem .7rem 2.3rem; font-size: .9rem; color: var(--muted); }
.step-list li { padding: .12rem 0; }
.step-list li.is-done { color: #a99581; text-decoration: line-through; text-decoration-color: #ffd5a780; }
.step-list li.is-current { color: var(--text); font-weight: 650; }
.step-list li.is-current::marker { color: var(--peach); }

.step-card {
  padding: 1.2rem 1.25rem 1.3rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--peach);
  border-radius: 1rem;
  background: var(--panel);
}
.step-number { margin: 0; color: var(--amber); font-size: .78rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.step-card h2 { margin: .3rem 0 .5rem; font-size: clamp(1.6rem, 3vw, 2rem); }
.step-card h2:focus { outline: none; }
.step-text { margin: 0 0 .9rem; }
.step-how {
  margin: 0;
  padding: .65rem .85rem;
  border: 1px dashed color-mix(in srgb, var(--peach) 55%, transparent);
  border-radius: .7rem;
  background: color-mix(in srgb, var(--peach) 7%, transparent);
  font-size: .95rem;
}
.step-keys { margin: .5rem 0 0; color: var(--muted); font-size: .88rem; }
.brew-sim:not(.is-keys) .step-keys {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.step-hint { min-height: 1.65em; margin: .8rem 0 0; color: var(--peach); font-style: italic; }
.step-hint:empty { min-height: 0; margin: 0; }
.step-card.is-done { border-left-color: #9fdc9f; }
.step-card.is-done .step-hint { color: #b9e8b9; font-style: normal; font-weight: 650; }
.step-nav { display: flex; justify-content: flex-end; margin-top: .9rem; }
.step-nav[hidden] { display: none; }
.step-nav .button { min-width: 9rem; }

.sim-options { display: grid; gap: .4rem; color: var(--muted); font-size: .9rem; }
.sim-options input { accent-color: var(--peach); }

/* Scene details */
.scene .lcd { font: 600 10px ui-monospace, Menlo, Consolas, monospace; fill: #8dffb9; }
.scene .lcd.warm { font-size: 12px; fill: #ffb37a; }
.scene .tiny { font: 600 6.5px system-ui, sans-serif; fill: #b7b2ad; letter-spacing: .04em; }
.scene .tiny.dim { fill: #6d6a72; }
.scene .porcelain { fill: url(#g-porcelain); }
.scene .raku { fill: url(#g-raku); }
.scene .mug { fill: url(#g-mug); }
.scene .shelf-tin rect, .scene .caddy rect { fill: var(--swatch); }
.scene .shelf-tin .tin-lid, .scene .caddy .tin-lid { fill: color-mix(in srgb, var(--swatch) 55%, #120a06); }
.scene .caddy .tin-label { fill: #f6ecdd; opacity: .85; }
.scene .shelf-tin.is-out { opacity: .12; }
.scene .tiny.dark { fill: #4a3426; }
.scene .tool { opacity: 0; visibility: hidden; transition: opacity .35s, visibility 0s .35s; }
.scene .tool.is-shown { opacity: 1; visibility: visible; transition-delay: 0s; }

/* Things in the kitchen you can use. Only their hit areas take the pointer, and only while they're
   part of the step. The next thing to do has a moving dashed outline. */
.scene svg * { pointer-events: none; }
.scene .obj { outline: none; }
.scene .obj.is-on .hit { pointer-events: all; cursor: grab; touch-action: none; }
.scene .obj.is-press.is-on .hit { cursor: pointer; }
.scene.is-dragging svg, .scene.is-dragging .obj.is-on .hit { cursor: grabbing; }
.scene .hit { fill: none; stroke: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
.scene .obj.is-on:hover .hit { stroke: #fff8; stroke-dasharray: 4 4; }
.scene .obj.is-cue .hit { stroke: var(--peach); stroke-dasharray: 6 5; animation: cue 1.2s linear infinite; }
.scene .obj:focus-visible .hit { stroke: #fff; stroke-width: 2.5; stroke-dasharray: none; animation: none; }
@keyframes cue { to { stroke-dashoffset: -22; } }
.scene .bits { stroke-dasharray: 1 8; animation: flow .3s linear infinite; }
.scene .led-on { filter: drop-shadow(0 0 3px #ff6a3d); }
.scene .steam path { fill: none; stroke: #fff6ea; stroke-width: 3; stroke-linecap: round; opacity: .35; animation: steam 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
.scene .steam path:nth-child(2) { animation-delay: -.8s; }
.scene .steam path:nth-child(3) { animation-delay: -1.6s; }
@keyframes steam {
  0% { opacity: 0; transform: translateY(8px) scaleX(.8); }
  35% { opacity: .45; }
  100% { opacity: 0; transform: translateY(-22px) scaleX(1.3); }
}
.scene .flow { stroke-dasharray: 9 5; animation: flow .35s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -14; } }
.scene .bubble { animation: bubble 1s ease-in infinite; }
.scene .bubble.b1 { animation-delay: -.25s; }
.scene .bubble.b2 { animation-delay: -.5s; }
.scene .bubble.b3 { animation-delay: -.75s; }
@keyframes bubble { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-80px); opacity: 0; } }
.scene .dust { animation: dust .5s linear infinite; }
.scene .dust.d1 { animation-delay: -.17s; }
.scene .dust.d2 { animation-delay: -.34s; }
@keyframes dust { from { transform: translateY(0); opacity: 1; } to { transform: translateY(26px); opacity: 0; } }
.scene #kettle-lid { transition: transform .2s; }

/* Brew report */
.brew-result { margin: 2rem 0 0; scroll-margin-top: 4.5rem; }
.brew-report { margin: 0; }
.report-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem 2rem; }
.report-head .page-title:focus { outline: none; }
.brew-report .tagline { max-width: 40rem; }
.score { display: grid; justify-items: end; margin: 1rem 0 0; line-height: 1; }
.score strong { font: 400 clamp(4rem, 10vw, 6rem)/1 Georgia, serif; color: var(--peach); }
.score span { color: var(--muted); font-size: 1.1rem; }
.score small { margin-top: .5rem; color: var(--amber); font-weight: 650; }
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .75rem 2rem; margin: 1.5rem 0; }
.meter dt { color: var(--amber); font-size: .78rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.meter dd { display: flex; align-items: center; gap: .75rem; margin: .3rem 0 0; }
.meter-bar { flex: 1; height: .5rem; overflow: hidden; border-radius: 1rem; background: var(--panel-2); }
.meter-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--amber), var(--swatch, var(--peach))); }
.unlock { padding: .9rem 1.1rem; border: 1px solid var(--line); border-radius: .9rem; background: #ffffff08; }
.unlock.is-new { border-color: var(--peach); background: color-mix(in srgb, var(--peach) 12%, transparent); }
.brew-report h3 { margin: 2rem 0 .75rem; font: 400 1.6rem/1.1 Georgia, serif; }
.report { display: grid; gap: .6rem; margin: 0; padding: 0; list-style: none; }
.report li { display: grid; grid-template-columns: 1.6rem 1fr; gap: .75rem; padding: .7rem .9rem; border-radius: .8rem; background: #00000022; }
.report .detail { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.report p { margin: .15rem 0 0; color: var(--muted); font-size: .95rem; }
.report .mark { display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; font-weight: 800; font-size: .85rem; }
.report .ok .mark { color: #16321c; background: #9fdc9f; }
.report .ok .mark::after { content: "✓"; }
.report .meh .mark { color: #3a2a06; background: #f1c860; }
.report .meh .mark::after { content: "~"; }
.report .bad .mark { color: #3d0c0c; background: #f08a8a; }
.report .bad .mark::after { content: "✕"; }
.brew-report .verdict h3 { margin-top: 0; }

@media (max-width: 60rem) {
  .brew-sim { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "panel" "stage" "more"; }
  .brew-stage { position: relative; top: auto; }
  .step-card { padding: 1rem 1.05rem 1.1rem; }
  .step-card h2 { margin: .2rem 0 .35rem; }
  .readout { padding: .4rem .6rem .5rem; }
  .readout strong { font-size: 1.05rem; }
  .readout small { font-size: .7rem; }
}
@media (max-width: 40rem) {
  .scene { aspect-ratio: 4 / 3; }
  .step-text { font-size: .95rem; }
}
@media (max-width: 30rem) {
  .readouts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .readout small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .scene .steam path, .scene .flow, .scene .bits, .scene .bubble, .scene .dust, .scene .obj.is-cue .hit { animation: none; }
  .scene .tool, .step-progress span, .scene #kettle-lid { transition: none; }
}
