:root {
  --ink: #15152a;
  --paper: #fff5df;
  --coral: #ff5d5d;
  --blue: #4f7cff;
  --butter: #ffd166;
  --mint: #58d6a9;
  --lilac: #b695ff;
  --tile: var(--paper);
  --mustard: var(--butter);
  --mustard-dark: #d79025;
  --coral-dark: #b84232;
  --screen: var(--ink);
  --aqua: var(--blue);
  --coffee: #5a3024;
  --white: #fffdf7;
  --shadow: rgb(21 21 42 / 0.18);
  --display-font: Impact, Haettenschweiler, "Arial Narrow Bold", "Franklin Gothic Condensed", sans-serif;
  --body-font: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", sans-serif;
  --utility-font: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: clip;
  color: var(--ink);
  background-color: var(--tile);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.48) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.48) 2px, transparent 2px);
  background-size: 52px 52px;
  font-family: var(--body-font);
  line-height: 1.5;
}

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 4px solid var(--blue);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  padding: 10px 16px;
  color: var(--white);
  background: var(--ink);
  border-radius: 8px;
  font-weight: 800;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header,
.coffee-lab,
footer {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding-block: 38px 28px;
}

.eyebrow,
.section-label {
  margin: 0 0 4px;
  font-family: var(--utility-font);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: -8px;
  font-family: var(--display-font);
  font-size: clamp(3.8rem, 9vw, 7.3rem);
  line-height: 0.82;
  letter-spacing: -0.075em;
}

h1 span {
  color: var(--coral);
}

.intro {
  max-width: 365px;
  margin-bottom: 0;
  padding-bottom: 4px;
  font-size: clamp(1rem, 2vw, 1.18rem);
  font-weight: 700;
  line-height: 1.45;
}

.coffee-lab {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(330px, 0.75fr);
  align-items: start;
  gap: 24px;
}

.machine-stage,
.control-panel {
  border: 3px solid var(--ink);
  box-shadow: 9px 9px 0 var(--ink);
}

.machine-stage {
  min-width: 0;
  overflow: hidden;
  background: var(--paper);
  border-radius: 38px 38px 14px 14px;
}

.stage-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 25px 18px;
  border-bottom: 3px solid var(--ink);
}

.stage-heading h2,
.panel-title-row h2 {
  margin: 0;
  font-family: var(--display-font);
  font-size: clamp(1.25rem, 2.5vw, 1.65rem);
  line-height: 1.1;
}

