/* ddebel.shop: the page is a burger. Top bun, lettuce, cheese, Embata as the
   patty, bottom bun, all sitting on a red fast-food tray. */

:root {
  --tray: #b81d15;
  --tray-light: #d8392b;
  --tray-dark: #7c0f0a;
  --bun: #e8a33f;
  --bun-light: #f8d48a;
  --bun-dark: #c4722a;
  --crust: #9a5517;
  --sesame: #fff3d6;
  --lettuce: #5bb33a;
  --lettuce-dark: #2e7a1c;
  --cheese: #ffc61f;
  --cheese-deep: #f59b00;
  --cheese-pale: #ffe596;
  --ink: #2a1407;
  --ink-soft: #6b3b12;
  --paper: #fffaf0;
  --ketchup: #e0281c;
  --board: #1f1611;

  --font-display: "Dela Gothic One", "Arial Black", sans-serif;
  --font-body: "Golos Text", system-ui, sans-serif;
  --font-mono: "Martian Mono", ui-monospace, monospace;
  --font-logo: "Rubik Wet Paint", "Dela Gothic One", sans-serif;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  /* Sesame seeds for the top bun, drawn once as a tile. */
  --seeds: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='210' height='86'%3E%3Cg fill='%23fff3d6' fill-opacity='.8'%3E%3Cellipse cx='22' cy='14' rx='4' ry='2' transform='rotate(-25 22 14)'/%3E%3Cellipse cx='96' cy='9' rx='4' ry='2' transform='rotate(18 96 9)'/%3E%3Cellipse cx='168' cy='20' rx='4' ry='2' transform='rotate(-8 168 20)'/%3E%3Cellipse cx='60' cy='58' rx='4' ry='2' transform='rotate(32 60 58)'/%3E%3Cellipse cx='140' cy='70' rx='4' ry='2' transform='rotate(-35 140 70)'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html {
  height: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  background: var(--tray-dark);
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--ink);
  /* The tray: red paper with a faint printed dot. */
  background:
    radial-gradient(rgba(255, 236, 200, 0.07) 1.2px, transparent 1.6px) 0 0 / 16px 16px,
    radial-gradient(ellipse 80% 70% at 50% 48%, var(--tray-light) 0%, var(--tray) 55%, var(--tray-dark) 100%);
}

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  grid-template-areas: "top" "lettuce" "cheese" "stage" "bottom";
  height: 100dvh;
}

/* ---------- Top bun ---------- */

.bun-top {
  grid-area: top;
  position: relative;
  z-index: 4;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  border-radius: 50% 50% 0 0 / 34px 34px 0 0;
  background:
    var(--seeds) 10px 2px / 210px 86px,
    radial-gradient(140% 160% at 28% 0%, var(--bun-light) 0%, var(--bun) 40%, var(--bun-dark) 100%);
  box-shadow: inset 0 -5px 0 rgba(154, 85, 23, 0.45);
}

.bun-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  margin: 0;
  font-family: var(--font-logo);
  font-weight: 400;
  font-size: 28px;
  line-height: 1;
  color: var(--ink);
  text-shadow: 0 2px 0 rgba(255, 243, 214, 0.55);
}
.logo span { color: var(--ketchup); }

