/* Forest Bakery -- cream book paper, six inks, everything carved rather than
   drawn. No gradients, no blurred shadows, no rounded cards. */

@font-face {
  font-family: 'Bevan';
  src: url('../fonts/bevan-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Lora';
  src: url('../fonts/lora-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Lora';
  src: url('../fonts/lora-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Caveat';
  src: url('../fonts/caveat-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Caveat';
  src: url('../fonts/caveat-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #EFE0C2;
  --ink: #33241B;
  --crust: #B96B33;
  --honey: #E3A63C;
  --brick: #B23F2C;
  --olive: #55603A;
  --dusk: #4C6068;
  --flour: #FBF3E0;
  --u: 20px;
  --pad: 12px;
  --topstrip: 52px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Lora', Georgia, 'Times New Roman', serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#stage canvas {
  display: block;
  touch-action: none;
}

#ui {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.noscript {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  font-size: 1.1rem;
  color: var(--ink);
  background: var(--paper);
  z-index: 9;
}

/* ------------------------------------------------------------- top strip */

#topbar {
  position: absolute;
  top: env(safe-area-inset-top, 0);
  left: 0;
  right: 0;
  height: var(--topstrip);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 calc(var(--pad) + 6px);
  pointer-events: none;
}

#brandname {
  font-family: 'Bevan', Georgia, serif;
  font-weight: 400;
  font-size: clamp(13px, calc(var(--u) * 0.86), 22px);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.92;
  white-space: nowrap;
}

#steps {
  display: flex;
  align-items: center;
  gap: clamp(4px, calc(var(--u) * 0.34), 12px);
  flex-wrap: nowrap;
  overflow: hidden;
}

.step {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: 'Bevan', Georgia, serif;
  font-size: clamp(9px, calc(var(--u) * 0.52), 14px);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.32;
  white-space: nowrap;
}

.step i {
  font-style: normal;
}

.step b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(15px, calc(var(--u) * 0.86), 24px);
  height: clamp(15px, calc(var(--u) * 0.86), 24px);
  border-radius: 50%;
  font-weight: 400;
  font-size: 0.86em;
  color: var(--paper);
  background: var(--ink);
  opacity: 0.5;
}

.step.done {
  opacity: 0.6;
}

.step.done b {
  background: var(--olive);
  opacity: 1;
}

.step.on {
  opacity: 1;
}

.step.on b {
  background: var(--brick);
  opacity: 1;
}

#steps.compact .step i {
  display: none;
}

/* --------------------------------------------------------- the recipe card */

#card {
  position: absolute;
  background: var(--flour);
  padding: calc(var(--u) * 0.72) calc(var(--u) * 0.86) calc(var(--u) * 0.66);
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 0.36);
  overflow: hidden;
  pointer-events: none;
  /* a torn deckled edge, cut by hand */
  clip-path: polygon(0px 4px, 6% 1px, 14% 5px, 24% 0px, 34% 4px, 45% 1px, 56% 5px, 67% 1px, 78% 4px,
      89% 0px, 100% 4px,
      calc(100% - 4px) 14%, calc(100% - 1px) 27%, calc(100% - 5px) 41%, calc(100% - 0px) 55%,
      calc(100% - 4px) 69%, calc(100% - 1px) 83%, calc(100% - 3px) 96%,
      100% calc(100% - 4px), 88% calc(100% - 1px), 76% calc(100% - 5px), 64% calc(100% - 0px),
      52% calc(100% - 4px), 40% calc(100% - 1px), 28% calc(100% - 5px), 16% calc(100% - 0px),
      5% calc(100% - 3px), 0 calc(100% - 5px),
      4px 86%, 1px 72%, 5px 58%, 0px 44%, 4px 30%, 1px 16%);
  filter: drop-shadow(2px 4px 0 rgba(51, 36, 27, 0.16));
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: 50% 100%;
}

#card.lift {
  transform: scale(1.012);
}

#card.wide {
  /* the title and the verdict card sit on the bench and grow upward */
}