.mood-badge {
  flex: 0 0 auto;
  margin: 0;
  padding: 7px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--mint);
  font-family: var(--utility-font);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.machine-wrap {
  position: relative;
  min-height: 560px;
  padding: 6px 18px 28px;
  background:
    radial-gradient(circle at 88% 13%, rgba(239, 107, 77, 0.13) 0 47px, transparent 49px),
    linear-gradient(180deg, var(--white) 0 72%, #d7c8a6 72% 74%, #b98e62 74% 100%);
}

.machine {
  display: block;
  width: min(100%, 620px);
  height: auto;
  margin: 0 auto;
  overflow: visible;
}

.machine-caption {
  position: absolute;
  right: 20px;
  bottom: 16px;
  margin: 0;
  padding: 5px 9px;
  color: var(--paper);
  background: var(--ink);
  font-family: var(--utility-font);
  font-size: 0.66rem;
  font-weight: 700;
  transform: rotate(-1.5deg);
}

/* Machine illustration */
.counter-shadow {
  fill: rgba(23, 59, 63, 0.2);
}

.machine-shell {
  transform-origin: 51% 68%;
}

.machine-body-shadow {
  fill: var(--mustard-dark);
  stroke: var(--ink);
  stroke-width: 5;
}

.machine-body {
  fill: var(--mustard);
  stroke: var(--ink);
  stroke-width: 6;
}

.machine-top {
  fill: var(--coral);
  stroke: var(--ink);
  stroke-width: 5;
}

.vent path {
  fill: none;
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-width: 7;
}

.tank-frame {
  fill: var(--mustard-dark);
  stroke: var(--ink);
  stroke-width: 5;
}

.tank-glass {
  fill: var(--white);
  stroke: var(--ink);
  stroke-width: 4;
}

.tank-water {
  fill: var(--aqua);
}

.tank-bubbles {
  fill: url(#tankBubbles);
}

.tank-line {
  fill: none;
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-width: 3;
}

.svg-label,
.gauge-title,
.gauge-min,
.gauge-max,
.cup-copy {
  fill: var(--ink);
  font-family: var(--utility-font);
  font-weight: 900;
  letter-spacing: 0.08em;
}

.svg-label {
  font-size: 13px;
}

.screen-bezel {
  fill: var(--coral-dark);
  stroke: var(--ink);
  stroke-width: 5;
}

.screen-glass {
  fill: var(--screen);
  stroke: var(--ink);
  stroke-width: 3;
}

.machine-eyes path {
  fill: none;
  stroke: var(--mint);
  stroke-linecap: round;
  stroke-width: 9;
}

.machine-eyes .machine-mouth {
  stroke-width: 5;
}

.status-light {
  stroke: var(--ink);
  stroke-width: 4;
}

.status-light--red {
  fill: var(--coral);
}

.status-light--green {
  fill: #679b78;
}

.gauge-face {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 5;
}

.gauge-track {
  fill: none;
  stroke: var(--coral);
  stroke-linecap: round;
  stroke-width: 9;
}

.gauge-needle {
  fill: none;
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-width: 5;
  transform-origin: 245px 327px;
}

.gauge-pin {
  fill: var(--ink);
}

.gauge-title {
  font-size: 10px;
}

.gauge-min,
.gauge-max {
  font-size: 9px;
}

.brew-neck,
.brew-head-body {
  fill: var(--coral-dark);
  stroke: var(--ink);
  stroke-width: 5;
}

.spout {
  fill: var(--screen);
  stroke: var(--ink);
  stroke-linejoin: round;
  stroke-width: 5;
}

.side-lever path,
.side-lever circle {
  stroke: var(--ink);
  stroke-width: 5;
}

.side-lever path {
  fill: var(--paper);
}

.side-lever .lever-arm {
  fill: none;
  stroke-width: 10;
}

.lever-knob {
  fill: var(--coral);
}

.machine-foot {
  fill: var(--screen);
  stroke: var(--ink);
  stroke-width: 5;
}

.drip-tray {
  fill: var(--screen);
  stroke: var(--ink);
  stroke-linejoin: round;
  stroke-width: 5;
}

.tray-lines path {
  fill: none;
  stroke: var(--mint);
  stroke-linecap: round;
  stroke-width: 3;
}

.steam-cloud {
  opacity: 0;
}

.steam {
  fill: none;
  stroke: var(--white);
  stroke-linecap: round;
  stroke-width: 10;
}

.coffee-drop,
.coffee-fill,
.coffee-speck {
  fill: var(--coffee);
}

.coffee-drop {
  opacity: 0;
}

.cup-handle {
  fill: none;
  stroke: var(--ink);
  stroke-width: 18;
}

.cup-body {
  fill: rgba(255, 248, 223, 0.72);
  stroke: var(--ink);
  stroke-width: 6;
}

.cup-rim {
  fill: none;
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-width: 8;
}

.coffee-fill {
  transform: scaleY(0);
  transform-box: fill-box;
  transform-origin: center bottom;
  transition: transform 1.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.coffee-speck {
  opacity: 0;
}

.cup-copy {
  font-size: 13px;
}

.machine-wrap.is-brewing .machine-shell {
  animation: machine-shake 0.18s linear infinite;
}

.machine-wrap.is-brewing .steam-cloud {
  opacity: 1;
}

.machine-wrap.is-brewing .steam {
  animation: steam-rise 1s ease-in-out infinite;
}

.machine-wrap.is-brewing .steam--two {
  animation-delay: 0.2s;
}

.machine-wrap.is-brewing .steam--three {
  animation-delay: 0.42s;
}

.machine-wrap.is-brewing .status-light--red {
  animation: light-blink 0.4s steps(2, end) infinite;
}

.machine-wrap.is-brewing .status-light--green {
  animation: light-blink 0.4s 0.2s steps(2, end) infinite;
}

.machine-wrap.is-brewing .gauge-needle {
  animation: gauge-waver 0.7s ease-in-out infinite alternate;
}

.machine-wrap.has-drop .coffee-drop {
  animation: single-drop 0.85s cubic-bezier(0.55, 0.06, 0.68, 0.19) both;
}

.machine-wrap.has-drop .coffee-speck {
  opacity: 1;
  transition: opacity 0s 0.75s;
}

.machine-wrap.is-success .coffee-fill {
  transform: scaleY(1);
}

.machine-wrap.is-success .machine-eyes path:not(.machine-mouth) {
  transform: rotate(-8deg);
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes machine-shake {
  0%,
  100% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(-2px, 1px) rotate(-0.35deg); }
  50% { transform: translate(2px, -1px) rotate(0.35deg); }
  75% { transform: translate(-1px, -1px) rotate(-0.2deg); }
}

@keyframes steam-rise {
  0% { opacity: 0; transform: translateY(14px); }
  45% { opacity: 0.85; }
  100% { opacity: 0; transform: translateY(-18px); }
}

@keyframes light-blink {
  50% { fill: var(--white); }
}

@keyframes gauge-waver {
  to { transform: rotate(18deg); }
}

@keyframes single-drop {
  0% { opacity: 0; transform: translateY(0) scale(0.5); }
  14% { opacity: 1; transform: translateY(4px) scale(1); }
  88% { opacity: 1; transform: translateY(120px) scale(0.8); }
  100% { opacity: 0; transform: translateY(126px) scale(1.4, 0.3); }
}

/* Control panel */
.control-panel {
  position: relative;
  padding: 28px;
  color: var(--paper);
  background: var(--coral);
  border-radius: 18px 18px 40px 18px;
}

.panel-rivets {
  position: absolute;
  top: 11px;
  right: 14px;
  left: 14px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.panel-rivets span {
  width: 8px;
  height: 8px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.model-stamp {
  padding: 3px 7px;
  border: 2px solid currentColor;
  border-radius: 4px;
  font-family: var(--utility-font);
  font-size: 0.77rem;
  font-weight: 900;
  transform: rotate(2deg);
}

.progress-screen {
  min-height: 205px;
  padding: 18px;
  color: var(--mint);
  background: var(--screen);
  border: 4px solid var(--ink);
  border-radius: 13px;
  box-shadow: inset 0 0 0 2px rgba(169, 228, 194, 0.12);
  font-family: var(--utility-font);
}

.screen-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 11px;
  border-bottom: 1px solid rgba(169, 228, 194, 0.3);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.status-message {
  display: flex;
  align-items: center;
  min-height: 78px;
  margin: 6px 0;
  color: var(--white);
  font-family: var(--display-font);
  font-size: clamp(1.25rem, 3vw, 1.65rem);
  line-height: 1.12;
}

.progress-track {
  height: 14px;
  overflow: hidden;
  border: 2px solid var(--mint);
  border-radius: 999px;
  background: rgba(169, 228, 194, 0.1);
}

.progress-fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--coral);
  transition: width 0.45s ease;
}

.progress-track[data-progress="12"] .progress-fill {
  width: 12%;
}

.progress-track[data-progress="31"] .progress-fill {
  width: 31%;
}

.progress-track[data-progress="58"] .progress-fill {
  width: 58%;
}

.progress-track[data-progress="87"] .progress-fill {
  width: 87%;
}

.progress-track[data-progress="92"] .progress-fill {
  width: 92%;
}

.progress-track[data-progress="100"] .progress-fill {
  width: 100%;
}

.progress-screen.is-success .progress-fill {
  background: var(--mint);
}

.progress-screen.is-denied {
  box-shadow: inset 0 0 0 2px rgba(239, 107, 77, 0.38);
}

.diagnostics {
  display: flex;
  flex-wrap: wrap;
  gap: 13px;
  margin-top: 12px;
  font-size: 0.62rem;
  font-weight: 800;
}

.diagnostics span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.diagnostic-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--coral);
}

.diagnostic-dot--ready {
  background: var(--mint);
}

.brew-button {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 68px;
  margin-top: 18px;
  padding: 12px 18px;
  color: var(--ink);
  background: var(--mustard);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 6px 0 var(--ink);
  font-family: var(--display-font);
  font-size: 1.24rem;
  font-weight: 900;
  text-align: left;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.brew-button:hover:not(:disabled) {
  background: #ffc957;
  transform: translateY(-1px);
  box-shadow: 0 7px 0 var(--ink);
}

.brew-button:active:not(:disabled) {
  transform: translateY(5px);
  box-shadow: 0 1px 0 var(--ink);
}

.brew-button:disabled {
  color: rgba(23, 59, 63, 0.62);
  background: #cab87e;
  cursor: not-allowed;
}

.brew-button-light {
  width: 15px;
  height: 15px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--coral);
}

.brew-button.is-busy .brew-button-light {
  animation: button-pulse 0.75s ease-in-out infinite alternate;
}

.button-arrow {
  font-family: var(--body-font);
  font-size: 1.7rem;
  line-height: 1;
}

.brew-hint {
  margin: 12px 0 19px;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
  text-align: center;
}

@keyframes button-pulse {
  to { background: var(--mint); box-shadow: 0 0 0 5px rgba(169, 228, 194, 0.18); }
}

.secondary-controls {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 10px;
}

.utility-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  color: var(--paper);
  background: transparent;
  border: 2px solid var(--ink);
  border-radius: 9px;
  font-size: 0.8rem;
  font-weight: 900;
  cursor: pointer;
}

