/* AI Agent Insider — Shared Stylesheet */

/* ── CSS Custom Properties — Dark (default) ── */
:root {
  --bg: #0f0f0f;
  --bg-card: #161616;
  --bg-code: #111111;
  --border: #222222;
  --border-light: #2a2a2a;
  --text: #e0e0e0;
  --text-muted: #888888;
  --text-dim: #555555;
  --text-hook: #c0c0c0;
  --text-strong: #f0f0f0;
  --text-em: #c0c0c0;
  --text-code: #aaaaaa;
  --text-do-this: #b0b0b0;
  --accent: #00a8ff;
  --accent-dim: rgba(0, 168, 255, 0.15);
  --font-mono: 'Courier New', 'Lucida Console', monospace;
  --font-serif: Georgia, 'Times New Roman', serif;

  /* Theme toggle */
  --toggle-bg: #222222;
  --toggle-color: #888888;
  --toggle-hover-bg: #2a2a2a;
  --toggle-hover-color: #e0e0e0;
}

/* ── CSS Custom Properties — Light ── */
[data-theme="light"] {
  --bg: #f8f8f8;
  --bg-card: #ffffff;
  --bg-code: #f0f0f0;
  --border: #d8d8d8;
  --border-light: #cccccc;
  --text: #1a1a1a;
  --text-muted: #555555;
  --text-dim: #888888;
  --text-hook: #333333;
  --text-strong: #0a0a0a;
  --text-em: #444444;
  --text-code: #444444;
  --text-do-this: #333333;
  --accent: #00a8ff;
  --accent-dim: rgba(0, 168, 255, 0.1);

  /* Theme toggle */
  --toggle-bg: #e8e8e8;
  --toggle-color: #555555;
  --toggle-hover-bg: #d8d8d8;
  --toggle-hover-color: #1a1a1a;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  line-height: 1.7;
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ── Layout ── */

.site-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Site Header ── */

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 28px 0 24px;
  margin-bottom: 48px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.site-header__name {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: normal;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.site-header__name a {
  color: inherit;
  text-decoration: none;
}

.site-header__tagline {
  font-family: var(--font-serif);
  font-size: 0.875rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Theme Toggle ── */

.theme-toggle {
  position: absolute;
  top: 28px;
  right: 0;
  background: var(--toggle-bg);
  border: 1px solid var(--border);
  color: var(--toggle-color);
  font-family: var(--font-mono);
  font-size: 14px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  user-select: none;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--toggle-hover-bg);
  color: var(--toggle-hover-color);
  border-color: var(--accent);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Site Footer ── */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0 40px;
  margin-top: 72px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}

.site-footer a {
  color: var(--text-dim);
  text-decoration: underline;
}

.site-footer a:hover {
  color: var(--text-muted);
}

/* ── Index: Hero Issue ── */

.hero-issue {
  margin-bottom: 56px;
}

.hero-issue__label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
  display: block;
}

.hero-issue__title {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  color: var(--text);
  font-weight: bold;
  margin-bottom: 6px;
  line-height: 1.3;
}

.hero-issue__title a {
  color: inherit;
  text-decoration: none;
}

.hero-issue__title a:hover {
  color: var(--accent);
}

.hero-issue__meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  margin-bottom: 20px;
}

.hero-issue__hook {
  font-size: 1.0625rem;
  color: var(--text-hook);
  line-height: 1.75;
  border-left: 2px solid var(--accent);
  padding-left: 18px;
  margin-bottom: 24px;
}

.hero-issue__cta {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-decoration: none;
  text-transform: uppercase;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
}

.hero-issue__cta:hover {
  color: var(--text-strong);
  border-color: var(--text-strong);
}

/* ── Index: Archive ── */

.archive {
  margin-bottom: 56px;
}

.archive__heading {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.archive__list {
  list-style: none;
}

.archive__item {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.archive__item-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  min-width: 56px;
  flex-shrink: 0;
}

.archive__item-title a {
  font-size: 0.9375rem;
  color: var(--text);
  text-decoration: none;
}

.archive__item-title a:hover {
  color: var(--accent);
}

.archive__item-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Support Section (replaces Subscribe CTA) ── */

.support-cta {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent);
  padding: 28px 28px 24px;
  margin-bottom: 56px;
}

