/* Ant Evolution Wiki - Sunlit Ant Terrarium & Colony Field Atlas
   Direction: Warm Sand (#f7f1e8 / #fffaf2 / #2b2118 / #6b5b4b / #c2562f / #e0a03a)
   Fonts: Fraunces (700) + Inter (400, 600) */

:root {
  --bg: #f7f1e8;
  --card: #fffaf2;
  --text: #2b2118;
  --muted: #6b5b4b;
  --primary: #c2562f;
  --accent: #e0a03a;
  --primary-dark: #9f4322;
  --line: #dfd2be;
  --tint: #efe5d5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06);
  --shadow-up: 0 8px 24px rgba(0, 0, 0, .08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.6 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-underline-offset: 4px;
}

a:hover {
  color: var(--primary-dark);
}

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

button,
input,
textarea {
  font: inherit;
}

button,
a,
input,
textarea,
summary {
  touch-action: manipulation;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  z-index: 30;
}

.skip:focus {
  left: 16px;
}

/* Header */
.masthead {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-row {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-text {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.brand-text em {
  font-style: normal;
  color: var(--primary);
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.top-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.top-nav a:hover {
  color: var(--primary);
}

.header-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.header-cta:hover {
  background: var(--primary-dark);
  color: #ffffff;
}

/* Typography */
h1,
h2,
h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  margin: 0;
}

h1 {
  font-size: 48px;
}

h2 {
  font-size: 28px;
}

h3 {
  font-size: 22px;
}

p {
  max-width: 70ch;
  margin: 0 0 16px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 8px;
}

.eyebrow-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius);
  background: var(--accent);
}

.fine {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

/* Buttons */
.btn,
.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.2;
}

.btn {
  background: var(--primary);
  color: #ffffff;
  border: 1px solid var(--primary);
}

.btn:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #ffffff;
}

.btn-outline {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-outline:hover {
  background: var(--tint);
  border-color: var(--primary);
  color: var(--text);
}

[data-gf-liked] {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #ffffff !important;
}

/* First-Screen Terrarium Hero */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr);
  gap: 24px;
  align-items: stretch;
  padding: 24px 0 16px;
}

