:root {
  --bg-page: #f7f6f2;
  --bg-surface: #ffffff;
  --bg-subtle: #efede6;
  --bg-ink: #12151e;
  --bg-ink-soft: #1d2230;
  --text-main: #161922;
  --text-muted: #525866;
  --text-light: #6d7382;
  --border: #e4e1d8;
  --border-strong: #cfc9bc;
  --accent: #b84a14;
  --accent-hover: #963a0d;
  --accent-soft: #fdf0ea;
  --mana-w: #f3e6b3;
  --mana-u: #b6d8f5;
  --mana-b: #ccc4d6;
  --mana-r: #f5bcae;
  --mana-g: #b8dec5;
  --success: #166534;
  --success-bg: #dcfce7;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(18, 21, 30, 0.06);
  --shadow-md: 0 8px 24px rgba(18, 21, 30, 0.08);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: Georgia, "Times New Roman", Times, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --max-w: 1180px;
}

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

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-main);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  width: 100%;
}

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

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

a:hover {
  text-decoration: underline;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--bg-ink);
  color: #fff;
  padding: 10px 16px;
  z-index: 999;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
}

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

/* Header & Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding-top: 6px;
  padding-bottom: 6px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
  font-weight: 800;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  min-width: 0;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.brand-sub {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: block;
  line-height: 1.15;
}

.nav-desktop {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-desktop a {
  color: var(--text-main);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.nav-desktop a:hover,
.nav-desktop a[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.nav-cta {
  background: var(--bg-ink);
  color: #fff !important;
  padding: 8px 14px !important;
  border-radius: var(--radius-sm);
  border-bottom: none !important;
  font-size: 0.86rem !important;
}

.nav-cta:hover {
  background: var(--accent);
}

.mobile-toggle {
  display: none;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.88rem;
  flex-shrink: 0;
}

.nav-mobile {
  display: none;
  flex-direction: column;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 10px 20px 18px;
}

.nav-mobile.is-open {
  display: flex;
}

.nav-mobile a {
  padding: 11px 4px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  font-weight: 600;
}

/* Breadcrumbs */
.breadcrumbs {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 14px 0 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.breadcrumbs a {
  color: var(--text-muted);
}

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

/* Hero Section */
.hero {
  padding: 24px 0 36px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 28px;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 3.2vw, 2.55rem);
  line-height: 1.2;
  margin: 0 0 12px;
  color: var(--text-main);
  letter-spacing: -0.015em;
}

.hero-lead {
  font-size: 1.02rem;
  color: var(--text-muted);
  margin: 0 0 20px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 0.15s ease;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: #e5e1d6;
}

.hero-media {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-ink);
}

.hero-media img {
  width: 100%;
  height: auto;
  display: block;
}

.media-caption {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Quick Stats Strip */
.strip-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 36px;
}

.strip-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.strip-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.strip-val {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 4px;
}

/* Section Headers */
.sec-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 10px;
}

.sec-head h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0;
}

.sec-head a {
  font-size: 0.9rem;
  font-weight: 700;
}

/* Grids & Cards (Zero image cropping!) */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  margin-bottom: 44px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-bottom: 40px;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-img-wrap {
  background: var(--bg-ink);
  width: 100%;
}

.card-img-wrap img {
  width: 100%;
  height: auto;
  display: block;
}

.card-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 6px;
}

.card h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.3;
  margin: 0 0 8px;
}

.card h3 a {
  color: var(--text-main);
}

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

.card p {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin: 0 0 14px;
  flex: 1;
}

.card-meta {
  font-size: 0.8rem;
  color: var(--text-light);
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

/* Article Page Layout */
.article-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 32px;
  padding: 14px 0 52px;
  align-items: start;
}

.article-main {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  max-width: 100%;
  overflow-wrap: break-word;
}

.article-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  line-height: 1.22;
  margin: 0 0 12px;
}

.byline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.article-hero-img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin-bottom: 22px;
  border: 1px solid var(--border);
}

.article-main h2 {
  font-family: var(--font-display);
  font-size: 1.48rem;
  margin: 30px 0 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.article-main h3 {
  font-size: 1.15rem;
  margin: 20px 0 8px;
  color: var(--text-main);
}

.article-main p {
  margin: 0 0 16px;
}

.article-main ul,
.article-main ol {
  margin: 0 0 18px;
  padding-left: 20px;
}

.article-main li {
  margin-bottom: 6px;
}

/* Quick Answer / AEO Summary Box */
.quick-answer {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  padding: 15px 18px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 0 0 22px;
}

.quick-answer-title {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 6px;
}

.note-callout {
  background: var(--bg-subtle);
  border-left: 4px solid var(--bg-ink);
  padding: 15px 18px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 20px 0;
}

/* Responsive Tables */
.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 18px 0 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--bg-surface);
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-subtle);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:last-child td {
  border-bottom: none;
}

