/* ==========================================================================
   Earth Genome Jekyll Theme
   Fonts: Inter (body/UI) + Tiempos Headline (display/headings)
   Colors derived from earthgenome.org
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

@font-face {
  font-family: 'Tiempos Headline';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: local('Tiempos Headline Light'), local('TiemposHeadline-Light');
}
@font-face {
  font-family: 'Tiempos Headline';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local('Tiempos Headline Regular'), local('TiemposHeadline-Regular');
}

/* --------------------------------------------------------------------------
   Design tokens
   -------------------------------------------------------------------------- */
:root {
  --color-ink:          #0A0A0A;
  --color-ink-muted:    #4A4A4A;
  --color-ink-faint:    #8A8A8A;
  --color-surface:      #F7F6F2;
  --color-surface-card: #FFFFFF;
  --color-surface-soft: #EEECEA;
  --color-border:       #E0DED9;

  --color-accent:       #2E7D5A;
  --color-accent-light: #3E9E70;
  --color-accent-pale:  #E8F4EE;

  --color-nav-bg:       rgba(247, 246, 242, 0.94);
  --color-nav-border:   rgba(0, 0, 0, 0.07);

  --font-display: 'Tiempos Headline', 'Georgia', 'Times New Roman', serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  2rem;
  --text-4xl:  2.75rem;
  --text-5xl:  3.75rem;

  --leading-tight:  1.2;
  --leading-snug:   1.35;
  --leading-normal: 1.6;
  --leading-loose:  1.8;

  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-24: 6rem;

  --content-width: 860px;   /* wider reading column */
  --content-wide:  1100px;  /* wider nav/footer container */
  --nav-height:    88px;    /* two-row nav */

  --radius-sm: 4px;
  --radius-md: 8px;

  --ease:     cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 200ms;
}

/* --------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: var(--leading-normal);
  color: var(--color-ink);
  background: var(--color-surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --------------------------------------------------------------------------
   Navigation — two-row floating header
   -------------------------------------------------------------------------- */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--color-nav-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--color-nav-border);
  transition: box-shadow var(--duration) var(--ease);
}

.site-nav.scrolled {
  box-shadow: 0 2px 24px rgba(0,0,0,0.07);
}

.nav-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* ── Row 1: logo + title + mobile controls ── */
.nav-row-top {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: 56px;
}

.nav-logos {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.nav-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.nav-logo img {
  height: 34px;
  width: auto;
  display: block;
}

.nav-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--color-ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 0 0;
  min-width: 0;
  width: 0;
  opacity: 0;
  padding-left: 0;
  border-left: 0 solid transparent;
  margin-left: 0;
  transition: opacity var(--duration) var(--ease),
              width var(--duration) var(--ease),
              flex var(--duration) var(--ease),
              padding-left var(--duration) var(--ease),
              margin-left var(--duration) var(--ease),
              border-left-width var(--duration) var(--ease);
}

.nav-title.is-visible {
  flex: 1 1 auto;
  width: auto;
  opacity: 1;
  padding-left: var(--space-4);
  border-left-width: 1px;
  border-left-color: var(--color-border);
  margin-left: var(--space-2);
}

/* Mobile section indicator — hidden on desktop */
.nav-mobile-section {
  display: none;
}

/* ── Row 2: section links ── */
.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  height: 32px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: var(--space-1);
}

.nav-links::-webkit-scrollbar { display: none; }

.nav-links li { flex-shrink: 0; }

.nav-links a {
  display: block;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-ink-muted);
  text-decoration: none;
  padding: 4px var(--space-3);
  border-radius: var(--radius-sm);
  transition: color var(--duration) var(--ease),
              font-weight var(--duration) var(--ease);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.nav-links a:hover {
  color: var(--color-ink);
  background: var(--color-surface-soft);
}

/* Active section */
.nav-links a.active {
  color: var(--color-ink);
  font-weight: 600;
}