#cardhead {
  display: flex;
  align-items: baseline;
  gap: calc(var(--u) * 0.40);
}

#stepno {
  font-family: 'Bevan', Georgia, serif;
  font-size: calc(var(--u) * 1.15);
  line-height: 1;
  color: var(--brick);
}

#stepname {
  font-family: 'Bevan', Georgia, serif;
  font-size: calc(var(--u) * 0.70);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.86;
}

#hint {
  margin: 0;
  font-family: 'Lora', Georgia, serif;
  font-size: calc(var(--u) * 0.72);
  line-height: 1.42;
  color: var(--ink);
  max-width: 62ch;
}

/* the measure: a stamped scale on the card, so it is always in reach */
#gauge {
  display: none;
  position: relative;
  height: calc(var(--u) * 0.86);
  margin-top: calc(var(--u) * 0.10);
  background: rgba(51, 36, 27, 0.10);
  box-shadow: inset 0 0 0 2px rgba(51, 36, 27, 0.55);
}

#gauge.on {
  display: block;
}

#gband {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--honey);
  opacity: 0.60;
}

#gfill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: var(--brick);
}

#gtick {
  position: absolute;
  top: calc(var(--u) * -0.16);
  bottom: calc(var(--u) * -0.16);
  width: 2px;
  background: var(--ink);
}

#gtext {
  display: block;
  margin-top: calc(var(--u) * 0.16);
  font-family: 'Bevan', Georgia, serif;
  font-size: calc(var(--u) * 0.50);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.62;
}

#actions {
  display: flex;
  gap: calc(var(--u) * 0.44);
  align-items: center;
  flex-wrap: wrap;
}

#note {
  margin: 0;
  font-family: 'Caveat', 'Segoe Script', cursive;
  font-size: calc(var(--u) * 1.02);
  line-height: 1.15;
  color: var(--crust);
  min-height: 1.15em;
  opacity: 0;
  transition: opacity 200ms ease-out;
}

#note.good {
  color: var(--olive);
}

#note.meh {
  color: var(--brick);
}

/* ------------------------------------------------------------- the stamps */

.stamp,
.stamp2 {
  font-family: 'Bevan', Georgia, serif;
  font-size: calc(var(--u) * 0.66);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  line-height: 1;
  padding: calc(var(--u) * 0.62) calc(var(--u) * 0.96);
  border: 0;
  border-radius: 0;
  cursor: pointer;
  position: relative;
  pointer-events: none;
}

.stamp {
  background: var(--ink);
  color: var(--flour);
  box-shadow: 3px 4px 0 0 rgba(185, 107, 51, 0.55);
  transition: box-shadow 180ms cubic-bezier(0.22, 1, 0.36, 1), transform 180ms cubic-bezier(0.22, 1, 0.36, 1), background 180ms ease-out;
}

/* a second, fainter impression lands beside it, like a double strike */
.stamp:hover {
  box-shadow: 3px 4px 0 0 rgba(185, 107, 51, 0.55), 7px 8px 0 0 rgba(51, 36, 27, 0.16);
}

/* the press sinks the stamp into the paper. The stamp is not a real button --
   a press anywhere is the press -- so the class is set from the input handler
   rather than left to :active, which never fires under pointer-events: none. */
#ui.down .stamp {
  background: #241a13;
  box-shadow: 1px 2px 0 0 rgba(185, 107, 51, 0.85);
  transform: translate(2px, 2px);
}

.stamp2 {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--ink);
  pointer-events: auto;
}

.stamp2:hover {
  background: rgba(51, 36, 27, 0.07);
  box-shadow: inset 0 0 0 2px var(--ink), 5px 6px 0 0 rgba(51, 36, 27, 0.14);
}

#ui.down .stamp2 {
  background: rgba(51, 36, 27, 0.14);
  box-shadow: inset 0 0 0 2px var(--ink), 1px 2px 0 0 rgba(51, 36, 27, 0.45);
  transform: translate(2px, 2px);
}

/* the stamp takes the pointer so it can answer a hover and show a cursor. A
   press on it still bubbles to the one window handler, so it is not a second
   control with its own wiring. */
