/* =========================================================================
   pyjokes — terminal theme
   Dark, monospace, honey/amber accent. No external deps.
   ========================================================================= */

:root {
  color-scheme: light dark;

  --content-width: 960px;
  --radius: 12px;
  --radius-sm: 8px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo,
    Consolas, "Liberation Mono", monospace;

  /* light palette (default) — a "light editor" take on the terminal theme */
  --bg: #fbfaf6;
  --surface: #f3f1ea;
  --surface-2: #e9e5da;
  --text: #1c1b17;
  --muted: #6c6657;
  --border: #e2ddcf;
  --accent: #b5820c;      /* deep honey for contrast on light */
  --accent-soft: rgba(181, 130, 12, 0.12);
  --term-green: #1a7f4b;  /* prompt / output */
  --term-red: #ff5f56;
  --term-yellow: #ffbd2e;
  --term-grn: #27c93f;
  --code-bg: #f6f3ec;
  --nav-bg: rgba(251, 250, 246, 0.85);
  --selection: rgba(181, 130, 12, 0.22);
  --shadow: 0 1px 2px rgba(28, 26, 20, 0.06), 0 12px 32px rgba(28, 26, 20, 0.1);

  /* syntax (Pygments) — light */
  --syn-comment: #6a737d;
  --syn-keyword: #d73a49;
  --syn-string: #032f62;
  --syn-number: #005cc5;
  --syn-func: #6f42c1;
  --syn-class: #6f42c1;
  --syn-builtin: #005cc5;
  --syn-var: #e36209;
  --syn-op: #d73a49;
  --syn-tag: #22863a;
  --syn-err: #b31d28;
}

/* Dark palette, applied when the visitor explicitly chooses dark. */
:root[data-theme="dark"] {
  --bg: #0e1016;
  --surface: #161922;
  --surface-2: #1f2430;
  --text: #e8e4d8;
  --muted: #99a0ad;
  --border: #2a3040;
  --accent: #f6c343;      /* honey / bee */
  --accent-soft: rgba(246, 195, 67, 0.14);
  --term-green: #5ce08f;
  --term-red: #ff5f56;
  --term-yellow: #ffbd2e;
  --term-grn: #27c93f;
  --code-bg: #0a0c11;
  --nav-bg: rgba(14, 16, 22, 0.85);
  --selection: rgba(246, 195, 67, 0.28);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.45);

  --syn-comment: #8b949e;
  --syn-keyword: #ff7b72;
  --syn-string: #a5d6ff;
  --syn-number: #79c0ff;
  --syn-func: #d2a8ff;
  --syn-class: #f0883e;
  --syn-builtin: #79c0ff;
  --syn-var: #ffa657;
  --syn-op: #ff7b72;
  --syn-tag: #7ee787;
  --syn-err: #ffa198;
}

/* Auto mode: no explicit choice -> follow the OS preference. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0e1016;
    --surface: #161922;
    --surface-2: #1f2430;
    --text: #e8e4d8;
    --muted: #99a0ad;
    --border: #2a3040;
    --accent: #f6c343;
    --accent-soft: rgba(246, 195, 67, 0.14);
    --term-green: #5ce08f;
    --term-red: #ff5f56;
    --term-yellow: #ffbd2e;
    --term-grn: #27c93f;
    --code-bg: #0a0c11;
    --nav-bg: rgba(14, 16, 22, 0.85);
    --selection: rgba(246, 195, 67, 0.28);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.45);

    --syn-comment: #8b949e;
    --syn-keyword: #ff7b72;
    --syn-string: #a5d6ff;
    --syn-number: #79c0ff;
    --syn-func: #d2a8ff;
    --syn-class: #f0883e;
    --syn-builtin: #79c0ff;
    --syn-var: #ffa657;
    --syn-op: #ff7b72;
    --syn-tag: #7ee787;
    --syn-err: #ffa198;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 50% -200px, rgba(246, 195, 67, 0.08), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--selection);
}

img {
  max-width: 100%;
  height: auto;
}

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

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-mono);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text);
  overflow-wrap: break-word;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.container {
  width: 100%;
  max-width: var(--content-width);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

.site-main {
  flex: 1 0 auto;
}

/* -------------------------------------------------------------------------
   Nav
   ------------------------------------------------------------------------- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--nav-bg);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-nav .container {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 60px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-right: auto;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}

.brand img {
  width: 30px;
  height: 30px;
}

.brand .accent {
  color: var(--accent);
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
}

.nav-links a {
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.nav-links a:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 38px;
  height: 38px;
  margin-left: 0.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  background: var(--surface-2);
  color: var(--text);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* Show the icon for the theme you'd switch TO: moon while light, sun while dark. */
.theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-sun {
    display: block;
  }
  :root:not([data-theme]) .theme-toggle .icon-moon {
    display: none;
  }
}

/* -------------------------------------------------------------------------
   Hero + terminal joke box
   ------------------------------------------------------------------------- */
.hero {
  text-align: center;
  padding: 3.5rem 0 1rem;
}

.hero img.logo {
  width: 110px;
  height: auto;
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  margin: 0;
}

.hero h1 .cursor {
  color: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}

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

.hero .tagline {
  color: var(--muted);
  font-size: 1.1rem;
  margin: 0.5rem 0 2rem;
}

.terminal {
  max-width: 720px;
  margin: 0 auto;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-align: left;
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.terminal-bar .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
}

.terminal-bar .dot:nth-child(1) {
  background: var(--term-red);
}
.terminal-bar .dot:nth-child(2) {
  background: var(--term-yellow);
}
.terminal-bar .dot:nth-child(3) {
  background: var(--term-grn);
}