.online {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 99px;
  background: rgba(74, 37, 17, 0.82);
  color: var(--sesame);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.online svg { width: 16px; height: 16px; color: #6ee07a; flex: none; }

.stats {
  display: grid;
  grid-template-columns: 1.25fr 1fr 0.8fr;
  gap: 6px;
  margin: 10px 0 0;
}
.stats div {
  min-width: 0;
  padding: 6px 10px 7px;
  border-radius: 12px;
  background: rgba(255, 246, 225, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 1px 0 rgba(154, 85, 23, 0.25);
}
.stats dt {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.stats dd {
  margin: 1px 0 0;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Lettuce: the current status and what's next ---------- */

.lettuce {
  grid-area: lettuce;
  position: relative;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 9px 16px 5px;
  background: var(--lettuce);
  color: #0f2a07;
}
/* Frilly edge hanging over the cheese. */
.lettuce::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -10px;
  height: 11px;
  background: radial-gradient(circle at 11px 0, var(--lettuce) 10px, transparent 10.5px) 0 0 / 22px 11px repeat-x;
}

.cur {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.15;
  padding: 5px 10px 6px;
  border-radius: 8px;
  background: var(--cheese);
  color: var(--ink);
  box-shadow: 0 2px 0 var(--lettuce-dark);
}
.go { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14px; }
.go small { font-weight: 700; font-size: 12px; color: #1f4d12; margin-left: 4px; }
.lettuce.maxed .arrows, .lettuce.maxed .go small { display: none; }

.arrows { display: inline-flex; color: var(--cheese); font-size: 19px; line-height: 1; text-shadow: 0 1px 0 var(--lettuce-dark); }
.arrows i { font-style: normal; margin-right: -2px; animation: chase 900ms var(--ease-in-out) infinite; }
.arrows i:nth-child(2) { animation-delay: 150ms; }
.arrows i:nth-child(3) { animation-delay: 300ms; }
@keyframes chase {
  0%, 100% { opacity: 0.2; transform: translateX(0); }
  50% { opacity: 1; transform: translateX(3px); }
}

/* Status text swap: brief blur so the old and new name don't double-expose. */
.swap { animation: swap 260ms var(--ease-out); }
@keyframes swap { from { opacity: 0; filter: blur(3px); } }

/* ---------- Cheese: progress to the next status ---------- */

.cheese {
  grid-area: cheese;
  position: relative;
  z-index: 2;
  height: 14px;
  background: var(--cheese-pale);
  overflow: visible;
}
.cheese-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(var(--cheese), var(--cheese-deep));
  transform-origin: 0 50%;
  transform: scaleX(0);
  transition: transform 240ms var(--ease-out);
}
/* Drips hanging into the stage. */
.cheese::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='14'%3E%3Cpath d='M14 0h16v6a8 8 0 0 1-16 0zM70 0h10v10a5 5 0 0 1-10 0zM98 0h12v4a6 6 0 0 1-12 0z' fill='%23ffd34d'/%3E%3C/svg%3E") 0 0 / 120px 14px repeat-x;
  pointer-events: none;
}

/* ---------- Stage: Embata, the patty ---------- */

.stage {
  grid-area: stage;
  position: relative;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.fig {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-top: 24px;
}

/* The weight: a paper flag on a toothpick stuck in his head. */
.flag {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: -2px;
}
.flag-paper {
  padding: 6px 14px 8px;
  border-radius: 4px;
  background:
    linear-gradient(var(--ketchup), var(--ketchup)) 0 0 / 100% 5px no-repeat,
    var(--paper);
  box-shadow: 0 3px 0 rgba(60, 10, 5, 0.35), 0 10px 22px rgba(60, 10, 5, 0.3);
  transform: rotate(-2.5deg);
  text-align: center;
}
.flag-paper small {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #8a5a3a;
}
.weight {
  display: block;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(26px, 3.6vw, 40px);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.weight em { font-style: normal; font-family: var(--font-display); font-size: 0.5em; color: var(--ketchup); margin-left: 3px; letter-spacing: 0; }
.flag-pick {
  width: 4px;
  height: 22px;
  border-radius: 0 0 2px 2px;
  background: linear-gradient(90deg, #e9c98c, #c79a52);
}

.embata {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  outline-offset: 6px;
}
.jiggle {
  display: block;
  transform-origin: 50% 100%;
}
.embata canvas { display: block; }

.shadow {
  position: absolute;
  z-index: 0;
  left: 50%;
  bottom: -14px;
  width: 300px;
  height: 34px;
  margin-left: -150px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(40, 6, 3, 0.55), transparent);
  transform-origin: 50% 50%;
  pointer-events: none;
}

/* Speech bubble next to his mouth. Grows out of its tail. */
.bubble {
  position: absolute;
  z-index: 5;
  left: 0;
  top: 0;
  max-width: 190px;
  padding: 9px 13px 10px;
  border-radius: 16px 16px 16px 4px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
  font-size: 15px;
  line-height: 1.2;
  box-shadow: 0 4px 0 rgba(60, 10, 5, 0.3);
  transform-origin: 0 100%;
  opacity: 0;
  scale: 0.92;
  transition: opacity 150ms var(--ease-out), scale 150ms var(--ease-out);
  pointer-events: none;
}
.bubble.show {
  opacity: 1;
  scale: 1;
  transition-duration: 220ms;
}

/* New status: a sticker slapped on the stage. */
.stamp {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 64%;
  translate: -50% -50%;
  width: max-content;
  max-width: min(92%, 560px);
  padding: 12px 22px 16px;
  border-radius: 14px;
  background: var(--cheese);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 6px 0 var(--cheese-deep), 0 18px 40px rgba(40, 6, 3, 0.45);
  rotate: -4deg;
  opacity: 0;
  pointer-events: none;
}
.stamp small {
  display: block;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ketchup);
}
.stamp b {
  display: block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(22px, 6vw, 38px);
  line-height: 1.1;
  text-wrap: balance;
}

/* Test mode only: the autoclicker. */
.mauto {
  display: none;
  position: absolute;
  z-index: 6;
  right: 10px;
  bottom: 10px;
  padding: 8px 13px;
  border: 0;
  border-radius: 99px;
  background: var(--board);
  color: var(--cheese);
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 120ms var(--ease-out);
}
.mauto:active { transform: scale(0.96); }
.mauto.on { display: block; }
.mauto.running { background: var(--cheese); color: var(--ink); }

/* ---------- Bottom bun: he stands on it ---------- */

.bun-bottom {
  grid-area: bottom;
  position: relative;
  z-index: 3;
  padding: 12px 16px calc(env(safe-area-inset-bottom, 0px) + 12px);
  border-radius: 0 0 50% 50% / 0 0 22px 22px;
  background: linear-gradient(var(--bun-light) 0, var(--bun) 30%, var(--bun-dark) 100%);
  box-shadow: inset 0 4px 0 rgba(255, 238, 200, 0.55);
  text-align: center;
}
.bun-bottom p {
  margin: 0;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: #5a2c0b;
}

/* ---------- Menu board (desktop) ---------- */

.menu {
  grid-area: menu;
  display: none;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 26px 20px 20px 0;
  padding: 20px 22px;
  border-radius: 18px;
  background:
    linear-gradient(rgba(255, 198, 31, 0.05), transparent 30%),
    var(--board);
  color: var(--sesame);
  box-shadow: 0 0 0 6px #3a2a20, 0 24px 50px rgba(40, 6, 3, 0.5);
}
.menu h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  color: var(--cheese);
}
.menu-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.menu-list li {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 15px;
  color: rgba(255, 243, 214, 0.72);
}
.menu-list li::after {
  content: "";
  order: 2;
  flex: 1;
  border-bottom: 2px dotted rgba(255, 243, 214, 0.25);
  translate: 0 -4px;
}
.menu-list li span { order: 1; }
.menu-list li b { order: 3; font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.menu-list li.eaten { color: rgba(255, 243, 214, 0.38); }
.menu-list li.eaten span { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--ketchup); }
.menu-list li.now { background: var(--cheese); color: var(--ink); }
.menu-list li.now::after { border-color: rgba(42, 20, 7, 0.3); }

.receipt {
  margin-top: auto;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  font-weight: 600;
}
.receipt b { font-family: var(--font-display); font-weight: 400; font-size: 14px; }

.auto { display: none; }
.auto.on { display: block; }
.auto .rates { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.auto button {
  padding: 6px 11px;
  border: 2px solid rgba(255, 243, 214, 0.35);
  border-radius: 8px;
  background: transparent;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  transition: transform 120ms var(--ease-out);
}
.auto button:active { transform: scale(0.96); }
.auto button[aria-pressed="true"] { background: var(--cheese); border-color: var(--cheese); color: var(--ink); }
.auto-label { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--cheese); }

/* Particles: burgers in flight, crumbs, "+1 г". */
.fx {
  position: fixed;
  inset: 0;
  z-index: 50;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@media (min-width: 900px) {
  .app {
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-areas: "top top" "lettuce lettuce" "cheese cheese" "stage menu" "bottom bottom";
  }
  .menu { display: flex; }
  .mauto { display: none !important; }
  .bun-top { padding: 14px 28px 14px; border-radius: 50% 50% 0 0 / 46px 46px 0 0; }
  .bun-row { gap: 24px; }
  .logo { font-size: 36px; }
  .stats { position: absolute; right: 150px; top: 50%; translate: 0 -50%; margin: 0; grid-template-columns: repeat(3, 150px); }
  .lettuce { padding: 10px 28px 6px; }
}

@media (hover: hover) and (pointer: fine) {
  .auto button:hover { border-color: var(--cheese); }
  .mauto:hover { filter: brightness(1.1); }
}

@media (prefers-reduced-motion: reduce) {
  .arrows i { animation: none; opacity: 1; }
  .cheese-fill { transition: none; }
  .bubble, .bubble.show { scale: 1; transition: opacity 200ms ease; }
}
