/* ========================================
   Half Pint Pub — homepage "tavern terminal"
   Nostalgic glitch CRT / RPG-HUD art piece.
   Self-contained: no external fonts or assets.
   ======================================== */

:root {
  --bg: #050508;
  --bg-2: #0b0b14;
  --panel: #0d0d18;
  --line: #26263a;
  --text: #d8d8e8;
  --muted: #8a8aa3;
  --green: #39ff6a;
  --purple: #8a2be2;
  --cyan: #00e5ff;
  --pink: #ff4fd8;
  --gold: #ffd166;
  --red: #ff3355;
  --font-mono: "Courier New", ui-monospace, Menlo, Consolas, monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  min-height: 100vh;
  background: var(--bg);
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(138, 43, 226, 0.12), transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(0, 229, 255, 0.08), transparent 50%);
  color: var(--text);
  font-family: var(--font-mono);
  line-height: 1.6;
}

::selection {
  background: var(--purple);
  color: #fff;
}

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: #07070d; }
::-webkit-scrollbar-thumb { background: var(--line); border: 2px solid #07070d; }
::-webkit-scrollbar-thumb:hover { background: var(--purple); }

/* === CRT overlays === */
.overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.scanlines {
  z-index: 90;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px 3px);
}

.scanlines::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 80px;
  background: linear-gradient(180deg, transparent, rgba(120, 255, 180, 0.05), transparent);
  animation: sweep-down 7s linear infinite;
}

@keyframes sweep-down {
  from { top: -80px; }
  to { top: 100%; }
}

.vignette {
  z-index: 91;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
  animation: crt 6s infinite;
}

@keyframes crt {
  0%, 100% { opacity: 1; }
  48% { opacity: 1; }
  50% { opacity: 0.92; }
  52% { opacity: 1; }
}

.noise {
  z-index: 92;
  opacity: 0.07;
  background-image: url("data:image/svg+xml;utf8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='120'%20height='120'%3E%3Cfilter%20id='n'%3E%3CfeTurbulence%20type='fractalNoise'%20baseFrequency='0.9'%20numOctaves='2'/%3E%3C/filter%3E%3Crect%20width='120'%20height='120'%20filter='url(%23n)'%20opacity='0.6'/%3E%3C/svg%3E");
  animation: noise-shift 1.2s steps(4) infinite;
}

@keyframes noise-shift {
  0% { background-position: 0 0; }
  25% { background-position: -40px 20px; }
  50% { background-position: 30px -30px; }
  75% { background-position: -20px -40px; }
  100% { background-position: 0 0; }
}

.tear {
  position: fixed;
  left: -2%;
  width: 104%;
  height: 46px;
  top: 30%;
  z-index: 93;
  pointer-events: none;
  opacity: 0;
  background: repeating-linear-gradient(0deg, rgba(0, 229, 255, 0.12) 0 2px, rgba(255, 79, 216, 0.1) 2px 4px, transparent 4px 6px);
  mix-blend-mode: screen;
}

.tear.active {
  opacity: 1;
  animation: tear-jitter 0.12s steps(2) infinite;
}

@keyframes tear-jitter {
  0% { transform: translateX(-8px) skewX(-2deg); }
  50% { transform: translateX(6px) skewX(1deg); }
  100% { transform: translateX(-4px); }
}

.screen {
  transition: transform 0.08s, filter 0.08s;
}

.screen.torn {
  transform: translateX(3px);
  filter: hue-rotate(18deg) saturate(1.4);
}

body.flash .screen,
body.flash .topbar {
  animation: crit-flash 0.16s linear;
}

@keyframes crit-flash {
  0% { filter: brightness(2.2) hue-rotate(45deg); }
  100% { filter: none; }
}

.tracking {
  position: fixed;
  left: 0;
  right: 0;
  top: -4px;
  height: 3px;
  z-index: 94;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--pink), transparent);
  box-shadow: 0 0 12px var(--cyan);
}

.tracking.run {
  opacity: 1;
  animation: track-sweep 1.1s linear;
}

