/* =============================================================
   Froggy's Sprint Planning Disaster — styles
   Palette + typography per spec ("swamp modernism").
   ============================================================= */

:root {
  --swamp-dark: #1C2B1E;
  --pond-mid: #2E4A32;
  --lily-cream: #F0ECD8;
  --frog-amber: #C9832A;
  --mrs-teal: #4A8C89;
  --chaos-red: #C0392B;
  --mrs-card: #DCE4E0;

  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "IBM Plex Mono", Consolas, monospace;
  --font-ui: "Inter", system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  /* exit animations translate the card 130% sideways; without this, right-side
     overflow expands the mobile scroll canvas and shifts the whole viewport */
  overflow-x: hidden;
}

body {
  background-color: var(--swamp-dark);
  /* subtle lily-pad / ripple geometry */
  background-image:
    radial-gradient(circle at 15% 85%, rgba(46, 74, 50, 0.55) 0 120px, transparent 121px),
    radial-gradient(circle at 85% 15%, rgba(46, 74, 50, 0.45) 0 90px, transparent 91px),
    repeating-radial-gradient(circle at 50% 120%, transparent 0 58px, rgba(240, 236, 216, 0.025) 58px 60px);
  color: var(--lily-cream);
  font-family: var(--font-body);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 12px;
  transition: background-color 3s ease;
}

/* the swamp darkens as the project ages */
body.phase-early { background-color: #1C2B1E; }
body.phase-mid   { background-color: #20281A; }
body.phase-late  { background-color: #241F16; }

/* ---------------- Ambience ---------------- */

#ambience { position: fixed; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }
#app { position: relative; z-index: 2; }

.firefly {
  position: absolute;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #E8D48A;
  box-shadow: 0 0 8px 2px rgba(232, 212, 138, 0.6);
  opacity: 0;
  animation: drift linear infinite, flicker ease-in-out infinite;
}
@keyframes drift {
  from { transform: translate(0, 0); }
  25%  { transform: translate(30px, -40px); }
  50%  { transform: translate(-20px, -75px); }
  75%  { transform: translate(25px, -110px); }
  to   { transform: translate(0, -150px); }
}
@keyframes flicker {
  0%, 100% { opacity: 0; }
  50% { opacity: 0.85; }
}

.lilypad {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(86, 124, 90, 0.30), rgba(46, 74, 50, 0.18) 70%);
  /* a notch, like every lily pad since the dawn of ponds */
  clip-path: polygon(0 0, 100% 0, 100% 100%, 58% 100%, 50% 52%, 42% 100%, 0 100%);
  animation: bob-pad ease-in-out infinite;
}
@keyframes bob-pad {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(14px, -8px) rotate(5deg); }
}

#app { width: 100%; max-width: 520px; }

button { font-family: var(--font-ui); cursor: pointer; }

/* ---------------- Title screen ---------------- */

#title-screen { text-align: center; padding: 24px 12px; }

.title-logo { display: flex; justify-content: center; align-items: flex-end; gap: 4px; margin-bottom: 12px; }
.title-logo img { width: 130px; height: auto; filter: drop-shadow(0 6px 12px rgba(0,0,0,0.4)); animation: bob 3.4s ease-in-out infinite; }
.title-logo img:last-child { animation-delay: 1.7s; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

.brand {
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--frog-amber);
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 6vw, 42px);
  line-height: 1.15;
  margin: 8px 0 14px;
}

.tagline { font-size: 13px; opacity: 0.75; margin-bottom: 28px; }

.cta {
  background: var(--frog-amber);
  color: var(--swamp-dark);
  border: none;
  font-size: 16px;
  font-weight: 600;
  padding: 14px 38px;
  border-radius: 6px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.cta:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(201, 131, 42, 0.35); }
#btn-start { animation: cta-glow 2.6s ease-in-out infinite; }
@keyframes cta-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 131, 42, 0.0); }
  50% { box-shadow: 0 0 22px 2px rgba(201, 131, 42, 0.45); }
}

/* ---------------- Game header & meters ---------------- */

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 10px;
  opacity: 0.9;
}
.game-header .right { display: flex; gap: 10px; align-items: center; }

