/* ── The Map — Shared Stylesheet ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root, [data-theme="dark"] {
  --bg:             #1A1410;
  --surface:        #221C16;
  --surface-mid:    #2D241C;
  --surface-hi:     #3A2E24;
  --sand:           #C8AE82;
  --clay:           #C49A6C;
  --terracotta:     #D4725A;
  --moss:           #7A9068;
  --text-primary:   #EDE6D6;
  --text-secondary: #A8957A;
  --text-dim:       #6E5E4A;
  --border:         rgba(200,174,130,0.1);
  --border-hover:   rgba(200,174,130,0.28);
  --nav-bg:         rgba(26,20,16,0.85);
  --btn-shadow:     rgba(212,114,90,0.25);
  --btn-hover-bg:   #E08060;
}

[data-theme="light"] {
  --bg:             #F7F2EA;
  --surface:        #EDE6D6;
  --surface-mid:    #F0EBE0;
  --surface-hi:     #D4C4A0;
  --sand:           #B5896A;
  --clay:           #9A7250;
  --terracotta:     #C4694A;
  --moss:           #6B7C5C;
  --text-primary:   #2A1F14;
  --text-secondary: #5A4030;
  --text-dim:       #9A8070;
  --border:         rgba(181,137,106,0.18);
  --border-hover:   rgba(181,137,106,0.4);
  --nav-bg:         rgba(247,242,234,0.88);
  --btn-shadow:     rgba(196,105,74,0.3);
  --btn-hover-bg:   #A85038;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.4s, color 0.4s;
}

body::after {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.055'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 9999;
}

/* ── Nav ── */
nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2.5rem; height: 64px;
  background: var(--nav-bg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  transition: background 0.4s, border-color 0.4s;
}
.nav-logo {
  font-family: 'Lora', serif; font-size: 1.25rem; font-weight: 600;
  color: var(--text-primary); text-decoration: none; letter-spacing: -0.02em;
  transition: color 0.3s;
}
.nav-logo span { color: var(--terracotta); }
.nav-right { display: flex; align-items: center; gap: 1.5rem; }
.nav-links { display: flex; gap: 1.75rem; list-style: none; }
.nav-links a {
  font-size: 0.875rem; font-weight: 500; color: var(--text-secondary);
  text-decoration: none; letter-spacing: 0.02em; transition: color 0.25s;
}
.nav-links a:hover { color: var(--clay); }
.nav-back {
  font-size: 0.8125rem; color: var(--text-dim); text-decoration: none;
  display: flex; align-items: center; gap: 0.35rem; transition: color 0.25s;
}
.nav-back:hover { color: var(--clay); }

.theme-toggle {
  display: flex; align-items: center; gap: 0.5rem;
  background: none; border: 1.5px solid var(--border); border-radius: 100px;
  padding: 0.3rem 0.75rem 0.3rem 0.5rem; cursor: pointer;
  color: var(--text-secondary); font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem; font-weight: 500; letter-spacing: 0.03em;
  transition: border-color 0.25s, color 0.25s, background 0.25s;
  white-space: nowrap;
}
.theme-toggle:hover { border-color: var(--clay); color: var(--clay); background: rgba(196,154,108,0.06); }
.toggle-icon { font-size: 0.875rem; line-height: 1; transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1); }
.theme-toggle:hover .toggle-icon { transform: rotate(20deg) scale(1.15); }
.toggle-text { display: none; }
@media (min-width: 640px) { .toggle-text { display: inline; } }

/* ── Page Header ── */
.page-header {
  padding: 120px 2.5rem 3rem;
  max-width: 780px; margin: 0 auto;
  position: relative; z-index: 1;
}
.page-header .breadcrumb {
  font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--terracotta); margin-bottom: 1.25rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.page-header .breadcrumb::before {
  content: ''; display: block; width: 18px; height: 1px;
  background: var(--terracotta); opacity: 0.5;
}
.page-header h1 {
  font-family: 'Lora', serif;
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  font-weight: 700; line-height: 1.1; letter-spacing: -0.03em;
  color: var(--text-primary); margin-bottom: 1.25rem;
  transition: color 0.4s;
}
.page-header .lead {
  font-size: 1.125rem; color: var(--text-secondary);
  line-height: 1.75; max-width: 620px; transition: color 0.4s;
}

.page-header .read-time {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.75rem; color: var(--text-dim);
  margin-top: 1rem; letter-spacing: 0.03em;
}
.page-header .read-time::before {
  content: '';
  display: inline-block; width: 12px; height: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236E5E4A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpolyline points='12 6 12 12 16 14'/%3E%3C/svg%3E");
  background-size: contain; background-repeat: no-repeat; opacity: 0.7;
}

/* ── Article Body ── */
.article {
  max-width: 780px; margin: 0 auto;
  padding: 0 2.5rem 6rem; position: relative; z-index: 1;
}

.article h2 {
  font-family: 'Lora', serif; font-size: 1.625rem; font-weight: 600;
  letter-spacing: -0.02em; color: var(--text-primary);
  margin: 3rem 0 1rem; padding-top: 0.5rem;
  border-top: 1px solid var(--border); transition: color 0.4s, border-color 0.4s;
}
.article h2:first-child { margin-top: 0; border-top: none; }

.article h3 {
  font-family: 'Lora', serif; font-size: 1.125rem; font-weight: 600;
  color: var(--text-primary); margin: 2rem 0 0.625rem; letter-spacing: -0.01em;
  transition: color 0.4s;
}

.article p {
  color: var(--text-secondary); margin-bottom: 1.1rem; transition: color 0.4s;
}
.article p:last-child { margin-bottom: 0; }

