/* ============ Springfield Suggestion Machine ============ */

/* Fan-made Simpsons fonts — personal use only (see fonts/simpsonfont/readme.txt). */
@font-face {
  font-family: "Simpsonfont";
  src: url("/fonts/simpsonfont/Simpsonfont-DEMO.otf") format("opentype");
  font-display: swap;
}
@font-face {
  font-family: "Akbar";
  src: url("/fonts/akbar/akbar.ttf") format("truetype");
  font-display: swap;
}

:root {
  --font-title: "Simpsonfont", "Akbar", "Comic Sans MS", cursive;
  --font-text: "Akbar", "Comic Sans MS", "Segoe UI", system-ui, sans-serif;
  --yellow: #ffd90f;
  --sky-top: #6fc4ee;
  --sky-bottom: #cdeef9;
  --ink: #26221c;
  --outline: #2b2620;
  --paper: #fbf3d0;
  --red-dark: #7e171c;
  --panel: #20313b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: var(--font-text);
  color: var(--ink);
  background: linear-gradient(var(--sky-top), var(--sky-bottom) 70%);
  overflow-x: hidden;
}

/* clouds */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(90px 30px at 12% 14%, #fff 97%, transparent 100%),
    radial-gradient(60px 22px at 18% 17%, #fff 97%, transparent 100%),
    radial-gradient(120px 36px at 78% 10%, #fff 97%, transparent 100%),
    radial-gradient(70px 24px at 71% 13%, #fff 97%, transparent 100%),
    radial-gradient(100px 32px at 45% 6%, #fff 97%, transparent 100%),
    radial-gradient(80px 26px at 92% 26%, #fff 97%, transparent 100%);
  opacity: 0.85;
}

/* ============ background scene: cooling towers ============ */
.scene { position: fixed; left: 0; right: 0; bottom: 0; height: 260px; z-index: 0; pointer-events: none; }
.scene .ground { position: absolute; left: 0; right: 0; bottom: 0; height: 64px; background: linear-gradient(#7fb25a, #557f37); border-top: 4px solid #44672c; }
.tower {
  position: absolute; bottom: 60px; width: 140px; height: 210px;
  background: linear-gradient(90deg, #b6bfb2, #e8ebe1 45%, #a3ada0);
  border-radius: 48% 48% 8px 8px / 58% 58% 8px 8px;
  opacity: 0.95;
}
.tower::before {
  content: ""; position: absolute; top: 30px; left: -7px; right: -7px; height: 12px;
  border-radius: 50%; background: #8d978a;
}
.tower .steam {
  position: absolute; left: 50%; bottom: calc(100% - 34px);
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.75); filter: blur(6px);
  animation: steam 7s linear infinite;
}
.tower .steam.s2 { animation-delay: 3.5s; left: 30%; }
.t1 { left: 5%; }
.t2 { right: 4%; width: 110px; height: 170px; }
@keyframes steam {
  0% { transform: translate(-50%, 0) scale(0.5); opacity: 0; }
  15% { opacity: 0.7; }
  100% { transform: translate(-80%, -130px) scale(1.8); opacity: 0; }
}

/* ============ masthead sign ============ */
.masthead { position: relative; z-index: 2; text-align: center; padding: 34px 16px 8px; }
.plant-sign {
  display: inline-block; position: relative; max-width: 92vw;
  background: linear-gradient(#96613a, #6f4526);
  border: 4px solid #402712; border-radius: 14px; padding: 16px 34px 14px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
}
.plant-sign h1 {
  margin: 0; font-family: var(--font-title); font-weight: 400;
  color: var(--yellow); letter-spacing: 2px; line-height: 1.05;
  font-size: clamp(26px, 5vw, 44px); text-shadow: 3px 3px 0 #402712;
}
.plant-sign .tagline {
  margin: 8px 0 0; color: #f6e8c8; font-weight: 700; letter-spacing: 1.2px;
  font-size: clamp(11px, 2vw, 14px);
}
.plant-sign .atom { font-size: 22px; vertical-align: middle; margin: 0 6px; }

/* ============ layout ============ */
main {
  position: relative; z-index: 1; max-width: 1080px; margin: 0 auto;
  padding: 30px 20px 90px;
  display: grid; grid-template-columns: 420px minmax(300px, 520px);
  gap: 44px; justify-content: center; align-items: start;
}
@media (max-width: 940px) { main { grid-template-columns: min(94vw, 420px); } }

/* ============ the vending machine ============ */
.machine-wrap { text-align: center; }
.machine {
  position: relative; width: 100%; max-width: 400px; margin: 0 auto;
  background: linear-gradient(#f4f0e3, #ded7c3);
  border: 3px solid var(--outline); border-radius: 18px; padding: 12px;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.35), inset 0 2px 0 #fff;
  text-align: left;
}
.m-head {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel); border: 2px solid var(--outline);
  border-radius: 10px; padding: 8px 12px;
}
.m-title {
  font-family: var(--font-title); color: var(--yellow);
  font-size: 22px; letter-spacing: 2px; text-shadow: 2px 2px 0 #000;
}
.m-model { color: #9db8c6; font-size: 10px; font-weight: 800; letter-spacing: 1px; text-align: right; line-height: 1.4; }

.m-glass {
  position: relative; margin-top: 10px; height: 252px;
  border: 3px solid var(--outline); border-radius: 10px;
  background: linear-gradient(155deg, #d8f1fb, #a9d9ec 55%, #9ccde4);
  box-shadow: inset 0 0 26px rgba(0, 40, 60, 0.35);
  overflow: hidden;
}
.m-shelf {
  height: 25%; display: flex; align-items: center; gap: 6px;
  padding: 0 8px; border-bottom: 5px solid var(--outline); position: relative;
}
.m-shelf.apples { border-bottom: none; }
.coil {
  position: absolute; left: 4px; right: 4px; bottom: 3px; height: 8px;
  background: repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.22) 0 5px, transparent 5px 10px);
  border-radius: 4px;
}
.item {
  flex: 1; height: 46px; max-width: 88px; z-index: 1;
  background: #fffef8; border: 2px solid var(--outline); border-radius: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}
.item .e { font-size: 17px; line-height: 1; }
.item .n { font-size: 8px; font-weight: 800; text-align: center; margin-top: 2px; color: #333; padding: 0 2px; line-height: 1.1; }

.apple-btn {
  background: none; border: none; padding: 0 6px 4px; cursor: pointer;
  display: flex; align-items: flex-end; z-index: 1; position: relative;
}
.apple-btn span { font-size: 22px; margin: 0 -4px; filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.35)); }
.apple-btn span:nth-child(2) { transform: translateY(-6px) rotate(8deg); }
.apple-btn span:nth-child(3) { transform: translateY(-3px) rotate(-10deg); }
.apple-btn span:nth-child(4) { transform: translateY(-9px) rotate(3deg); }
.apple-btn span:nth-child(5) { transform: translateY(-4px) rotate(-5deg); }
.apples-tag {
  align-self: center; z-index: 1; background: #fffef8;
  border: 2px solid var(--outline); border-radius: 6px; padding: 4px 8px;
  font-size: 10px; font-weight: 800;
}
.apples-tag s { color: #d63c3c; }
.apples-tag em { display: block; font-style: normal; color: #d63c3c; font-size: 9px; letter-spacing: 0.5px; }
.glare {
  position: absolute; inset: 0; z-index: 4; pointer-events: none;
  background: linear-gradient(105deg, transparent 32%, rgba(255, 255, 255, 0.5) 40%, rgba(255, 255, 255, 0.08) 47%, transparent 55%);
}

/* ============ Homer's note ============ */
.m-sign {
  position: absolute; right: -6px; bottom: 168px; width: 236px; z-index: 6;
  background: var(--paper); color: #8c1d1d; padding: 12px 12px 10px;
  transform: rotate(-3deg); border-radius: 2px; pointer-events: none;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.35);
  font-family: var(--font-text);
  font-size: 15px; line-height: 1.25;
}
.m-sign .ps { display: block; font-size: 10px; margin-top: 6px; color: #6b4a3a; }
.m-sign .sig { display: block; text-align: right; font-size: 13px; margin-top: 4px; color: #402712; }
.m-sign::before, .m-sign::after {
  content: ""; position: absolute; width: 62px; height: 16px;
  background: rgba(250, 250, 235, 0.65); border: 1px solid rgba(0, 0, 0, 0.08);
}
.m-sign::before { top: -8px; left: -16px; transform: rotate(-38deg); }
.m-sign::after { top: -8px; right: -14px; transform: rotate(35deg); }

/* ============ controls ============ */
.m-controls { display: flex; gap: 10px; margin-top: 12px; align-items: stretch; }
.coin {
  width: 84px; flex: 0 0 auto; background: #ece7d8;
  border: 2px solid var(--outline); border-radius: 8px; padding: 6px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.coin .slot {
  width: 7px; height: 30px; background: #17130f; border-radius: 3px;
  box-shadow: inset 0 0 0 2px #4a453c, 0 0 0 2px #d5cfbf;
}
.coin small { font-size: 8px; font-weight: 800; color: #5c564a; text-align: center; letter-spacing: 0.4px; }

.keypad {
  flex: 1; margin: 0; background: var(--panel); border: 2px solid var(--outline);
  border-radius: 10px; padding: 8px; display: grid;
  grid-template-columns: 1fr 1fr; gap: 6px;
}
.keypad .legend {
  grid-column: 1 / -1; color: #9db8c6; font-size: 8px; font-weight: 800;
  letter-spacing: 1px; text-align: center; margin-bottom: 2px; padding: 0;
}
.key { position: relative; display: block; }
.key input { position: absolute; opacity: 0; width: 100%; height: 100%; left: 0; top: 0; margin: 0; cursor: pointer; }
.key .face {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: #33505f; color: #d7e7f0; border: 2px solid #16232b; border-radius: 7px;
  padding: 5px 2px; font-weight: 800; font-size: 11px; letter-spacing: 1px;
  cursor: pointer; transition: background 0.15s, color 0.15s, transform 0.05s;
}
.key .face small { font-size: 8px; letter-spacing: 0.8px; opacity: 0.85; }
.key input:checked ~ .face {
  background: var(--yellow); color: #20242a; border-color: var(--outline);
  box-shadow: inset 0 0 0 2px #fff29a, 0 0 10px rgba(255, 217, 15, 0.55);
}
.key input:focus-visible ~ .face { outline: 3px solid #9ccde4; outline-offset: 1px; }
.key .face:active { transform: translateY(1px); }

.push-bar {
  display: block; width: 100%; margin-top: 12px; appearance: none;
  background: linear-gradient(#ef5f64, #c1272d); color: #fff;
  border: 3px solid var(--outline); border-radius: 10px; padding: 10px 0 12px;
  font-family: var(--font-title); font-size: 28px; letter-spacing: 8px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4); cursor: pointer;
  box-shadow: 0 6px 0 var(--red-dark);
}
.push-bar:hover { filter: brightness(1.05); }
.push-bar:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--red-dark); }
.push-bar:disabled { opacity: 0.7; cursor: wait; }
.push-hint { margin: 6px 0 0; text-align: center; font-size: 11px; font-weight: 700; color: #5c564a; letter-spacing: 0.6px; }

.m-tray {
  margin-top: 10px; height: 62px; border: 3px solid var(--outline); border-radius: 10px;
  background: linear-gradient(#241f19, #15110d); position: relative; overflow: hidden;
}
.flap {
  position: absolute; left: 16px; right: 16px; top: 12px; height: 24px;
  background: #0b0907; border-radius: 8px;
  box-shadow: inset 0 -4px 8px rgba(255, 255, 255, 0.07);
}
.tray-label {
  position: absolute; left: 0; right: 0; bottom: 4px; text-align: center;
  color: #6e7f88; font-size: 8px; font-weight: 800; letter-spacing: 1.5px;
}
.drop {
  position: absolute; left: 50%; top: -46px; transform: translateX(-50%); z-index: 2;
  display: flex; align-items: center; gap: 6px; opacity: 0;
  background: var(--yellow); color: #20242a; border: 2px solid var(--outline); border-radius: 6px;
  padding: 5px 10px; font-weight: 800; font-size: 11px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}
.drop .e { font-size: 16px; }
.drop.show { animation: dropfall 0.55s cubic-bezier(0.5, 0, 0.9, 0.4) forwards; }
@keyframes dropfall { from { top: -46px; opacity: 1; } to { top: 16px; opacity: 1; } }
.drop.fade { transition: opacity 0.6s ease; opacity: 0 !important; }

.fineprint { margin: 10px auto 0; max-width: 380px; font-size: 12.5px; color: #3d4f59; line-height: 1.45; }

/* ============ suggestion slip ============ */
.slip-panel { padding-top: 6px; }
.slip {
  position: relative; background: #fdf9e7; border: 1px solid #d9cfae; border-radius: 4px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18); padding: 18px 18px 16px;
  transform: rotate(0.5deg);
}
.slip::before {
  content: ""; position: absolute; top: -10px; left: 50%;
  transform: translateX(-50%) rotate(-2deg); width: 90px; height: 20px;
  background: rgba(250, 250, 235, 0.7); border: 1px solid rgba(0, 0, 0, 0.08);
}
.slip h2 {
  margin: 0 0 8px; font-family: var(--font-title); font-weight: 400;
  font-size: 30px; letter-spacing: 2px; color: #402712;
  text-shadow: 2px 2px 0 rgba(64, 39, 18, 0.15);
}
.slip label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 8px; color: #40342a; }
.slip textarea {
  width: 100%; min-height: 150px; resize: vertical;
  background: #fffdf4; border: 2px dashed #c9b778; border-radius: 8px;
  padding: 12px; font-family: var(--font-text);
  font-size: 16px; line-height: 1.5; color: #2f2a22;
}
.slip textarea:focus { outline: 3px solid var(--yellow); outline-offset: 2px; border-style: solid; }
.slip-meta {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  margin-top: 8px; font-size: 12px; font-weight: 700; color: #6b6250;
}
.slip-meta .anon { color: #2e7d32; text-align: right; }
.slip-submit {
  margin-top: 12px; width: 100%; appearance: none;
  background: var(--yellow); border: 3px solid var(--outline); border-radius: 10px;
  padding: 10px; font-family: var(--font-title); font-size: 20px; letter-spacing: 2px;
  color: #20242a; cursor: pointer; box-shadow: 0 5px 0 #c9a800;
}
.slip-submit:active { transform: translateY(3px); box-shadow: 0 2px 0 #c9a800; }
.slip-submit:disabled { opacity: 0.7; cursor: wait; }

.status { min-height: 22px; margin: 10px 0 0; font-weight: 700; font-size: 14px; }
.status.ok { color: #2e7d32; }
.status.error { color: #c1272d; }

.privacy {
  margin-top: 20px; background: #eaf6fd; border: 2px solid #9ccde4;
  border-radius: 12px; padding: 14px 16px; box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}
.privacy h3 {
  margin: 0 0 6px; font-family: var(--font-title); font-weight: 400;
  letter-spacing: 1.5px; font-size: 19px; color: #17506e;
}
.privacy ul { margin: 0; padding-left: 20px; }
.privacy li { font-size: 13.5px; margin: 3px 0; }
.privacy .last { margin: 8px 0 0; font-size: 12.5px; font-weight: 700; color: #17506e; }

/* ============ comic burst ============ */
.burst {
  position: fixed; left: 50%; top: 34%; z-index: 60; pointer-events: none;
  transform: translate(-50%, -50%) scale(0.3); opacity: 0;
  font-family: var(--font-title); font-size: clamp(54px, 12vw, 96px);
  color: var(--yellow); letter-spacing: 3px; white-space: nowrap;
  text-shadow: 4px 4px 0 #000, -4px 4px 0 #000, 4px -4px 0 #000, -4px -4px 0 #000, 8px 8px 0 rgba(0, 0, 0, 0.25);
}
.burst.show { animation: burst 1.15s ease-out forwards; }
@keyframes burst {
  0% { transform: translate(-50%, -50%) scale(0.3) rotate(-8deg); opacity: 0; }
  18% { transform: translate(-50%, -50%) scale(1.18) rotate(3deg); opacity: 1; }
  30% { transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
  75% { opacity: 1; }
  100% { transform: translate(-50%, -62%) scale(1.05) rotate(-2deg); opacity: 0; }
}

/* ============ animations ============ */
.machine.shaking { animation: shake 0.5s ease-in-out; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  20% { transform: translate(-3px, 1px) rotate(-0.4deg); }
  40% { transform: translate(3px, -1px) rotate(0.4deg); }
  60% { transform: translate(-2px, 1px) rotate(-0.2deg); }
  80% { transform: translate(2px, -1px) rotate(0.2deg); }
}
.m-sign.wiggle { animation: wiggle 0.55s ease-in-out; }
@keyframes wiggle {
  0%, 100% { transform: rotate(-3deg); }
  30% { transform: rotate(-0.5deg) scale(1.03); }
  65% { transform: rotate(-5.5deg); }
}

footer { position: relative; z-index: 1; text-align: center; padding: 12px 16px 22px; font-size: 12px; color: #40525c; }

/* ============ small screens ============ */
@media (max-width: 430px) {
  .item .n { display: none; }
  .item { height: 40px; }
  .m-glass { height: 220px; }
  .m-sign { width: 210px; font-size: 13px; right: -4px; }
  .push-bar { font-size: 24px; letter-spacing: 6px; }
}

/* ============ reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
  .machine.shaking, .drop.show, .tower .steam, .m-sign.wiggle { animation: none !important; }
  .drop.show { top: 16px; opacity: 1; }
  .burst.show { animation: burst-static 1.2s forwards; }
  @keyframes burst-static { 0% { opacity: 0; } 15% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
}
