/* Midnight Pantry — candlelit haunted pantry theme.
   Design rule (Costume Contest): the spooky layer encodes information.
   Glow intensity = expiry urgency; tier color + label carry the same signal
   in text so nothing depends on motion or color alone. */

:root {
  --bg-deep: #14101d;
  --bg: #1e1626;
  --surface: #241a30;
  --surface-2: #2d2040;
  --ink: #f3e9d2;
  --ink-dim: #c9b896;
  --ink-faint: #9a8a6d;
  --pumpkin: #ff8c42;
  --ember: #ffb347;
  --blood: #e4572e;
  --ghost: #9fe8c9;
  --line: #3d2c52;
  --parchment: #f6ead0;
  --parchment-ink: #3a2a18;
  --radius: 14px;
  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1100px 600px at 50% -10%, #33204d 0%, transparent 60%),
    radial-gradient(900px 500px at 85% 110%, #2a1836 0%, transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- atmosphere ---------- */

.fog {
  position: fixed;
  left: -20%;
  width: 140%;
  height: 180px;
  bottom: -60px;
  pointer-events: none;
  background: radial-gradient(ellipse 60% 100% at 50% 100%, rgba(200, 180, 230, 0.16), transparent 70%);
  filter: blur(6px);
  z-index: 1;
}
.fog-a { animation: fog-drift 26s ease-in-out infinite alternate; }
.fog-b { bottom: -100px; opacity: 0.7; animation: fog-drift 38s ease-in-out infinite alternate-reverse; }
@keyframes fog-drift {
  from { transform: translateX(-3%); }
  to { transform: translateX(3%); }
}

.embers { position: fixed; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }
.ember {
  position: absolute;
  bottom: -10px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 8px 2px rgba(255, 179, 71, 0.55);
  opacity: 0;
  animation: ember-rise linear infinite;
}
@keyframes ember-rise {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  12% { opacity: 0.9; }
  70% { opacity: 0.5; }
  100% { transform: translateY(-88vh) translateX(4vw); opacity: 0; }
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 2.6rem 1.2rem 1.2rem;
  text-align: center;
  flex-wrap: wrap;
}

.sconce {
  position: relative;
  width: 14px; height: 54px;
  background: linear-gradient(180deg, #e8dcc0, #b8a67e);
  border-radius: 4px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.5);
  flex: none;
}
.sconce .flame {
  position: absolute;
  left: 50%; top: -26px;
  width: 16px; height: 26px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse 50% 60% at 50% 65%, #fff3c4 0%, var(--ember) 45%, var(--pumpkin) 75%, transparent 78%);
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  filter: drop-shadow(0 0 14px rgba(255, 179, 71, 0.8));
  animation: flicker 1.6s ease-in-out infinite;
  transform-origin: 50% 100%;
}
.sconce-right .flame { animation-duration: 1.9s; animation-delay: 0.4s; }
@keyframes flicker {
  0%, 100% { transform: translateX(-50%) scaleY(1) rotate(-1.5deg); opacity: 1; }
  30% { transform: translateX(-50%) scaleY(1.12) rotate(1.5deg); opacity: 0.92; }
  55% { transform: translateX(-50%) scaleY(0.94) rotate(-2.5deg); opacity: 0.97; }
  75% { transform: translateX(-50%) scaleY(1.06) rotate(2deg); opacity: 0.9; }
}

.hero-text .eyebrow {
  margin: 0 0 0.4rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--ember);
  font-weight: 600;
}
.hero-text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1.05;
  background: linear-gradient(180deg, #fff6dd, var(--ember) 70%, var(--pumpkin));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 34px rgba(255, 140, 66, 0.22);
}
.tagline { margin: 0.6rem 0 0; color: var(--ink-dim); font-size: 1.02rem; line-height: 1.5; }

.souls {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: rgba(36, 26, 48, 0.85);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  text-align: left;
  box-shadow: 0 10px 26px rgba(0,0,0,0.35);
}
.souls-icon { font-size: 1.7rem; filter: drop-shadow(0 0 8px rgba(159, 232, 201, 0.6)); }
.souls strong { display: block; color: var(--ghost); font-size: 1.02rem; }
.souls span { display: block; color: var(--ink-faint); font-size: 0.82rem; max-width: 220px; }

/* ---------- banner ---------- */

.banner {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: center;
  margin: 0.4rem auto 0;
  max-width: 860px;
  padding: 0.7rem 1.1rem;
  background: linear-gradient(90deg, rgba(228, 87, 46, 0.16), rgba(255, 140, 66, 0.22), rgba(228, 87, 46, 0.16));
  border: 1px solid rgba(255, 140, 66, 0.45);
  border-radius: 999px;
  color: #ffd9b8;
  font-weight: 600;
}
.banner p { margin: 0; }

/* ---------- layout & panels ---------- */

.layout {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 340px 1fr 320px;
  gap: 1.1rem;
  max-width: 1400px;
  margin: 1.4rem auto 0;
  padding: 0 1.1rem 2rem;
  align-items: start;
}

.panel {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.1rem 1.3rem;
  box-shadow: 0 18px 40px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.04);
}
.panel h2 {
  margin: 0 0 0.3rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--ink);
}
.panel-hint { margin: 0 0 1rem; color: var(--ink-faint); font-size: 0.88rem; line-height: 1.45; }

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.92rem;
}
.empty p { margin: 0 0 0.7rem; }

