:root {
  --primary: #0b2d4a;
  --secondary: #b00020;
  --bg: #f6f8fb;
  --text: #111827;
  --muted: #6b7280;
  --card: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
  --radius: 14px;
  --maxw: 1100px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
               "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

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

.author-link { color: var(--secondary); font-weight: 600; }
.author-link:hover { color: var(--secondary); text-decoration: underline; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  border-radius: 999px;
  background: var(--secondary);
  color: #ffffff;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: var(--shadow);
}

.button:hover {
  text-decoration: none;
  filter: brightness(0.95);
}

.button:focus-visible {
  outline: 3px solid rgba(176, 0, 32, 0.35);
  outline-offset: 3px;
}

/* ── HEADER ── */
header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.header-inner img {
  max-height: 64px;
  width: auto;
  height: auto;
  display: block;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.header-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

/* ── HERO ── */
main {
  max-width: var(--maxw);
  margin: 0 auto;
}

.hero {
  padding: 3rem 1.5rem 2rem 1.5rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2.5rem;
  align-items: start;
}

.book-cover-wrapper {
  flex-shrink: 0;
}

.book-cover-link {
  display: block;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(17, 24, 39, 0.18);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  width: 220px;
}

.book-cover-link:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 36px rgba(17, 24, 39, 0.26);
  text-decoration: none;
}

.book-cover-link img {
  width: 100%;
  height: auto;
  display: block;
}

.book-cover-hint {
  text-align: center;
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.hero-info h1 {
  font-size: clamp(1.8rem, 2.8vw, 2.4rem);
  line-height: 1.15;
  margin: 0 0 0.35rem 0;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.hero-info .subtitle {
  font-size: 1.05rem;
  color: var(--muted);
  margin: 0 0 1.25rem 0;
  font-style: italic;
}

.book-meta {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  display: inline-grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.85rem;
  row-gap: 0.3rem;
}

.book-meta dt {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.book-meta dd {
  margin: 0;
  color: #374151;
}

.hero-desc {
  color: #374151;
  font-size: 1rem;
  max-width: 72ch;
  margin: 0 0 1.5rem 0;
}

/* ── SECTIONS ── */
section {
  padding: 2.2rem 1.5rem;
}

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

section h2 {
  font-size: 1.65rem;
  margin: 0 0 0.5rem 0;
  color: var(--primary);
  letter-spacing: -0.01em;
}

section .section-intro {
  margin: 0 0 1.5rem 0;
  color: var(--muted);
  max-width: 80ch;
}

/* ── SLIDES GRID ── */
.slides-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 1.25rem;
}

.slide-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  display: flex;
  flex-direction: column;
}

.slide-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(17, 24, 39, 0.13);
}

.slide-card a {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

.slide-card a:hover { text-decoration: none; }

.slide-thumbnail {
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  background: #e5e7eb;
}

.slide-info {
  padding: 0.65rem 0.85rem 0.85rem 0.85rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.slide-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--secondary);
}

.slide-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.3;
  margin: 0;
}

.slide-dl {
  margin-top: auto;
  padding-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
}

/* ── FOOTER ── */
footer {
  background: #ffffff;
  border-top: 1px solid var(--border);
  margin-top: 0;
}

.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.75rem 1.5rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.footer-inner p { margin: 0.35rem 0; }

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .book-cover-link {
    width: 160px;
    margin: 0 auto;
  }
  .book-cover-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
}

@media (max-width: 900px) {
  .header-inner { flex-wrap: wrap; }
}

/* ── LANGUAGE SWITCH ── */
.header-inner { justify-content: space-between; }
.header-brand { display: flex; align-items: center; gap: 1.25rem; }
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  border: 2px solid var(--secondary);
  color: var(--secondary);
  font-weight: 700;
  white-space: nowrap;
}
.lang-switch:hover { background: var(--secondary); color: #ffffff; text-decoration: none; }
.lang-switch .lang-current { color: var(--muted); font-weight: 600; }
.lang-switch:hover .lang-current { color: #ffe4e8; }

.button-secondary {
  background: #ffffff;
  color: var(--primary);
  border: 1px solid var(--border);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* ── CARDS AND LISTS ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.parts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
}
.parts-grid .card { padding: 1.25rem; }
.parts-grid h3 { margin: 0 0 0.5rem 0; color: var(--secondary); font-size: 1.05rem; }
.parts-grid ul { margin: 0; padding-left: 1.25rem; color: #4b5563; font-size: 0.97rem; line-height: 1.7; }

/* ── PDDL VERSIONS TABLE ── */
.table-wrap { overflow-x: auto; }
table.versions {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 0.95rem;
}
table.versions th, table.versions td {
  text-align: left;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.versions th { background: var(--primary); color: #ffffff; font-weight: 700; }
table.versions td:first-child { font-weight: 700; color: var(--primary); white-space: nowrap; }

/* ── METHOD ── */
.method-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  padding: 0;
  margin: 0;
  list-style: none;
}
.method-steps li { padding: 1rem; }
.method-steps .letter {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  color: var(--secondary);
  line-height: 1;
}
.method-steps strong { color: var(--primary); }
.method-steps p { margin: 0.35rem 0 0 0; color: #4b5563; font-size: 0.93rem; }

/* ── PDDL CODE ── */
.code-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 1.25rem;
}
.code-block { overflow: hidden; }
.code-block.wide { grid-column: 1 / -1; }
.code-block pre.terminal { height: 100%; }
.code-block h3 {
  margin: 0;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  color: #ffffff;
  background: var(--primary);
}
.code-block pre {
  margin: 0;
  padding: 1rem;
  font-size: 0.78rem;
  line-height: 1.45;
  background: #f8f8f5;
  white-space: pre-wrap;      /* long lines wrap inside the box, never cut */
  overflow-wrap: anywhere;
}
.code-block pre.terminal { background: #000000; color: #f0f0f0; }
.code-block code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ── FAQ ── */
.faq details {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  margin-bottom: 0.75rem;
}
.faq summary { cursor: pointer; font-weight: 700; color: var(--primary); }
.faq details p { margin: 0.6rem 0 0 0; color: #374151; }

/* ── BIBTEX ── */
.bibtex-wrapper { position: relative; }
.bibtex-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.85rem;
  margin: 0;
}
.bibtex-copy {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.7rem;
  font-weight: 600;
  cursor: pointer;
}
.bibtex-copy.copied { background: #dcfce7; }

@media (max-width: 640px) {
  .header-inner { gap: 0.75rem; }
  .header-inner img { max-height: 44px; }
  .code-grid { grid-template-columns: 1fr; }
}

.button-examples { background: var(--primary); }
.examples-table td:last-child, .examples-table th:last-child { text-align: right; }