.support-cta__heading {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.support-cta__copy {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.6;
}

.support-cta__buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.support-cta__btn {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 10px 20px;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease;
  cursor: pointer;
  white-space: nowrap;
}

.support-cta__btn:hover {
  background: var(--accent);
  color: #000;
  text-decoration: none;
}

.support-cta__btn--primary {
  background: var(--accent);
  color: #000;
}

.support-cta__btn--primary:hover {
  background: transparent;
  color: var(--accent);
}

/* ── Issue Page ── */

.issue-header {
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.issue-header__number {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
  display: block;
}

.issue-header__title {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  color: var(--text);
  font-weight: bold;
  line-height: 1.3;
  margin-bottom: 8px;
}

.issue-header__meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

/* ── Issue Body ── */

.issue-body {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.78;
  color: var(--text);
}

.issue-body p {
  margin-bottom: 1.2em;
}

.issue-body .hook {
  font-size: 1.0625rem;
  color: var(--text-hook);
  border-left: 2px solid var(--accent);
  padding-left: 18px;
  margin-bottom: 2em;
  font-style: italic;
}

.issue-section {
  margin-bottom: 2.5em;
}

.issue-section__label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-bottom: 18px;
  display: block;
}

.issue-section h3 {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text);
  font-weight: bold;
  line-height: 1.4;
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}

.playbook-block {
  margin-bottom: 2em;
  padding-bottom: 2em;
  border-bottom: 1px solid var(--border);
}

.playbook-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.do-this {
  background: var(--bg-card);
  border-left: 2px solid var(--border-light);
  padding: 12px 16px;
  font-size: 0.875rem;
  font-family: var(--font-mono);
  color: var(--text-do-this);
  line-height: 1.65;
  margin-top: 12px;
}

.do-this strong,
.do-this b {
  color: var(--accent);
}

.steal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  padding: 22px 24px;
}

.steal-box p {
  margin-bottom: 1em;
}

.steal-box p:last-child {
  margin-bottom: 0;
}

pre, .code-block {
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 16px 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-code);
  line-height: 1.8;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 1em 0;
}

strong, b {
  font-weight: bold;
  color: var(--text-strong);
}

em, i {
  font-style: italic;
  color: var(--text-em);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── Issue nav (prev/next) ── */

.issue-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0;
  border-top: 1px solid var(--border);
  margin-top: 48px;
  gap: 16px;
}

.issue-nav__link {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.issue-nav__link:hover {
  color: var(--accent);
}

.issue-nav__link--prev {
  align-items: flex-start;
}

.issue-nav__link--next {
  align-items: flex-end;
}

.issue-nav__dir {
  color: var(--text-dim);
  font-size: 10px;
}

.issue-nav__label {
  color: inherit;
}

.issue-nav__spacer {
  flex: 1;
}

/* ── Responsive ── */

@media (max-width: 600px) {
  html {
    font-size: 15px;
  }

  .site-wrap {
    padding: 0 16px;
  }

  .site-header {
    padding: 20px 0 18px;
    margin-bottom: 36px;
  }

  .hero-issue__title {
    font-size: 1.25rem;
  }

  .issue-header__title {
    font-size: 1.2rem;
  }

  .archive__item {
    flex-wrap: wrap;
    gap: 4px;
  }

  .archive__item-date {
    margin-left: 0;
    width: 100%;
    font-size: 10px;
  }

  .support-cta__buttons {
    flex-direction: column;
  }

  .support-cta__btn {
    text-align: center;
  }

  .issue-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
  }

  .issue-nav__link--next {
    align-items: flex-start;
  }

  .theme-toggle {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }
}

@media (min-width: 601px) and (max-width: 768px) {
  .site-wrap {
    padding: 0 24px;
  }
}

