:root {
  --bg: #0f1422;
  --bg-alt: #151b2e;
  --surface: #1b2236;
  --text: #e8ecf5;
  --muted: #a7b0c4;
  --accent: #6c8cff;
  --accent-hover: #8aa3ff;
  --border: #2a3350;
  --maxw: 1080px;
  --maxw-narrow: 680px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

.container.narrow { max-width: var(--maxw-narrow); }
.center { text-align: center; }

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }

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

/* Hero */
.hero {
  padding: 96px 0 104px;
  background: radial-gradient(1200px 480px at 50% -10%, rgba(108,140,255,0.18), transparent 70%), var(--bg);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 16px;
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4rem);
  margin: 0 0 20px;
}

.tagline {
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  max-width: 760px;
  margin: 0 auto 20px;
  color: var(--text);
}

.subtitle {
  font-size: 1.05rem;
  max-width: 680px;
  margin: 0 auto 36px;
  color: var(--muted);
}

/* Buttons */
.cta-row {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 13px 26px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  border: 1px solid transparent;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); color: #0c1020; }
.btn-primary:hover { background: var(--accent-hover); color: #0c1020; }

.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent-hover); }

.cta-row-left { justify-content: flex-start; }

.cta-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 18px;
}

/* Hero cover + two-column layout */
.hero-grid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 56px;
  text-align: left;
}
.hero-cover {
  flex: 0 0 auto;
  width: 240px;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.hero-copy { max-width: 560px; }
.hero-copy .tagline,
.hero-copy .subtitle { margin-left: 0; margin-right: 0; }
.hero-copy .cta-row { justify-content: flex-start; }

@media (max-width: 820px) {
  .hero-grid { flex-direction: column; text-align: center; gap: 36px; }
  .hero-cover { width: 200px; }
  .hero-copy .tagline,
  .hero-copy .subtitle { margin-left: auto; margin-right: auto; }
  .hero-copy .cta-row { justify-content: center; }
}

/* Sections */
.section { padding: 72px 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

.section h2 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  margin: 0 0 24px;
}
.section.section-alt .container > h2 { text-align: center; margin-bottom: 40px; }

.section p { color: var(--muted); margin: 0 0 18px; }
.section p strong { color: var(--text); }

.video-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-top: 28px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}
.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Card grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}
.card h3 { margin: 0 0 10px; font-size: 1.15rem; color: var(--text); }
.card p { margin: 0; font-size: 0.97rem; }
.card-wide { grid-column: 1 / -1; }

/* Author */
.author-layout {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}
.author-photo {
  flex: 0 0 auto;
  display: block;
  width: 200px;
  height: auto;          /* preserve the photo's natural 4:5 aspect ratio */
  border-radius: 12px;
  border: 1px solid var(--border);
}
.author-bio { flex: 1 1 auto; }
.author-bio p:last-child { margin-bottom: 0; }

@media (max-width: 600px) {
  .author-layout { flex-direction: column; align-items: center; text-align: left; }
  .author-photo { width: 180px; }
}

/* MailerLite embedded form */
.ml-embedded {
  max-width: 460px;
  margin: 24px auto 0;
}

/* Feedback form (/feedback) */
.feedback-title {
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0 0 20px;
  text-align: center;
}

.feedback-form { margin-top: 36px; }

.feedback-form .field { margin-bottom: 22px; }

.feedback-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.feedback-form .req { color: var(--accent); }

.feedback-form select,
.feedback-form input,
.feedback-form textarea {
  width: 100%;
  padding: 11px 14px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.feedback-form textarea { resize: vertical; }

.feedback-form select:focus,
.feedback-form input:focus,
.feedback-form textarea:focus {
  outline: 2px solid var(--accent-hover);
  outline-offset: 1px;
  border-color: var(--accent);
}

.feedback-form .field-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 8px 0 0;
}

/* Honeypot: hidden from humans, present for bots */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form-error { color: #ff8a8a; }

.form-thanks { text-align: center; padding: 40px 0; }
.form-thanks h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); margin: 0 0 12px; }

/* Subpage title (errata, examples) */
.page-title {
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0 0 20px;
  text-align: center;
}

/* Errata (/errata) */
.errata-list { margin-top: 48px; }
.errata-list h2 { font-size: clamp(1.4rem, 2.6vw, 1.8rem); margin: 0 0 20px; }
.erratum {
  border-top: 1px solid var(--border);
  padding: 18px 0 6px;
}
.erratum-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 6px;
}
.erratum-loc { color: var(--text); font-weight: 600; }
.erratum-desc { margin: 0 0 12px; }

/* Book examples (/examples) */
.examples-intro { padding: 0; margin-bottom: 8px; }

.chapter-index {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 24px auto 8px;
  max-width: 820px;
}
.chip {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}
.chip:hover { border-color: var(--accent); color: var(--accent-hover); text-decoration: none; }

.examples-loading { color: var(--muted); margin-top: 40px; }

.chapter-block { margin-top: 56px; }
.chapter-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 18px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 8px;
}
.chapter-head h2 { margin: 0; font-size: clamp(1.4rem, 2.6vw, 1.8rem); }
.chapter-meta { display: flex; align-items: center; gap: 14px; }
.chapter-count { font-size: 0.9rem; color: var(--muted); }

.btn-small {
  padding: 7px 14px;
  font-size: 0.85rem;
  border-radius: 7px;
  font-family: inherit;
  cursor: pointer;
}
button.btn-small:disabled { opacity: 0.7; cursor: default; }

.example {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  margin-top: 24px;
}
.example:target { border-color: var(--accent); }

.example-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-bottom: 10px;
}
.example-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}
.example-title h3 { margin: 0; font-size: 1.05rem; color: var(--text); }
.example-anchor { color: var(--muted); font-weight: 600; }
.example-anchor:hover { color: var(--accent-hover); text-decoration: none; }

.type-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: var(--bg-alt);
}

.example-actions { display: flex; gap: 8px; flex-shrink: 0; }

.example-desc { font-size: 0.95rem; margin: 0 0 12px; }

.example-code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 0;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.55;
  tab-size: 4;
}
.example-code code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  white-space: pre;
}

/* Footer nav links */
.footer-nav a { color: var(--muted); }
.footer-nav a:hover { color: var(--accent-hover); }

/* Footer */
.footer {
  padding: 40px 0;
  border-top: 1px solid var(--border);
  background: var(--bg);
  text-align: center;
}
.footer p { margin: 4px 0; color: var(--muted); font-size: 0.9rem; }

/* Focus visibility for keyboard users */
a:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 3px;
}

@media (max-width: 600px) {
  .hero { padding: 72px 0 56px; }
  .section { padding: 56px 0; }
}
