/* ─────────────────────────────────────────────────────────────
   Slime Colony — landing site styles
   Mobile-first. Breakpoints at 640 and 960.
   ───────────────────────────────────────────────────────────── */

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

:root {
  --bg:         #1A1A2E;
  --bg-soft:    #232342;
  --card:       #F4F0E8;
  --ink:        #3A3028;
  --ink-soft:   #6B5D4E;
  --accent:     #5A8AA0;
  --accent-2:   #B86B40;
  --gold:       #D9B96A;
  --line:       rgba(255,255,255,0.08);
  --dim:        #8B9EAA;

  --ember:  #D48A5A;
  --dew:    #5A8AA0;
  --moss:   #7A9A5A;
  --pebble: #8B7DAA;

  --radius:    12px;
  --radius-sm: 8px;
  --pad:       18px;
  --pad-lg:    32px;
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Fredoka', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: #F0F0E0;
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: #7BB1CC; }
img { max-width: 100%; height: auto; display: block; }

/* ─── Layout containers ─── */
.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}
.wrap-wide { max-width: 960px; }

/* ─── Top nav ─── */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
  padding: 4px 0;
}
.site-nav .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: #F0F0E0;
  letter-spacing: 1.5px;
  font-size: 15px;
}
.site-nav .brand img { width: 28px; height: 28px; }
.site-nav .links {
  display: flex;
  gap: 18px;
  font-size: 14px;
}
.site-nav .links a {
  color: var(--dim);
  font-weight: 500;
}
.site-nav .links a.active,
.site-nav .links a:hover { color: #F0F0E0; }

/* ─── Hero ─── */
.hero {
  text-align: center;
  padding: 40px 0 32px;
}
.hero .logo {
  width: 96px;
  height: auto;
  margin: 0 auto 18px;
}
.hero h1 {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #F0F0E0;
  margin-bottom: 8px;
}
.hero .tagline {
  color: var(--dim);
  font-size: 16px;
  max-width: 520px;
  margin: 0 auto;
}
.hero .meta {
  margin-top: 16px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.hero .meta span + span::before {
  content: "·";
  margin: 0 10px;
  color: var(--line);
}

.hero-cta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 32px auto 0;
  max-width: 380px;
}
@media (min-width: 640px) {
  .hero-cta { grid-template-columns: repeat(3, 1fr); max-width: 620px; }
}

.btn {
  display: block;
  text-align: center;
  padding: 14px 18px;
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 15px;
  border: 2px solid transparent;
  transition: border-color .15s, transform .1s;
}
.btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  color: var(--ink);
}
.btn.subtle {
  background: transparent;
  border-color: var(--line);
  color: var(--dim);
  font-weight: 500;
}
.btn.subtle:hover {
  border-color: var(--accent);
  color: var(--ink);
}

