/* ================================================================
   OECD Education at a Glance — Design System
   ================================================================ */

/* ── Google Font is loaded in index.html (Source Sans 3) ── */

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

html { font-size: 15px; }

body {
  margin: 0;
  background: #F4F6F8;
  color: #1A2733;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* ── CSS custom properties ── */
:root {
  --oecd-blue: #003865;
  --bright:    #0070CC;
  --teal:      #00877A;
  --orange:    #E87722;
  --red:       #C6002B;
  --light:     #9DC3E6;
  --grey:      #6D6E71;
  --border:    #E1E5EA;
}

/* ================================================================
   HEADER  (.hdr)
   ================================================================ */
.hdr {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 60px;
  background: var(--oecd-blue);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
}

/* Hamburger — only shown on narrow screens */
.hdr-menu {
  display: none;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  color: #fff;
  font-size: 16px;
  line-height: 1;
  padding: 5px 9px;
  cursor: pointer;
  flex-shrink: 0;
}

.hdr-brand { display: flex; flex-direction: column; gap: 1px; }

.hdr-pub {
  color: #fff;
  font-weight: 600;
  font-size: 17px;
  line-height: 1.2;
}

.hdr-tag {
  color: rgba(255, 255, 255, 0.65);
  font-size: 12px;
  line-height: 1.2;
}

.hdr-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.hdr-badge {
  background: #E87722;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 20px;
  flex-shrink: 0;
}

.hdr-src {
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
}

/* ================================================================
   CONTROLS BAR  (.cbar)
   ================================================================ */
.cbar {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  z-index: 99;
  height: 44px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 10px;
}

.cbar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--grey);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.cbar-select {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 14px;
  font-family: inherit;
  color: #1A2733;
  background: #fff;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.cbar-select:focus { border-color: var(--bright); }

.cbar-hint {
  font-size: 12px;
  color: #8493A0;
  margin-left: 14px;
}

/* ================================================================
   LAYOUT SHELL
   ================================================================ */
.shell {
  display: flex;
  flex-direction: row;
  height: calc(100vh - 104px);
  margin-top: 104px;   /* hdr(60) + cbar(44) */
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 270px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Main content ── */
.main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px 36px;
}

/* ================================================================
   SIDEBAR NAVIGATION
   ================================================================ */

/* Search / filter box at the top of the sidebar */
.nav-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: #FAFBFC;
}

.nav-search input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  color: #1A2733;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}

.nav-search input:focus { border-color: var(--bright); }

.nav-search input::placeholder { color: #8493A0; }

/* Standing note at the foot of the sidebar: the site is public but noindex'd. */
.nav-note {
  margin: 16px 12px 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  line-height: 1.5;
  color: #8493A0;
}

/* Overview / Country Profile items (styled like a chapter row).
   These rows carry both `nav-item` and `nav-overview`; the compound selector
   outranks the later `.nav-item` rule so its 46px indent / zero gap don't apply,
   keeping the badge aligned with the chapter badges below. */
.nav-item.nav-overview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: #1A2733;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.nav-item.nav-overview:hover { background: #F0F4F8; }

/* Chapter header row */
.nav-chapter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: #1A2733;
  cursor: pointer;
  border-bottom: 1px solid #F0F2F5;
  transition: background 0.12s;
  user-select: none;
}

.nav-chapter:hover { background: #F0F4F8; }

/* Colored letter badge */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ch-color, var(--oecd-blue));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.nav-chlabel { flex: 1; }

/* Arrow rotates when group is open */
.nav-arrow {
  font-size: 12px;
  color: #8493A0;
  transition: transform 0.2s;
  display: inline-block;
}

.nav-group.open .nav-arrow { transform: rotate(180deg); }