/* Badges & Mana Pips */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-active {
  background: var(--success-bg);
  color: var(--success);
}

.badge-tier {
  background: var(--bg-ink);
  color: #fff;
}

.mana-pips {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.pip {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  color: #111;
  border: 1px solid rgba(0, 0, 0, 0.25);
}

.pip-w { background: var(--mana-w); }
.pip-u { background: var(--mana-u); }
.pip-b { background: var(--mana-b); }
.pip-r { background: var(--mana-r); }
.pip-g { background: var(--mana-g); }

/* Copyable Code / Decklist Widget */
.copy-box {
  background: var(--bg-ink);
  color: #f3f4f6;
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 16px 0 22px;
  max-width: 100%;
  overflow: hidden;
}

.copy-box-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 0.84rem;
  color: #cbd5e1;
}

.copy-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.copy-btn:hover {
  background: var(--accent-hover);
}

.copy-btn.copied {
  background: #15803d;
}

.copy-box pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
}

.code-chip {
  font-family: var(--font-mono);
  font-weight: 700;
  background: var(--bg-subtle);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  font-size: 0.86rem;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.side-widget {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  min-width: 0;
}

.side-widget h3 {
  font-family: var(--font-display);
  font-size: 1.08rem;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.toc-list,
.side-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-list li,
.side-links li {
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.toc-list a,
.side-links a {
  color: var(--text-main);
}

.toc-list a:hover,
.side-links a:hover {
  color: var(--accent);
}

/* Card Showcase Row */
.card-showcase {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 22px 0 32px;
}

.card-showcase figure {
  margin: 0;
  text-align: center;
}

.card-showcase img {
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  margin: 0 auto;
  width: 100%;
  height: auto;
}

.card-showcase figcaption {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Card Database Explorer */
.filter-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.filter-field label {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.filter-field input,
.filter-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.94rem;
  background: var(--bg-page);
  color: var(--text-main);
}

.cards-meta-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.card-db-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 44px;
}

.mtg-card-tile {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  min-width: 0;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.mtg-card-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.mtg-card-tile img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--bg-ink);
}

.mtg-card-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-main);
  margin-bottom: 4px;
}

.mtg-card-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.card-modal {
  position: fixed;
  inset: 0;
  background: rgba(18, 21, 30, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 16px;
}

.card-modal.is-open {
  display: flex;
}

.card-modal-box {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  max-width: 760px;
  width: 100%;
  padding: 24px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 24px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.card-modal-box img {
  width: 100%;
  height: auto;
  border-radius: 10px;
}

.card-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 6px 12px;
  font-weight: 700;
  cursor: pointer;
}

/* FAQ Accordion */
.faq-list details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  margin-bottom: 10px;
  background: var(--bg-page);
}

.faq-list summary {
  font-weight: 700;
  cursor: pointer;
  color: var(--text-main);
}

.faq-list details p {
  margin: 10px 0 0;
  font-size: 0.93rem;
  color: var(--text-muted);
}

/* Footer */
.site-footer {
  background: var(--bg-ink);
  color: #cbd5e1;
  padding: 44px 0 26px;
  margin-top: 44px;
  width: 100%;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.site-footer h4 {
  color: #fff;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 12px;
}

.site-footer ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.site-footer li {
  margin-bottom: 8px;
  font-size: 0.88rem;
}

.site-footer a {
  color: #cbd5e1;
}

.site-footer a:hover {
  color: #fff;
}

.footer-bottom {
  padding-top: 18px;
  font-size: 0.8rem;
  color: #94a3b8;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

@media (max-width: 960px) {
  .hero-grid,
  .article-shell,
  .footer-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .strip-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .card-db-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .card-showcase {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sidebar {
    position: static;
  }
}

@media (max-width: 720px) {
  .container {
    padding: 0 14px;
  }
  .nav-desktop {
    display: none;
  }
  .mobile-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .hero-grid,
  .article-main,
  .side-widget {
    padding: 18px;
  }
  .grid-3,
  .grid-2,
  .strip-bar,
  .filter-bar,
  .card-modal-box {
    grid-template-columns: minmax(0, 1fr);
  }
  .card-db-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  th, td {
    padding: 8px 10px;
    font-size: 0.82rem;
  }
}