.nav-links a.active:hover {
  color: var(--color-ink);
  background: transparent;
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  margin-left: auto;
  flex-shrink: 0;
}

.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-ink);
  border-radius: 2px;
  transition: transform var(--duration) var(--ease),
              opacity var(--duration) var(--ease);
}

/* --------------------------------------------------------------------------
   Reading progress bar
   -------------------------------------------------------------------------- */
.reading-progress {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  height: 3px;
  z-index: 99;
}

.reading-progress-bar {
  height: 100%;
  background: var(--color-accent);
  width: 0%;
  transition: width 80ms linear;
}

/* --------------------------------------------------------------------------
   Hero / article header
   -------------------------------------------------------------------------- */
.article-hero {
  padding-top: calc(var(--nav-height) + var(--space-16));
  padding-bottom: var(--space-12);
  border-bottom: 1px solid var(--color-border);
}

.article-hero-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.article-title {
  font-family: var(--font-display);
  font-size: clamp(var(--text-3xl), 5vw, var(--text-5xl));
  font-weight: 300;
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
  color: var(--color-ink);
  margin-bottom: var(--space-8);
}

.article-meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-ink-faint);
  flex-wrap: wrap;
}

.article-meta .meta-separator {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--color-ink-faint);
}

/* --------------------------------------------------------------------------
   Main layout
   -------------------------------------------------------------------------- */
.page-wrapper {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-16) var(--space-6);
}

/* --------------------------------------------------------------------------
   Article body
   -------------------------------------------------------------------------- */

/* Summary — wrap section in `<section class="article-summary" markdown="1">` */
.article-summary {
  margin-bottom: var(--space-12);
  padding: var(--space-8) var(--space-8);
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.article-summary h2 {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: var(--leading-normal);
  color: var(--color-accent);
  margin: 0 0 var(--space-6);
}

.article-summary p {
  font-family: var(--font-body);
  font-size: var(--text-xl);
  font-weight: 400;
  line-height: var(--leading-loose);
  color: var(--color-ink-muted);
  margin-bottom: var(--space-5);
}

.article-summary p:last-child {
  margin-bottom: 0;
}

.article-body h2 {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 300;
  line-height: var(--leading-snug);
  letter-spacing: -0.02em;
  color: var(--color-ink);
  margin-top: var(--space-16);
  margin-bottom: var(--space-6);
}

.article-body h2:first-child { margin-top: 0; }

.article-body h3 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
  line-height: var(--leading-snug);
  color: var(--color-ink);
  margin-top: var(--space-10);
  margin-bottom: var(--space-3);
}

.article-body h4 {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-ink);
  margin-top: var(--space-8);
  margin-bottom: var(--space-2);
}

.article-body p {
  font-size: var(--text-lg);
  line-height: var(--leading-loose);
  color: var(--color-ink);
  margin-bottom: var(--space-6);
}

.article-body > p:first-of-type {
  font-size: var(--text-xl);
  font-weight: 300;
  color: var(--color-ink-muted);
  line-height: 1.7;
}

.article-body a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--duration) var(--ease);
}

.article-body a:hover { color: var(--color-accent-light); }

.article-body ul:not(.callout-insights),
.article-body ol:not(.callout-insights) {
  margin: var(--space-8) 0;
  padding: var(--space-5) var(--space-6);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  list-style: none;
}

/* Insights callout — add `{: .callout-insights}` on the line after ul or ol in markdown */
.article-body :is(ul, ol).callout-insights {
  position: relative;
  margin: var(--space-8) 0;
  padding: var(--space-6);
  padding-bottom: var(--space-10);
  background: var(--color-accent-pale);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  list-style: none;
}

.article-body :is(ul, ol).callout-insights::before {
  content: 'Insights';
  position: absolute;
  right: var(--space-5);
  bottom: var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
  pointer-events: none;
}

.article-body :is(ul, ol).callout-insights > li {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 400;
  line-height: var(--leading-loose);
  color: var(--color-ink);
  margin-bottom: var(--space-4);
  padding-left: 0;
}