/* Collapsible pages list */
.nav-pages {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.nav-group.open .nav-pages { max-height: 400px; }

/* Individual page item */
.nav-item {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 13px;
  padding: 8px 14px 8px 46px;
  cursor: pointer;
  color: #45525E;
  transition: background 0.1s, color 0.1s;
  position: relative;
}

.nav-item:hover { background: #F0F4F8; }

.nav-item.active {
  background: #E8F1FA;
  color: var(--oecd-blue);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--bright);
}

/* Short code label inside nav-item */
.nav-code {
  font-size: 11px;
  font-weight: 700;
  color: #45525E;
  margin-right: 6px;
  opacity: 0.7;
}

.nav-item.active .nav-code {
  color: var(--oecd-blue);
  opacity: 1;
}

/* ================================================================
   PAGE HEADER  (.page-hdr)
   ================================================================ */
.page-hdr {
  background: #fff;
  border-left: 4px solid var(--ch-color, var(--oecd-blue));
  border-radius: 0 6px 6px 0;
  padding: 18px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(16, 33, 49, 0.06);
}

.ph-crumb {
  font-size: 11px;
  font-weight: 600;
  color: var(--grey);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.ph-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--oecd-blue);
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.25;
}

/* Small colored chip before title */
.ph-code {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--ch-color, var(--oecd-blue));
  color: #fff;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.ph-sub {
  font-size: 14px;
  color: var(--grey);
  margin: 2px 0 0;
  max-width: 70ch;
  line-height: 1.5;
}

/* ================================================================
   PANELS
   ================================================================ */
.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(16, 33, 49, 0.06);
  margin-bottom: 20px;
}

/* Panels inside a grid have no individual margin */
.panel-grid .panel { margin-bottom: 0; }

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;          /* pages with two toggle groups wrap gracefully */
  padding: 16px 20px 8px;
  gap: 8px 12px;
}

.panel-head > div:first-child { flex: 1; min-width: 0; }

.panel-kicker {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ch-color, var(--grey));
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 2px;
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
  color: #14324E;
  margin: 2px 0;
  line-height: 1.3;
}

.panel-note {
  font-size: 12.5px;
  color: #5A6B7A;
  margin-top: 2px;
}

.panel-body {
  position: relative;
  padding: 8px 20px 16px;
}

.chart-wrap {
  position: relative;
  width: 100%;
}

.panel-src {
  padding: 8px 20px 12px;
  font-size: 11.5px;
  color: #8493A0;
  border-top: 1px solid #EEF1F4;
}

/* ── Panel grid ── */
.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

/* ================================================================
   LOADING & ERROR
   ================================================================ */
.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 13px;
  color: var(--grey);
  background: rgba(255, 255, 255, 0.85);
  z-index: 10;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid #E1E5EA;
  border-top-color: var(--bright);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.err {
  color: var(--red);
  font-size: 13px;
  max-width: 48ch;
  text-align: center;
  line-height: 1.4;
}

/* ================================================================
   TOGGLE BUTTON GROUP  (.pbtn-group)
   ================================================================ */
.pbtn-group {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}

