/* Grow the Hive — the skin that curdles.
 * Phase 1: warm cream and amber. Phase 2: cooling, clinical.
 * Phase 3: near-black, amber data-glow. The palette is the narrative.
 */

/* Type: a warm characterful serif is the hive's voice; a tabular mono carries
 * the relentless numbers. Web fonts with graceful system fallbacks (file://). */
:root {
  --font-voice: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-num: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --comb: rgba(176,127,36,0.55);  /* honeycomb stroke, retinted per act */
  --combOpacity: 0.55;
}

/* Act I — the wildflower meadow: warm, generous, alive */
:root {
  --bg: #faf3e1;
  --bg-panel: #fffcf4;
  --ink: #3b2f18;
  --ink-dim: #93805a;
  --accent: #e0a022;
  --accent-dark: #a8741a;
  --line: #ead9b4;
  --btn-bg: #fdf6e6;
  --btn-ink: #3b2f18;
  --btn-border: #d2bf93;
  --danger: #b3471d;
  --comb: rgba(176,127,36,0.5);
  --combOpacity: 0.5;
}

/* Act II — the long summer: the world bleaches to wax, still and featureless */
body.phase-2 {
  --bg: #e9e5d9;
  --bg-panel: #f4f1e9;
  --ink: #46423a;
  --ink-dim: #908a79;
  --accent: #a98f4a;
  --accent-dark: #7d672e;
  --line: #ddd6c5;
  --btn-bg: #efece2;
  --btn-border: #bcb6a6;
  --danger: #8f2f12;
  --comb: rgba(150,135,95,0.4);
  --combOpacity: 0.32;
}

/* Act III — the dark between stars: near-black, amber bioluminescence */
body.phase-3 {
  --bg: #100e09;
  --bg-panel: #1a160d;
  --ink: #dcc794;
  --ink-dim: #756542;
  --accent: #f2b441;
  --accent-dark: #b78a2c;
  --line: #2d2615;
  --btn-bg: #211b10;
  --btn-ink: #dcc794;
  --btn-border: #4a3d20;
  --danger: #e06636;
  --comb: rgba(242,180,65,0.34);
  --combOpacity: 0.55;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-voice);
  font-size: 15px;
  line-height: 1.5;
  transition: background-color 2s ease, color 2s ease;
  padding: 14px 18px 60px;
  position: relative;
}

/* A honeycomb field behind everything, retinted and dimmed per act. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--combOpacity);
  transition: opacity 2s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100' viewBox='0 0 56 100'%3E%3Cg fill='none' stroke='%23c89a3a' stroke-width='1.2'%3E%3Cpath d='M28 66L0 50V16L28 0l28 16v34L28 66z'/%3E%3Cpath d='M28 100L0 84M28 66v34M28 66l28 18'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 56px 100px;
}
body.phase-3::before { /* amber comb glows faintly on the dark */ }

/* numbers wear the mono face */
.val, #honeyCount, #honeyCounter, .row, .meter, #rateGraph,
.design-row, .slider-labels, #lcOps, #lcHoney, #lcPower {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

h1 {
  font-family: var(--font-voice);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0 0 4px;
  color: var(--ink);
}
h1 .mark { color: var(--accent); }

/* ---- splash: the jar you click to begin ---- */

#splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #faf3e3;
  display: flex;
  align-items: center;
  justify-content: center;
}

#splash img {
  width: min(600px, 85vw);
  cursor: pointer;
  transition: transform 0.25s ease;
}

#splash img:hover { transform: scale(1.03); }

#splash.leaving {
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}

#honeyCounter {
  font-size: 26px;
  margin: 4px 0 10px;
  font-variant-numeric: tabular-nums;
}

#honeyCounter .label { color: var(--ink-dim); font-size: 16px; font-family: var(--font-voice); }
body.phase-3 #honeyCount { text-shadow: 0 0 14px rgba(242,180,65,0.5); }

/* ---- layout ---- */

#columns {
  display: flex;
  gap: 26px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.col { min-width: 270px; flex: 1 1 300px; max-width: 430px; }

.panel {
  border-top: 1px solid var(--line);
  margin-bottom: 18px;
  padding-top: 8px;
  transition: opacity 0.8s ease;
}

.panel h2 {
  font-family: var(--font-voice);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0 0 8px;
}

.panel h2::before {
  content: '\2B22'; /* ⬢ */
  color: var(--accent);
  opacity: 0.65;
  margin-right: 7px;
  font-size: 11px;
}

.panel .row {
  margin: 3px 0;
}

.row .val { color: var(--accent-dark); }
body.phase-3 .row .val { color: var(--accent); }

/* honey-fill meters — a cell filling with amber, behind the number */
.meter {
  height: 5px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  margin: 1px 0 7px;
}
.meter .fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
  transition: width 0.25s ease;
}
body.phase-3 .meter .fill {
  box-shadow: 0 0 6px rgba(242,180,65,0.55);
}

.hidden { display: none !important; }

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

