/* ============================================================================
   GLORPIS CULTUS — stylesheet
   Early-web weirdness x classified alien terminal x CRT decay.
   v1.1 — readability pass: gentler scanlines, calmer motion, higher contrast
   where it matters (body text) and lower glare everywhere else.
   ========================================================================= */

:root {
  --void: #07080a;
  --void-2: #0b0d10;
  --slate: #080b09;
  --slime: #4ce62b;
  --slime-bright: #7dff63;
  --slime-dim: #2f7a1e;
  --mint: #35d97a;
  --acid: #e8dc4a;
  --purple: #9b4dd8;
  --blood: #d94a4a;
  --chalk: #d8e6d4;
  --ink: #a9d6a0;

  --font-pixel: 'Silkscreen', monospace;
  --font-term: 'VT323', monospace;
  --font-mono: 'Share Tech Mono', monospace;

  --border-thick: 3px solid var(--slime);
  --border-thin: 2px solid var(--slime-dim);

  /* Readability knobs */
  --scanline-alpha: 0.05;
  --glow-soft: 0 0 8px rgba(76, 230, 43, 0.25);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--void);
  /* Very faint terminal grid — kept below glare threshold. */
  background-image:
    linear-gradient(rgba(76, 230, 43, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(76, 230, 43, 0.022) 1px, transparent 1px);
  background-size: 48px 48px;
  color: var(--ink);
  font-family: var(--font-term);
  font-size: 20px;
  line-height: 1.6;
  overflow-x: hidden;
}

::selection { background: var(--slime-dim); color: #f2fff0; }

/* ─── CRT overlay ──────────────────────────────────────────────────────── */
/* Subtle by default. Raise --scanline-alpha toward 0.15 for harsher retro. */
.crt-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 3px,
      rgba(0, 0, 0, var(--scanline-alpha)) 3px,
      rgba(0, 0, 0, var(--scanline-alpha)) 4px
    );
}

.crt-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 62%, rgba(0, 0, 0, 0.4) 100%);
}

/* ─── Utility ──────────────────────────────────────────────────────────── */
.muted { color: #71916b; }
.acid { color: var(--acid); }
.center { text-align: center; }
code {
  background: rgba(76, 230, 43, 0.09);
  border: 1px solid var(--slime-dim);
  padding: 0 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

/* Gentle pulse replaces the old hard blink — much kinder to the eyes. */
@keyframes soft-pulse { 50% { opacity: 0.35; } }

.dot-live {
  display: inline-block;
  width: 9px;
  height: 9px;
  background: var(--slime);
  border-radius: 50%;
  box-shadow: var(--glow-soft);
  animation: soft-pulse 2.4s ease-in-out infinite;
}

/* ─── Ticker (Web 1.0 marquee) ─────────────────────────────────────────── */
.ticker {
  border-bottom: var(--border-thin);
  background: var(--void-2);
  color: var(--acid);
  overflow: hidden;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 6px 0;
  position: relative;
  z-index: 2;
}

.ticker-inner {
  display: inline-block;
  padding-left: 100%;
  animation: marquee 60s linear infinite;
}

@keyframes marquee {
  to { transform: translateX(-100%); }
}

/* ─── Header ───────────────────────────────────────────────────────────── */
.site-head {
  padding: 26px 22px 10px;
  border-bottom: var(--border-thin);
  background: linear-gradient(180deg, rgba(76, 230, 43, 0.035), transparent 70%);
}

.head-grid {
  display: grid;
  grid-template-columns: minmax(210px, 300px) 1fr auto;
  gap: 24px;
  align-items: start;
  max-width: 1380px;
  margin: 0 auto;
}

.head-shot {
  margin: 0;
  max-width: 280px;
}

.shot-frame {
  border: 3px solid var(--void);
  outline: 2px solid var(--slime-dim);
  background: #000;
  padding: 6px;
  box-shadow: 6px 6px 0 rgba(76, 230, 43, 0.22);
}

.shot-frame img {
  display: block;
  width: 100%;
  height: auto;
  /* Slight green cast so the photo sits inside the palette instead of
     fighting it. Remove for the untouched original colors. */
  filter: saturate(1.08) contrast(1.04);
}

.head-shot figcaption {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #7ba274;
  text-align: center;
  letter-spacing: 1px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--acid);
  margin: 0 0 6px;
}

.site-title {
  font-family: var(--font-pixel);
  font-size: clamp(28px, 5.4vw, 56px);
  margin: 0;
  color: var(--slime-bright);
  letter-spacing: 2px;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.75);
  position: relative;
}