.terminal-bar .terminal-title {
  margin-left: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.terminal-body {
  padding: 1.25rem 1.35rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.98rem;
  line-height: 1.7;
}

.terminal-body .term-cmd {
  color: var(--muted);
}

.terminal-body .term-cmd .prompt {
  color: var(--accent);
  font-weight: 700;
  margin-right: 0.4rem;
}

#pyjoke {
  margin: 0.4rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--term-green);
  background: none;
  border: 0;
  padding: 0;
  font-family: var(--font-mono);
}

#pyjoke::before {
  content: "> ";
  color: var(--accent);
}

#pyjoke code {
  font: inherit;
  color: inherit;
  background: none;
  padding: 0;
}

.hero .install {
  margin-top: 1.5rem;
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 0.95rem;
}

.hero .install code {
  color: var(--accent);
}

/* -------------------------------------------------------------------------
   Sections
   ------------------------------------------------------------------------- */
.section {
  padding: 3rem 0;
}

.section + .section {
  border-top: 1px solid var(--border);
}

.section-head {
  text-align: center;
  margin-bottom: 2rem;
}

.section-head h2 {
  font-size: 1.8rem;
  margin: 0;
}

.section-head h2::before {
  content: "# ";
  color: var(--accent);
}

/* friends / card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.card .thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  margin-bottom: 1rem;
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.card .thumb img {
  max-height: 100%;
  width: auto;
  object-fit: contain;
}

.card h3 {
  font-size: 1.1rem;
  margin: 0 0 0.35rem;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

/* -------------------------------------------------------------------------
   Prose (rendered markdown: home usage, api, story, society)
   ------------------------------------------------------------------------- */
.prose {
  font-size: 1.05rem;
  line-height: 1.75;
  overflow-wrap: break-word;
}

.prose > :first-child {
  margin-top: 0;
}

.prose h2 {
  font-size: 1.5rem;
  margin: 2.25rem 0 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.prose h3 {
  font-size: 1.2rem;
  margin: 1.75rem 0 0.5rem;
}

.prose p {
  margin: 1.1rem 0;
}

.prose ul,
.prose ol {
  margin: 1.1rem 0;
  padding-left: 1.4rem;
}

.prose li + li {
  margin-top: 0.35rem;
}

.prose img {
  border-radius: var(--radius-sm);
}

.prose a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* inline code + code blocks */
code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

.prose code {
  background: var(--surface-2);
  padding: 0.15em 0.4em;
  border-radius: 5px;
  color: var(--accent);
}

.codehilite,
.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.15rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.6;
}

.codehilite pre {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  overflow: visible;
}

.codehilite code,
.prose pre code {
  background: none;
  padding: 0;
  color: var(--text);
  font-size: inherit;
}

/* Pygments tokens */
.codehilite .c, .codehilite .ch, .codehilite .cm, .codehilite .cp,
.codehilite .cpf, .codehilite .c1, .codehilite .cs { color: var(--syn-comment); font-style: italic; }
.codehilite .k, .codehilite .kc, .codehilite .kd, .codehilite .kn,
.codehilite .kp, .codehilite .kr { color: var(--syn-keyword); }
.codehilite .kt { color: var(--syn-class); }
.codehilite .o, .codehilite .ow { color: var(--syn-op); }
.codehilite .s, .codehilite .sa, .codehilite .sb, .codehilite .sc,
.codehilite .dl, .codehilite .sd, .codehilite .s2, .codehilite .se,
.codehilite .sh, .codehilite .si, .codehilite .sx, .codehilite .sr,
.codehilite .s1, .codehilite .ss { color: var(--syn-string); }
.codehilite .m, .codehilite .mb, .codehilite .mf, .codehilite .mh,
.codehilite .mi, .codehilite .mo, .codehilite .il { color: var(--syn-number); }
.codehilite .nb, .codehilite .bp { color: var(--syn-builtin); }
.codehilite .nf, .codehilite .fm { color: var(--syn-func); }
.codehilite .nc, .codehilite .nn, .codehilite .no, .codehilite .ne { color: var(--syn-class); }
.codehilite .nd, .codehilite .na { color: var(--syn-func); }
.codehilite .nt { color: var(--syn-tag); }
.codehilite .nv, .codehilite .vc, .codehilite .vg, .codehilite .vi, .codehilite .nl { color: var(--syn-var); }
.codehilite .err { color: var(--syn-err); }
.codehilite .w { color: inherit; }

/* tables (api reference) */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  display: block;
  overflow-x: auto;
}

.prose th,
.prose td {
  text-align: left;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border);
}

.prose thead th {
  border-bottom: 2px solid var(--border);
  color: var(--accent);
  white-space: nowrap;
}

.prose blockquote {
  margin: 1.5rem 0;
  padding: 0.4rem 0 0.4rem 1.2rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

/* -------------------------------------------------------------------------
   Page header (content pages)
   ------------------------------------------------------------------------- */
.page-header {
  padding: 2.5rem 0 0.5rem;
}

.page-header h1 {
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  margin: 0;
}

.page-header h1::before {
  content: "~/ ";
  color: var(--accent);
}

.page-body {
  padding: 1.5rem 0 3rem;
}

/* -------------------------------------------------------------------------
   Footer
   ------------------------------------------------------------------------- */
.site-footer {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
}

.site-footer .container {
  padding-block: 2.5rem;
}

.site-footer h3 {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 1rem;
}

.social {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
}

.social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.social a:hover {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}

.social svg {
  width: 20px;
  height: 20px;
}

.copyright {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.85rem;
}
