/* Conway's Game of Life — full-screen interactive hero chrome.
   Ported from the prototype's styles, recolored to the warm landing palette and
   scoped under #life-stage so nothing leaks into the docs section below. The
   canvas colors live in landing.css (--gol-*) and are read by life.js. */

#life-stage {
  position: relative;
  height: 100vh;
  min-height: 520px;
  overflow: hidden;

  --ink: #1a1b1f;
  --ink-dim: #5a5a57;
  --ink-faint: #95938c;
  --line: rgba(20, 20, 20, 0.1);
  --line-soft: rgba(20, 20, 20, 0.05);
  --elev: #fbf8ee;
  --elev-2: #fffdf4;
  --accent: var(--brand);
  --accent-ink: #ffffff;
  --danger: #d4563f;
  --danger-ink: #ffffff;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-lg: 0 24px 60px -32px rgba(20, 20, 20, 0.28), 0 1px 0 rgba(0, 0, 0, 0.04) inset;
}

@media (prefers-color-scheme: dark) {
  #life-stage {
    --ink: #f8efd7;
    --ink-dim: #a8a29e;
    --ink-faint: #6b675f;
    --line: rgba(255, 255, 255, 0.08);
    --line-soft: rgba(255, 255, 255, 0.04);
    --elev: #25221f;
    --elev-2: #2d2926;
    --accent: #7c78e6;
    --shadow-lg: 0 24px 80px -32px rgba(0, 0, 0, 0.7), 0 2px 0 rgba(255, 255, 255, 0.03) inset;
  }
}

#life-stage .life-canvas-wrap {
  position: absolute;
  inset: 0;
  touch-action: none;
}

#life-stage .life-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---- Top toolbar ---- */
#life-stage .topbar {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  background: color-mix(in oklab, var(--elev) 92%, transparent);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  overflow: hidden;
}

#life-stage .topbar > * {
  flex-shrink: 0;
}

#life-stage .tb-spacer {
  flex: 1 1 0;
  min-width: 4px;
}

#life-stage .tb-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
}

#life-stage .brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-right: 14px;
  margin-right: 4px;
  border-right: 1px solid var(--line);
  height: 32px;
  line-height: 32px;
}

#life-stage .brand-mark {
  color: var(--accent);
  font-size: 9px;
  line-height: 1;
  transform: translateY(-2px);
}

#life-stage .brand-name {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.01em;
  color: var(--ink);
  white-space: nowrap;
  text-decoration: none;
}

#life-stage .brand-sub {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.22em;
  color: var(--ink-faint);
  font-weight: 500;
  transform: translateY(-1px);
}

#life-stage .tb-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  background: var(--elev-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

#life-stage .tb-divider {
  width: 1px;
  align-self: stretch;
  background: var(--line);
  margin: 4px 4px;
}

#life-stage .icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-dim);
  font: 500 11px/1 var(--font-mono);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition:
    background 120ms ease,
    color 120ms ease,
    border-color 120ms ease,
    transform 80ms ease;
}

#life-stage .icon-btn:hover {
  background: color-mix(in oklab, var(--ink) 8%, transparent);
  color: var(--ink);
}

#life-stage .icon-btn:active {
  transform: translateY(0.5px);
}

#life-stage .icon-btn.is-active {
  background: color-mix(in oklab, var(--accent) 16%, transparent);
  color: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 32%, transparent);
}

#life-stage .icon-btn.accent {
  background: var(--accent);
  color: var(--accent-ink);
}

#life-stage .icon-btn.accent:hover {
  background: color-mix(in oklab, var(--accent) 88%, black);
}

#life-stage .icon-btn.danger {
  background: var(--danger);
  color: var(--danger-ink);
}

#life-stage .icon-btn.danger:hover {
  background: color-mix(in oklab, var(--danger) 88%, black);
}

#life-stage .icon-btn-label {
  text-transform: uppercase;
}