.site-title.is-glitching::before,
.site-title.is-glitching::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  overflow: hidden;
}

.site-title.is-glitching::before {
  color: var(--acid);
  transform: translate(-3px, 1px);
  clip-path: inset(0 0 62% 0);
}

.site-title.is-glitching::after {
  color: var(--purple);
  transform: translate(3px, -1px);
  clip-path: inset(58% 0 0 0);
}

.tagline {
  margin: 10px 0 4px;
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--chalk);
}

.subtag {
  margin: 0 0 10px;
  font-size: 19px;
  color: #86a881;
}

.subtag em { color: var(--acid); font-style: normal; }

.acolyte-line {
  font-family: var(--font-mono);
  font-size: 13px;
  color: #7ba274;
  margin: 0;
}

.head-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-end;
}

/* ─── Navigation ───────────────────────────────────────────────────────── */
.nav {
  max-width: 1380px;
  margin: 18px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.nav a {
  font-family: var(--font-pixel);
  font-size: 12px;
  color: var(--slime);
  text-decoration: none;
  border: 2px solid transparent;
  padding: 7px 9px;
}

.nav a:hover,
.nav a:focus-visible {
  background: var(--slime-dim);
  color: #f2fff0;
  border-color: var(--acid);
  outline: none;
}

/* ─── Panels ───────────────────────────────────────────────────────────── */
main {
  max-width: 1380px;
  margin: 0 auto;
  padding: 30px 22px 60px;
}

.panel {
  border: var(--border-thin);
  background: rgba(9, 12, 10, 0.66);
  margin-bottom: 44px;
  position: relative;
}

.panel:nth-child(odd) { box-shadow: 7px 7px 0 rgba(76, 230, 43, 0.16); }
.panel:nth-child(even) { box-shadow: 7px 7px 0 rgba(232, 220, 74, 0.14); }

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  background: var(--slime-dim);
  color: #eaffea;
  padding: 9px 12px;
  border-bottom: var(--border-thin);
}

.panel-head-yellow {
  background: #8a8220;
  color: #fffde8;
}

.panel-head-purple {
  background: #6b3a9c;
  color: #f4e9ff;
}

.panel-head h2 {
  font-family: var(--font-pixel);
  font-size: clamp(12px, 2.2vw, 17px);
  margin: 0;
  letter-spacing: 1px;
}

.panel-num {
  font-family: var(--font-pixel);
  font-size: 14px;
  border: 2px solid currentColor;
  padding: 2px 6px;
}

.panel-flag {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  border: 2px solid currentColor;
  padding: 2px 7px;
}

.panel-body { padding: 18px 18px 24px; }

.panel-blurb {
  max-width: 78ch;
  margin: 0 0 18px;
  color: var(--chalk);
  border-left: 4px solid var(--purple);
  padding-left: 12px;
}

.panel-blurb em { color: var(--acid); font-style: normal; font-weight: bold; }

.sub-head {
  font-family: var(--font-pixel);
  font-size: 13px;
  color: var(--acid);
  margin: 0 0 14px;
}

.fine-print {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #6e8b68;
  margin: 14px 0 0;
}

.fine-print strong { color: var(--acid); }

