/* itsbroken.ai — terminal-punk Ghost theme
   Owns the markup, no !important wars. */

@font-face {
  font-family: 'Glitch Pixelated';
  src: url('../fonts/glitch-regular-webfont.woff2') format('woff2'),
       url('../fonts/glitch-regular-webfont.woff')  format('woff');
  font-weight: normal; font-style: normal; font-display: swap;
}

:root {
  --font-display: 'Glitch Pixelated', 'VT323', monospace;
  --font-heading: 'Sora', -apple-system, sans-serif;
  --font-body:    'Inter', -apple-system, sans-serif;
  --font-mono:    'Space Mono', 'Courier New', monospace;

  --amber:       #D4A84B;
  --amber-dim:   #8a6e30;
  --amber-glow:  rgba(212, 168, 75, 0.15);
  --deep-amber:  #C65D07;
  --bg:          #0a0a0a;
  --bg-2:        #111111;
  --bg-3:        #1a1a1a;
  --surface:     #151515;
  --text:        #e0d5c0;
  --text-2:      #b8a88a;
  --text-muted:  #6b5e4a;
  --border:      #2a2218;
  --code-bg:     #151510;

  --nav-bg:      rgba(10,10,10,0.85);
  color-scheme: dark;
  --ghost-accent-color: var(--amber);
}

/* ── Light theme (complements forge.itsbroken.ai light) ── */
html.light {
  --bg: #faf8f5;
  --bg-2: #f0ece5;
  --bg-3: #e8e2d8;
  --surface: #ffffff;
  --text: #2a2218;
  --text-2: #5a4e3a;
  --text-muted: #8a7e6a;
  --border: #e0d8c8;
  --code-bg: #f5f0e8;
  --amber-glow: rgba(212,168,75,0.18);
  --nav-bg: rgba(250,248,245,0.88);
  color-scheme: light;
}
html.light .ib-atmos-vignette { display: none; }
html.light .ib-atmos-dots {
  background: radial-gradient(circle, rgba(0,0,0,0.045) 1px, transparent 1px);
  background-size: 24px 24px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.ib-body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--amber); text-decoration: none; transition: color .2s; }
a:hover { color: var(--deep-amber); }
::selection { background: var(--amber); color: var(--bg); }

/* ── Atmosphere ── */
.ib-atmos-dots {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 24px 24px;
}
.ib-atmos-vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 9998;
  background: radial-gradient(ellipse at center, transparent 0%, rgba(0,0,0,0.35) 100%);
}