/* Topbar links (Open the app, Docs) */
#life-stage .tb-link {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--ink-dim);
  text-decoration: none;
  font: 500 11px/1 var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition:
    background 120ms ease,
    color 120ms ease;
}

#life-stage .tb-link:hover,
#life-stage .tb-link:focus-visible {
  background: color-mix(in oklab, var(--ink) 8%, transparent);
  color: var(--ink);
}

/* Speed slider */
#life-stage .speed-group {
  padding: 3px 10px 3px 12px;
  gap: 10px;
}

#life-stage .speed-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.22em;
  color: var(--ink-faint);
  font-weight: 500;
}

#life-stage .speed-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 4px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--p, 25%),
    var(--line) var(--p, 25%),
    var(--line) 100%
  );
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

#life-stage .speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--ink);
  border-radius: 50%;
  border: 2px solid var(--elev-2);
  box-shadow: 0 0 0 1px var(--line);
  cursor: grab;
}

#life-stage .speed-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--ink);
  border-radius: 50%;
  border: 2px solid var(--elev-2);
  box-shadow: 0 0 0 1px var(--line);
  cursor: grab;
}

#life-stage .speed-readout {
  font-size: 11px;
  color: var(--ink);
  min-width: 36px;
  text-align: right;
  letter-spacing: 0.04em;
}

#life-stage .view-group {
  gap: 6px;
  padding-left: 10px;
  padding-right: 6px;
}

#life-stage .zoom-readout {
  font-size: 10.5px;
  color: var(--ink-dim);
  letter-spacing: 0.06em;
  padding: 0 2px;
  min-width: 36px;
  text-align: center;
}

#life-stage .mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---- HUD (bottom right) ---- */
#life-stage .hud {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, auto));
  gap: 14px 22px;
  padding: 14px 18px;
  background: color-mix(in oklab, var(--elev) 92%, transparent);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 20;
}

#life-stage .stat-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.22em;
  color: var(--ink-faint);
  font-weight: 600;
  margin-bottom: 4px;
}

#life-stage .stat-value {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink);
}

/* ---- Status strip (bottom left) ---- */
#life-stage .status-strip {
  position: absolute;
  left: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: color-mix(in oklab, var(--elev) 92%, transparent);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--ink-dim);
  z-index: 20;
}

#life-stage .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 12px currentColor;
}

#life-stage .status-sep {
  color: var(--ink-faint);
}

/* ---- Direction pad (right edge, on-screen panning) ---- */
#life-stage .dpad {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: color-mix(in oklab, var(--elev) 92%, transparent);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 20;
}

#life-stage .dpad-mid {
  display: flex;
  /* Gap between left/right leaves a hole at the centre of the cross. */
  gap: 30px;
}

#life-stage .dpad-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--elev-2);
  color: var(--ink-dim);
  cursor: pointer;
  touch-action: none;
  transition:
    background 120ms ease,
    color 120ms ease,
    transform 80ms ease;
}

#life-stage .dpad-btn:hover {
  background: color-mix(in oklab, var(--ink) 8%, transparent);
  color: var(--ink);
}

#life-stage .dpad-btn:active {
  transform: translateY(0.5px);
}

/* The `chev` icon points down; rotate it for the other three directions. */
#life-stage .dpad-up svg {
  transform: rotate(180deg);
}

#life-stage .dpad-left svg {
  transform: rotate(90deg);
}

#life-stage .dpad-right svg {
  transform: rotate(-90deg);
}

/* ---- Selection action bar (floats above the selection) ---- */
#life-stage .selection-bar {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: color-mix(in oklab, var(--elev) 92%, transparent);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 21;
}

/* ---- Pattern panel (left) ---- */
#life-stage .patterns-panel {
  position: absolute;
  top: 90px;
  left: 18px;
  width: 280px;
  max-height: calc(100vh - 90px - 80px);
  display: flex;
  flex-direction: column;
  background: color-mix(in oklab, var(--elev) 92%, transparent);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  overflow: hidden;
}

#life-stage .patterns-panel.is-collapsed {
  max-height: 44px;
}

