/* OpenClaw Newsletter - Modern, clean design inspired by Morning Brew / TLDR */

/* ===== Custom Properties ===== */
:root {
  --bg: #ffffff;
  --bg-secondary: #f7f8fa;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --accent: #6366f1;
  --accent-light: #eef2ff;
  --accent-hover: #4f46e5;
  --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --code-bg: #f1f5f9;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 740px;
  --transition: 0.2s ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c111b;
    --bg-secondary: #131a2b;
    --bg-card: #162032;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #818cf8;
    --accent-light: #1e1b4b;
    --accent-hover: #a5b4fc;
    --accent-gradient: linear-gradient(135deg, #818cf8, #a78bfa);
    --border: #1e293b;
    --border-light: #1e293b;
    --code-bg: #1e293b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

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

/* ===== Base ===== */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-secondary);
  color: var(--text);
  line-height: 1.7;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
}

a {
  transition: color var(--transition);
}

/* ===== Header ===== */
.header {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2rem 2rem 1.5rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent-gradient);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo {
  width: 40px;
  height: 40px;
  background: var(--accent-gradient);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.header .subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.header .date {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 100px;
  margin-top: 0.75rem;
}

/* Navigation */
.nav {
  display: flex;
  gap: 0.25rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border-radius: 100px;
  transition: all var(--transition);
}

.nav a:hover {
  background: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
}

/* ===== Table of Contents ===== */
.toc {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
}

.toc h2 {
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.toc ul {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.toc li {
  counter-increment: toc-counter;
}

.toc a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.toc a::before {
  counter-increment: toc-item;
  content: counter(toc-counter);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.toc a:hover {
  background: var(--bg-secondary);
  color: var(--accent);
}

/* ===== Sections ===== */
.section {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.75rem 2rem;
  margin-bottom: 1.25rem;
  transition: box-shadow var(--transition);
}

.section:hover {
  box-shadow: var(--shadow-md);
}

.section-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  letter-spacing: -0.01em;
}

.section-title::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 1.2em;
  background: var(--accent-gradient);
  border-radius: 2px;
  flex-shrink: 0;
}

.section-content {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.75;
}

.section-content h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 1.5rem 0 0.5rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.section-content h3:first-child {
  margin-top: 0;
}

.section-content p {
  margin-bottom: 0.85rem;
  color: var(--text);
}

.section-content a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition), color var(--transition);
}

.section-content a:hover {
  color: var(--accent-hover);
  border-bottom-color: var(--accent-hover);
  text-decoration: none;
}

.section-content ul {
  margin: 0.75rem 0 1rem 0;
  padding-left: 0;
  list-style: none;
}

.section-content li {
  margin-bottom: 0.5rem;
  padding-left: 1.4rem;
  position: relative;
}

.section-content li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

.section-content code {
  background: var(--code-bg);
  padding: 0.15em 0.45em;
  border-radius: 5px;
  font-size: 0.88em;
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
}

.section-content pre {
  background: var(--code-bg);
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--border);
}

.section-content pre code {
  background: none;
  padding: 0;
}

.section-content strong {
  font-weight: 650;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 2rem 1.5rem;
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer p {
  margin-bottom: 0.4rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 0.75rem;
}

.footer a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition);
}

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

.footer-divider {
  width: 40px;
  height: 3px;
  background: var(--accent-gradient);
  border-radius: 2px;
  margin: 0 auto 1rem;
}

/* ===== Archive Page ===== */
.archive-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 1.25rem;
  letter-spacing: -0.025em;
}

.archive-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.archive-list li {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem 1.5rem;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.archive-list li:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.archive-list a {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
  transition: color var(--transition);
}

.archive-list a:hover {
  color: var(--accent);
  text-decoration: none;
}

.archive-list .meta {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}

/* ===== Archive Gate ===== */
.archive-gate {
  text-align: center;
  padding: 3rem 2rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
}

.archive-gate h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.35rem;
  letter-spacing: -0.025em;
}

.archive-gate p {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.archive-gate .subscribe {
  max-width: 400px;
  margin: 1rem auto 0;
}

.archive-gate .subscribe form {
  justify-content: center;
}

.archive-reveal {
  display: inline-block;
  margin-top: 1.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition);
}

.archive-reveal:hover {
  color: var(--accent);
}

.archive-content {
  display: none;
}

.archive-toggle:checked ~ .archive-content {
  display: block;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.empty-state h2 {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.empty-state p {
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.empty-state a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.empty-state a:hover {
  text-decoration: underline;
}

/* ===== Subscribe Form ===== */
.subscribe {
  margin-top: 1rem;
}

.subscribe form {
  display: flex;
  gap: 0.5rem;
}

.subscribe input[type="email"] {
  flex: 1;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}

.subscribe input[type="email"]:focus {
  border-color: var(--accent);
}

.subscribe button {
  padding: 0.55rem 1.25rem;
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--transition);
}

.subscribe button:hover {
  opacity: 0.9;
}

.footer .subscribe {
  margin-bottom: 1rem;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .container {
    padding: 1rem 0.75rem 1.5rem;
  }

  .header {
    padding: 1.5rem 1.25rem 1.25rem;
  }

  .header h1 {
    font-size: 1.25rem;
  }

  .header-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  .toc {
    padding: 1.25rem;
  }

  .toc ul {
    grid-template-columns: 1fr;
  }

  .section {
    padding: 1.25rem;
  }

  .section-title {
    font-size: 1.1rem;
  }

  .nav {
    flex-wrap: wrap;
  }

  .archive-list li {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .subscribe form {
    flex-direction: column;
  }
}