/* ─── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--slime);
  background: var(--void);
  border: 2px solid var(--slime-dim);
  border-radius: 0;
  padding: 9px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  box-shadow: 3px 3px 0 rgba(76, 230, 43, 0.22);
}

.btn:hover, .btn:focus-visible {
  background: var(--slime-dim);
  color: #f2fff0;
  outline: none;
}

.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(76, 230, 43, 0.22); }
.btn:disabled { opacity: 0.45; cursor: wait; }

.btn-yellow { color: var(--acid); border-color: #8a8220; box-shadow: 3px 3px 0 rgba(232, 220, 74, 0.25); }
.btn-yellow:hover, .btn-yellow:focus-visible { background: #8a8220; color: #fffde8; }

.btn-danger { color: var(--blood); border-color: var(--blood); box-shadow: 3px 3px 0 rgba(217, 74, 74, 0.25); }
.btn-danger:hover, .btn-danger:focus-visible { background: var(--blood); color: #fff; }

.btn-ghost { box-shadow: none; border-color: var(--slime-dim); }
.btn-mini { font-size: 10px; padding: 6px 8px; box-shadow: 2px 2px 0 rgba(76, 230, 43, 0.2); }
.btn-block { display: block; width: 100%; text-align: center; margin-top: 10px; }

/* ─── Toolbar / controls ───────────────────────────────────────────────── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  align-items: center;
  border: 2px dashed var(--slime-dim);
  padding: 12px;
  background: rgba(0, 0, 0, 0.35);
  margin-bottom: 14px;
}

.tool-group { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.tool-group-end { margin-left: auto; }

.tool-label {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--acid);
  letter-spacing: 1px;
}

.tool-readout {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--chalk);
  border: 1px solid var(--slime-dim);
  padding: 3px 6px;
}

.swatches { display: flex; gap: 8px; }

.swatch {
  width: 30px;
  height: 30px;
  border: 2px solid var(--sw, var(--slime-dim));
  background: var(--sw, transparent);
  border-radius: 0;
  cursor: pointer;
  padding: 0;
}

.swatch.is-active {
  outline: 2px solid var(--acid);
  outline-offset: 2px;
  box-shadow: 0 0 10px var(--sw, var(--slime));
}

/* ─── Dedicated eraser control ─────────────────────────────────────────── */
.tool-group-erase { margin-left: 6px; }

.btn-eraser {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #14181c;
  border: 3px solid #98a8b8;
  border-radius: 0;
  padding: 8px 14px;
  cursor: pointer;
  box-shadow: 4px 4px 0 rgba(152, 168, 184, 0.25);
}

.btn-eraser:hover, .btn-eraser:focus-visible {
  background: #1d242b;
  border-color: #d5e2ee;
  outline: none;
}

.btn-eraser:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(152, 168, 184, 0.25); }

.btn-eraser.is-active {
  background: var(--blood);
  border-color: #ffb3b3;
  box-shadow: 0 0 14px rgba(217, 74, 74, 0.5);
  color: #fff;
}

.btn-eraser.is-active .eraser-icon,
.btn-eraser.is-active .eraser-text small { color: #ffe3e3; }

.eraser-icon {
  font-size: 22px;
  color: #d5e2ee;
  letter-spacing: -3px;
}

.eraser-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.eraser-text strong { font-family: var(--font-pixel); font-size: 13px; color: inherit; }
.btn-eraser:not(.is-active) .eraser-text strong { color: #e8f1f8; }
.eraser-text small { font-family: var(--font-mono); font-size: 10px; color: #8fa0ae; }

/* ─── Range slider ─────────────────────────────────────────────────────── */
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 160px;
  height: 10px;
  background: var(--void);
  border: 2px solid var(--slime-dim);
  border-radius: 0;
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 26px;
  background: var(--acid);
  border: 2px solid var(--void);
  cursor: pointer;
}

.range::-moz-range-thumb {
  width: 18px;
  height: 26px;
  background: var(--acid);
  border: 2px solid var(--void);
  border-radius: 0;
  cursor: pointer;
}

/* ─── Canvas frame ─────────────────────────────────────────────────────── */
.canvas-frame {
  position: relative;
  border: var(--border-thin);
  background: var(--slate);
}

#slate {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  cursor: crosshair;
}

/* Eraser mode: swap the crosshair for a fat round cursor so it's obvious
   what's about to get eaten. */
#slate.erasing {
  cursor: cell;
}

