/* chill-games.com — shared style system
   Library × Desk substrate + glitch layer.
   Glitch intensity is controlled by data-glitch="off|subtle|loud" on <html>.
*/

:root {
  --bg: #f3ede1;
  --paper: #fbf6ea;
  --paper-2: #f7f0df;
  --ink: #211d18;
  --dim: #5a5147;
  --faint: #9a8f7e;
  --rule: #d8cfba;
  --rule-soft: #e6dfca;
  --accent: #7a3d2e;
  --accent-glow: #c44a2e;
  --crt-r: rgba(255, 60, 60, 0.55);
  --crt-c: rgba(60, 200, 220, 0.5);

  --serif: "Source Serif 4", "Tiempos Text", "Iowan Old Style", Georgia, serif;
  --display: "Playfair Display", "GT Sectra", Georgia, serif;
  --mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #14110d;
  --paper: #1c1814;
  --paper-2: #221d18;
  --ink: #ece4d2;
  --dim: #a89e8c;
  --faint: #6b6357;
  --rule: #3a342a;
  --rule-soft: #2a251f;
  --accent: #d4663d;
  --accent-glow: #ff7a3d;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* paper texture layer */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(rgba(122, 61, 46, 0.04) 1px, transparent 1px);
  background-size: 4px 4px;
  opacity: 0.7;
}
[data-theme="dark"] body::before {
  background-image: radial-gradient(rgba(212, 102, 61, 0.06) 1px, transparent 1px);
}

/* ─── masthead ─────────────────────────────────────────────────────── */
.mast {
  position: relative; z-index: 5;
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 22px 56px 18px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.mast .wm {
  font-family: var(--display);
  font-size: 22px; font-style: italic; font-weight: 400;
  letter-spacing: -0.3px;
  color: var(--ink);
  text-decoration: none;
  position: relative;
}
.mast nav {
  display: flex; gap: 26px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--dim);
}
.mast nav a { color: inherit; text-decoration: none; }
.mast nav a:hover { color: var(--accent); }

/* transmission strip — thin marquee under masthead */
.transmit {
  position: relative; z-index: 4;
  height: 22px; overflow: hidden;
  background: var(--ink); color: var(--bg);
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 1.5px; text-transform: uppercase;
  display: flex; align-items: center;
  border-bottom: 1px solid var(--rule);
}
.transmit-inner {
  display: inline-flex; gap: 32px; white-space: nowrap;
  padding-left: 100%;
  animation: transmit 38s linear infinite;
}
.transmit b { color: var(--accent-glow); font-weight: 500; }
@keyframes transmit { to { transform: translateX(-100%); } }

/* ─── glitch wordmark (used on .mast .wm and on .glitch headings) ──── */
.glitch {
  position: relative;
  display: inline-block;
}
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  opacity: 0;
}
.glitch::before { color: var(--crt-r); transform: translate(-1px, 0); mix-blend-mode: multiply; }
.glitch::after  { color: var(--crt-c); transform: translate(1px, 0);  mix-blend-mode: multiply; }

/* glitch dial — controlled by data-glitch on <html> */
[data-glitch="subtle"] .glitch::before,
[data-glitch="subtle"] .glitch::after { opacity: 0.55; }
[data-glitch="subtle"] .glitch:hover::before { animation: gx 1.6s steps(8) infinite; }
[data-glitch="subtle"] .glitch:hover::after  { animation: gy 1.6s steps(8) infinite; }

[data-glitch="loud"] .glitch::before,
[data-glitch="loud"] .glitch::after { opacity: 0.85; }
[data-glitch="loud"] .glitch::before { animation: gx 2.2s steps(10) infinite; }
[data-glitch="loud"] .glitch::after  { animation: gy 2.2s steps(10) infinite; }

[data-glitch="off"] .glitch::before,
[data-glitch="off"] .glitch::after { display: none; }

@keyframes gx {
  0%, 100% { transform: translate(-1px, 0); clip-path: inset(0 0 0 0); }
  20% { transform: translate(-2px, -1px); clip-path: inset(20% 0 60% 0); }
  40% { transform: translate(-3px, 1px); clip-path: inset(40% 0 30% 0); }
  60% { transform: translate(-1px, 0); clip-path: inset(70% 0 10% 0); }
  80% { transform: translate(-2px, 0); clip-path: inset(10% 0 80% 0); }
}
@keyframes gy {
  0%, 100% { transform: translate(1px, 0); clip-path: inset(0 0 0 0); }
  20% { transform: translate(2px, 1px); clip-path: inset(60% 0 20% 0); }
  40% { transform: translate(3px, -1px); clip-path: inset(10% 0 70% 0); }
  60% { transform: translate(1px, 0); clip-path: inset(30% 0 50% 0); }
  80% { transform: translate(2px, 0); clip-path: inset(80% 0 5% 0); }
}

/* CRT bleed on the BIG display type (Inbox Hero hero, section heads) */
.crt {
  position: relative;
  text-shadow:
    -1px 0 var(--crt-r),
    1px 0 var(--crt-c);
}
[data-glitch="loud"] .crt {
  text-shadow:
    -2px 0 var(--crt-r),
    2px 0 var(--crt-c),
    0 1px var(--crt-r);
  animation: crt-pulse 4.5s ease-in-out infinite;
}
[data-glitch="off"] .crt { text-shadow: none; }
@keyframes crt-pulse {
  0%, 100% { text-shadow: -2px 0 var(--crt-r), 2px 0 var(--crt-c); }
  48% { text-shadow: -2px 0 var(--crt-r), 2px 0 var(--crt-c); }
  50% { text-shadow: -6px 1px var(--crt-r), 6px -1px var(--crt-c); transform: translateX(-1px); }
  52% { text-shadow: -2px 0 var(--crt-r), 2px 0 var(--crt-c); transform: translateX(0); }
}

