/* What2Eat — 設計權杖與主題 */

:root,
[data-theme="coral"] {
  --bg: #faf2e6;
  --bg-soft: #f7ebd4;
  --surface: #fffdf8;
  --ink: #40271e;
  --ink-soft: #785e51;
  --coral: #d7473d;
  --coral-dark: #a4423c;
  --coral-soft: #fad7d3;
  --teal: #1a6669;
  --teal-dark: #11474a;
  --teal-soft: #d3eae7;
  --mustard: #df9925;
  --mustard-soft: #f8e7bd;
  --line: #e9d4b9;
  --shadow: 0 10px 24px rgba(160, 90, 40, 0.12);
  --machine-bg: #fef4e6;
  --pattern: rgba(215, 71, 61, 0.06);
  color-scheme: light;
}

[data-theme="berry"] {
  --bg: #fceef4;
  --bg-soft: #fae3eb;
  --surface: #fffafc;
  --ink: #482235;
  --ink-soft: #875873;
  --coral: #d74d7d;
  --coral-dark: #a74064;
  --coral-soft: #fad4e1;
  --teal: #7063b3;
  --teal-dark: #574e86;
  --teal-soft: #e1ddf2;
  --mustard: #e38db1;
  --mustard-soft: #f9d8e5;
  --line: #e7c7d5;
  --shadow: 0 10px 24px rgba(180, 60, 100, 0.10);
  --machine-bg: #fee9f1;
  --pattern: rgba(215, 77, 125, 0.07);
  color-scheme: light;
}

[data-theme="mint"] {
  --bg: #eef7f2;
  --bg-soft: #e0f1e8;
  --surface: #fafffc;
  --ink: #1c3b32;
  --ink-soft: #52786c;
  --coral: #319164;
  --coral-dark: #226d49;
  --coral-soft: #cef0de;
  --teal: #3f87a6;
  --teal-dark: #2c647c;
  --teal-soft: #d2e8f1;
  --mustard: #d7b73d;
  --mustard-soft: #f5ebc0;
  --line: #c0ddd0;
  --shadow: 0 10px 24px rgba(40, 120, 90, 0.10);
  --machine-bg: #e9f7ef;
  --pattern: rgba(49, 145, 100, 0.07);
  color-scheme: light;
}

[data-theme="sunset"] {
  --bg: #fef2e9;
  --bg-soft: #fbe5d6;
  --surface: #fffaf7;
  --ink: #48261a;
  --ink-soft: #875f4c;
  --coral: #f15b2c;
  --coral-dark: #ba4a2a;
  --coral-soft: #fdd6c7;
  --teal: #d5992c;
  --teal-dark: #9e7327;
  --teal-soft: #faebc7;
  --mustard: #f48f57;
  --mustard-soft: #fae1d1;
  --line: #e8ccb9;
  --shadow: 0 10px 24px rgba(180, 80, 40, 0.12);
  --machine-bg: #feeee2;
  --pattern: rgba(241, 91, 44, 0.07);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root,
  [data-theme="coral"] {
  --bg: #1c1510;
  --bg-soft: #251b15;
  --surface: #2e211a;
  --ink: #f5eadf;
  --ink-soft: #c5ab94;
  --coral: #f46757;
  --coral-dark: #f4806f;
  --coral-soft: #36231f;
  --teal: #489596;
  --teal-dark: #64c1be;
  --teal-soft: #1c2a2c;
  --mustard: #e6a93d;
  --mustard-soft: #342a1c;
  --line: #3b2c21;
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  --machine-bg: #2b211a;
  --pattern: rgba(244, 103, 87, 0.08);
  color-scheme: dark;
  }

  [data-theme="berry"] {
  --bg: #1d0f15;
  --bg-soft: #29171f;
  --surface: #37212b;
  --ink: #faeaf1;
  --ink-soft: #cfa3b8;
  --coral: #f56499;
  --coral-dark: #f683af;
  --coral-soft: #361e2c;
  --teal: #9888d9;
  --teal-dark: #afa1e5;
  --teal-soft: #252134;
  --mustard: #e38db1;
  --mustard-soft: #2f2129;
  --line: #3c2c37;
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  --machine-bg: #32212d;
  --pattern: rgba(245, 100, 153, 0.08);
  color-scheme: dark;
  }

  [data-theme="mint"] {
  --bg: #0f1815;
  --bg-soft: #15211c;
  --surface: #1e312a;
  --ink: #e5f4ee;
  --ink-soft: #9fc2b4;
  --coral: #45bf83;
  --coral-dark: #60d09f;
  --coral-soft: #1b3027;
  --teal: #50a7cd;
  --teal-dark: #6fbee1;
  --teal-soft: #192b36;
  --mustard: #d7b73d;
  --mustard-soft: #2e2b1c;
  --line: #263a34;
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  --machine-bg: #1c2f28;
  --pattern: rgba(69, 191, 131, 0.08);
  color-scheme: dark;
  }

  [data-theme="sunset"] {
  --bg: #1b130f;
  --bg-soft: #261b15;
  --surface: #37271e;
  --ink: #faefe6;
  --ink-soft: #cfaa94;
  --coral: #f37a49;
  --coral-dark: #f4966b;
  --coral-soft: #362219;
  --teal: #e0a83a;
  --teal-dark: #e9b857;
  --teal-soft: #2e291d;
  --mustard: #f48f57;
  --mustard-soft: #34291d;
  --line: #3c2d25;
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  --machine-bg: #30241b;
  --pattern: rgba(243, 122, 73, 0.08);
  color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 8%, var(--pattern) 0 18%, transparent 19%),
    radial-gradient(circle at 88% 12%, var(--pattern) 0 14%, transparent 15%),
    radial-gradient(ellipse at 50% 100%, var(--bg-soft), var(--bg) 55%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Noto Sans TC", system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.55;
  min-height: 100dvh;
}

button { font-family: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

/* ---------- Header ---------- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.brand {
  font-family: "Baloo 2", "Noto Sans TC", sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--coral);
  line-height: 1;
}

.theme-picker {
  display: flex;
  gap: 8px;
  align-items: center;
}

.theme-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  background: var(--swatch, var(--coral));
  padding: 0;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.theme-dot:hover { transform: scale(1.08); }
.theme-dot:active { transform: scale(0.95); }
.theme-dot[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--swatch, var(--coral));
}

header { text-align: center; }

.hero-img {
  display: block;
  width: min(280px, 72vw);
  height: auto;
  margin: 4px auto 2px;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.08));
}

h1 {
  margin: 4px 0 2px;
  font-family: "Baloo 2", "Noto Sans TC", sans-serif;
  font-size: clamp(32px, 9vw, 42px);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.15;
}

h1 .accent { color: var(--coral); }

.tagline {
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 500;
}

/* ---------- Category tabs ---------- */
.cats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 20px 0 6px;
}

.cat-btn {
  min-height: 58px;
  border: 2.5px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 2px;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.1s;
}

.cat-btn .cat-emoji { font-size: 22px; line-height: 1.1; }
.cat-btn[aria-pressed="true"] {
  border-color: var(--coral);
  background: var(--coral-soft);
  color: var(--coral-dark);
}
.cat-btn:hover:not(:disabled) { border-color: var(--coral); }
.cat-btn:active:not(:disabled) { transform: scale(0.96); }
.cat-btn:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

.mode-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0 2px;
}