/* ─── Footer / secondary links ─── */
.site-foot {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.site-foot a { color: var(--dim); }
.site-foot a:hover { color: #F0F0E0; }

/* ─── Page headers ─── */
.page-title {
  font-size: 28px;
  font-weight: 700;
  color: #F0F0E0;
  margin-bottom: 6px;
  letter-spacing: 1px;
}
.page-sub {
  color: var(--dim);
  margin-bottom: 28px;
  font-size: 14px;
}

/* ─── Card blocks ─── */
.card {
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: 14px;
}
.card h2, .card h3 {
  color: var(--ink);
  margin-bottom: 8px;
}
.card p { color: var(--ink-soft); }

/* ─── Setup steps ─── */
.step {
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  align-items: start;
}
.step-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #F0F0E0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}
.step-body h3 {
  color: var(--ink);
  font-size: 17px;
  margin-bottom: 4px;
}
.step-body p, .step-body li { color: var(--ink-soft); font-size: 15px; }
.step-body ul { padding-left: 22px; margin-top: 6px; }
.step-body ul li { margin-bottom: 2px; }
.step-body strong { color: var(--ink); }

/* ─── Rules content (rendered from markdown) ─── */
.rules-content {
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 28px 24px;
  /* Isolate paint so scroll doesn't repaint the whole cream block
     against the dark body on every frame (kills scroll flicker). */
  contain: layout paint style;
}
.rules-content h1, .rules-content h2, .rules-content h3, .rules-content h4 {
  color: var(--ink);
  margin: 24px 0 10px;
  line-height: 1.25;
}
.rules-content h1 { font-size: 28px; margin-top: 0; }
.rules-content h2 { font-size: 22px; border-bottom: 1px solid rgba(0,0,0,0.1); padding-bottom: 6px; }
.rules-content h3 { font-size: 18px; }
.rules-content h4 { font-size: 16px; color: var(--ink-soft); }
.rules-content p, .rules-content li { color: var(--ink-soft); }
.rules-content p { margin-bottom: 10px; }
.rules-content ul, .rules-content ol { padding-left: 22px; margin-bottom: 12px; }
.rules-content li { margin-bottom: 4px; }
.rules-content strong { color: var(--ink); }
.rules-content blockquote {
  border-left: 4px solid var(--accent);
  padding: 10px 16px;
  margin: 14px 0;
  background: rgba(90,138,160,0.08);
  border-radius: 0 8px 8px 0;
}
.rules-content blockquote p { color: var(--ink); }
.rules-content hr {
  border: 0;
  border-top: 1px solid rgba(0,0,0,0.1);
  margin: 24px 0;
}
.rules-content code {
  background: rgba(0,0,0,0.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.9em;
}
.rules-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 14px;
}
.rules-content th, .rules-content td {
  border: 1px solid rgba(0,0,0,0.12);
  padding: 6px 10px;
  text-align: left;
}
.rules-content th {
  background: rgba(90,138,160,0.15);
  color: var(--ink);
  font-weight: 600;
}
.rules-content a { color: var(--accent); }

/* Placeholder icons inside content */
.rules-content .icon-inline,
.rules-content .slime-inline,
.step-body .icon-inline,
.step-body .slime-inline {
  height: 1em;
  width: auto;
  vertical-align: -0.15em;
  display: inline-block;
}
.rules-content .slime-inline,
.step-body .slime-inline { height: 1.2em; vertical-align: -0.25em; }

.rules-content .ab-cost,
.step-body .ab-cost {
  display: inline-block;
  background: var(--accent);
  color: #F0F0E0;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.85em;
  font-weight: 600;
  white-space: nowrap;
}
.phase-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.8em;
  font-weight: 700;
  letter-spacing: 1px;
  color: #F0F0E0;
  vertical-align: 1px;
  white-space: nowrap;
}
.phase-tag.emerge { background: #D48A5A; }
.phase-tag.mush   { background: #7A9A5A; }
.phase-tag.swarm  { background: #5A8AA0; }
.phase-tag.settle { background: #8B7DAA; }

/* ─── ToC (rules page) ─── */
.rules-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
@media (min-width: 960px) {
  .rules-layout { grid-template-columns: 220px 1fr; }
  .toc {
    position: sticky;
    top: 20px;
    align-self: start;
    /* Promote the sticky element to its own compositor layer so scroll
       doesn't repaint it (and its inner overflow container) each frame. */
    will-change: transform;
  }
}
.toc {
  background: transparent;
  border-radius: var(--radius);
  padding: 12px 6px;
  font-size: 13px;
  color: var(--dim);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  contain: layout paint style;
}
.toc h4 {
  color: var(--dim);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 1.5px;
  font-weight: 700;
  margin-bottom: 8px;
  padding-left: 8px;
}
.toc a {
  display: block;
  padding: 5px 8px;
  color: var(--dim);
  border-left: 2px solid transparent;
  border-radius: 0 4px 4px 0;
}
.toc a:hover, .toc a.current { color: #F0F0E0; border-left-color: var(--accent); }
.toc a.lvl-3 { padding-left: 18px; font-size: 12px; }

/* ─── Reference (quick-ref cards) ─── */
.ref-section {
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 16px var(--pad);
  margin-bottom: 12px;
}
.ref-section h2 {
  color: var(--ink);
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.ref-row {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  font-size: 14px;
  color: var(--ink-soft);
}
.ref-row:last-child { border-bottom: 0; }
.ref-row .cost {
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}
.ref-row .name {
  color: var(--ink);
  font-weight: 600;
}
.ref-row .desc {
  grid-column: 1 / -1;
  font-size: 13px;
  color: var(--ink-soft);
}
/* Description-only rows are plain prose — opt them out of the 3-col grid
   entirely, and indent so they align under the name column. */
.ref-row.desc {
  display: block;
  padding: 4px 0 10px 70px;
  font-size: 13px;
  color: var(--ink-soft);
}
@media (max-width: 480px) {
  .ref-row.desc { padding-left: 0; }
}
.ref-row .icon-inline { height: 1em; vertical-align: -0.15em; }

.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.ref-tile {
  background: rgba(0,0,0,0.04);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
}
.ref-tile .k { color: var(--ink); font-weight: 600; }
.ref-tile .v { color: var(--ink-soft); }

/* Sticky section headers in reference page for mobile */
@media (max-width: 640px) {
  .ref-section h2 {
    position: sticky;
    top: 0;
    background: var(--card);
    z-index: 2;
    margin: -16px calc(-1 * var(--pad)) 10px;
    padding: 12px var(--pad);
    border-bottom: 1px solid rgba(0,0,0,0.08);
    font-size: 15px;
  }
}

/* ─── Print ─── */
@media print {
  body { background: white; color: black; }
  .site-nav, .site-foot, .hero-cta { display: none; }
  .wrap { max-width: none; padding: 0; }
  .card, .rules-content, .ref-section, .step {
    background: white;
    color: black;
    padding: 6px 0;
    margin: 0;
    border-radius: 0;
    page-break-inside: avoid;
  }
  a { color: black; text-decoration: none; }
}