/* ---------- form ---------- */

.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.7rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
label { font-size: 0.82rem; font-weight: 600; color: var(--ink-dim); }
input, select {
  min-height: 44px;
  min-width: 0;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(20, 16, 29, 0.7);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}
.form-error { color: #ff9d7a; font-size: 0.86rem; margin: 0 0 0.6rem; }

.btn {
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--ember), var(--pumpkin));
  color: #2a1503;
  border-color: #ff9d52;
  box-shadow: 0 6px 18px rgba(255, 140, 66, 0.35);
  width: 100%;
}
.btn-primary:hover { box-shadow: 0 8px 24px rgba(255, 140, 66, 0.5); }
.btn-ghost { background: transparent; color: var(--ember); }
.btn-ghost:hover { background: rgba(255, 140, 66, 0.1); }

.chips { margin: 0.9rem 0 0.4rem; font-size: 0.85rem; }
.chips-label { color: var(--ink-faint); margin-right: 0.4rem; }
.chip {
  display: inline-block;
  margin: 0.18rem 0.12rem;
  padding: 0.3rem 0.6rem;
  min-height: 32px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(20, 16, 29, 0.55);
  color: var(--ink-dim);
  font-size: 0.82rem;
  cursor: pointer;
}
.chip:hover { border-color: var(--pumpkin); color: var(--ink); }

/* ---------- shelf (pantry) ---------- */

.shelf { list-style: none; margin: 0.8rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }

.shelf-item {
  --glow: 0.1;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  background: rgba(20, 16, 29, 0.55);
  border: 1px solid var(--line);
  box-shadow: 0 0 calc(var(--glow) * 26px) rgba(255, 140, 66, calc(var(--glow) * 0.55));
  animation: card-in 0.35s ease both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.shelf-item.tier-screaming { border-color: rgba(228, 87, 46, 0.7); animation: card-in 0.35s ease both, pulse-glow 1.8s ease-in-out infinite; }
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 18px rgba(228, 87, 46, 0.45); }
  50% { box-shadow: 0 0 30px rgba(228, 87, 46, 0.75); }
}
.shelf-item.tier-moaning { border-color: rgba(255, 140, 66, 0.5); }
.shelf-item.tier-whispering { border-color: rgba(255, 179, 71, 0.3); }