@keyframes track-sweep {
  0% { top: -4px; opacity: 1; }
  90% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* === Top bar === */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 40px;
  padding: 0 14px;
  background: rgba(5, 5, 8, 0.92);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: bold;
}

.brand-logo {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
  border: 1px solid var(--line);
}

.brand-name { white-space: nowrap; }

.topnav {
  display: flex;
  gap: 2px;
  margin-left: 8px;
}

.topnav a {
  color: var(--muted);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid transparent;
}

.topnav a:hover {
  color: var(--green);
  border-color: var(--line);
  background: var(--bg-2);
}

.topnav a.active {
  color: #04140a;
  background: var(--green);
  box-shadow: 0 0 10px rgba(57, 255, 106, 0.6);
}

.top-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.clock {
  color: var(--green);
  font-weight: bold;
}

.lang-switch a {
  color: var(--muted);
  text-decoration: none;
  padding: 2px 6px;
  border: 1px solid var(--line);
  margin-left: 4px;
}

.lang-switch a:hover { color: var(--text); }

.lang-switch a.active {
  color: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
}

/* === Layout === */
.screen {
  position: relative;
  z-index: 10;
  max-width: 980px;
  margin: 0 auto;
  padding: 96px 20px 48px;
}

/* === Hero === */
.hero {
  text-align: center;
  padding: 4vh 0 2.5rem;
}

.boot-line {
  max-width: 640px;
  margin: 0 auto 1.5rem;
  min-height: 1.5em;
  text-align: left;
  color: var(--green);
  font-size: clamp(0.8rem, 2vw, 1rem);
}

.prompt { color: var(--pink); }

.cursor {
  color: var(--green);
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.glitch {
  position: relative;
  display: inline-block;
  margin: 0.2em 0 0.3em;
  font-size: clamp(2.4rem, 9vw, 5.2rem);
  font-weight: bold;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  text-shadow:
    0 0 18px rgba(0, 229, 255, 0.55),
    0 0 42px rgba(138, 43, 226, 0.35);
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.glitch::before {
  z-index: -1;
  color: var(--pink);
  transform: translate(-2px, 0);
}

.glitch::after {
  z-index: -2;
  color: var(--cyan);
  transform: translate(2px, 0);
}

.glitch.is-glitching { animation: title-jitter 0.18s steps(2) infinite; }

.glitch.is-glitching::before {
  animation: slice-a 0.18s steps(2) infinite;
  text-shadow: -3px 0 var(--pink);
}

.glitch.is-glitching::after {
  animation: slice-b 0.15s steps(2) infinite;
  text-shadow: 3px 0 var(--cyan);
}

@keyframes slice-a {
  0% { clip-path: inset(10% 0 60% 0); transform: translate(-4px, -2px); }
  50% { clip-path: inset(50% 0 20% 0); transform: translate(4px, 1px); }
  100% { clip-path: inset(80% 0 5% 0); transform: translate(-3px, 2px); }
}

@keyframes slice-b {
  0% { clip-path: inset(60% 0 10% 0); transform: translate(4px, 2px); }
  50% { clip-path: inset(20% 0 55% 0); transform: translate(-4px, -1px); }
  100% { clip-path: inset(5% 0 80% 0); transform: translate(3px, -2px); }
}

@keyframes title-jitter {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 1px) skewX(-1deg); }
  50% { transform: translate(2px, -1px); }
  75% { transform: translate(-1px, -2px) skewX(1deg); }
  100% { transform: translate(0, 0); }
}

.tagline {
  margin-bottom: 1.8rem;
  color: var(--muted);
  font-size: clamp(0.85rem, 2.4vw, 1.05rem);
  letter-spacing: 0.12em;
}

.cta-row {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  padding: 12px 22px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: bold;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--green);
  background: var(--bg-2);
  border: 2px solid var(--green);
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--bg), 0 0 14px rgba(57, 255, 106, 0.35), inset 0 0 8px rgba(57, 255, 106, 0.15);
  transition: all 0.15s;
}

