/* ===== Clean-docs theme: light + dark, syntax-highlighted code ===== */
:root {
  --max: 860px;
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-card: #ffffff;
  --fg: #1c2024;
  --fg-muted: #5b6570;
  --border: #e3e7eb;
  --accent: #2f6fed;
  --accent-soft: #eaf1ff;
  --code-bg: #f6f8fa;
  --code-fg: #24292e;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --radius: 10px;
  --mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #0e1116;
  --bg-soft: #161b22;
  --bg-card: #161b22;
  --fg: #e6edf3;
  --fg-muted: #9aa5b1;
  --border: #262c36;
  --accent: #6ea8fe;
  --accent-soft: #17233b;
  --code-bg: #0b0f14;
  --code-fg: #e6edf3;
  --shadow: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 20px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--fg-muted); }

/* ===== Header / footer ===== */
.site-header {
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { display: inline-flex; gap: 8px; align-items: baseline; color: var(--fg); font-weight: 600; }
.brand:hover, .brand a:hover { text-decoration: none; }
.brand-team { color: var(--accent); }
.brand-sep { color: var(--fg-muted); }
.brand-event { color: var(--fg-muted); font-weight: 500; }
.site-nav { display: flex; align-items: center; gap: 18px; }
.site-nav a { color: var(--fg-muted); font-weight: 500; }
.site-nav a:hover { color: var(--fg); text-decoration: none; }
#theme-toggle {
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--fg);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 15px; line-height: 1;
}
#theme-toggle:hover { border-color: var(--accent); }
.theme-light { display: none; }
:root[data-theme="dark"] .theme-dark { display: none; }
:root[data-theme="dark"] .theme-light { display: inline; }

.site-footer { border-top: 1px solid var(--border); margin-top: 64px; padding: 28px 0; color: var(--fg-muted); font-size: 0.9rem; }
.site-footer p { margin: 2px 0; }

main.wrap { padding-top: 36px; padding-bottom: 24px; }

/* ===== Hero (landing) ===== */
.hero { padding: 20px 0 8px; border-bottom: 1px solid var(--border); margin-bottom: 32px; }
.hero-kicker { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.78rem; color: var(--accent); font-weight: 700; margin: 0 0 6px; }
.hero-title { font-size: 2.4rem; margin: 0 0 12px; line-height: 1.15; }
.hero-intro { font-size: 1.1rem; color: var(--fg); margin: 0 0 16px; }
.hero-desc { margin: 0 0 16px; padding: 12px 16px; border-left: 3px solid var(--accent); background: var(--bg-soft); border-radius: 6px; color: var(--fg-muted); font-size: 0.95rem; }
.hero-meta { font-size: 0.9rem; }

/* ===== Challenge index ===== */
.index h2 { font-size: 1.5rem; margin: 8px 0 4px; }
.cat-head { margin: 30px 0 12px; font-size: 1.15rem; padding-left: 12px; border-left: 4px solid var(--accent); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column; gap: 10px;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
  background: var(--bg-card); box-shadow: var(--shadow); color: var(--fg);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.card-title { font-weight: 650; font-size: 1.05rem; }
.card-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.card-flag { font-family: var(--mono); font-size: 0.78rem; color: var(--fg-muted); word-break: break-all; }

/* ===== Tags ===== */
.tag { display: inline-block; font-size: 0.74rem; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--bg-soft); color: var(--fg-muted); border: 1px solid var(--border); }
.tag-points { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag-part { background: #f3e8ff; color: #7c3aed; border-color: transparent; }
:root[data-theme="dark"] .tag-part { background: #2a1e3d; color: #c4a1ff; }
.tag-crypto { border-left: 0; }
.tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

/* ===== Write-up ===== */
.crumbs { font-size: 0.86rem; color: var(--fg-muted); margin-bottom: 18px; }
.crumbs span { margin: 0 4px; }
.writeup-head { border-bottom: 1px solid var(--border); padding-bottom: 20px; margin-bottom: 24px; }
.writeup-head h1 { font-size: 2.1rem; margin: 4px 0 10px; }
.byline { color: var(--fg-muted); margin: 0 0 10px; font-size: 0.95rem; }
.author-card { display: inline-flex; align-items: center; gap: 10px; margin: 4px 0 8px; padding: 6px 12px 6px 6px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-soft); color: var(--fg); }
.author-card:hover { text-decoration: none; border-color: var(--accent); }
.author-avatar { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-card); flex: none; }
.author-meta { display: flex; flex-direction: column; line-height: 1.2; }
.author-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-muted); }
.author-name { font-weight: 650; font-size: 0.95rem; }
.chall-desc { margin: 12px 0 0; padding: 12px 16px; border-left: 3px solid var(--accent); background: var(--bg-soft); border-radius: 6px; font-size: 0.95rem; }

.attachments { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 28px; }
.attachments h2 { font-size: 1rem; margin: 0 0 8px; }
.attach-list { margin: 0; padding-left: 2px; list-style: none; }
.attach-list li { margin: 4px 0; }
.attach-list a { font-family: var(--mono); font-size: 0.9rem; }

.writeup-body { font-size: 1.02rem; }
.writeup-body h2 { font-size: 1.4rem; margin: 34px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.writeup-body h3 { font-size: 1.15rem; margin: 26px 0 10px; }
.writeup-body p { margin: 14px 0; }
.writeup-body img { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; display: block; margin: 18px auto; }
.writeup-body ul, .writeup-body ol { padding-left: 24px; }
.writeup-body li { margin: 6px 0; }
.writeup-body blockquote { margin: 16px 0; padding: 10px 16px; border-left: 3px solid var(--accent); background: var(--bg-soft); border-radius: 6px; color: var(--fg-muted); }
.writeup-body table { border-collapse: collapse; width: 100%; margin: 18px 0; font-size: 0.94rem; display: block; overflow-x: auto; }
.writeup-body th, .writeup-body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.writeup-body th { background: var(--bg-soft); }

/* ===== Inline + block code ===== */
code { font-family: var(--mono); font-size: 0.9em; }
:not(pre) > code { background: var(--code-bg); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; color: var(--code-fg); }
pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; overflow-x: auto; line-height: 1.5; font-size: 0.88rem; }
pre code { background: none; border: 0; padding: 0; color: var(--code-fg); }

.flag-block { margin-top: 34px; }
.flag-block h2 { font-size: 1.2rem; margin-bottom: 8px; }
.flag { border-color: var(--accent); background: var(--accent-soft); }
.flag code { color: var(--accent); font-weight: 600; word-break: break-all; white-space: pre-wrap; }

.writeup-foot { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); }

@media (max-width: 600px) {
  .hero-title { font-size: 1.9rem; }
  .writeup-head h1 { font-size: 1.7rem; }
  .card-grid { grid-template-columns: 1fr; }
}