.fav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border: 2.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 700;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.fav-toggle .heart { color: var(--coral); font-size: 17px; }
.fav-toggle[aria-pressed="true"] {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}
.fav-toggle:hover { border-color: var(--teal); }

.mode-hint {
  min-height: 1.4em;
  margin: 6px 0 0;
  text-align: center;
  color: var(--coral-dark);
  font-size: 13.5px;
  font-weight: 600;
}

.storage-hint {
  margin: 8px 0 0;
  text-align: center;
  color: var(--coral-dark);
  font-size: 13px;
  font-weight: 600;
  background: var(--coral-soft);
  border-radius: 12px;
  padding: 8px 12px;
}

/* ---------- Machine / Reel ---------- */
.machine {
  margin-top: 14px;
  background: var(--machine-bg);
  border: 3px solid var(--coral);
  border-radius: 26px;
  padding: 20px 16px 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: visible;
}

.machine-top {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}

.bulb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--mustard);
  box-shadow: 0 0 0 3px var(--mustard-soft);
}
.bulb.teal { background: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.bulb.coral { background: var(--coral); box-shadow: 0 0 0 3px var(--coral-soft); }
.machine.spinning .bulb { animation: blink 0.36s steps(2, start) infinite; }
.machine.spinning .bulb.teal { animation-delay: 0.12s; }
.machine.spinning .bulb.coral { animation-delay: 0.24s; }
@keyframes blink { 50% { opacity: 0.25; } }

.reel-window {
  position: relative;
  height: 92px;
  border: 3.5px solid var(--teal);
  border-radius: 18px;
  background: var(--surface);
  overflow: hidden;
}
.reel-window::before,
.reel-window::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 22px;
  z-index: 3;
  pointer-events: none;
}
.reel-window::before {
  top: 0;
  background: linear-gradient(to bottom, var(--surface), transparent);
}
.reel-window::after {
  bottom: 0;
  background: linear-gradient(to top, var(--surface), transparent);
}

.reel-strip { will-change: transform; text-align: center; }

.reel-item {
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(27px, 7.5vw, 34px);
  font-weight: 900;
  letter-spacing: 0.03em;
  padding: 0 10px;
  white-space: nowrap;
}
.reel-item.dim {
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 22px;
}