button {
  font-family: var(--font);
  font-size: 13px;
  background: var(--btn-bg);
  color: var(--btn-ink, var(--ink));
  border: 1px solid var(--btn-border);
  border-radius: 3px;
  padding: 4px 12px;
  margin: 2px 4px 2px 0;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

button:hover:not(:disabled) { background: var(--bg); border-color: var(--accent-dark); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: default; }

/* mobile: no double-tap zoom on rapid clicking, no tap highlight,
 * no accidental text selection while mashing Make Honey */
button, .project, #splash img {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

@media (max-width: 600px) {
  body { padding: 10px 12px 70px; }
  #btnMakeHoney { width: 100%; padding: 14px; font-size: 18px; }
  button { padding: 8px 14px; font-size: 14px; min-height: 36px; }
  .col { max-width: none; }
  #logPanel { height: 84px; }
}

#btnMakeHoney {
  font-size: 16px;
  padding: 8px 22px;
  border-color: var(--accent-dark);
  border-width: 1.5px;
}

button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

/* ---- activity log ---- */

#logPanel {
  border: 1px solid var(--line);
  background: var(--bg-panel);
  height: 96px;
  overflow-y: auto;
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--ink-dim);
  margin-bottom: 14px;
  scroll-behavior: smooth;
}

#logPanel .entry { margin: 1px 0; }
#logPanel .entry:last-child { color: var(--ink); }

/* ---- projects ---- */

.project {
  border: 1px solid var(--line);
  background: var(--bg-panel);
  border-radius: 3px;
  padding: 7px 10px;
  margin-bottom: 7px;
  cursor: pointer;
  transition: border-color 0.15s ease, opacity 0.3s ease;
}

.project:hover.affordable { border-color: var(--accent); }
.project.unaffordable { opacity: 0.55; cursor: default; }
.project .ptitle { font-size: 13.5px; }
.project .pcost { font-size: 11.5px; color: var(--accent-dark); margin-left: 4px; }
.project .pdesc { font-size: 12px; color: var(--ink-dim); margin-top: 2px; }
.project.danger { border-color: var(--danger); }
.project.danger .ptitle { color: var(--danger); }

/* ---- quorum nodes ---- */

#quorumNodes { display: flex; gap: 4px; margin: 6px 0; }
.qnode {
  width: 22px; height: 22px;
  border: 1px solid var(--btn-border);
  background: #000;
}

/* ---- sliders ---- */

input[type="range"] { width: 100%; accent-color: var(--accent); }
.slider-labels {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: 0.1em;
}

/* ---- probe designer ---- */

.design-row {
  display: flex; align-items: center; justify-content: space-between;
  margin: 2px 0; font-variant-numeric: tabular-nums;
}
.design-row .dname { flex: 1; }
.design-row button { padding: 0 8px; font-size: 13px; margin: 0 2px; }
.design-row .dval { width: 28px; text-align: center; color: var(--accent); }

/* ---- combat canvas ---- */

#combatCanvas {
  width: 100%;
  height: 120px;
  border: 1px solid var(--line);
  display: block;
  background: #16130d;
}

#beeCanvas {
  width: 100%;
  height: 90px;
  display: block;
  margin-bottom: 10px;
}

#rateGraph {
  display: block;
  width: 240px;
  height: 32px;
  margin: -4px 0 10px;
  opacity: 0.8;
}

/* ---- endgame ---- */

#queenMessage, #directivePrompt {
  border: 1px solid var(--accent-dark);
  background: var(--bg-panel);
  padding: 14px 16px;
  margin: 10px 0;
  font-style: italic;
}
#queenMessage p, #directivePrompt p { margin: 6px 0; }

#finalScreen {
  text-align: center;
  padding-top: 12vh;
}
#finalCount {
  font-size: 20px;
  word-break: break-all;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  margin: 24px auto;
  max-width: 700px;
}

/* ---- the moment ---- */

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-6px, 3px); }
  20% { transform: translate(5px, -4px); }
  30% { transform: translate(-4px, -3px); }
  40% { transform: translate(6px, 2px); }
  50% { transform: translate(-5px, 4px); }
  60% { transform: translate(4px, -2px); }
  70% { transform: translate(-6px, -4px); }
  80% { transform: translate(5px, 3px); }
  90% { transform: translate(-3px, 2px); }
}
body.shaking { animation: shake 0.7s linear 3; }

@keyframes bloomflash {
  0% { opacity: 0; }
  15% { opacity: 1; }
  100% { opacity: 0; }
}
#bloomFlash {
  position: fixed;
  inset: 0;
  background: #ffd684;
  opacity: 0;
  pointer-events: none;
  z-index: 99;
}
#bloomFlash.go { animation: bloomflash 2.2s ease-out 1; }

/* ---- dev panel ---- */

#devPanel {
  position: fixed;
  bottom: 0; right: 0;
  background: rgba(0,0,0,0.82);
  color: #9fdfa0;
  font: 11px/1.5 monospace;
  padding: 8px 10px;
  z-index: 100;
  max-width: 320px;
}
#devPanel button {
  font: 10px monospace;
  background: #222; color: #9fdfa0;
  border: 1px solid #555;
  padding: 1px 6px;
}

#footer {
  position: fixed;
  bottom: 6px; left: 18px;
  font-size: 11px;
  color: var(--ink-dim);
}
#footer button {
  font-size: 10px;
  padding: 1px 6px;
}