/* ─── paper card (windowed container) ──────────────────────────────── */
.card {
  background: var(--paper);
  border: 1px solid var(--rule);
  position: relative;
  display: flex; flex-direction: column;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 8px 24px rgba(60, 40, 20, 0.08),
    0 2px 6px rgba(60, 40, 20, 0.04);
}
[data-theme="dark"] .card {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 12px 32px rgba(0, 0, 0, 0.5);
}
.card-bar {
  height: 30px; padding: 0 14px; gap: 10px;
  display: flex; align-items: center;
  background: var(--paper-2);
  border-bottom: 1px solid var(--rule-soft);
}
.card-dots { display: flex; gap: 5px; }
.card-dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--faint); opacity: 0.55;
  display: block;
}
.card-title {
  flex: 1; text-align: center;
  font-family: var(--serif); font-style: italic;
  font-size: 12.5px; color: var(--dim);
  letter-spacing: 0.2px;
}
.card-bar .spacer { width: 30px; }
.card-body { padding: 28px 32px; flex: 1; min-height: 0; }
.card-body.tight { padding: 18px 22px; }

/* ─── tape-deck CTA button ─────────────────────────────────────────── */
.btn-tape {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  background: var(--ink); color: var(--bg);
  font-family: var(--serif); font-size: 14px;
  text-decoration: none; cursor: pointer;
  border: none;
  position: relative;
  letter-spacing: 0.2px;
}
.btn-tape .rec {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-glow);
  box-shadow: 0 0 6px var(--accent-glow);
  animation: rec-pulse 1.4s ease-in-out infinite;
}
[data-glitch="off"] .btn-tape .rec { animation: none; }
@keyframes rec-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}
.btn-tape:hover { background: var(--accent); }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 18px;
  border: 1px solid var(--rule);
  font-family: var(--serif); font-size: 14px;
  color: var(--ink); text-decoration: none;
  background: transparent;
}
.btn-ghost:hover { border-color: var(--ink); }

/* ─── small atoms ──────────────────────────────────────────────────── */
.kicker {
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 1.8px; text-transform: uppercase;
  color: var(--accent);
}
.kicker.dim { color: var(--faint); }
.label {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--faint);
}
.rule { height: 1px; background: var(--rule); }
.ornament {
  display: flex; align-items: center; gap: 16px;
  font-family: var(--display); font-size: 18px;
  font-style: italic; color: var(--faint);
}
.ornament .rule { flex: 1; }

.ascii-divider {
  font-family: var(--mono); font-size: 12px;
  color: var(--faint); letter-spacing: 1px;
  text-align: center; padding: 12px 0;
  user-select: none;
}
[data-glitch="loud"] .ascii-divider { color: var(--accent); }

/* ─── tier strip (era evolution) ───────────────────────────────────── */
.tiers { display: grid; grid-template-columns: repeat(6, 1fr); border-top: 1px solid var(--rule); }
.tier {
  padding: 16px 16px 18px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.tier:last-child { border-right: none; }
.tier .y { font-family: var(--mono); font-size: 10px; color: var(--faint); margin-bottom: 6px; }
.tier .n { font-family: var(--display); font-size: 18px; color: var(--ink); margin-bottom: 4px; }
.tier .d { font-family: var(--serif); font-style: italic; font-size: 12px; color: var(--dim); line-height: 1.4; }

/* ─── footer / newsletter ──────────────────────────────────────────── */
.foot {
  border-top: 1px solid var(--rule);
  padding: 22px 56px;
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg);
  position: relative; z-index: 5;
}
.foot .ask { font-style: italic; color: var(--dim); font-size: 13.5px; }
.sub-input {
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--ink);
  padding: 4px 0;
  min-width: 320px;
}
.sub-input input {
  flex: 1; border: none; background: transparent;
  font-family: var(--mono); font-size: 12px;
  color: var(--ink); outline: none;
  padding: 4px 0;
}
.sub-input input::placeholder { color: var(--faint); }
.sub-input button {
  border: none; background: transparent; cursor: pointer;
  font-family: var(--display); font-style: italic;
  font-size: 14px; color: var(--ink);
}

/* ─── tiny helpers ─────────────────────────────────────────────────── */
.dot-sep { color: var(--faint); padding: 0 8px; }
a.inline { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--rule); }
a.inline:hover { border-bottom-color: var(--accent); }

/* CRT screenshot panel (used in hero key art) */
.crt-screen {
  background: #1a2417;
  position: relative;
  overflow: hidden;
  font-family: var(--mono);
  color: #7ea66e;
  font-size: 11px;
  line-height: 1.65;
}
.crt-screen::after {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(0, 0, 0, 0.22) 3px);
}
[data-glitch="loud"] .crt-screen::before {
  content: "";
  position: absolute; left: 0; right: 0; height: 2px;
  background: rgba(207, 230, 194, 0.4);
  animation: tracking 5.5s linear infinite;
  pointer-events: none; z-index: 2;
}
@keyframes tracking {
  0% { top: -2%; }
  100% { top: 102%; }
}

/* ─── responsive ───────────────────────────────────────────────────── */
@media (max-width: 880px) {
  .mast { padding: 18px 22px 14px; }
  .foot { padding: 18px 22px; flex-direction: column; gap: 14px; align-items: stretch; }
  .sub-input { min-width: 0; }
}