.pbtn {
  font-size: 12px;
  font-family: inherit;
  padding: 5px 12px;
  background: #fff;
  border: none;
  border-left: 1px solid var(--border);
  color: #45525E;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}

.pbtn:first-child { border-left: none; }

.pbtn:hover:not(.active) { background: #F0F4F8; }

.pbtn.active {
  background: var(--bright);
  color: #fff;
}

/* ================================================================
   STAT CARDS  (overview page)
   ================================================================ */
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  border-top: 4px solid var(--ch-color, var(--oecd-blue));
  box-shadow: 0 1px 2px rgba(16, 33, 49, 0.06);
  padding: 16px 20px 14px;
  flex: 1;
  min-width: 180px;
}

.stat-kicker {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--grey);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.stat-val {
  font-size: 30px;
  font-weight: 800;
  color: var(--oecd-blue);
  line-height: 1.1;
  margin-bottom: 4px;
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 12px;
  color: var(--grey);
  line-height: 1.3;
}

/* ================================================================
   PAGE FOOTER NAVIGATION  (.page-footnav)
   ================================================================ */
.page-footnav {
  display: flex;
  gap: 16px;
  margin: 4px 0 28px;
}

.fn-link {
  flex: 1;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fn-link:hover:not(.fn-empty) {
  border-color: var(--bright);
  box-shadow: 0 1px 4px rgba(0, 112, 204, 0.12);
}

.fn-empty { visibility: hidden; }

.fn-next { text-align: right; align-items: flex-end; }

.fn-dir {
  font-size: 11px;
  font-weight: 600;
  color: var(--grey);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.fn-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--oecd-blue);
}

/* ================================================================
   PAGE VISIBILITY
   ================================================================ */
.page { display: none; }
.page.active { display: block; }

/* ================================================================
   SITE FOOTER  (.main-ftr — scrolls with page content)
   ================================================================ */
.main-ftr {
  margin-top: 8px;
  padding: 18px 4px 6px;
  border-top: 1px solid var(--border);
}

.mf-brand {
  font-size: 12px;
  font-weight: 700;
  color: var(--oecd-blue);
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.mf-note {
  font-size: 12px;
  color: #8493A0;
  max-width: 90ch;
  line-height: 1.5;
}

.mf-note a { color: var(--bright); text-decoration: none; }
.mf-note a:hover { text-decoration: underline; }

/* ================================================================
   FOCUS & SELECTION
   ================================================================ */
:focus-visible {
  outline: 2px solid var(--bright);
  outline-offset: 1px;
}

::selection { background: #CFE3F5; }

/* ================================================================
   SCROLLBARS  (WebKit)
   ================================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(109, 110, 113, 0.35);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(109, 110, 113, 0.55); }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 1100px) {
  .sidebar { width: 220px; }
  .main { padding: 20px 24px; }
}

@media (max-width: 900px) {
  .panel-grid {
    grid-template-columns: 1fr;
  }

  .main { padding: 16px; }

  .hdr-src { display: none; }

  /* Off-canvas sidebar with hamburger toggle */
  .hdr-menu { display: inline-block; }

  .sidebar {
    position: fixed;
    top: 104px;
    bottom: 0;
    left: 0;
    width: 280px;
    z-index: 98;
    transform: translateX(-100%);
    transition: transform 0.22s ease, box-shadow 0.22s ease;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 18px rgba(16, 33, 49, 0.18);
  }

  .page-footnav { flex-direction: column; }
  .fn-empty { display: none; }
}

/* ================================================================
   PRINT
   ================================================================ */
@media print {
  .hdr, .cbar, .sidebar, .page-footnav, .nav-search, .pbtn-group { display: none !important; }
  .shell { margin-top: 0; height: auto; overflow: visible; }
  .main { overflow: visible; padding: 0; }
  body { background: #fff; }
  .panel, .page-hdr, .stat-card { box-shadow: none; break-inside: avoid; }
  .panel-grid { grid-template-columns: 1fr; }
}

/* ================================================================
   COMPANION EDITION ADDITIONS
   ================================================================ */

/* Control-bar pills — each selector is accented with its chart colour (orange for the
   highlight country, teal for the compare country) so the whole bar is easy to see and
   reads as a legend for the charts. */
.cbar { box-shadow: 0 2px 5px rgba(16, 33, 49, 0.07); }

.cbar-ctl {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px 3px 11px;
  border: 1px solid var(--border);
  border-radius: 18px;
}

.cbar-ctl + .cbar-ctl { margin-left: 12px; }

.cbar-highlight { background: #FDF2E9; border-color: #F1CFAE; }
.cbar-compare  { background: #EAF6F3; border-color: #BFE0DB; }

.cbar-highlight .cbar-label { color: var(--orange); }
.cbar-compare  .cbar-label { color: var(--teal); }

.cbar-highlight .cbar-select { border-color: #E9B889; }
.cbar-compare  .cbar-select { border-color: #7FC4BA; }

.cbar-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.cbar-dot-hl  { background: var(--orange); }
.cbar-dot-cmp { background: var(--teal); }

/* Country Profile — compare banner (makes the compare feature discoverable from the page) */
.pf-compare-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: #2A4A45;
  background: #EAF6F3;
  border: 1px solid #BFE0DB;
  border-left: 3px solid var(--teal);
  border-radius: 6px;
  padding: 9px 14px;
  margin-bottom: 16px;
}

.pf-compare-banner.is-on { background: #DDEFEA; }

.pf-cmp-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--teal);
  flex-shrink: 0;
}

.pf-cmp-clear {
  margin-left: auto;
  font-size: 12px;
  font-family: inherit;
  color: var(--teal);
  background: #fff;
  border: 1px solid #7FC4BA;
  border-radius: 4px;
  padding: 2px 10px;
  cursor: pointer;
}

.pf-cmp-clear:hover { border-color: var(--teal); }

/* question chips on the overview */
.qchips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}

.qc-lead {
  font-size: 12px;
  font-weight: 700;
  color: var(--grey);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 2px;
}

.qchip {
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 5px 13px;
  color: var(--oecd-blue);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.qchip:hover { border-color: var(--bright); background: #F0F7FD; }

/* panel foot: source + export tools on one line */
.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid #EEF1F4;
}

.panel-foot .panel-src { border-top: none; flex: 1; }

.panel-tools { display: flex; align-items: center; gap: 6px; padding-right: 12px; }

/* small "Download" lead-in so the export chips read clearly as a download control */
.panel-tools::before {
  content: 'Download';
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--grey);
  margin-right: 2px;
}

.ptool {
  font-size: 11.5px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.03em;
  color: var(--bright);
  background: #EAF2FB;
  border: 1px solid #CFE1F5;
  border-radius: 4px;
  padding: 4px 11px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

/* download arrow on the file-export chips (not on the copy-link chip) */
.ptool[data-act="png"]::before,
.ptool[data-act="csv"]::before { content: '\2193\00A0'; }

.ptool:hover { background: var(--bright); border-color: var(--bright); color: #fff; }

/* ── Country Profile ── */
.pf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  min-height: 120px;
}

.pf-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px 10px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pf-card:hover { border-color: var(--bright); box-shadow: 0 1px 6px rgba(0, 112, 204, 0.12); }

.pf-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--grey);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.3;
}

.pf-valrow { display: flex; align-items: baseline; gap: 8px; }

.pf-val {
  font-size: 24px;
  font-weight: 800;
  color: var(--oecd-blue);
  font-variant-numeric: tabular-nums;
}

.pf-year { font-size: 11px; color: #8493A0; }

.pf-comparow { display: flex; gap: 10px; font-size: 12px; min-height: 16px; }

.pf-oecd { color: var(--grey); }

.pf-cmp { color: var(--teal); font-weight: 600; }

.pf-bottomrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

.pf-rank {
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 8px;
  white-space: nowrap;
}

.pf-rank-top    { background: #E3F2EC; color: #00694A; }
.pf-rank-mid    { background: #EEF1F4; color: #45525E; }
.pf-rank-bottom { background: #FBEAE5; color: #B7472A; }

.pf-nospark { color: #C6CDD4; font-size: 12px; }

.pf-unitnote { font-size: 10.5px; color: #8493A0; }

.pf-standout { margin: 0; padding-left: 18px; }

.pf-standout li {
  font-size: 13.5px;
  line-height: 1.55;
  margin-bottom: 10px;
  cursor: pointer;
}

.pf-standout li:hover .pf-golink { text-decoration: underline; }

.pf-golink { color: var(--bright); font-weight: 600; font-size: 12px; white-space: nowrap; }

.pf-similar { font-size: 14px; line-height: 1.6; margin: 0; }

.pf-none { color: var(--grey); font-size: 13px; }

.pf-print { margin-left: auto; flex-shrink: 0; }

@media print {
  .pf-print, .panel-tools { display: none !important; }
  .pf-grid { grid-template-columns: repeat(3, 1fr); }
}

/* retry button inside panel error state */
.err-retry { border: 1px solid var(--border); border-radius: 4px; }

/* profile card: side-by-side country duel (compare mode) */
.pf-duel { display: flex; flex-direction: column; gap: 2px; }

.pf-duelrow {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.pf-duelname {
  font-size: 12px;
  font-weight: 600;
  min-width: 72px;
  color: #45525E;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pf-duel .pf-val { font-size: 19px; }

.pf-val-a { color: #E87722; }
.pf-val-b { color: var(--teal); }

/* clickable overview stat cards */
.stat-link { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.stat-link:hover { border-color: var(--bright); box-shadow: 0 2px 8px rgba(0, 112, 204, 0.14); }