.utility-button:hover {
  color: var(--ink);
  background: var(--paper);
}

.attempt-log {
  margin-top: 24px;
  padding-top: 20px;
  color: var(--ink);
  border-top: 2px dashed rgba(23, 59, 63, 0.65);
}

.log-heading-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.log-heading-row h3 {
  margin-bottom: 10px;
  font-family: var(--display-font);
  font-size: 1rem;
}

.log-heading-row span {
  font-family: var(--utility-font);
  font-size: 0.66rem;
  font-weight: 800;
}

.attempt-log ol {
  max-height: 176px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-color: var(--ink) transparent;
}

.attempt-log li {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid rgba(23, 59, 63, 0.25);
  font-size: 0.78rem;
  font-weight: 800;
}

.attempt-log li::before {
  content: attr(data-attempt);
  font-family: var(--utility-font);
  font-size: 0.68rem;
}

.attempt-log .empty-log {
  display: block;
  border-top: 0;
  font-style: italic;
  font-weight: 700;
}

.attempt-log .empty-log::before {
  content: none;
}

.attempt-log .drop-entry::after {
  content: "1 DROP";
  align-self: center;
  width: max-content;
  margin-left: 34px;
  padding: 1px 5px;
  color: var(--paper);
  background: var(--coffee);
  font-family: var(--utility-font);
  font-size: 0.57rem;
  transform: rotate(-1deg);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-block: 35px 28px;
  font-family: var(--utility-font);
  font-size: 0.67rem;
  font-weight: 800;
}