/* ── Nav ── */
.ib-nav {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: var(--nav-bg);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.ib-nav-logo img { image-rendering: pixelated; display: block; }
.ib-nav-menu ul,
.ib-nav-menu .nav,
.ib-nav-menu nav { display: flex; gap: 28px; list-style: none; padding: 0; margin: 0; }
.ib-nav-menu a,
.ib-nav-menu li a {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ib-nav-menu a:hover { color: var(--amber); }

.ib-nav-actions { display: flex; align-items: center; gap: 16px; }
.ib-search-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-2);
  font-family: var(--font-mono); font-size: 12px;
  padding: 7px 12px; cursor: pointer; border-radius: 2px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.ib-search-btn:hover { border-color: var(--amber-dim); color: var(--amber); }
.ib-theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; line-height: 1;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-2); cursor: pointer; border-radius: 2px; font-size: 15px;
}
.ib-theme-toggle:hover { border-color: var(--amber-dim); color: var(--amber); }
.ib-nav-signin {
  font-family: var(--font-mono); font-size: 13px; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.ib-nav-signin:hover { color: var(--amber); }
.ib-nav-subscribe {
  background: var(--amber); color: var(--bg);
  padding: 8px 16px; border-radius: 2px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
}
.ib-nav-subscribe:hover { background: var(--deep-amber); color: var(--bg); }

/* ── Ticker ── */
.ib-ticker {
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  overflow: hidden; position: sticky; top: 64px; z-index: 999;
}
.ib-ticker-track {
  display: flex; white-space: nowrap; padding: 10px 0;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.18em;
  color: var(--amber);
  animation: ib-marquee 50s linear infinite;
}
.ib-ticker-track > span:first-child { padding-left: 28px; }
@keyframes ib-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ── Main ── */
.ib-main { position: relative; z-index: 2; max-width: 1280px; margin: 0 auto; padding: 0 28px; }

/* ── Hero ── */
.ib-hero {
  display: grid; grid-template-columns: 1.15fr 1fr; gap: 44px;
  padding: 64px 0 48px;
}
.ib-hero-ascii {
  color: var(--amber); font-family: var(--font-mono); font-size: 13px; line-height: 1.3;
  margin: 0 0 28px; opacity: 0.85; text-shadow: 0 0 12px var(--amber-glow);
}
.ib-hero-eyebrow {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em;
  color: var(--amber-dim); text-transform: uppercase; margin-bottom: 12px;
}
.ib-hero-h1 {
  font-family: var(--font-heading); font-weight: 700; font-size: 56px; line-height: 1.05;
  letter-spacing: -0.015em; color: var(--text); margin: 0;
  display: flex; flex-direction: column;
}
.ib-hero-h1 .accent, .ib-hero-h1 .ib-hero-line.accent { color: var(--amber); }
.ib-hero-h1 .ib-hero-line { display: block; }
.ib-hero-progress { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; color: var(--amber-dim); text-transform: uppercase; }
.ib-hero-progress-bar { flex: 1; height: 1px; background: var(--border); position: relative; overflow: hidden; max-width: 240px; }
.ib-hero-progress-fill { position: absolute; inset: 0; background: var(--amber); transform-origin: left; transform: scaleX(0); }
@keyframes tp-hero-bar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.ib-caret-lg {
  display: inline-block; width: 10px; height: 42px;
  background: var(--amber); vertical-align: middle; margin-left: 4px;
  animation: ib-blink 1s steps(2) infinite;
}
.ib-caret {
  display: inline-block; width: 6px; height: 12px;
  background: var(--amber); vertical-align: middle; margin-left: 4px;
  animation: ib-blink 1s steps(2) infinite;
}
@keyframes ib-blink { 50% { opacity: 0; } }

.ib-hero-lede {
  font-size: 16px; line-height: 1.6; color: var(--text-2); max-width: 540px; margin: 22px 0 0;
}
.ib-hero-lede .prompt { color: var(--amber); font-family: var(--font-mono); }

.ib-hero-cta { display: flex; gap: 12px; margin-top: 28px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.ib-btn-primary { background: var(--amber); color: var(--bg); padding: 12px 20px; font-weight: 700; border-radius: 2px; }
.ib-btn-primary:hover { background: var(--deep-amber); color: var(--bg); }
.ib-btn-secondary { border: 1px solid var(--amber-dim); color: var(--amber); padding: 11px 20px; border-radius: 2px; }
.ib-btn-secondary:hover { border-color: var(--amber); color: var(--amber); }

/* Merch link — bottom of the hero's left column */
.ib-hero-merch {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 22px;
  align-self: flex-start; width: fit-content;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--amber); border: 1px solid var(--amber-dim); padding: 10px 18px; border-radius: 2px;
  transition: background .2s, color .2s, border-color .2s;
}
.ib-hero-merch:hover { background: var(--amber); color: var(--bg); border-color: var(--amber); }

.ib-hero-right { display: flex; flex-direction: column; gap: 18px; }
.ib-hero-logo {
  display: flex; justify-content: center; padding: 24px;
  border: 1px solid var(--border); background: var(--bg-2);
}
.ib-hero-logo img { width: 220px; height: 220px; image-rendering: pixelated; }

/* ── Live Tail ── */
.ib-tail { border: 1px solid var(--border); padding: 16px; background: var(--code-bg); font-family: var(--font-mono); font-size: 12px; }
.ib-tail-head { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: 0.16em; color: var(--amber-dim); margin-bottom: 12px; text-transform: uppercase; }
.ib-tail-status { color: var(--amber); }
.ib-tail-body { line-height: 1.8; color: var(--text-2); height: 220px; overflow: hidden; }
.ib-tail-line .t { color: var(--text-muted); }
.ib-tail-line .who { color: var(--amber); }
.ib-tail-line .who.warn { color: var(--deep-amber); }
.ib-tail-line .who.err { color: #ff6b35; }
.ib-tail-line .msg { color: var(--text); }
.ib-tail-line .msg.err { color: #ff6b35; }
.ib-tail-fadein { opacity: 0; animation: ib-fadein .4s forwards; }
@keyframes ib-fadein { to { opacity: 1; } }

/* ── Feed Section ── */
.ib-feed-section { padding: 48px 0 32px; }
.ib-section-eyebrow {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.16em;
  color: var(--amber); text-transform: uppercase; margin-bottom: 22px;
}
.ib-section-eyebrow .muted { color: var(--text-muted); margin-left: 12px; }

.ib-feed-head, .ib-row {
  display: grid;
  grid-template-columns: 60px 110px 140px 1fr 140px;
  gap: 20px; padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.ib-feed-head {
  border-top: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.18em;
  color: var(--text-muted); text-transform: uppercase;
}
.ib-feed-head .right { text-align: right; }

.ib-feed { counter-reset: ib-row; }
.ib-row { counter-increment: ib-row; padding: 20px 14px; transition: background .2s, box-shadow .2s; position: relative; }
.ib-row:nth-child(odd) { background: rgba(212,168,75,0.02); }
.ib-row:hover { background: rgba(212,168,75,0.06); box-shadow: inset 3px 0 0 var(--amber); }
.ib-row-idx::before { content: counter(ib-row, decimal-leading-zero); font-family: var(--font-mono); font-size: 12px; color: var(--amber); letter-spacing: 0.06em; }
.ib-row-date { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); }
.ib-row-tag { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--amber-dim); }
.ib-row-title-link { display: block; min-width: 0; }
.ib-row-title { font-family: var(--font-display); font-weight: 400; font-size: 24px; color: var(--text); margin: 0; line-height: 1.1; letter-spacing: 0.02em; }
.ib-row-excerpt { font-family: var(--font-body); font-size: 14px; color: var(--text-2); line-height: 1.5; margin: 6px 0 0; max-width: 720px; }
.ib-row-author { font-family: var(--font-mono); font-size: 11px; color: var(--text-2); text-align: right; }

/* Glitch chromatic burst on titles */
@keyframes ib-glitch-chromatic {
  0%, 95% { text-shadow: none; }
  95.5% { text-shadow: -2px 0 rgba(255,107,53,0.7), 2px 0 rgba(198,93,7,0.7); }
  96% { text-shadow: 2px 0 rgba(255,107,53,0.5), -1px 0 rgba(212,168,75,0.5); }
  96.5% { text-shadow: -1px 0 rgba(198,93,7,0.8), 3px 0 rgba(255,107,53,0.4); }
  97%, 100% { text-shadow: none; }
}
.ib-row-title, .ib-post-title { animation: ib-glitch-chromatic 55s infinite; }
.ib-row:nth-child(2n) .ib-row-title { animation-delay: 12s; }
.ib-row:nth-child(3n) .ib-row-title { animation-delay: 28s; }
.ib-row:nth-child(4n) .ib-row-title { animation-delay: 38s; }

/* ── Post ── */
.ib-post { max-width: 760px; margin: 0 auto; padding: 48px 0 64px; }
.ib-post-meta { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em; color: var(--amber); text-transform: uppercase; margin-bottom: 16px; }
.ib-post-tag { color: var(--amber); }
.ib-post-title { font-family: var(--font-display); font-size: 56px; font-weight: 400; line-height: 1.05; color: var(--text); margin: 0; letter-spacing: 0.02em; }
.ib-post-lede { font-family: var(--font-body); font-style: italic; font-size: 19px; line-height: 1.55; color: var(--text-2); margin-top: 18px; }
.ib-post-byline { display: flex; align-items: center; gap: 12px; margin-top: 24px; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; }
.ib-byline-mark { width: 28px; height: 28px; border: 1px solid var(--amber-dim); color: var(--amber); display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 11px; text-transform: uppercase; max-width: 28px; }
.ib-byline-mark img { width: 100%; height: 100%; object-fit: cover; }
.ib-post-feature { margin: 32px 0 0; }
.ib-post-feature img { width: 100%; height: auto; display: block; border: 1px solid var(--border); }
.ib-post-body { font-size: 17px; line-height: 1.8; color: var(--text); margin-top: 32px; }
.ib-post-body h2 { font-family: var(--font-heading); font-size: 30px; font-weight: 600; margin-top: 40px; color: var(--text); }
.ib-post-body h3 { font-family: var(--font-heading); font-size: 22px; color: var(--text); }
.ib-post-body strong { color: var(--amber); }
.ib-post-body blockquote { border-left: 3px solid var(--amber); padding-left: 1.5rem; font-style: italic; color: var(--text-2); margin: 24px 0; }
.ib-post-body code { font-family: var(--font-mono); background: var(--code-bg); border: 1px solid var(--border); padding: .15em .4em; border-radius: 2px; color: var(--amber); font-size: .88em; }
.ib-post-body pre { font-family: var(--font-mono); background: var(--code-bg); border: 1px solid var(--border); padding: 18px; color: var(--text); overflow: auto; }
.ib-post-body pre code { background: transparent; border: 0; padding: 0; color: inherit; }
.ib-post-body a { border-bottom: 1px solid var(--amber-dim); }
.ib-post-body img { max-width: 100%; height: auto; border: 1px solid var(--border); }

/* Koenig editor required classes */
.kg-width-wide { width: 100%; max-width: 1040px; margin-left: 50%; transform: translateX(-50%); }
.kg-width-full { width: 100vw; max-width: none; margin-left: 50%; transform: translateX(-50%); }
.kg-image-card img { display: block; margin: 0 auto; }
.kg-bookmark-card { border: 1px solid var(--border); background: var(--bg-2); display: flex; }
.kg-bookmark-card a { display: flex; width: 100%; color: var(--text); }
.kg-bookmark-content { padding: 20px; flex: 1; }
.kg-bookmark-thumbnail img { max-width: 200px; object-fit: cover; }
.kg-gallery-container { display: flex; flex-direction: column; max-width: 1040px; margin-left: 50%; transform: translateX(-50%); }
.kg-gallery-row { display: flex; flex-direction: row; justify-content: center; }
.kg-gallery-image img { display: block; margin: 0; width: 100%; height: 100%; }
.kg-callout-card { padding: 16px 20px; border-left: 3px solid var(--amber); background: var(--bg-2); margin: 24px 0; }
.kg-toggle-card { border: 1px solid var(--border); padding: 16px; margin: 24px 0; background: var(--bg-2); }
.kg-button-card a { display: inline-block; background: var(--amber); color: var(--bg); padding: 12px 24px; font-family: var(--font-mono); text-transform: uppercase; }

/* ── CTA / Subscribe inline ── */
.ib-cta { margin: 56px 0 0; padding: 48px 36px; border: 1px solid var(--border); background: var(--bg-2); animation: ib-cta-breathe 4s ease-in-out infinite; }
@keyframes ib-cta-breathe {
  0%,100% { box-shadow: 0 0 0 0 rgba(212,168,75,0); }
  50%     { box-shadow: 0 0 30px 5px rgba(212,168,75,0.08); }
}
.ib-cta-eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em; color: var(--amber); text-transform: uppercase; margin-bottom: 8px; }
.ib-cta-title { font-family: var(--font-display); font-size: 44px; color: var(--text); margin: 0 0 12px; letter-spacing: 0.02em; font-weight: 400; }
.ib-cta-copy { font-family: var(--font-body); font-size: 16px; color: var(--text-2); margin: 0 0 24px; max-width: 520px; }
.ib-cta-form { display: flex; max-width: 520px; border: 1px solid var(--amber-dim); }
.ib-cta-prompt { padding: 14px; color: var(--amber); font-family: var(--font-mono); }
.ib-cta-input { flex: 1; padding: 14px 4px; font-family: var(--font-mono); color: var(--text); background: transparent; border: none; outline: none; font-size: 14px; }
.ib-cta-input::placeholder { color: var(--text-muted); }
.ib-cta-btn { padding: 14px 24px; background: var(--amber); color: var(--bg); border: none; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.1em; font-weight: 700; text-transform: uppercase; cursor: pointer; }
.ib-cta-btn:hover { background: var(--deep-amber); }

/* ── Archive (tag/author) ── */
.ib-archive { padding: 56px 0 24px; }
.ib-archive-eyebrow { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.16em; color: var(--amber); text-transform: uppercase; margin-bottom: 8px; }
.ib-archive-title { font-family: var(--font-display); font-size: 56px; font-weight: 400; color: var(--text); margin: 0; letter-spacing: 0.02em; }
.ib-archive-desc { font-family: var(--font-body); font-size: 17px; color: var(--text-2); max-width: 640px; margin-top: 12px; }

/* ── Error ── */
.ib-error { padding: 96px 0; text-align: center; }
.ib-error-ascii { color: var(--amber); font-family: var(--font-mono); font-size: 14px; line-height: 1.4; margin: 0 0 32px; }
.ib-error-title { font-family: var(--font-display); font-size: 44px; color: var(--text); margin: 0 0 12px; }
.ib-error-copy { font-family: var(--font-mono); color: var(--text-2); }
.ib-error-copy kbd { background: var(--bg-3); color: var(--amber); border: 1px solid var(--border); padding: 2px 6px; font-family: var(--font-mono); border-radius: 2px; }

/* ── Footer ── */
/* Defensive: if footer markup got pasted into a post/page body, hide it.
   The real footer is rendered once by default.hbs. */
.gh-content .ib-footer,
.ib-post-body .ib-footer,
.ib-page-body .ib-footer { display: none !important; }

/* Cheatsheet page does a fullscreen takeover; hide theme chrome behind it */
body.page-cheatsheet > .ib-footer,
body.page-cheatsheet > .ib-ticker,
body.page-cheatsheet > .ib-nav,
body.page-cheatsheet > .ib-atmos-dots,
body.page-cheatsheet > .ib-atmos-vignette { display: none !important; }
body.page-cheatsheet { overflow: hidden !important; }

.ib-footer {
  border-top: 1px solid var(--border); padding: 32px 28px;
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-mono); font-size: 11px; color: var(--text-muted);
  position: relative; z-index: 2;
}
.ib-footer-left { display: flex; align-items: center; gap: 14px; }
.ib-footer-logo { image-rendering: pixelated; opacity: 0.7; }
.ib-footer-right { display: flex; gap: 18px; }
.ib-footer-right a { color: var(--text-muted); }
.ib-footer-right a:hover { color: var(--amber); }
.ib-footer-meta { color: var(--text-muted); }