.spin-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  min-height: 62px;
  border: none;
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  font-family: "Baloo 2", "Noto Sans TC", sans-serif;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.14em;
  box-shadow: 0 6px 0 var(--coral-dark);
  transition: transform 0.08s, box-shadow 0.08s;
}
@media (prefers-color-scheme: dark) {
  .spin-btn { color: #1a1210; }
}
.spin-btn:hover:not(:disabled) { filter: brightness(1.05); }
.spin-btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--coral-dark);
}
.spin-btn:disabled { box-shadow: 0 6px 0 var(--coral-dark); }
.spin-btn:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
}

/* ---------- Result ---------- */
.result {
  margin-top: 20px;
  text-align: center;
}
.result[hidden] { display: none; }

.result-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink-soft);
  margin: 0;
}

.result-icon {
  display: block;
  font-size: 42px;
  line-height: 1;
  margin: 6px 0 0;
}

.result-food {
  font-family: "Baloo 2", "Noto Sans TC", sans-serif;
  font-size: clamp(36px, 11vw, 48px);
  font-weight: 800;
  color: var(--coral);
  margin: 2px 0 4px;
  letter-spacing: 0.03em;
}

.result-note {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 15px;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.maps-btn,
.fav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 56px;
  border-radius: 16px;
  font-size: 17px;
  font-weight: 800;
  padding: 10px 14px;
  text-decoration: none;
  transition: transform 0.1s, box-shadow 0.1s, filter 0.15s;
}

.maps-btn {
  background: var(--teal);
  color: #fff;
  border: none;
  box-shadow: 0 4px 0 var(--teal-dark);
}
@media (prefers-color-scheme: dark) {
  .maps-btn { color: #0d2224; }
}
.maps-btn:hover:not(:disabled) { filter: brightness(1.05); }
.maps-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--teal-dark);
}

.fav-btn {
  background: var(--surface);
  color: var(--coral-dark);
  border: 2.5px solid var(--coral);
}
.fav-btn.added {
  background: var(--coral-soft);
  border-color: var(--coral-soft);
  color: var(--coral-dark);
}
.fav-btn:hover:not(:disabled) { background: var(--coral-soft); }

.btn-emoji { font-size: 20px; line-height: 1; }

/* ---------- Favourites list ---------- */
.favs {
  margin-top: 34px;
  background: var(--surface);
  border: 2.5px solid var(--line);
  border-radius: 22px;
  padding: 18px 14px 14px;
  box-shadow: var(--shadow);
}

.favs h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 900;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.favs h2 .count {
  font-family: "Baloo 2", "Noto Sans TC", sans-serif;
  font-size: 15px;
  font-weight: 800;
  color: var(--teal-dark);
  background: var(--teal-soft);
  border-radius: 999px;
  padding: 1px 10px;
}

.favs-sub {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 13.5px;
}

.fav-empty {
  margin: 6px 0 10px;
  color: var(--ink-soft);
  font-size: 15px;
  text-align: center;
  padding: 16px 8px;
  border: 2px dashed var(--line);
  border-radius: 14px;
}

.fav-group { margin-bottom: 14px; }
.fav-group:last-child { margin-bottom: 2px; }

.fav-group-name {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.fav-group-emoji { font-size: 16px; }

.fav-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fav-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 8px 6px 10px;
  background: var(--bg-soft);
  border: 2px solid var(--line);
  border-radius: 16px;
  transition: border-color 0.15s, background 0.15s;
}

.fav-row:hover { border-color: var(--mustard); }

.fav-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface);
  border: 2px solid var(--mustard-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
}

.fav-name {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-row-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.chip-maps {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 40px;
  padding: 4px 10px;
  border: none;
  border-radius: 12px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 800;
  transition: filter 0.15s, transform 0.1s;
}
.chip-maps:hover:not(:disabled) { filter: brightness(0.97); }
.chip-maps:active:not(:disabled) { transform: scale(0.96); }

.chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 16px;
  font-weight: 900;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.chip-remove:hover {
  background: var(--coral-soft);
  color: var(--coral-dark);
}

footer {
  margin-top: 30px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13.5px;
}
.footer-note { margin: 0 0 8px; }
.copyright {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0.9;
}

/* Confetti */
.confetti {
  position: absolute;
  top: -8px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 5;
  animation: fall 1.15s ease-in forwards;
}
@keyframes fall {
  to { transform: translateY(190px) rotate(560deg); opacity: 0; }
}
@keyframes pop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.result.pop .result-food { animation: pop 0.45s ease-out; }
.result.pop .result-icon { animation: pop 0.4s ease-out; }

@media (prefers-reduced-motion: reduce) {
  .machine.spinning .bulb { animation: none; }
  .confetti { display: none; }
  .result.pop .result-food,
  .result.pop .result-icon { animation: none; }
  .cat-btn:active,
  .maps-btn:active,
  .spin-btn:active:not(:disabled),
  .theme-dot:hover { transform: none; }
}