footer p {
  margin: 0;
}

.collection-link {
  color: var(--ink);
  font-family: var(--display-font);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-underline-offset: 3px;
}

@media (max-width: 900px) {
  .coffee-lab {
    grid-template-columns: 1fr;
  }

  .control-panel {
    width: min(100%, 620px);
    margin-inline: auto;
  }

  .machine-wrap {
    min-height: 500px;
  }
}

@media (max-width: 640px) {
  .site-header,
  .coffee-lab,
  footer {
    width: min(100% - 24px, 1180px);
  }

  .site-header {
    display: block;
    padding-block: 28px 20px;
  }

  h1 {
    font-size: clamp(3.2rem, 19vw, 5.2rem);
  }

  .intro {
    margin-top: 22px;
  }

  .stage-heading {
    align-items: flex-start;
    padding: 17px;
  }

  .mood-badge {
    max-width: 132px;
    white-space: normal;
  }

  .machine-wrap {
    min-height: 0;
    padding: 5px 2px 45px;
  }

  .machine-caption {
    right: 10px;
    bottom: 11px;
  }

  .control-panel {
    padding: 24px 18px;
    border-radius: 16px 16px 30px 16px;
  }

  .screen-meta {
    font-size: 0.6rem;
  }

  .secondary-controls {
    grid-template-columns: 1fr;
  }

  footer {
    display: block;
  }

  footer p + p {
    margin-top: 8px;
  }
}

@media (max-width: 390px) {
  .stage-heading {
    display: block;
  }

  .mood-badge {
    display: inline-block;
    margin-top: 12px;
  }

  .panel-title-row {
    align-items: flex-start;
  }

  .progress-screen {
    padding: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