.stamp {
  pointer-events: auto;
  cursor: pointer;
}

.stamp,
.stamp2 {
  transition: box-shadow 180ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 180ms cubic-bezier(0.22, 1, 0.36, 1),
    background 180ms ease-out;
}

/* a press should feel immediate, not eased */
#ui.down .stamp,
#ui.down .stamp2 {
  transition-duration: 60ms;
}

/* ----------------------------------------------------------- the verdict */

/* the verdict always reads down the card: name, score, what happened to it,
   then the shelf. A row of columns crushes at every size but the widest. */
#verdict {
  display: none;
  flex-direction: column;
  gap: calc(var(--u) * 0.26);
}

#loafname {
  font-family: 'Bevan', Georgia, serif;
  font-size: calc(var(--u) * 1.22);
  line-height: 1.06;
  letter-spacing: 0.01em;
  color: var(--ink);
}

#loafnote {
  font-family: 'Lora', Georgia, serif;
  font-size: calc(var(--u) * 0.66);
  line-height: 1.42;
  color: var(--ink);
  opacity: 0.86;
  max-width: 64ch;
}

#loafscore {
  display: flex;
  align-items: baseline;
  gap: calc(var(--u) * 0.30);
  flex-wrap: wrap;
}

#loafscore .num {
  font-family: 'Bevan', Georgia, serif;
  font-size: calc(var(--u) * 1.85);
  line-height: 0.9;
  color: var(--brick);
}

#loafscore .den {
  font-family: 'Bevan', Georgia, serif;
  font-size: calc(var(--u) * 0.72);
  color: var(--ink);
  opacity: 0.6;
}

#loafscore .vd {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: calc(var(--u) * 0.72);
  color: var(--olive);
}

#board {
  margin-top: calc(var(--u) * 0.14);
  border-top: 2px solid rgba(51, 36, 27, 0.20);
  padding-top: calc(var(--u) * 0.24);
}

#board .bt {
  font-family: 'Bevan', Georgia, serif;
  font-size: calc(var(--u) * 0.50);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.5;
  margin-bottom: calc(var(--u) * 0.14);
}

#board .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-family: 'Lora', Georgia, serif;
  font-size: calc(var(--u) * 0.62);
  line-height: 1.5;
  color: var(--ink);
}

#board .row.mine {
  font-weight: 600;
  color: var(--brick);
}

#board .row a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

#board .loading {
  font-family: 'Lora', Georgia, serif;
  font-size: calc(var(--u) * 0.58);
  color: var(--ink);
  opacity: 0.45;
}

/* ------------------------------------------------------------ the title */

.titlebig {
  display: block;
  font-family: 'Bevan', Georgia, serif;
  font-size: calc(var(--u) * 1.95);
  line-height: 1.0;
  letter-spacing: 0.005em;
  color: var(--ink);
  margin-bottom: calc(var(--u) * 0.34);
}

.sub {
  display: block;
  font-family: 'Lora', Georgia, serif;
  font-size: calc(var(--u) * 0.70);
  line-height: 1.45;
  color: var(--ink);
  opacity: 0.86;
  max-width: 58ch;
}

.sub2 {
  display: block;
  margin-top: calc(var(--u) * 0.30);
  font-family: 'Caveat', cursive;
  font-size: calc(var(--u) * 0.92);
  color: var(--crust);
}

/* ------------------------------------------------------------- the sound */

#sound {
  flex: 0 0 auto;
  pointer-events: auto;
  font-family: 'Bevan', Georgia, serif;
  font-size: clamp(8px, calc(var(--u) * 0.44), 11px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 8px;
  border: 0;
  background: rgba(51, 36, 27, 0.12);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  clip-path: polygon(1px 0, 100% 2px, calc(100% - 1px) 100%, 0 calc(100% - 2px));
}

#sound.off {
  color: var(--brick);
  background: rgba(178, 63, 44, 0.14);
}

@media (max-width: 560px) {
  #brandname {
    font-size: clamp(11px, calc(var(--u) * 0.72), 16px);
  }
}
