/*
 * style.css – layout and look of the page around the canvas.
 * Mobile first: the stage fills the phone screen; on desktop it becomes a
 * centred portrait column. Colours follow the product packaging (red/yellow).
 */

/* ---------- fonts (self-hosted Rubik, SIL OFL) ---------- */
@font-face {
  font-family: 'Rubik'; font-weight: 500; font-display: swap;
  src: url('../assets/fonts/rubik-hebrew-500-normal.woff2') format('woff2');
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: 'Rubik'; font-weight: 500; font-display: swap;
  src: url('../assets/fonts/rubik-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Rubik'; font-weight: 900; font-display: swap;
  src: url('../assets/fonts/rubik-hebrew-900-normal.woff2') format('woff2');
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: 'Rubik'; font-weight: 900; font-display: swap;
  src: url('../assets/fonts/rubik-latin-900-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}

/* ---------- tokens ---------- */
:root {
  --red: #c8161d;
  --red-deep: #7a070b;
  --red-ink: #3a0204;
  --yellow: #ffd34d;
  --yellow-deep: #f2a516;
  --cream: #fff6ea;
  --panel: rgba(58, 2, 4, 0.82);
  --radius: 18px;
  --font: 'Rubik', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(circle at 50% 30%, #9c0f14, #2a0103 75%);
  color: var(--cream);
  font-family: var(--font);
  font-weight: 500;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

[hidden] { display: none !important; }

/* ---------- stage ---------- */
#stage {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
}

#game {
  position: absolute;
  inset: 0;
  display: block;
  touch-action: none;   /* our drag, not page scroll/zoom */
  user-select: none;
  -webkit-user-select: none;
  outline: none;
}

/* ---------- buttons ---------- */
.btn {
  font: inherit;
  font-weight: 900;
  font-size: 1.25rem;
  color: var(--red);
  background: linear-gradient(var(--yellow), var(--yellow-deep));
  border: 0;
  border-radius: 999px;
  padding: 0.8em 1.6em;
  min-height: 52px;
  cursor: pointer;
  box-shadow: 0 5px 0 #a8100f, 0 10px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #a8100f, 0 4px 8px rgba(0, 0, 0, 0.35); }
.btn.ghost {
  color: var(--cream);
  background: transparent;
  border: 2px solid rgba(255, 246, 234, 0.6);
  box-shadow: none;
  font-size: 1rem;
  min-height: 44px;
}
.btn:focus-visible, .icon-btn:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: var(--cream);
  cursor: pointer;
  padding: 0;
}
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }

#mute {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: 10px;
  z-index: 5;
}
#mute .ico-off { display: none; }
#mute.muted .ico-on { display: none; }
#mute.muted .ico-off { display: block; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: 12px;
  left: 62px;   /* leave room for the mute button */
  z-index: 2;
  pointer-events: none;
}
#hud button { pointer-events: auto; }

.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hud-score {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
#hud-score {
  font-weight: 900;
  font-size: 2.2rem;
  line-height: 1;
  color: var(--yellow);
  /* dark outline + glow keeps the score readable on light kitchen walls too */
  text-shadow: 0 3px 0 var(--red-ink), 0 0 2px var(--red-ink), 0 0 10px rgba(0, 0, 0, 0.65);
  font-variant-numeric: tabular-nums;
}
#hud-combo {
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--red);
  background: var(--yellow);
  border-radius: 999px;
  padding: 2px 10px;
  opacity: 0;
}
#hud-combo.on { opacity: 1; }
#hud-combo.bump { animation: bump 0.35s ease-out; }

.hud-side { display: flex; align-items: center; gap: 8px; }

#hud-lives { display: flex; gap: 3px; }
.heart svg { width: 24px; height: 24px; fill: #ff3b45; filter: drop-shadow(0 2px 0 var(--red-ink)); }
.heart.lost svg { fill: rgba(0, 0, 0, 0.4); filter: none; }

#hud-bonuses {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: min(36%, 150px);   /* narrow so it never covers the pot in the middle */
}
.bonus {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  padding: 4px 8px 6px;
  border-inline-start: 4px solid var(--c);
}
.bonus-name { display: block; font-size: 0.8rem; font-weight: 900; }
.bonus-track {
  display: block;
  height: 5px;
  margin-top: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.2);
  overflow: hidden;
}
.bonus-fill {
  display: block;
  height: 100%;
  background: var(--c);
  transform-origin: right center;
}