.article-body :is(ul, ol).callout-insights > li:last-child {
  margin-bottom: 0;
}

.article-body :is(ul, ol).callout-insights > li::before {
  content: none;
}

.article-body :is(ul, ol).callout-insights > li p {
  margin: 0;
}

.article-body :is(ul, ol).callout-insights > li strong {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--color-ink);
  margin-bottom: var(--space-1);
}

.article-body ul ul,
.article-body ol ol,
.article-body ul ol,
.article-body ol ul,
.article-body :is(ul, ol).callout-insights :is(ul, ol) {
  margin: var(--space-3) 0 0;
  padding: 0;
  background: none;
  border-left: none;
  border-radius: 0;
}

.article-body li {
  font-size: var(--text-lg);
  line-height: var(--leading-loose);
  margin-bottom: var(--space-3);
}

.article-body li:last-child {
  margin-bottom: 0;
}

.article-body ul:not(.callout-insights) li {
  position: relative;
  padding-left: var(--space-5);
}

.article-body ul:not(.callout-insights) li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--color-accent);
  font-weight: 300;
}

.article-body ol:not(.callout-insights) {
  counter-reset: list-item;
}

.article-body ol:not(.callout-insights) li {
  counter-increment: list-item;
  position: relative;
  padding-left: var(--space-6);
}

.article-body ol:not(.callout-insights) li::before {
  content: counter(list-item) '.';
  position: absolute;
  left: 0;
  color: var(--color-accent);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.article-body strong {
  font-weight: 600;
  color: var(--color-ink);
}

/* Hide <hr> — spacing handled by h2 margins */
.article-body hr { display: none; }

.article-body blockquote {
  border-left: 3px solid var(--color-accent);
  padding: var(--space-4) var(--space-6);
  margin: var(--space-8) 0;
  background: var(--color-accent-pale);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.article-body blockquote p {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 300;
  font-style: italic;
  color: var(--color-ink-muted);
  margin: 0;
}

.article-body code {
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: 0.85em;
  background: var(--color-surface-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.15em 0.4em;
}

.article-body pre {
  background: #0F1A14;
  border-radius: var(--radius-md);
  padding: var(--space-6);
  margin: var(--space-8) 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow-x: auto;
}

.article-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: var(--text-sm);
  color: #B8D4C4;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.article-body .language-json .highlight {
  max-width: 100%;
}

.article-body h2[id],
.article-body h3[id] {
  scroll-margin-top: calc(var(--nav-height) + var(--space-4));
}

/* Appendix — wrap in `<section class="article-appendix" markdown="1">` */
.article-body .article-appendix {
  margin-top: var(--space-16);
  padding-top: var(--space-12);
  border-top: 1px solid var(--color-border);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-ink-muted);
}

.article-body .article-appendix :is(h2, h3, h4, p, li, a, strong, em) {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

.article-body .article-appendix h2 {
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--color-ink);
  margin: 0 0 var(--space-6);
}

.article-body .article-appendix h3 {
  font-weight: 600;
  color: var(--color-ink);
  margin: var(--space-8) 0 var(--space-2);
}

.article-body .article-appendix h3:first-of-type {
  margin-top: var(--space-6);
}

.article-body .article-appendix p {
  margin-bottom: var(--space-4);
}

.article-body .article-appendix p:last-child {
  margin-bottom: 0;
}

.article-body .article-appendix strong {
  font-weight: 600;
}

.article-body .article-appendix a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.article-body .article-appendix a:hover {
  color: var(--color-accent-light);
}

.article-body .article-appendix :is(ul, ol) {
  margin: var(--space-3) 0 var(--space-5);
  padding: 0 0 0 var(--space-5);
  background: none;
  border: none;
  border-left: none;
  border-radius: 0;
  list-style: disc;
}

.article-body .article-appendix ol {
  list-style: decimal;
}

.article-body .article-appendix :is(ul, ol) li {
  margin-bottom: var(--space-3);
  padding-left: 0;
}

.article-body .article-appendix :is(ul, ol) li:last-child {
  margin-bottom: 0;
}

.article-body .article-appendix :is(ul, ol) li::before {
  content: none;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-3) 0;
  margin-top: var(--space-24);
}