.article a {
  color: var(--terracotta); text-decoration: underline;
  text-decoration-color: rgba(212,114,90,0.4); text-underline-offset: 3px;
  transition: color 0.2s, text-decoration-color 0.2s;
}
.article a:hover { color: var(--clay); text-decoration-color: var(--clay); }

.article ul, .article ol {
  color: var(--text-secondary); padding-left: 1.5rem;
  margin-bottom: 1.25rem; display: flex; flex-direction: column; gap: 0.4rem;
  transition: color 0.4s;
}
.article li { padding-left: 0.25rem; }

.article strong { color: var(--text-primary); font-weight: 600; }
.article em { color: var(--clay); font-style: italic; }

/* ── Callout boxes ── */
.callout {
  background: var(--surface); border-left: 3px solid var(--terracotta);
  border-radius: 0 10px 10px 0; padding: 1.25rem 1.5rem;
  margin: 1.75rem 0; transition: background 0.4s;
}
.callout.tip   { border-color: var(--moss); }
.callout.warn  { border-color: #C4924A; }
.callout p { margin-bottom: 0; }
.callout-label {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--terracotta);
  margin-bottom: 0.5rem; display: block;
}
.callout.tip .callout-label  { color: var(--moss); }
.callout.warn .callout-label { color: #C4924A; }

/* ── Key term cards ── */
.term-grid {
  display: grid; gap: 0.875rem; margin: 1.5rem 0 2rem;
}
.term-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.1rem 1.35rem;
  transition: background 0.4s, border-color 0.4s;
}
.term-card:hover { border-color: var(--border-hover); background: var(--surface-mid); }
.term-name {
  font-weight: 600; color: var(--text-primary); font-size: 0.9375rem;
  margin-bottom: 0.2rem;
}
.term-def { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.6; }

/* ── Comparison table ── */
.compare-table {
  width: 100%; border-collapse: collapse; margin: 1.5rem 0 2rem;
  font-size: 0.9rem;
}
.compare-table th {
  text-align: left; padding: 0.75rem 1rem;
  background: var(--surface-hi); color: var(--text-primary);
  font-weight: 600; font-size: 0.8125rem; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  transition: background 0.4s;
}
.compare-table td {
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--border);
  color: var(--text-secondary); vertical-align: top;
  transition: color 0.4s, border-color 0.4s;
}
.compare-table tr:last-child td { border-bottom: none; }
.compare-table tr:hover td { background: var(--surface); }

/* ── Step list ── */
.steps { display: flex; flex-direction: column; gap: 1.25rem; margin: 1.5rem 0 2rem; }
.step {
  display: flex; gap: 1.25rem; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.25rem;
  transition: background 0.4s, border-color 0.4s;
}
.step-num {
  font-family: 'Lora', serif; font-size: 1.5rem; font-weight: 700;
  color: var(--terracotta); opacity: 0.35; line-height: 1;
  flex-shrink: 0; min-width: 2rem;
}
.step-content h4 {
  font-size: 0.9375rem; font-weight: 600; color: var(--text-primary);
  margin-bottom: 0.3rem;
}
.step-content p { font-size: 0.875rem; color: var(--text-secondary); margin: 0; }

/* ── Divider ── */
.divider { height: 1px; background: linear-gradient(to right, transparent, var(--surface-hi), transparent); margin: 2.5rem 0; }

/* ── Related pages ── */
.related {
  margin-top: 4rem; padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.related-label {
  font-size: 0.7rem; font-weight: 500; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--terracotta);
  margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem;
}
.related-label::before { content: ''; display: block; width: 16px; height: 1px; background: var(--terracotta); opacity: 0.5; }
.related-links { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.related-link {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: 100px; font-size: 0.8125rem; color: var(--clay);
  text-decoration: none; transition: background 0.25s, border-color 0.25s, color 0.25s, transform 0.25s;
}
.related-link:hover { background: var(--surface-mid); border-color: var(--border-hover); color: var(--text-primary); transform: translateY(-1px); }
.related-link::before { content: '→'; font-size: 0.75rem; color: var(--terracotta); transition: transform 0.2s; }
.related-link:hover::before { transform: translateX(2px); }

/* ── Disclaimer ── */
.disclaimer-bar {
  background: var(--surface); border-left: 2px solid var(--terracotta);
  border-radius: 0 8px 8px 0; padding: 1rem 1.25rem;
  font-size: 0.8rem; color: var(--text-dim); font-style: italic;
  margin-top: 3rem; transition: background 0.4s;
}

/* ── Footer ── */
footer {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 2.5rem; text-align: center; position: relative; z-index: 1;
  transition: background 0.4s, border-color 0.4s;
}
.footer-logo {
  font-family: 'Lora', serif; font-size: 1.25rem; font-weight: 600;
  color: var(--text-primary); margin-bottom: 0.3rem; letter-spacing: -0.02em;
}
.footer-logo span { color: var(--terracotta); }
.footer-copy { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.5rem; }

/* ── Fade-in ── */
.fade-in { opacity: 0; transform: translateY(20px); transition: opacity 0.6s ease, transform 0.6s ease; }
.fade-in.visible { opacity: 1; transform: translateY(0); }

/* ── Responsive ── */
@media (max-width: 768px) {
  nav { padding: 0 1.25rem; }
  .nav-links { display: none; }
  .page-header { padding: 100px 1.25rem 2rem; }
  .article { padding: 0 1.25rem 4rem; }
  footer { padding: 2rem 1.25rem; }
}