.flame-dot {
  flex: none;
  width: calc(10px + var(--glow) * 10px);
  height: calc(14px + var(--glow) * 14px);
  background: radial-gradient(ellipse 50% 60% at 50% 65%, #fff3c4 0%, var(--ember) 50%, var(--pumpkin) 80%, transparent 82%);
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  filter: drop-shadow(0 0 calc(4px + var(--glow) * 10px) rgba(255, 179, 71, 0.8));
}
.shelf-item .ing-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.shelf-item .ing-name { font-weight: 600; text-transform: capitalize; }
.shelf-item .ing-meta { color: var(--ink-faint); font-size: 0.8rem; }
.tier-tag {
  flex: none;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.22rem 0.5rem;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.tier-screaming .tier-tag { color: #ff8a5c; }
.tier-moaning .tier-tag { color: var(--pumpkin); }
.tier-whispering .tier-tag { color: var(--ember); }
.tier-resting .tier-tag { color: var(--ghost); }

.remove-btn {
  flex: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.remove-btn:hover { color: #ff9d7a; border-color: #ff9d7a; }

/* ---------- recipes ---------- */

.summon-controls {
  display: flex;
  gap: 0.7rem;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.summon-controls label { display: block; margin-bottom: 0.3rem; }
.summon-controls select { width: auto; }
.summon-controls .btn-primary { width: auto; }

.recipes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.9rem; }

.scroll-card {
  position: relative;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 243, 196, 0.5), transparent 55%),
    linear-gradient(180deg, var(--parchment), #ecd9ae);
  color: var(--parchment-ink);
  border-radius: 10px;
  padding: 1rem 1rem 0.9rem;
  box-shadow: 0 14px 30px rgba(0,0,0,0.45);
  animation: card-in 0.4s ease both;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.scroll-card::before, .scroll-card::after {
  content: "";
  position: absolute;
  left: 6px; right: 6px;
  height: 10px;
  background: radial-gradient(circle at 8px 5px, transparent 6px, #d9c28c 6.5px);
  background-size: 16px 10px;
  opacity: 0.55;
}
.scroll-card::before { top: -5px; }
.scroll-card::after { bottom: -5px; transform: rotate(180deg); }

.scroll-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 800;
  color: #4a2c10;
}
.scroll-card .real-name { margin: 0; font-size: 0.86rem; font-style: italic; color: #7a5c2e; }
.scroll-card .blurb { margin: 0; font-size: 0.9rem; line-height: 1.45; }
.scroll-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; font-size: 0.78rem; font-weight: 600; }
.scroll-meta span { background: rgba(74, 44, 16, 0.1); border: 1px solid rgba(74, 44, 16, 0.25); padding: 0.18rem 0.5rem; border-radius: 999px; }
.scroll-meta .urgent-badge { background: #e4572e; color: #fff6dd; border-color: #c7431f; }

.coverage { height: 8px; border-radius: 999px; background: rgba(74, 44, 16, 0.18); overflow: hidden; }
.coverage > div { height: 100%; background: linear-gradient(90deg, var(--pumpkin), var(--blood)); border-radius: 999px; transition: width 0.5s ease; }
.coverage-label { font-size: 0.78rem; color: #7a5c2e; font-weight: 600; }

.ing-list { font-size: 0.85rem; line-height: 1.5; }
.ing-list .have { color: #2e6b34; font-weight: 600; }
.ing-list .missing { color: #a33d16; }

.scroll-actions { display: flex; gap: 0.5rem; margin-top: auto; padding-top: 0.4rem; }
.btn-seal {
  flex: 1;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid #8a5a1d;
  background: #fdf6e3;
  color: #6b4210;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn-seal[aria-pressed="true"] { background: #8a1f2d; color: #ffe9c9; border-color: #6e1622; }
.btn-cook {
  flex: 1;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid #2e6b34;
  background: #2e6b34;
  color: #eaffea;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn-cook:hover { background: #357a3d; }

/* ---------- shopping ---------- */

.shopping { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.shopping li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: rgba(20, 16, 29, 0.55);
  border: 1px solid var(--line);
  text-transform: capitalize;
}
.shopping li.bought { opacity: 0.45; text-decoration: line-through; }
.shopping input[type="checkbox"] { width: 22px; height: 22px; min-height: 22px; accent-color: var(--pumpkin); }
.shopping .for-recipes { margin-left: auto; font-size: 0.74rem; color: var(--ink-faint); text-transform: none; }
.copy-note { color: var(--ghost); font-size: 0.85rem; margin: 0.5rem 0 0; }

/* ---------- footer & bats ---------- */

footer {
  position: relative;
  z-index: 2;
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.86rem;
  padding: 0 1rem 2.4rem;
}
footer a { color: var(--ember); }

.bats { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.bat {
  position: absolute;
  font-size: 1.6rem;
  animation: bat-fly 1.6s ease-out forwards;
}
@keyframes bat-fly {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}

/* ---------- responsive ---------- */

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr 1fr; }
  .panel-wide { grid-column: span 2; order: 3; }
}
@media (max-width: 680px) {
  .layout { grid-template-columns: 1fr; }
  .panel-wide { grid-column: span 1; }
  .sconce { display: none; }
  .banner { border-radius: var(--radius); margin: 0.4rem 1rem 0; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .fog, .ember, .sconce .flame, .shelf-item.tier-screaming, .bat { animation: none !important; }
  .embers, .bats { display: none; }
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