/* Crypto wallets */
.support-cta__crypto {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border, #222);
}
.support-cta__crypto-heading {
  font-family: var(--font-heading, 'Courier New', monospace);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-accent, #00a8ff);
  margin-bottom: 0.75rem;
}
.support-cta__wallet {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}
.support-cta__coin {
  font-family: var(--font-heading, 'Courier New', monospace);
  font-weight: bold;
  min-width: 3.5rem;
  color: var(--color-accent, #00a8ff);
}
.support-cta__wallet code {
  font-size: 0.75rem;
  word-break: break-all;
  color: var(--color-muted, #888);
  background: var(--color-surface, #1a1a1a);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  user-select: all;
  cursor: pointer;
}

/* ── Copy button ── */
.copy-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}
.support-cta__wallet .copy-wrap {
  flex: 1;
  min-width: 0;
}
.btn-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  line-height: 1.6;
}
.btn-copy:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-copy.copied {
  border-color: #22c55e;
  color: #22c55e;
}
pre .btn-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 10px;
}
pre {
  position: relative;
}

/* ── Reading time ── */
.reading-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  margin-top: 4px;
}
.archive__item-read {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* ── Table of Contents ── */
.toc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  padding: 0;
  margin-bottom: 2em;
  font-family: var(--font-mono);
  font-size: 12px;
}
.toc summary {
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 10px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.toc summary::-webkit-details-marker { display: none; }
.toc summary::before {
  content: '▶';
  font-size: 8px;
  transition: transform 0.15s ease;
  color: var(--accent);
}
details.toc[open] summary::before {
  transform: rotate(90deg);
}
.toc summary:hover {
  color: var(--text-muted);
}
.toc ol {
  list-style: none;
  padding: 0 16px 12px 24px;
  margin: 0;
  counter-reset: toc-counter;
}
.toc ol li {
  counter-increment: toc-counter;
  padding: 3px 0;
}
.toc ol li a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
}
.toc ol li a:hover {
  color: var(--accent);
}

/* ── Social share buttons ── */
.share-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 32px 0 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.share-bar__label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-right: 4px;
}
.btn-share {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 5px 11px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: transparent;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.btn-share:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}
.btn-share.copied {
  border-color: #22c55e;
  color: #22c55e;
}

/* ── Keyboard nav hint ── */
.kbd-hint {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  padding: 12px 0 4px;
  opacity: 0.6;
}

/* ── Search bar ── */
.search-wrap {
  position: relative;
  margin: 0 0 32px;
}
.search-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 10px 38px 10px 14px;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
  letter-spacing: 0.04em;
}
.search-input:focus {
  border-color: var(--accent);
}
.search-input::placeholder {
  color: var(--text-dim);
}
.search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 14px;
  pointer-events: none;
}
.search-results {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  z-index: 100;
  max-height: 320px;
  overflow-y: auto;
  display: none;
}
.search-results.open {
  display: block;
}
.search-result-item {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background 0.1s;
}
.search-result-item:last-child {
  border-bottom: none;
}
.search-result-item:hover,
.search-result-item.active {
  background: var(--accent-dim);
}
.search-result-item__title {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 2px;
}
.search-result-item__meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.search-result-item__excerpt {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-result-item__excerpt mark {
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 2px;
}
.search-no-results {
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

/* ── Back to top button ── */
.back-to-top {
  position: fixed;
  bottom: 28px;
  right: 24px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, background 0.15s, color 0.15s, border-color 0.15s;
  z-index: 99;
  text-decoration: none;
}
.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}
.back-to-top:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* ── Print styles ── */
@media print {
  .theme-toggle,
  .issue-nav,
  .back-to-top,
  .share-bar,
  .kbd-hint,
  .support-cta,
  .search-wrap,
  .btn-copy,
  .toc {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 12pt;
  }

  .site-wrap {
    max-width: 100%;
    padding: 0;
  }

  a {
    color: #000 !important;
    text-decoration: underline !important;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #555;
  }

  /* Don't show URL for nav/internal links */
  .site-header a::after,
  .site-footer a::after {
    content: none;
  }

  pre, .code-block {
    background: #f5f5f5 !important;
    color: #000 !important;
    border: 1px solid #ccc !important;
    page-break-inside: avoid;
  }

  .issue-body {
    color: #000 !important;
  }

  .issue-body p,
  .issue-body h2,
  .issue-body h3 {
    color: #000 !important;
  }

  .issue-body .hook {
    color: #222 !important;
    border-left-color: #999 !important;
  }

  h1, h2, h3 {
    page-break-after: avoid;
  }

  .site-header {
    border-bottom: 1px solid #ccc;
  }

  .site-footer {
    border-top: 1px solid #ccc;
    color: #666 !important;
  }
}