.btn:hover {
  background: var(--green);
  color: #04140a;
  box-shadow: 0 0 24px rgba(57, 255, 106, 0.8);
  transform: translate(-1px, -1px);
}

.btn:active { transform: translate(1px, 1px); }

.btn-primary {
  color: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--bg), 0 0 14px rgba(255, 209, 102, 0.35), inset 0 0 8px rgba(255, 209, 102, 0.15);
}

.btn-primary:hover {
  background: var(--gold);
  color: #1a1204;
  box-shadow: 0 0 26px rgba(255, 209, 102, 0.8);
}

/* === HUD panels === */
.hud {
  display: grid;
  grid-template-columns: minmax(0, 380px);
  justify-content: center;
  gap: 16px;
  margin: 2.5rem 0 3rem;
}

.panel {
  position: relative;
  padding: 16px;
  background: linear-gradient(180deg, rgba(20, 20, 34, 0.9), rgba(10, 10, 18, 0.95));
  border: 2px solid var(--line);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.6), 0 0 0 1px #000;
}

.panel::before {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  height: 3px;
  background: linear-gradient(90deg, var(--purple), var(--cyan), var(--pink));
}

.panel-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 0.7rem;
  font-weight: bold;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: blink 1.6s steps(1) infinite;
}

/* Dice panel */
.panel-dice { text-align: center; }

.d20-wrap {
  padding: 6px;
  background: none;
  border: none;
  cursor: pointer;
}

.d20 {
  width: 110px;
  height: 110px;
  filter: drop-shadow(0 0 10px rgba(255, 209, 102, 0.65));
  transition: transform 0.15s;
}

.d20-wrap:hover .d20 {
  transform: scale(1.06) rotate(3deg);
}

.d20-wrap.rolling .d20 { animation: dice-shake 0.42s linear; }

@keyframes dice-shake {
  0% { transform: rotate(0) scale(1); }
  25% { transform: rotate(-14deg) scale(1.12); }
  50% { transform: rotate(10deg) scale(1.06); }
  75% { transform: rotate(-6deg) scale(1.1); }
  100% { transform: rotate(0) scale(1); }
}

.lcd {
  max-width: 150px;
  margin: 10px auto 6px;
  padding: 4px 10px;
  background: #031007;
  border: 2px solid var(--line);
  box-shadow: inset 0 0 18px rgba(57, 255, 106, 0.25);
  color: var(--green);
  font-size: 2rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  text-shadow: 0 0 8px var(--green);
}

#dice-result.crit {
  color: var(--gold);
  text-shadow: 0 0 12px var(--gold);
}

#dice-result.fumble {
  color: var(--red);
  text-shadow: 0 0 12px var(--red);
}

.dice-msg {
  min-height: 1.2em;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

/* === Quest log === */
.section-title {
  margin: 0 0 16px;
  font-size: 1.1rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--green);
  text-shadow: 0 0 10px rgba(57, 255, 106, 0.5);
}

.section-title .count { color: var(--muted); }

.quest {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 10px;
  padding: 14px 16px;
  background: rgba(13, 13, 24, 0.8);
  border: 1px solid var(--line);
  border-left: 3px solid var(--purple);
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s, background 0.12s;
}

.quest:hover {
  background: rgba(18, 18, 32, 0.9);
  border-left-color: var(--cyan);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.15);
}

.quest.jittered {
  transform: translate(2px, -1px);
  border-left-color: var(--pink);
  box-shadow: 0 0 14px rgba(255, 79, 216, 0.4);
}

.quest time {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
}

.quest h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.quest-link {
  color: var(--text);
  font-weight: bold;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.quest-link:hover {
  color: var(--cyan);
  animation: rgb-split 0.35s steps(2);
}

@keyframes rgb-split {
  0% { text-shadow: none; }
  30% { text-shadow: 3px 0 var(--pink), -3px 0 var(--cyan); }
  60% { text-shadow: -3px 0 var(--pink), 3px 0 var(--cyan); }
  100% { text-shadow: none; }
}

.quest-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
}

