/* === Metropolis (EITI's brand typeface) === */

@font-face {
  font-family: "Metropolis";
  src: url("fonts/metropolis-light.otf") format("opentype");
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: "Metropolis";
  src: url("fonts/metropolis-regular.otf") format("opentype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Metropolis";
  src: url("fonts/metropolis-medium.otf") format("opentype");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Metropolis";
  src: url("fonts/metropolis-semibold.otf") format("opentype");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Metropolis";
  src: url("fonts/metropolis-bold.otf") format("opentype");
  font-weight: 700;
  font-display: swap;
}

/* === Tokens === */

:root {
  --fg: #15171c;
  --fg-muted: #474b56;
  --fg-subtle: #626670;       /* WCAG AA: 5.21:1 on --bg */
  --bg: #fbfcfd;
  --bg-soft: #eef2f6;
  --bg-elevated: #ffffff;
  --accent: #132856;         /* EITI navy */
  --accent-soft: #e4ebf4;
  --pending: #8a5800;         /* EITI gold, darkened for WCAG AA on light bg (5.6:1) */
  --pending-accent: #F6A70A;  /* the literal EITI gold, used on lines/borders */
  --pending-bg: #fdf3d2;
  --pending-rule: #f0c862;
  --rule: #d8dee8;
  --rule-soft: #e6ebf1;
  --code-fg: #132856;
  --code-bg: #eef2f6;
  --code-border: #d4dae4;
  --shadow: 0 1px 2px rgba(19, 40, 86, 0.06);
  --sans: "Metropolis", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --serif: "Metropolis", ui-serif, Georgia, Cambria, "Times New Roman", serif;
  --display: "Metropolis", ui-sans-serif, -apple-system, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* === Base === */

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

html {
  font-size: 17px;
  scroll-behavior: smooth;
}

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

/* === Focus ring (WCAG 2.4.7) === */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.site-header :focus-visible {
  outline-color: #ffffff;
  outline-offset: 3px;
}

.view-toggle button:focus-visible {
  outline-offset: 1px;
}

body {
  margin: 0;
  font-family: var(--sans);
  font-weight: 400;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration-color: var(--rule);
  text-underline-offset: 0.2em;
}
a:hover { text-decoration-color: currentColor; }

/* === Site header (EITI hero treatment — navy with the EITI hero image) === */

.site-header {
  background-color: var(--accent);
  background-image: url('hero-bg.png');
  background-size: 50%;
  background-position: right center;
  background-repeat: no-repeat;
  color: #ffffff;
}

.site-header-inner {
  position: relative;
  max-width: 80rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 2.5rem;
}

.eyebrow {
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
  margin: 0 0 0.45rem;
}

.site-header h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 2.6rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 0.6rem;
  color: #ffffff;
}

.lede {
  font-size: 1.02rem;
  color: rgba(255, 255, 255, 0.88);
  margin: 0;
  max-width: 56ch;
}

@media (max-width: 900px) {
  .site-header { background-size: 65%; }
}
@media (max-width: 600px) {
  .site-header { background-image: none; }
  .site-header-inner { padding: 1.75rem 1rem 1.5rem; }
}

/* === Sticky control strip (tabs + group-by) === */

.control-strip {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
}

.tabs {
  max-width: 80rem;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  gap: 0;
  font-family: var(--sans);
  font-size: 0.92rem;
}

.page-logo {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  display: inline-block;
  opacity: 0.85;
  transition: opacity 150ms;
  z-index: 12;
}
.page-logo:hover { opacity: 1; }
.page-logo img { display: block; height: 1.2rem; width: auto; }

/* Default state: logo sits on the dark hero, show the negative variant. */
.page-logo .logo-on-light { display: none; }
.page-logo .logo-on-dark { display: block; }

/* When pinned to the viewport top, the bg behind is the light sticky
   control bar, so flip to the positive (navy) variant. */
.page-logo.is-pinned {
  position: fixed;
  top: 0.85rem;
  opacity: 0.65;
}
.page-logo.is-pinned .logo-on-dark { display: none; }
.page-logo.is-pinned .logo-on-light { display: block; }

.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.85rem 1.1rem;
  color: var(--fg-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  letter-spacing: 0.01em;
  transition: color 120ms, border-color 120ms;
}
.tab:hover { color: var(--fg); }
.tab[aria-current="page"] {
  color: var(--fg);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tab[data-tab="pending"][aria-current="page"] {
  color: var(--pending);
  border-bottom-color: var(--pending-accent);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4em;
  padding: 0.1em 0.45em;
  border-radius: 999px;
  background: var(--pending-bg);
  color: var(--pending);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  border: 1px solid var(--pending-rule);
}

.badge.badge-muted {
  background: var(--bg-soft);
  color: var(--fg-subtle);
  border-color: var(--rule);
  font-weight: 500;
}

/* === Group-by toggle === */

.view-controls {
  max-width: 80rem;
  margin: 0 auto;
  padding: 0.6rem 1.5rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--fg-subtle);
  border-top: 1px solid var(--rule-soft);
}

body[data-tab="pending"] .view-controls { display: none; }

.view-label {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 600;
}

.view-toggle {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 2px;
}

.view-toggle button {
  font-family: var(--sans);
  font-size: 0.82rem;
  background: transparent;
  color: var(--fg-muted);
  border: none;
  padding: 0.3rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: color 120ms, background 120ms;
}

.view-toggle button:hover { color: var(--fg); }

.view-toggle button.is-active {
  background: var(--bg-elevated);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

/* === Layout === */

.layout {
  max-width: 80rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: 14rem 1fr;
  gap: 3rem;
  align-items: start;
}

body[data-tab="pending"] .layout {
  grid-template-columns: 1fr;
  max-width: 56rem;
}
body[data-tab="pending"] .toc { display: none; }

body[data-tab="decided"] .pending-view { display: none; }
body[data-tab="pending"] .decided-view { display: none; }

/* === TOC === */

.toc {
  position: sticky;
  top: 7rem;
  font-family: var(--sans);
  font-size: 0.87rem;
  max-height: calc(100vh - 9rem);
  overflow-y: auto;
}

.toc-title {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  margin: 0 0 0.6rem;
  font-weight: 600;
}

#toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--rule);
}
#toc-list li { margin: 0; }
#toc-list a {
  display: block;
  padding: 0.35rem 0.9rem;
  color: var(--fg-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -1px;
  line-height: 1.35;
  transition: color 120ms, border-color 120ms, background 120ms;
}
#toc-list a:hover {
  color: var(--accent);
  background: var(--accent-soft);
}
#toc-list a.is-active {
  color: var(--fg);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* === Main content === */

