/* ══════════════════════════════════════════════════════════════════════════
   GRID4EARTH — site styles
   Palette derived from the project's EGU talk: deep navy + teal/green accent.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  --navy:        #0a2540;
  --navy-deep:   #06192e;
  --navy-soft:   #14365c;
  --teal:        #2a9d8f;
  --teal-bright: #1ec8a0;
  --teal-dark:   #1f7a6f;
  --ink:         #16222e;
  --body:        #3d4b59;
  --muted:       #6b7a89;
  --line:        #e3e9f0;
  --light:       #f4f7fb;
  --light-alt:   #eef3f9;
  --white:       #ffffff;
  --radius:      14px;
  --radius-sm:   9px;
  --shadow:      0 6px 24px rgba(10, 37, 64, 0.08);
  --shadow-lg:   0 18px 48px rgba(10, 37, 64, 0.14);
  --maxw:        1140px;
  --font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --serif:       'Source Serif 4', Georgia, serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--body);
  background: var(--white);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

a { color: var(--teal-dark); text-decoration: none; }
a:hover { color: var(--teal); }

h1, h2, h3 { color: var(--ink); line-height: 1.2; margin: 0 0 .5em; }

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

/* ── Header ──────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 70px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 38px; width: auto; }
.brand-name { font-weight: 800; letter-spacing: .02em; color: var(--navy); font-size: 1.15rem; }
.site-nav { display: flex; align-items: center; gap: 8px; }
.nav-link {
  color: var(--ink); font-weight: 500; font-size: .94rem;
  padding: 8px 14px; border-radius: 8px; transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--light); color: var(--teal-dark); }
.nav-link.secondary {
  background: var(--navy); color: var(--white);
}
.nav-link.secondary:hover { background: var(--navy-soft); color: var(--white); }
.nav-toggle { display: none; background: none; border: 0; font-size: 1.4rem; color: var(--navy); cursor: pointer; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block; font-weight: 600; font-size: 1rem;
  padding: 13px 26px; border-radius: 10px; transition: transform .15s, box-shadow .15s, background .15s;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--teal); color: #fff; box-shadow: 0 6px 18px rgba(42, 157, 143, .35); }
.btn-primary:hover { background: var(--teal-dark); color: #fff; }
.btn-ghost { background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.3); }
.btn-ghost:hover { background: rgba(255,255,255,.16); color: #fff; }
/* secondary button on light backgrounds */
.btn-ghost-dark { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost-dark:hover { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
  position: relative; overflow: hidden;
  background: radial-gradient(1100px 520px at 75% -10%, var(--navy-soft) 0%, var(--navy) 45%, var(--navy-deep) 100%);
  color: #fff; padding: 96px 0 104px;
}
.hero-inner {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center;
}
.hero-text { max-width: 640px; }
.hero-visual { position: relative; }
.hero-visual img {
  width: 100%; max-width: 460px; margin: 0 auto;
  filter: drop-shadow(0 18px 50px rgba(0,0,0,.45));
  animation: floaty 7s ease-in-out infinite;
}
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
.eyebrow {
  text-transform: uppercase; letter-spacing: .14em; font-size: .78rem; font-weight: 600;
  color: var(--teal-bright); margin: 0 0 18px;
}
.hero-title {
  font-family: var(--serif); color: #fff; font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-weight: 700; margin-bottom: 22px; line-height: 1.12;
}
.hero-subtitle { font-size: clamp(1.05rem, 2vw, 1.25rem); color: #c9d6e3; margin-bottom: 34px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.hero-glow {
  position: absolute; right: -120px; top: -120px; width: 520px; height: 520px;
  background: radial-gradient(circle, rgba(30,200,160,.28) 0%, transparent 70%);
  z-index: 1; pointer-events: none;
}

/* ── Funders strip ───────────────────────────────────────────────────────── */
.funders { background: var(--navy-deep); color: #9fb2c5; }
.funders-inner { display: flex; align-items: center; gap: 20px; padding: 16px 24px; flex-wrap: wrap; }
.funders-label { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 600; }
.funder { color: #d6e2ee; font-weight: 600; }
.funder:hover { color: var(--teal-bright); }

/* ── Sections ────────────────────────────────────────────────────────────── */
.section { padding: 84px 0; }
.section-alt { background: var(--light); }
/* Keep anchored sections clear of the sticky header when navigating */
section[id], [id] { scroll-margin-top: 88px; }
.tag {
  display: inline-block; text-transform: uppercase; letter-spacing: .12em;
  font-size: .76rem; font-weight: 700; color: var(--teal-dark);
  background: rgba(42,157,143,.1); padding: 5px 12px; border-radius: 20px; margin-bottom: 16px;
}
.section-title { font-family: var(--serif); font-size: clamp(1.7rem, 3.5vw, 2.4rem); font-weight: 700; max-width: 760px; }
.section-lead { font-size: 1.12rem; color: var(--body); max-width: 760px; margin: 0 0 44px; }

/* ── Feature grid (overview) ─────────────────────────────────────────────── */
.feature-grid, .step-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.feature-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 30px; transition: transform .18s, box-shadow .18s;
}
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.feature-icon, .step-icon {
  width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center;
  font-size: 1.4rem; color: #fff; margin-bottom: 18px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
}
.feature-card h3, .step-card h3 { font-size: 1.18rem; }
.feature-card p, .step-card p { margin: 0; color: var(--body); font-size: .98rem; }

/* ── Step grid (DGGS explainer) ──────────────────────────────────────────── */
.step-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 30px; position: relative;
  border-top: 4px solid var(--teal);
}
.step-icon { background: var(--navy); }

/* ── Figures & illustrations ─────────────────────────────────────────────── */
.figure { margin: 0; }
.figure img {
  width: 100%; height: auto; border-radius: var(--radius);
  background: #fff; border: 1px solid var(--line);
}
.figure figcaption { margin-top: 12px; font-size: .88rem; color: var(--muted); line-height: 1.5; }
.figure-center { max-width: 420px; margin: 0 auto; text-align: center; }
.figure-center img { border-radius: 50%; border: none; background: transparent; padding: 0; }
.figure figcaption { max-width: 820px; }
/* interactive (Plotly) globe embed */
.figure-globe { max-width: 560px; margin: 0 auto; text-align: center; }
.figure-globe iframe {
  width: 100%; aspect-ratio: 1 / 1; border: 0; display: block; margin: 0 auto;
  background: transparent;
}
.figure-globe figcaption { margin-left: auto; margin-right: auto; }
/* full-width concept diagram */
.figure-wide { max-width: 900px; margin: 8px auto 0; text-align: center; }
.figure-wide img { padding: 24px; }
.figure-wide figcaption { margin-left: auto; margin-right: auto; }
/* a figure and its "show the code" box are one unit, separated from the next section */
.figure-block { margin: 0 auto 80px; }
.figure-block .figure { margin-left: auto; margin-right: auto; }
/* stacked wide result plots — each block gets the full content width */
.figure-stack { margin-top: 24px; }
.figure-stack .figure-block { max-width: 940px; }
.figure-stack .figure img { padding: 16px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: center; margin-bottom: 56px; }
.split-text .section-lead { margin-bottom: 0; }
.subsection-title { font-family: var(--serif); font-size: 1.4rem; margin: 24px 0 4px; text-align: center; }
.subsection-title-left { text-align: left; margin-top: 56px; }
.tool-note {
  font-size: .82rem; color: var(--muted); margin: 0 0 16px;
  padding: 8px 12px; background: var(--light-alt); border-radius: 8px;
}
.tool-note i { color: var(--teal-dark); margin-right: 4px; }
.code-card { margin-top: 24px; }
.code-card pre { margin: 0; font-size: .82rem; }
.code-caption { margin: 12px 0 0; font-size: .86rem; color: var(--muted); }
.code-caption a { font-weight: 600; white-space: nowrap; }

/* Expandable "show the code" box */
.code-details {
  max-width: 940px; margin: 32px auto 0;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--light);
}
.code-details > summary {
  cursor: pointer; list-style: none; padding: 16px 20px;
  font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 10px;
}
.code-details > summary::-webkit-details-marker { display: none; }
.code-details > summary::after { content: "▸"; margin-left: auto; color: var(--muted); transition: transform .15s; }
.code-details[open] > summary::after { transform: rotate(90deg); }
.code-details > summary i { color: var(--teal-dark); }
.code-details-meta { font-weight: 400; font-size: .82rem; color: var(--muted); font-family: 'SFMono-Regular', Consolas, monospace; }
.code-details pre { margin: 0 20px; max-height: 460px; overflow: auto; font-size: .8rem; }
.code-details .code-caption { padding: 14px 20px 18px; margin: 0; }
/* per-figure variant: sits just under its image */
.code-details-fig { max-width: 820px; margin: 12px auto 0; background: var(--white); }
.figure-stack .code-details-fig { max-width: 940px; }
.code-allnote { max-width: 820px; margin: 32px auto 0; text-align: center; }

