/* ============================================================
   Terrarium — Observer pattern demo
   ============================================================ */

:root {
  --bg: #12201a;
  --panel: #1b2c22;
  --panel-border: rgba(238, 245, 238, 0.08);
  --text: #f2efe6;
  --text-muted: #a9bdb0;

  --accent-gold: #e7b84f;
  --accent-blue: #6fb0c2;
  --accent-rust: #c07156;

  --leaf-thriving: #4f9d6e;
  --leaf-okay: #6c9c66;
  --leaf-stressed: #a68a4a;
  --leaf-wilting: #7c6a4d;

  --soil-color: #4a3524;
  --stem-color: #3f6b4a;
  --glass-color: rgba(238, 245, 238, 0.35);

  --font-display: "Fraunces", serif;
  --font-body: "Public Sans", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #182a20 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--font-body);
  padding: 2.5rem 1.5rem 4rem;
}

.app-shell {
  max-width: 1040px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 2.5rem;
}

.app-header {
  grid-column: 1 / -1;
  margin-bottom: 0.5rem;
}

.app-header h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 4vw, 2.6rem);
  margin: 0 0 0.35rem;
  letter-spacing: -0.01em;
}

.app-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 46ch;
}

/* ---------- stage: plant + controls ---------- */

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.75rem;
}

.plant {
  position: relative;
  width: min(100%, 320px);
}

.plant-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.plant-glow {
  opacity: calc(var(--sun-level, 0.5) * 0.9 + 0.1);
  transition: opacity 0.4s ease;
}

.jar-base {
  fill: rgba(0, 0, 0, 0.25);
}

.jar-glass {
  fill: none;
  stroke: var(--glass-color);
  stroke-width: 2.5;
}

.jar-mist {
  fill: rgba(238, 245, 238, 1);
  opacity: calc(var(--water-level, 0.5) * 0.18);
  transition: opacity 0.4s ease;
}

.soil {
  fill: var(--soil-color);
}

.plant-body {
  transform-origin: 120px 240px;
  transition: transform 0.6s ease;
}

.stem {
  fill: none;
  stroke: var(--stem-color);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke 0.5s ease;
}

.leaf {
  fill: var(--leaf-thriving);
  transition: fill 0.5s ease, opacity 0.5s ease;
}

.flower,
.flower-center {
  opacity: 0;
  transition: opacity 0.5s ease;
}
.flower {
  fill: var(--accent-rust);
}
.flower-center {
  fill: var(--accent-gold);
}

.plant-status-label {
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 0.5rem 0 0;
}

/* status variants — this is the whole payoff: one attribute
   toggled by JS, all the visual consequences handled here */

[data-status="thriving"] .leaf {
  fill: var(--leaf-thriving);
  opacity: 1;
}
[data-status="thriving"] .flower,
[data-status="thriving"] .flower-center {
  opacity: 1;
}
[data-status="thriving"] .plant-body {
  animation: sway 4.5s ease-in-out infinite;
}

[data-status="okay"] .leaf {
  fill: var(--leaf-okay);
  opacity: 1;
}

[data-status="stressed"] .leaf {
  fill: var(--leaf-stressed);
  opacity: 0.8;
}
[data-status="stressed"] .plant-body {
  transform: rotate(3deg);
}

[data-status="wilting"] .leaf {
  fill: var(--leaf-wilting);
  opacity: 0.55;
}
[data-status="wilting"] .plant-body {
  transform: rotate(9deg) translateX(-4px);
}
[data-status="wilting"] .stem {
  stroke: #5c4b34;
}

@keyframes sway {
  0%,
  100% {
    transform: rotate(-1.5deg);
  }
  50% {
    transform: rotate(1.5deg);
  }
}

/* ---------- controls ---------- */

.controls {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.control-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.control-label output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--panel-border);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-gold);
  cursor: pointer;
  border: 2px solid var(--bg);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-gold);
  cursor: pointer;
  border: 2px solid var(--bg);
}

#water-slider::-webkit-slider-thumb {
  background: var(--accent-blue);
}
#water-slider::-moz-range-thumb {
  background: var(--accent-blue);
}

/* ---------- sidebar cards ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1.25rem 1.35rem;
}

.card h2 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.85rem;
}

.gauge-track {
  height: 8px;
  border-radius: 4px;
  background: rgba(238, 245, 238, 0.08);
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  width: 80%;
  background: var(--leaf-thriving);
  border-radius: 4px;
  transition: width 0.5s ease, background 0.5s ease;
}

[data-status="thriving"] .gauge-fill {
  background: var(--leaf-thriving);
}
[data-status="okay"] .gauge-fill {
  background: var(--leaf-okay);
}
[data-status="stressed"] .gauge-fill {
  background: var(--accent-rust);
}
[data-status="wilting"] .gauge-fill {
  background: #7c6a4d;
}

.gauge-readout {
  margin: 0.65rem 0 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.gauge-readout #gauge-score {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.gauge-max {
  color: var(--text-muted);
}

.journal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.journal-list li {
  font-size: 0.85rem;
  line-height: 1.4;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.journal-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.journal-text {
  color: var(--text);
}
.journal-list time {
  color: var(--text-muted);
  font-size: 0.75rem;
}

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

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
}