main { min-width: 0; max-width: 56rem; }
main .loading { color: var(--fg-subtle); font-style: italic; }

.intro-hidden { display: none; }
main hr { display: none; }

main h2 {
  font-family: var(--display);
  color: var(--accent);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 3.5rem 0 1rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 8rem;
}
main h2.is-first {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

main h3 {
  font-family: var(--display);
  color: var(--accent);
  font-size: 1.18rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 2.25rem 0 0.5rem;
  scroll-margin-top: 8rem;
}

main p, main ul, main ol { margin: 0.6rem 0; }
main ul, main ol { padding-left: 1.4rem; }
main li { margin: 0.25rem 0; }

main strong {
  font-family: var(--sans);
  font-weight: 600;
  color: var(--fg);
}

main code {
  font-family: var(--mono);
  font-size: 0.83em;
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 0.12em 0.4em;
  border-radius: 3px;
  border: 1px solid var(--code-border);
  overflow-wrap: anywhere;
  word-break: break-word;
}

main p, main dd, .fields dd p { overflow-wrap: anywhere; }
body { overflow-x: hidden; }

main p code, main li code, main dd code {
  vertical-align: 0.05em;
}

main a { color: var(--accent); }

/* === Field grid === */

.fields {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.6rem 1.5rem;
  margin: 1.25rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--rule-soft);
}

.fields dt {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  padding-top: 0.45em;
  line-height: 1.4;
}

.fields dd {
  margin: 0;
  min-width: 0;
}

.fields dd > p:first-child { margin-top: 0; }
.fields dd > p:last-child { margin-bottom: 0; }
.fields dd > ul, .fields dd > ol { margin: 0.4rem 0; }

/* Technical detail rows are hidden by default; toggle reveals them. */
body:not(.show-technical) .field-technical { display: none; }

body.show-technical .fields dt.field-technical {
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.5em 0.65em 0.5em;
  border-radius: 4px 0 0 4px;
  margin-top: 0.35rem;
}
body.show-technical .fields dd.field-technical {
  background: var(--accent-soft);
  padding: 0.55rem 0.85rem;
  border-radius: 0 4px 4px 0;
  margin-top: 0.35rem;
}

.tech-controls {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-family: var(--sans);
  color: var(--fg-subtle);
}
.tech-controls .view-label {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.66rem;
  font-weight: 600;
}
.tech-controls .view-toggle {
  align-self: flex-start;
  padding: 1px;
}
.tech-controls .view-toggle button {
  font-size: 0.74rem;
  padding: 0.2rem 0.65rem;
  letter-spacing: 0;
}

.back-to-top {
  position: fixed;
  bottom: 1.25rem;
  left: 1.25rem;
  z-index: 50;
  background: var(--bg-elevated);
  color: var(--fg-muted);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  transition: color 120ms, border-color 120ms, opacity 200ms;
}
.back-to-top:hover {
  color: var(--fg);
  border-color: var(--fg-subtle);
}
.back-to-top[hidden] { display: none; }

/* === Pending tab: pending-view content reads like decided-view; the tab
   itself carries the orange affordance, so no need to re-style the body. */

.pending-view { margin: 0; }

/* The section heading "0. Pending Decisions" is redundant with the tab. */
.pending-view h2 { display: none; }

/* === Footer === */

.site-footer {
  max-width: 56rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--fg-subtle);
}
.site-footer p { margin: 0.3rem 0; }

@media (max-width: 900px) {
  .page-logo { top: 1rem; right: 1rem; }
  .page-logo img { height: 0.95rem; }
  .page-logo.is-pinned { top: 0.75rem; }
}

/* === Mobile === */

@media (max-width: 900px) {
  html { font-size: 16px; }

  .site-header-inner { padding: 1.25rem 1rem 0.75rem; }
  .site-header h1 { font-size: 1.7rem; }
  .tabs { padding: 0 1rem; }
  .view-controls { padding: 0.5rem 1rem 0.6rem; }

  .layout {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1.25rem 1rem 3rem;
  }

  .toc {
    position: static;
    max-height: none;
    margin: 0 -1rem 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--rule);
  }
  .toc-title { display: none; }
  #toc-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    border-left: none;
  }
  #toc-list a {
    padding: 0.2rem 0;
    border-left: none;
    margin-left: 0;
    font-size: 0.88rem;
  }
  #toc-list a.is-active { border-left: none; }

  main h2 { font-size: 1.35rem; margin: 2.5rem 0 0.75rem; padding-top: 1.75rem; }
  main h3 { font-size: 1.08rem; margin: 1.75rem 0 0.4rem; }

  .fields {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
  .fields dt {
    padding-top: 0.65rem;
    font-size: 0.68rem;
  }
  .fields dd { margin-bottom: 0.1rem; }

  .pending-view { padding: 1rem 1.25rem 1.5rem; }
}