/* ── Tools grid ──────────────────────────────────────────────────────────── */
.tool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.tool-card {
  display: flex; flex-direction: column; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 28px;
  color: var(--ink); transition: transform .18s, box-shadow .18s, border-color .18s;
}
.tool-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--teal); }
.tool-icon {
  width: 50px; height: 50px; border-radius: 12px; display: grid; place-items: center;
  font-size: 1.35rem; color: var(--teal-dark); background: rgba(42,157,143,.12); margin-bottom: 18px;
}
.tool-card h3 { font-size: 1.25rem; margin-bottom: 8px; }
.tool-tagline { color: var(--body); font-size: .96rem; flex: 1; margin: 0 0 20px; }
.tool-card-links { display: flex; align-items: center; gap: 8px; }
.tool-link {
  display: inline-flex; align-items: center; gap: 7px; font-size: .9rem; font-weight: 600;
  color: var(--ink); background: var(--light); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 8px; transition: background .15s, color .15s, border-color .15s;
}
.tool-link:hover { background: var(--teal); color: #fff; border-color: var(--teal); }
.tool-link.primary { background: rgba(42,157,143,.1); border-color: rgba(42,157,143,.25); color: var(--teal-dark); }
.tool-link.primary:hover { background: var(--teal); color: #fff; border-color: var(--teal); }

/* ── Community page ──────────────────────────────────────────────────────── */
.empty-note {
  padding: 26px 28px; background: var(--white); border: 1px dashed #c5d2df;
  border-radius: var(--radius); color: var(--muted); font-size: .98rem; margin: 0;
}
.empty-note i { color: var(--teal-dark); margin-right: 8px; }
.contribute-cta { text-align: center; }
.contribute-cta .section-title, .contribute-cta .section-lead { margin-left: auto; margin-right: auto; }

/* ── Demos ───────────────────────────────────────────────────────────────── */
.demo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.demo-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; color: var(--ink); transition: transform .18s, box-shadow .18s;
}
.demo-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.demo-card h3 { font-size: 1.12rem; display: flex; align-items: center; gap: 8px; }
.demo-card h3 i { font-size: .82rem; color: var(--muted); }
.demo-card p { margin: 0; color: var(--body); font-size: .96rem; }

/* ── Consortium logos ────────────────────────────────────────────────────── */
.logo-row { display: flex; align-items: center; justify-content: center; gap: 48px; flex-wrap: wrap; padding: 16px 0; }
.logo-item { display: grid; place-items: center; filter: grayscale(1); opacity: .7; transition: filter .2s, opacity .2s; }
.logo-item:hover { filter: grayscale(0); opacity: 1; }
.logo-item img { max-height: 64px; width: auto; }

/* ── Page hero (tools index, generic pages) ──────────────────────────────── */
.page-hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff; padding: 72px 0 60px;
}
.page-hero h1 { color: #fff; font-family: var(--serif); font-size: clamp(2rem, 4vw, 2.9rem); }
.page-lead { color: #c9d6e3; font-size: 1.15rem; max-width: 720px; }

/* ── Tool page ───────────────────────────────────────────────────────────── */
.tool-hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff; padding: 40px 0 56px;
}
.back-link { color: #9fb2c5; font-size: .9rem; font-weight: 500; display: inline-block; margin-bottom: 26px; }
.back-link:hover { color: var(--teal-bright); }
.tool-hero-head { display: flex; align-items: center; gap: 22px; }
.tool-hero-icon {
  width: 72px; height: 72px; flex: none; border-radius: 16px; display: grid; place-items: center;
  font-size: 1.9rem; color: #fff; background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
}
.tool-hero-head h1 { color: #fff; margin: 0; font-size: clamp(1.8rem, 4vw, 2.6rem); }
.tool-hero-tagline { color: #c9d6e3; font-size: 1.1rem; margin: 6px 0 0; }
.tool-links { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 26px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 600;
  color: #fff; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.22);
  padding: 8px 16px; border-radius: 30px; transition: background .15s;
}
.pill:hover { background: rgba(255,255,255,.2); color: #fff; }

.tool-body { display: grid; grid-template-columns: 1fr 320px; gap: 48px; padding-top: 56px; padding-bottom: 80px; }
.tool-content { min-width: 0; }
.tool-aside { display: flex; flex-direction: column; gap: 20px; }
.aside-card { background: var(--light); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.aside-card h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 14px; }
.install-block { margin: 0; }
.aside-links { list-style: none; margin: 0; padding: 0; }
.aside-links li { margin-bottom: 10px; }
.aside-links a { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--ink); }
.aside-links a:hover { color: var(--teal-dark); }
.aside-links i { width: 18px; text-align: center; color: var(--teal-dark); }

/* ── Prose (markdown body) ───────────────────────────────────────────────── */
.prose, .tool-content { color: var(--body); font-size: 1.04rem; }
.prose h2, .tool-content h2 { font-family: var(--serif); font-size: 1.6rem; margin-top: 1.6em; }
.prose h3, .tool-content h3 { font-size: 1.22rem; margin-top: 1.4em; }
.tool-content ul, .prose ul { padding-left: 1.3em; }
.tool-content li, .prose li { margin-bottom: .5em; }
.prose ol { padding-left: 1.3em; }
.prose ol li { margin-bottom: .8em; }
/* tables (e.g. the contribute guide) */
.prose table { border-collapse: collapse; width: 100%; margin: 1.4em 0; font-size: .96rem; }
.prose th, .prose td { border: 1px solid var(--line); padding: 10px 14px; text-align: left; vertical-align: top; }
.prose th { background: var(--light); font-weight: 600; color: var(--ink); }
.prose tbody tr:nth-child(even) { background: var(--light-alt); }
pre {
  background: var(--navy-deep); color: #e6edf3; padding: 18px 20px; border-radius: var(--radius-sm);
  overflow-x: auto; font-size: .9rem; line-height: 1.6;
}
pre code { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; }
:not(pre) > code {
  background: var(--light-alt); color: var(--teal-dark); padding: 2px 7px;
  border-radius: 5px; font-size: .9em; font-family: 'SFMono-Regular', Consolas, monospace;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer { background: var(--navy-deep); color: #9fb2c5; padding: 56px 0 28px; }
.footer-inner { display: flex; justify-content: space-between; gap: 40px; flex-wrap: wrap; padding-bottom: 32px; border-bottom: 1px solid rgba(255,255,255,.08); }
.footer-brand { max-width: 420px; }
.footer-logo { height: 40px; margin-bottom: 16px; }
.footer-brand p { margin: 0; font-size: .95rem; }
.footer-links { display: flex; flex-direction: column; gap: 10px; }
.footer-links a { color: #c9d6e3; font-weight: 500; }
.footer-links a:hover { color: var(--teal-bright); }
.footer-bottom { padding-top: 22px; }
.footer-bottom p { margin: 0; font-size: .85rem; color: #6b8199; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .feature-grid, .step-grid, .tool-grid, .demo-grid { grid-template-columns: 1fr 1fr; }
  .tool-body { grid-template-columns: 1fr; }
  .hero-inner { grid-template-columns: 1fr; text-align: center; }
  .hero-text { max-width: none; }
  .hero-actions { justify-content: center; }
  .hero-visual { order: -1; }
  .hero-visual img { max-width: 300px; }
  .split { grid-template-columns: 1fr; gap: 32px; }
  .figure-row { grid-template-columns: 1fr; }
}
/* ── Print / PDF export ──────────────────────────────────────────────────── */
@media print {
  .site-header { position: static; box-shadow: none; backdrop-filter: none; background: #fff; }
  .nav-toggle, .site-nav { display: none; }
  .hero-glow { display: none; }
  .hero-visual img { animation: none; }
  .hero { background: var(--navy); }
  .section { padding: 36px 0; }
  /* don't split cards/figures across pages */
  .feature-card, .step-card, .tool-card, .demo-card, .figure, .split, .code-card,
  .figure-row, section { break-inside: avoid; }
  a[target="_blank"]::after { content: ""; }
}

@media (max-width: 680px) {
  .nav-toggle { display: block; }
  .site-nav {
    display: none; position: absolute; top: 70px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 4px;
    background: #fff; border-bottom: 1px solid var(--line); padding: 12px 16px;
  }
  .site-nav.open { display: flex; }
  .feature-grid, .step-grid, .tool-grid, .demo-grid { grid-template-columns: 1fr; }
  .section { padding: 60px 0; }
  .hero { padding: 70px 0 76px; }
  .tool-hero-head { flex-direction: column; align-items: flex-start; }
}