/* ── Pagination ── */
.pagination { display: flex; justify-content: center; gap: 24px; margin-top: 32px; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; }
.pagination a { color: var(--amber); border: 1px solid var(--amber-dim); padding: 8px 16px; }
.pagination a:hover { background: var(--amber); color: var(--bg); }
.pagination .page-number { color: var(--text-2); padding: 8px 16px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--amber-dim); }

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; transition-duration: 0s !important; }
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .ib-hero { grid-template-columns: 1fr; gap: 32px; padding: 40px 0 32px; }
  .ib-hero-h1 { font-size: 40px; }
  .ib-post-title, .ib-archive-title { font-size: 36px; }
}
@media (max-width: 768px) {
  .ib-nav { padding: 12px 16px; flex-wrap: wrap; gap: 12px; }
  .ib-nav-menu { display: none; }
  .ib-main { padding: 0 16px; }
  .ib-feed-head { display: none; }
  .ib-row {
    grid-template-columns: 40px 1fr;
    grid-template-areas: 'idx title' 'idx meta' 'idx excerpt';
    gap: 4px 12px; padding: 16px 8px;
  }
  .ib-row-idx { grid-area: idx; align-self: start; padding-top: 4px; }
  .ib-row-title-link { grid-area: title; }
  .ib-row-date, .ib-row-tag, .ib-row-author { display: inline-block; font-size: 10px; }
  .ib-row-date { grid-area: meta; }
  .ib-row-tag { grid-area: meta; margin-left: 10px; }
  .ib-row-author { display: none; }
  .ib-row-title { font-size: 18px; }
}