#life-stage .patterns-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

#life-stage .patterns-title {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.24em;
  color: var(--ink-faint);
  font-weight: 600;
}

#life-stage .patterns-toggle {
  background: none;
  border: none;
  color: var(--ink-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition:
    transform 200ms ease,
    color 120ms;
  display: inline-flex;
}

#life-stage .patterns-panel.is-collapsed .patterns-toggle {
  transform: rotate(-90deg);
}

#life-stage .patterns-toggle:hover {
  color: var(--ink);
}

#life-stage .patterns-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#life-stage .patterns-panel.is-collapsed .patterns-body {
  display: none;
}

#life-stage .patterns-help {
  padding: 10px 14px 8px;
  font-size: 11px;
  color: var(--ink-dim);
  line-height: 1.5;
  border-bottom: 1px solid var(--line-soft);
}

#life-stage .patterns-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px;
}

#life-stage .patterns-list::-webkit-scrollbar {
  width: 8px;
}

#life-stage .patterns-list::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

#life-stage .pattern-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  transition:
    background 120ms ease,
    border-color 120ms ease;
}

#life-stage .pattern-item + .pattern-item {
  margin-top: 2px;
}

#life-stage .pattern-item:hover {
  background: color-mix(in oklab, var(--ink) 5%, transparent);
}

#life-stage .pattern-item.is-active {
  background: color-mix(in oklab, var(--accent) 14%, transparent);
  border-color: color-mix(in oklab, var(--accent) 32%, transparent);
}

#life-stage .pattern-thumb {
  flex-shrink: 0;
  background: var(--gol-bg);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
}

#life-stage .pattern-meta {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

#life-stage .pattern-name {
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#life-stage .pattern-note {
  font-size: 10.5px;
  color: var(--ink-dim);
  margin-top: 2px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#life-stage .patterns-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}

#life-stage .ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink-dim);
  font: 500 11px/1 var(--font-mono);
  letter-spacing: 0.04em;
  cursor: pointer;
  text-transform: uppercase;
}

#life-stage .ghost-btn:hover {
  color: var(--ink);
  border-color: var(--ink-dim);
}

#life-stage .hint {
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.1em;
}

/* Hide button text labels on narrower viewports — icons + tooltips remain */
@media (max-width: 1280px) {
  #life-stage .icon-btn-label {
    display: none;
  }
  #life-stage .icon-btn {
    padding: 0 7px;
  }
  #life-stage .speed-slider {
    width: 80px;
  }
  #life-stage .brand-sub {
    display: none;
  }
  #life-stage .tb-link.app-link {
    display: none;
  }
}

@media (max-width: 980px) {
  #life-stage .brand {
    padding-right: 10px;
    margin-right: 0;
  }
  #life-stage .brand-name {
    font-size: 18px;
  }
  #life-stage .speed-group {
    padding-left: 8px;
    padding-right: 8px;
    gap: 8px;
  }
  #life-stage .speed-label {
    display: none;
  }
  #life-stage .hud {
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
    padding: 10px 14px;
  }
  #life-stage .stat-value {
    font-size: 16px;
  }
  #life-stage .patterns-panel {
    width: 240px;
  }
}

@media (max-width: 640px) {
  #life-stage .patterns-panel {
    display: none;
  }
  #life-stage .dpad {
    display: none;
  }
}

/* ---- Embedded preview + in-page fullscreen (landing page) ---- */
/* The preview is the same #life-stage app, just sized as a framed box in the
   page flow instead of a 100vh hero. life.js's ResizeObserver re-fits the canvas
   whenever these rules change the element's size. */
#life-stage.life-stage--preview {
  height: min(72vh, 620px);
  min-height: 380px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

/* In-page fullscreen: cover the viewport without leaving the landing page. */
#life-stage.life-fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  z-index: 1000;
}

body.life-noscroll {
  overflow: hidden;
}

#life-stage .life-fullscreen-btn .life-fs-glyph {
  font-size: 14px;
  line-height: 1;
}