.canvas-corner {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--slime);
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid var(--slime-dim);
  padding: 2px 6px;
  pointer-events: none;
}

.canvas-corner.tl { top: 6px; left: 6px; }
.canvas-corner.br { bottom: 6px; right: 6px; }

.st-live { color: var(--slime); border-color: var(--slime-dim); }
.st-warn { color: var(--acid); border-color: #8a8220; }
.st-err { color: var(--blood); border-color: var(--blood); animation: soft-pulse 1.6s ease-in-out infinite; }

/* ─── Translator ───────────────────────────────────────────────────────── */
.io-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: stretch;
  margin-bottom: 16px;
}

.io-box {
  display: flex;
  flex-direction: column;
  border: var(--border-thin);
  background: rgba(0, 0, 0, 0.42);
}

.io-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-pixel);
  font-size: 11px;
  color: #eaffea;
  background: var(--slime-dim);
  padding: 6px 8px;
}

.io-box-out .io-head { background: #8a8220; color: #fffde8; }

.io-live {
  font-size: 9px;
  background: rgba(0, 0, 0, 0.28);
  padding: 2px 5px;
}

.io-box textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  background: var(--void);
  color: var(--chalk);
  border: none;
  border-bottom: 2px solid var(--slime-dim);
  border-radius: 0;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 17px;
  line-height: 1.55;
}

.io-box textarea:focus { outline: 2px solid var(--acid); outline-offset: -2px; }

.io-box textarea.sga {
  color: var(--slime-bright);
  font-size: 21px;
}

.io-box textarea.flash { animation: flash-out 0.22s steps(2); }

@keyframes flash-out {
  50% { background: rgba(76, 230, 43, 0.18); }
}

.io-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.phrase-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--mint);
  background: var(--void);
  border: 2px solid var(--slime-dim);
  border-radius: 0;
  padding: 5px 8px;
  cursor: pointer;
}

.chip:hover, .chip:focus-visible {
  border-color: var(--acid);
  color: var(--acid);
  outline: none;
}

/* ─── Cipher table ─────────────────────────────────────────────────────── */
.cipher-dump {
  border: 2px dashed var(--slime-dim);
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.32);
}

.cipher-dump summary {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--acid);
  cursor: pointer;
  padding: 4px 0;
}

.cipher-table-wrap { overflow-x: auto; margin-top: 12px; }

.cipher-table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--font-mono);
  font-size: 15px;
}

.cipher-table th {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: #eaffea;
  background: var(--slime-dim);
  text-align: left;
  padding: 6px 8px;
}

.cipher-table td {
  border: 1px solid rgba(76, 230, 43, 0.2);
  padding: 5px 8px;
  color: var(--chalk);
}

.cipher-table tr:nth-child(even) td { background: rgba(76, 230, 43, 0.04); }
.cipher-table .c-terra { color: var(--acid); width: 60px; }
.cipher-table .c-glyph { color: var(--slime-bright); font-size: 20px; width: 90px; }
.cipher-table .c-code { font-size: 12px; }
.c-null { color: var(--blood); font-size: 12px; }

/* ─── Shrine ───────────────────────────────────────────────────────────── */
.shrine-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  grid-template-areas:
    'watch praise';
  gap: 24px;
}

.shrine-col-wide { grid-area: watch; }
.praise-col { grid-area: praise; }

/* ─── Glorp watcher stage ──────────────────────────────────────────────── */
.glorp-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 26px 18px 20px;
  border: var(--border-thin);
  border-color: rgba(76, 230, 43, 0.35);
  background:
    radial-gradient(ellipse at 50% 42%, rgba(76, 230, 43, 0.07), transparent 62%),
    rgba(0, 0, 0, 0.45);
  min-height: 320px;
  justify-content: center;
}