/* ---------- banner ---------- */
#banner {
  position: absolute;
  top: 34%;
  left: 0;
  right: 0;
  text-align: center;
  font-weight: 900;
  font-size: 1.9rem;
  color: var(--c, var(--yellow));
  text-shadow: 0 3px 0 var(--red-ink), 0 0 18px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0;
  z-index: 3;
}
#banner.show { animation: banner 1.4s ease-out forwards; }

/* ---------- overlay screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: calc(60px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto;
  background: rgba(40, 0, 2, 0.45);
  animation: fade 0.25s ease-out;
}

.panel {
  width: 100%;
  max-width: 400px;
  text-align: center;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 18px 18px 22px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.panel.small { max-width: 300px; }

.logo {
  width: 88%;
  height: auto;
  margin: -54px auto -8px;
  display: block;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.45));
}

h1, h2, h3 { font-weight: 900; margin: 0.2em 0 0.3em; line-height: 1.15; }
h1 { font-size: 1.9rem; color: var(--yellow); text-shadow: 0 3px 0 var(--red); }
h2 { font-size: 1.8rem; color: var(--yellow); text-shadow: 0 3px 0 var(--red); }
h3 { font-size: 1.15rem; }

.lead { margin: 0 0 12px; line-height: 1.45; opacity: 0.95; }

/* item guide: 3 columns × 2 rows – big picture, small explanation */
.legend {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.legend li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 10px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  line-height: 1.25;
}
.legend li.danger { background: rgba(255, 60, 40, 0.14); box-shadow: inset 0 0 0 1px rgba(255, 90, 70, 0.35); }
.legend canvas { width: 64px; height: 64px; margin-bottom: 2px; }

/* kitchen background picker: 4 thumbnails in a row */
.bg-picker { margin: 0 0 12px; }
.bg-title { margin: 0 0 6px; font-weight: 900; font-size: 0.9rem; }
.bg-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bg-option {
  padding: 0;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: none;
  aspect-ratio: 4 / 3;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15);
  transition: box-shadow 0.15s, transform 0.15s;
}
.bg-option img { display: block; width: 100%; height: 100%; object-fit: cover; }
.bg-option[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--yellow); transform: scale(1.04); }
.bg-option.loading { opacity: 0.6; }
.bg-option:focus-visible { outline: 3px solid #ffffff; outline-offset: 3px; }
.legend strong { font-weight: 900; font-size: 0.9rem; }
.legend span { font-size: 0.74rem; opacity: 0.85; }

.hint { font-size: 0.85rem; opacity: 0.85; margin: 0 0 14px; }
.best { margin: 12px 0 0; font-size: 0.95rem; opacity: 0.9; min-height: 1.2em; }

/* small legal links at the bottom of the start screen */
.legal-links { margin: 10px 0 0; font-size: 0.78rem; opacity: 0.75; }
.legal-links a { color: inherit; }

.final {
  margin: 4px 0 0;
  font-weight: 900;
  line-height: 1;
}
#final-score {
  display: block;
  font-size: 4.2rem;
  color: var(--yellow);
  text-shadow: 0 4px 0 var(--red);
}
.final small { font-size: 1rem; font-weight: 500; }

.badge {
  display: inline-block;
  margin: 10px 0 0;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--red);
  font-weight: 900;
  animation: bump 0.6s ease-out 2;
}

.coupon {
  margin: 16px 0 4px;
  padding: 14px;
  border-radius: 14px;
  border: 2px dashed var(--yellow);
  background: rgba(255, 211, 77, 0.1);
}
.coupon.locked { border-color: rgba(255, 246, 234, 0.35); background: rgba(0, 0, 0, 0.2); }
.coupon p { margin: 0 0 8px; line-height: 1.4; }
.coupon .code {
  font-weight: 900;
  font-size: 1.7rem;
  letter-spacing: 0.08em;
  color: var(--yellow);
  user-select: all;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

/* ---------- animations ---------- */
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes banner {
  0% { opacity: 0; transform: scale(0.6); }
  15% { opacity: 1; transform: scale(1.1); }
  25% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-20px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  /* the banner still needs to be readable; JS removes .show after a moment */
  #banner.show { animation: none; opacity: 1; }
}

/* short screens (small phones, landscape): tighten the menus */
@media (max-height: 700px) {
  .logo { width: 70%; margin-top: -40px; }
  .lead { display: none; }
  .legend canvas { width: 48px; height: 48px; }
  .legend li { padding: 6px 4px 8px; }
}