.site-footer.is-anchored {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  margin-top: 0;
  background: var(--color-nav-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--color-nav-border);
}

.site-footer-spacer {
  height: 0;
}

.footer-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.footer-title {
  display: none;
}

.footer-details {
  display: contents;
}

.footer-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.footer-logo img {
  height: 34px;
  width: auto;
  display: block;
  opacity: 0.6;
  transition: opacity var(--duration) var(--ease);
}

.footer-logo:hover img { opacity: 1; }

.footer-links {
  display: flex;
  gap: var(--space-4);
  list-style: none;
  flex-wrap: wrap;
}

.footer-links a {
  font-size: var(--text-sm);
  color: var(--color-ink-faint);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
}

.footer-links a:hover { color: var(--color-ink); }

.footer-copy {
  font-size: var(--text-xs);
  color: var(--color-ink-faint);
}

/* --------------------------------------------------------------------------
   Mobile / tablet — title + current section bar
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {

  :root {
    --nav-height: 56px;  /* single row on mobile */
  }

  /* Hide page title in header; keep current section + menu */
  .nav-title,
  .nav-title.is-visible { display: none !important; }
  .nav-links { display: none; }

  .nav-logos { gap: var(--space-2); }

  .nav-logo img { height: 26px; }

  .footer-logo img { height: 26px; }

  /* Show hamburger */
  .nav-toggle { display: flex; }

  /* Current section indicator */
  .nav-mobile-section {
    display: block;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    text-align: right;
    padding-right: var(--space-2);
  }

  /* Mobile footer: anchored bar with title; expands after appendix */
  .site-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    margin-top: 0;
    background: var(--color-nav-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--color-nav-border);
  }

  .footer-inner {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
  }

  .footer-title {
    display: block;
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 400;
    line-height: var(--leading-snug);
    color: var(--color-ink-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
  }

  .footer-details {
    display: none;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-border);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .footer-details::-webkit-scrollbar { display: none; }

  .site-footer.is-expanded .footer-details {
    display: flex;
  }

  .site-footer.is-expanded .footer-logo {
    flex-shrink: 0;
  }

  .site-footer.is-expanded .footer-links {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: var(--space-3);
    flex: 1;
    min-width: 0;
    justify-content: center;
  }

  .site-footer.is-expanded .footer-links li {
    flex-shrink: 0;
  }

  .site-footer.is-expanded .footer-links a {
    font-size: var(--text-xs);
    white-space: nowrap;
  }

  .site-footer.is-expanded .footer-copy {
    flex-shrink: 0;
    font-size: var(--text-xs);
    white-space: nowrap;
  }

  .page-wrapper {
    padding: var(--space-10) var(--space-4);
    padding-bottom: calc(var(--footer-height, 56px) + var(--space-4));
  }

  /* Mobile nav dropdown */
  .nav-links.open {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-3) var(--space-4) var(--space-4);
    box-shadow: 0 6px 24px rgba(0,0,0,0.08);
    height: auto;
    overflow: visible;
  }

  .nav-links.open li { flex-shrink: unset; }

  .nav-links.open a {
    font-size: var(--text-sm);
    padding: var(--space-2) var(--space-3);
  }

  /* Stack article title smaller */
  .article-title {
    font-size: clamp(var(--text-2xl), 6vw, var(--text-3xl));
  }

  .article-summary p { font-size: var(--text-lg); }

  .article-body p,
  .article-body li { font-size: var(--text-base); }

  .article-body > p:first-of-type { font-size: var(--text-lg); }
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 1ms !important; }
}