.quest-open {
  color: var(--gold);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}

.quest-open:hover { text-shadow: 0 0 8px var(--gold); }

.questlog-empty {
  padding: 18px;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* === Bottom bar: ticker, badges, footer === */
.bottombar {
  position: relative;
  z-index: 10;
  padding: 14px 20px 18px;
  background: rgba(5, 5, 8, 0.95);
  border-top: 1px solid var(--line);
  text-align: center;
}

.ticker {
  overflow: hidden;
  white-space: nowrap;
  margin-bottom: 12px;
  padding: 6px 0;
  background: #07070d;
  border: 1px solid var(--line);
}

.ticker-inner {
  display: inline-block;
  animation: marquee 22s linear infinite;
}

.ticker-inner span {
  padding-right: 3rem;
  color: var(--green);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.badges {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.badge {
  padding: 5px 9px;
  background: linear-gradient(180deg, #14142a, #0a0a14);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.badge:nth-child(odd) {
  color: var(--cyan);
  border-color: rgba(0, 229, 255, 0.4);
}

.badge:nth-child(3n) {
  color: var(--pink);
  border-color: rgba(255, 79, 216, 0.4);
}

.footer-line {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

/* === Responsive === */
@media (max-width: 820px) {
  .quest { grid-template-columns: 1fr; gap: 6px; }
  .quest-open { justify-self: start; }
}

@media (max-width: 640px) {
  .topbar {
    height: auto;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 10px;
  }
  .topnav {
    order: 3;
    width: 100%;
    margin-left: 0;
  }
  .top-right {
    margin-left: auto;
    width: 100%;
    justify-content: space-between;
  }
  .screen { padding-top: 120px; }
  .d20 { width: 90px; height: 90px; }
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .ticker-inner { animation: none; }
}

/* === Print === */
@media print {
  .overlay, .tear, .tracking, .topbar { display: none !important; }
  .screen { padding-top: 0; }
  body { background: #fff; color: #000; }
}

/* === Single pages (post / about / 404) === */
.page-section { margin-bottom: 3rem; }

.post-panel { text-align: left; }

.post-title {
  margin-bottom: 0.4rem;
  font-size: clamp(1.5rem, 4.5vw, 2.4rem);
  text-align: left;
}

.post-date {
  display: block;
  margin-bottom: 1.2rem;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
}

.back-row { margin-top: 1.6rem; }

/* === Prose content === */
.prose {
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.8;
}

.prose p { margin-bottom: 1rem; }
.prose p:last-child { margin-bottom: 0; }

.prose a {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px dashed rgba(0, 229, 255, 0.4);
}

.prose a:hover {
  color: var(--pink);
  text-shadow: 0 0 8px var(--pink);
}

.prose h2,
.prose h3 {
  margin: 1.4rem 0 0.6rem;
  color: var(--green);
  letter-spacing: 0.1em;
}

.prose ul,
.prose ol { margin: 0 0 1rem 1.4rem; }
.prose li { margin-bottom: 0.3rem; }

.prose code {
  padding: 1px 6px;
  background: #07070d;
  border: 1px solid var(--line);
  color: var(--gold);
  font-size: 0.85em;
}

.prose pre {
  margin-bottom: 1rem;
  padding: 12px;
  overflow-x: auto;
  background: #07070d;
  border: 1px solid var(--line);
  border-left: 3px solid var(--purple);
}

.prose pre code {
  padding: 0;
  background: none;
  border: none;
}

.prose blockquote {
  margin: 0 0 1rem;
  padding: 4px 0 4px 14px;
  border-left: 3px solid var(--pink);
  color: var(--muted);
  font-style: italic;
}

.prose img {
  max-width: 100%;
  border: 1px solid var(--line);
  box-shadow: 0 0 14px rgba(138, 43, 226, 0.25);
}

.prose hr {
  margin: 1.2rem 0;
  border: none;
  border-top: 1px dashed var(--line);
}

.prose strong { color: var(--gold); }