#btn-music {
  background: none; border: 1px solid rgba(240,236,216,0.25);
  border-radius: 4px; color: var(--lily-cream); font-size: 13px; padding: 2px 7px;
}

#meters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }

.meter { position: relative; }
.meter-label {
  font-family: var(--font-ui);
  font-size: 10px;
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
  opacity: 0.85;
}
.meter-bar {
  height: 8px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  overflow: hidden;
}
.meter-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
#fill-ribs    { background: var(--frog-amber); }
#fill-client  { background: #8FB573; }
#fill-chaos   { background: var(--chaos-red); }
#fill-process { background: var(--mrs-teal); }

.meter.danger .meter-bar { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.0); }
  50% { box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.55); }
}

.delta {
  position: absolute;
  top: -18px;
  right: 0;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 9px;
  background: var(--pond-mid);
  animation: delta-rise 1.2s ease forwards;
  white-space: nowrap;
  z-index: 5;
}
.delta.up { color: #A9D18E; }
.delta.down { color: #E8A09A; }
@keyframes delta-rise {
  0% { opacity: 0; transform: translateY(6px); }
  20% { opacity: 1; transform: translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-8px); }
}

/* ---------------- Card ---------------- */

#card-zone { perspective: 900px; min-height: 430px; }

.card {
  position: relative;
  background:
    repeating-linear-gradient(0deg, transparent 0 26px, rgba(28, 43, 30, 0.03) 26px 27px),
    linear-gradient(160deg, #F4F0DF 0%, var(--lily-cream) 45%, #E7E2C9 100%);
  color: var(--swamp-dark);
  border-radius: 12px;
  border-top: 5px solid var(--frog-amber);
  padding: 26px 24px 30px;
  min-height: 420px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45), inset 0 0 60px rgba(28, 43, 30, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.18s ease, opacity 0.3s ease, background 0.3s ease;
  touch-action: pan-y;
  user-select: none;
  overflow: hidden;
}

.card.mrs {
  background:
    repeating-linear-gradient(0deg, transparent 0 26px, rgba(28, 43, 30, 0.03) 26px 27px),
    linear-gradient(160deg, #E4EBE7 0%, var(--mrs-card) 45%, #CBD7D2 100%);
  border-top-color: var(--mrs-teal);
}
.card.mrs .card-title { color: #2C5654; }

.card.milestone { outline: 2px solid var(--frog-amber); outline-offset: -8px; }

.cat-tag {
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 10px;
  margin-bottom: 4px;
  color: var(--lily-cream);
  background: var(--pond-mid);
}
.cat-mrsfroggy { background: var(--mrs-teal); }
.cat-milestone { background: var(--frog-amber); }
.cat-tadpole { background: #6E9E52; }
.cat-client_checkin { background: #8A6FA8; }
.cat-lucky { background: #A8842C; }

.watermark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--swamp-dark);
  opacity: 0.05;
  pointer-events: none;
}
.watermark svg { width: 65%; height: 65%; }

.portrait {
  width: 110px;
  height: 110px;
  object-fit: contain;
  margin: 6px 0 10px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
  pointer-events: none;
  animation: bob 4s ease-in-out infinite;
}

.card-title {
  font-family: var(--font-display);
  font-size: 23px;
  line-height: 1.2;
  margin-bottom: 12px;
}

.card-body {
  font-size: 13.5px;
  line-height: 1.55;
  max-width: 40ch;
}

.meters-note {
  margin-top: 12px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  color: var(--pond-mid);
}

.card-aside {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px dashed rgba(28, 43, 30, 0.3);
  font-size: 12px;
  font-style: italic;
  color: var(--mrs-teal);
  max-width: 38ch;
}
.card-aside .aside-attr { display: block; font-style: normal; font-size: 10px; opacity: 0.7; margin-top: 3px; }

.swipe-hint {
  position: absolute;
  top: 45%;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  max-width: 150px;
}
.left-hint  { left: 12px;  color: #fff; background: var(--frog-amber); transform: rotate(-6deg); }
.right-hint { right: 12px; color: #fff; background: var(--mrs-teal);  transform: rotate(6deg); }

/* card animations */
.card.enter { transform: translateY(60px) scale(0.95); opacity: 0; }
.card.enter-flip { transform: translateY(-60px) rotateX(50deg); opacity: 0; }
.card.exit-left  { transform: translateX(-130%) rotate(-18deg) !important; opacity: 0; transition: transform 0.3s ease, opacity 0.3s ease; }
.card.exit-right { transform: translateX(130%) rotate(18deg) !important; opacity: 0; transition: transform 0.3s ease, opacity 0.3s ease; }

/* ---------------- Choice buttons ---------------- */

#choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }

.choice {
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 13px 10px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--lily-cream);
  background: var(--pond-mid);
  transition: border-color 0.15s, transform 0.15s;
}
#btn-left:hover,  #btn-left.kb-focus  { border-color: var(--frog-amber); transform: translateY(-2px); }
#btn-right:hover, #btn-right.kb-focus { border-color: var(--mrs-teal);  transform: translateY(-2px); }

/* ---------------- Result flash ---------------- */

#flash {
  position: fixed;
  inset: 0;
  background: rgba(28, 43, 30, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  text-align: center;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.2s ease;
  cursor: pointer;
}
#flash.visible { opacity: 1; }
#flash[hidden] { display: none; }

#flash-text {
  font-family: var(--font-display);
  font-size: clamp(18px, 4vw, 24px);
  line-height: 1.45;
  max-width: 34ch;
}

#flash-deltas { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.flash-delta {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  animation: pop-in 0.35s ease backwards;
}
.flash-delta:nth-child(2) { animation-delay: 0.1s; }
.flash-delta:nth-child(3) { animation-delay: 0.2s; }
.flash-delta:nth-child(4) { animation-delay: 0.3s; }
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}
.flash-delta.up { color: #A9D18E; }
.flash-delta.down { color: #E8A09A; }

.flash-hint { font-family: var(--font-ui); font-size: 11px; opacity: 0.55; letter-spacing: 0.15em; text-transform: uppercase; }

/* ---------------- End screen ---------------- */

#end-screen {
  background: var(--lily-cream);
  color: var(--swamp-dark);
  border-radius: 12px;
  padding: 36px 28px;
  text-align: center;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}
#end-screen.loss { background: #E8DAD2; }

#end-subtitle {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--frog-amber);
}
#end-screen.loss #end-subtitle { color: var(--chaos-red); }

#end-title { font-family: var(--font-display); font-size: 30px; margin: 8px 0 16px; }

#end-body { font-size: 13.5px; line-height: 1.6; max-width: 44ch; margin: 0 auto 22px; }

.end-quotes { margin-bottom: 24px; font-size: 13px; }
.end-quotes p { margin: 6px 0; }
.end-quotes .who { font-family: var(--font-ui); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }
.q-froggy .who { color: var(--frog-amber); }
.q-mrs .who { color: var(--mrs-teal); }

#end-meters { display: flex; flex-direction: column; gap: 6px; max-width: 320px; margin: 0 auto 26px; }
.end-meter { display: grid; grid-template-columns: 86px 1fr 30px; align-items: center; gap: 8px; font-family: var(--font-ui); font-size: 11px; }
.end-meter > span:first-child { text-align: left; }
.end-bar { height: 7px; background: rgba(28, 43, 30, 0.15); border-radius: 4px; overflow: hidden; }
.end-fill { height: 100%; }
.f-ribs { background: var(--frog-amber); }
.f-client { background: #6E9E52; }
.f-chaos { background: var(--chaos-red); }
.f-process { background: var(--mrs-teal); }
.end-val { text-align: right; font-weight: 700; }

/* ---------------- Responsive ---------------- */

@media (max-width: 480px) {
  body { padding: 8px; align-items: flex-start; }
  .card { min-height: 62vh; }
  #card-zone { min-height: 62vh; }
  .portrait { width: 88px; height: 88px; }
  .card-title { font-size: 20px; }
}

/* ---------------- Reduced motion ---------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