.hero-panel {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.hero-panel h1 {
  margin-bottom: 8px;
}

.hero-lede {
  font-size: 16px;
  color: var(--muted);
  margin: 0;
}

.hero-lede strong {
  color: var(--text);
  font-weight: 600;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.telemetry-cell {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
}

.telemetry-cell span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.telemetry-cell strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.hero-engage {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.engage-btns {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stage-card {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-up);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stage-viewport {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--text);
  aspect-ratio: 16 / 9;
  flex: 1;
  min-height: 220px;
}

.stage-viewport img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stage-caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  padding: 0 4px;
}

.stage-caption strong {
  color: var(--text);
  font-weight: 600;
}

.stage-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stage-tab {
  min-height: 44px;
  padding: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.stage-tab:hover {
  border-color: var(--primary);
}

.stage-tab[aria-selected="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--card);
}

/* Signature Motif: Pheromone Lifecycle Trail */
.pheromone-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.pheromone-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--bg);
  text-decoration: none;
  color: var(--text);
}

.pheromone-step:hover {
  background: var(--tint);
  color: var(--text);
}

.pheromone-num {
  width: 24px;
  height: 24px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pheromone-step strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
}

.pheromone-step small {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

/* Sections */
.section {
  margin-top: 32px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 4px 12px;
  border-radius: var(--radius);
  background: var(--tint);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

/* Codes Cabin (2x2 Compact Grid) */
.codes-cabin {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.codes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.code-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.code-card code {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
}

.code-card span {
  display: block;
  font-size: 14px;
  color: var(--muted);
}

.codes-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

/* Colony Atlas Hub (3x3 Compact Grid) */
.atlas-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.atlas-card {
  display: block;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
}

.atlas-card:hover {
  border-color: var(--primary);
  background: var(--tint);
  color: var(--text);
}

.atlas-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
}

.atlas-card h3 {
  font-size: 18px;
  margin-bottom: 4px;
}

.atlas-card p {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
}

/* Two-Column Field Manual */
.manual-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 32px;
  margin-top: 32px;
  align-items: start;
}

.manual-rail {
  position: sticky;
  top: 88px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.manual-rail nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.manual-rail nav a {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 8px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.manual-rail nav a:hover {
  background: var(--tint);
  color: var(--text);
}

.manual-body {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 32px;
  box-shadow: var(--shadow);
}

.manual-block {
  padding-bottom: 24px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.manual-block:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: 0;
}

.manual-block h2 {
  margin-bottom: 12px;
}

.manual-block h3 {
  font-size: 18px;
  margin: 16px 0 8px;
}

.inline-shot {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}

.inline-shot figcaption {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--card);
}

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

th {
  background: var(--tint);
  font-weight: 600;
  color: var(--text);
}

tr:last-child td,
tr:last-child th {
  border-bottom: 0;
}

.callout {
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  margin: 16px 0;
}

.callout p {
  font-size: 14px;
  margin: 0;
}

/* FAQ Accordion */
.faq-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 32px;
  box-shadow: var(--shadow);
}

.faq-list {
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

.faq-list details {
  border-bottom: 1px solid var(--line);
}

.faq-list summary {
  cursor: pointer;
  padding: 12px 32px 12px 0;
  font-size: 16px;
  font-weight: 600;
  position: relative;
  list-style: none;
  min-height: 48px;
  display: flex;
  align-items: center;
}

.faq-list summary::-webkit-details-marker {
  display: none;
}

.faq-list summary::after {
  content: '+';
  position: absolute;
  right: 8px;
  font-size: 22px;
  color: var(--primary);
}

.faq-list details[open] summary::after {
  content: '-';
}

.faq-list details p {
  padding: 0 16px 16px 0;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

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

.article-main {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 32px;
  box-shadow: var(--shadow);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.article-main h1 {
  font-size: 36px;
  margin-bottom: 16px;
}

.prose h2 {
  font-size: 22px;
  margin: 24px 0 12px;
}

.prose h3 {
  font-size: 18px;
  margin: 16px 0 8px;
}

.prose p,
.prose li {
  color: var(--text);
}

.prose ul,
.prose ol {
  padding-left: 24px;
  margin: 0 0 16px;
}

.prose li {
  margin-bottom: 8px;
  max-width: 70ch;
}

.prose code {
  padding: 4px 8px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.prose .code-card code {
  display: inline-block;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 2px;
}

.prose table {
  margin: 16px 0;
  border: 1px solid var(--line);
}

.article-side {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.side-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.side-card h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.side-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.side-links a {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.side-links a:hover {
  background: var(--tint);
  color: var(--text);
}

/* Discussion & Comments */
.discussion {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 32px;
  box-shadow: var(--shadow);
}

.comment-form {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.form-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 12px;
}

.comment-form label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.comment-form input,
.comment-form textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
}

.comment-form textarea {
  resize: vertical;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.reply-state {
  display: none;
}

[data-gf-replying] .reply-state {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.empty-note {
  display: none;
  padding: 16px 0 0;
  font-size: 14px;
  color: var(--muted);
}

[data-gf-empty] .empty-note {
  display: block;
}

.comment {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.comment:last-child {
  border-bottom: 0;
}

.comment header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.comment time {
  font-size: 12px;
  color: var(--muted);
}

.comment p {
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}

.comment [data-gf-c-replies] {
  margin-left: 24px;
  padding-left: 16px;
  border-left: 2px solid var(--line);
}

.owner-badge {
  padding: 4px 8px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

[data-gf-owner] {
  background: var(--bg);
  padding: 16px;
  border-radius: var(--radius);
  border-left: 4px solid var(--primary);
}

/* Ads (Strictly outside first screen) */
.ad-slot {
  margin: 24px 0;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
  overflow: hidden;
}

.ad-frame-banner {
  width: 320px;
  max-width: 100%;
  min-height: 50px;
  margin: 4px auto 0;
}

.ad-frame-rect {
  width: 300px;
  max-width: 100%;
  min-height: 250px;
  margin: 4px auto 0;
}

/* Footer */
.footer {
  margin-top: 48px;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 32px 0 24px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr 0.9fr;
  gap: 24px;
}

.footer-title {
  display: inline-block;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  margin-bottom: 8px;
}

.footer-head {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
  margin: 0 0 8px;
}

.footer-links-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 16px;
}

.footer-links-one {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.footer-col nav a,
.footer-links-two a,
.footer-links-one a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
}

.footer-links-two a:hover,
.footer-links-one a:hover {
  color: var(--primary);
}

.footer-bottom {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* Responsive */
@media (max-width: 900px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
  }
  .stage-viewport {
    min-height: 0;
    flex: 0 0 auto;
  }
  .pheromone-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .atlas-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .manual-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .manual-rail {
    position: static;
  }
  .manual-rail nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .article-shell {
    grid-template-columns: 1fr;
  }
  .article-side {
    position: static;
  }
  .footer-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .wrap {
    padding: 0 16px;
  }
  .header-row {
    flex-wrap: wrap;
    padding: 8px 16px;
  }
  .top-nav {
    width: 100%;
    order: 3;
    gap: 12px;
    border-top: 1px solid var(--line);
    padding-top: 4px;
  }
  .top-nav a {
    min-height: 44px;
    font-size: 13px;
  }
  h1,
  .article-main h1 {
    font-size: 28px;
  }
  h2 {
    font-size: 22px;
  }
  .hero-panel,
  .codes-cabin,
  .manual-body,
  .faq-box,
  .article-main,
  .discussion {
    padding: 16px;
  }
  .hero-actions .btn,
  .hero-actions .btn-outline {
    width: 100%;
  }
  .stage-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .pheromone-strip,
  .codes-grid,
  .atlas-grid,
  .form-grid,
  .manual-rail nav {
    grid-template-columns: 1fr;
  }
  .prose table {
    display: block;
    overflow-x: auto;
  }
  .prose th,
  .prose td {
    padding: 8px 10px;
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    animation: none !important;
    transition: none !important;
  }
}