.glorp-portrait {
  position: relative;
  width: min(300px, 70vw);
  display: flex;
  justify-content: center;
  /* Lets him peek slightly past the frame without clipping the shadow. */
  padding: 10px;
}

.glorp-portrait::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 45%, rgba(76, 230, 43, 0.14), transparent 65%);
  pointer-events: none;
}

.glorp-portrait img {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  /* Transparent PNG, so no border box — just a soft green aura behind him. */
  filter: drop-shadow(0 0 22px rgba(76, 230, 43, 0.35));
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}

.glorp-caption {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
  border: 1px solid rgba(76, 230, 43, 0.3);
  background: rgba(0, 0, 0, 0.4);
  padding: 5px 10px;
}

.glorp-quote {
  margin: 0;
  font-family: var(--font-term);
  font-size: 18px;
  color: #7ea176;
  text-align: center;
}

/* ─── Praise counter ───────────────────────────────────────────────────── */
.praise-box {
  border: var(--border-thin);
  background: rgba(0, 0, 0, 0.45);
  box-shadow: 6px 6px 0 rgba(232, 220, 74, 0.16);
  padding: 16px;
  text-align: center;
}

.praise-label {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--acid);
  letter-spacing: 1px;
}

.praise-count {
  font-family: var(--font-pixel);
  font-size: clamp(28px, 4.6vw, 42px);
  color: var(--slime-bright);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.8);
  margin: 10px 0 14px;
}

.praise-btn {
  width: 100%;
  font-family: var(--font-pixel);
  font-size: 17px;
  padding: 18px 10px;
  color: #06130a;
  background: var(--slime);
  border: 3px solid var(--acid);
  border-radius: 0;
  cursor: pointer;
  box-shadow: 5px 5px 0 rgba(232, 220, 74, 0.35);
  letter-spacing: 1px;
}

.praise-btn:hover, .praise-btn:focus-visible {
  background: var(--slime-bright);
  border-color: #fff3a0;
  outline: none;
}

.praise-btn.is-pulsing { animation: praise-pulse 0.35s steps(2) 2; }

@keyframes praise-pulse {
  50% { transform: translate(3px, 3px); box-shadow: 0 0 0 rgba(0, 0, 0, 0); }
}

.praise-status {
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ─── LEDs ─────────────────────────────────────────────────────────────── */
.site-foot {
  border-top: var(--border-thin);
  padding: 22px 22px 44px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: #6e8b68;
}

.site-foot p { margin: 4px 0; }

.foot-art {
  margin: 0 0 10px;
  color: var(--slime-dim);
  font-size: 11px;
  letter-spacing: 2px;
  overflow: hidden;
  white-space: nowrap;
}

.footer-credit { margin-top: 12px; font-size: 14px; color: var(--ink); }

.footer-credit a {
  color: var(--acid);
  text-decoration: none;
  border-bottom: 1px dotted rgba(232, 220, 74, 0.6);
}

.footer-credit a:hover, .footer-credit a:focus-visible {
  color: #fff3a0;
  border-bottom-style: solid;
  outline: none;
}

/* ─── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1050px) {
  .head-grid { grid-template-columns: 1fr 1fr; }
  .head-shot { grid-column: 1 / -1; max-width: 320px; }
  .head-side { align-items: flex-start; }
  .shrine-grid {
    grid-template-columns: 1fr;
    grid-template-areas: 'watch' 'praise';
  }
}

@media (max-width: 760px) {
  body { font-size: 18px; }
  .head-grid { grid-template-columns: 1fr; }
  .io-grid { grid-template-columns: 1fr; }
  .tool-group-end { margin-left: 0; }
  .panel-flag { display: none; }
  .glorp-portrait { width: min(240px, 66vw); }
}

@media (prefers-reduced-motion: reduce) {
  .ticker-inner, .dot-live, .led-warn, .st-err { animation: none; }
  html { scroll-behavior: auto; }
}
