/*
File: assets/css/styles.css
Purpose: Site-wide styles: layout, responsive rules, sidebar/overlay stacking, active menu highlighting.
Related files:
  - assets/js/site.js
  - _includes/sidebar.html
  - _layouts/default.html
Safe edits:
  - OK: Typography, spacing, colors, responsive widths
  - Careful: z-index values for sidebar/overlay; breakpoints affecting mobile menu behavior
*/

/* ===== base typography ===== */
html, body, h1, h2, h3, h4, h5 {
    font-family: "Noto Sans", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  }

.site-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

html, body {
    margin: 0;
    min-height: 100%;
    font-size: 16px;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
  }

  :root {
    --site-accent: #3f536b;
    --site-accent-dark: #334457;
    --site-icon: #334457;
    --site-accent-strong: #3f536b;
    --site-on-accent: #fff;
    --site-surface: #e8eff7;
    --site-surface-2: #e8eff7;
    --site-widget-surface: #ffffff;
    --site-widget-surface-soft: #f6f9fd;
    --site-widget-border: #d8e1eb;
    --site-column-divider: rgba(88, 112, 134, 0.26);
    --site-text: #1f2a36;
    --site-card-separator: #3f536b;
    --site-link: #3f5e7d;
    --site-link-hover: #2f4963;
    --site-link-visited: #546f89;
    --site-mobile-menu-clearance: 64px;
    --site-sidebar-width: 328px;
  }

  body.w3-light-grey {
    background-color: var(--site-surface) !important;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }
  
  /* ===== layout: sidebar and main ===== */
  .w3-main {
    margin-left: var(--site-sidebar-width);
    margin-top: 0;
    padding-left: 40px;
    padding-right: 40px;
    border-left: 0;
    flex: 1 0 auto;
    transition: margin-left 0.22s ease;
  }

  .w3-main > header.w3-container {
    padding-top: 4px !important;
  }

  .w3-main > header.w3-container h5 {
    margin-top: 0;
    margin-bottom: 6px;
  }

  /* ===== readable prose blocks (informational pages) ===== */
  .readable-content {
    --reading-measure: 78ch;
  }
  .readable-content > h1,
  .readable-content > h2,
  .readable-content > h3,
  .readable-content > h4,
  .readable-content > h5,
  .readable-content > h6,
  .readable-content > p,
  .readable-content > ul,
  .readable-content > ol,
  .readable-content > blockquote {
    max-width: var(--reading-measure);
  }
  .readable-content p,
  .readable-content li {
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
    hyphens: auto;
    overflow-wrap: break-word;
    word-break: normal;
  }
  /* Keep very long URLs/link text from overflowing narrow columns. */
  .readable-content a {
    -webkit-hyphens: manual;
    -ms-hyphens: manual;
    hyphens: manual;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* ===== extra space before footer on content pages ===== */
  .w3-main > .w3-container.readable-content:last-child,
  .w3-main > .w3-container.text-columns:last-child,
  .w3-main > .w3-container.info-columns:last-child,
  .w3-main > .horizontal-container:last-child {
    margin-bottom: clamp(14px, 2vh, 28px);
  }

  /* ===== shared explainer toggle buttons (+ / -) ===== */
  .explainer-toggle-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    min-width: 42px;
    padding: 0;
    border-radius: 999px !important;
    border-width: 1px !important;
    border-style: solid !important;
    border-color: var(--site-accent-dark, #334457) !important;
    color: #fff !important;
    background: var(--site-accent, #3f536b) !important;
    box-shadow: none !important;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
  }

  .explainer-toggle-button:hover,
  .explainer-toggle-button:focus {
    background: var(--site-accent-dark, #334457) !important;
    border-color: var(--site-accent-dark, #334457) !important;
    color: #fff !important;
    outline: none;
  }

  .explainer-toggle-button:focus-visible {
    outline: 2px solid rgba(63, 83, 107, 0.42);
    outline-offset: 2px;
  }

  .explainer-toggle-button[aria-expanded="true"] {
    background: #fff !important;
    color: var(--site-accent-dark, #334457) !important;
    border-color: var(--site-accent, #3f536b) !important;
  }

  .explainer-toggle-button[aria-expanded="true"]:hover,
  .explainer-toggle-button[aria-expanded="true"]:focus {
    background: #edf3fa !important;
    color: var(--site-accent-dark, #334457) !important;
    border-color: var(--site-accent-dark, #334457) !important;
  }

  .explainer-toggle-icon {
    font-size: 1.28em;
    line-height: 1;
    pointer-events: none;
  }

  /* ===== textual column layouts: single, diptych, triptych ===== */
  .text-columns,
  .info-columns {
    display: grid;
    column-gap: 26px;
    row-gap: 24px;
    align-items: start;
    width: min(100%, 1320px);
    margin-inline: auto;
  }
  /* W3.CSS adds clearfix pseudo-elements on .w3-container; in grid layouts
     they become empty grid items and break the column order. */
  .text-columns::before,
  .text-columns::after,
  .info-columns::before,
  .info-columns::after {
    content: none;
    display: none;
  }
  .text-columns--1 {
    grid-template-columns: minmax(0, 1fr);
  }
  .text-columns--2,
  .info-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .text-columns--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .text-column,
  .info-column {
    min-width: 0;
  }
  .text-columns--2 > .text-column + .text-column,
  .text-columns--3 > .text-column + .text-column,
  .info-columns > .info-column + .info-column {
    position: relative;
    padding-left: 26px;
  }
  .text-columns--2 > .text-column + .text-column::before,
  .text-columns--3 > .text-column + .text-column::before,
  .info-columns > .info-column + .info-column::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 1px;
    background: linear-gradient(
      180deg,
      rgba(88, 112, 134, 0) 0%,
      var(--site-column-divider) 14%,
      var(--site-column-divider) 86%,
      rgba(88, 112, 134, 0) 100%
    );
  }
  .text-columns--1 > .text-column,
  .text-columns--1 > .info-column {
    width: min(100%, var(--text-single-column-max, 92ch));
    margin-inline: auto;
  }
  .text-column.readable-content > h1,
  .text-column.readable-content > h2,
  .text-column.readable-content > h3,
  .text-column.readable-content > h4,
  .text-column.readable-content > h5,
  .text-column.readable-content > h6,
  .text-column.readable-content > p,
  .text-column.readable-content > ul,
  .text-column.readable-content > ol,
  .text-column.readable-content > blockquote,
  .text-column.readable-content > div,
  .text-column.readable-content > section,
  .info-column.readable-content > h1,
  .info-column.readable-content > h2,
  .info-column.readable-content > h3,
  .info-column.readable-content > h4,
  .info-column.readable-content > h5,
  .info-column.readable-content > h6,
  .info-column.readable-content > p,
  .info-column.readable-content > ul,
  .info-column.readable-content > ol,
  .info-column.readable-content > blockquote,
  .info-column.readable-content > div,
  .info-column.readable-content > section {
    max-width: none;
  }

  @media (max-width: 1360px) {
    .text-columns--3 {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .text-columns--3 > .text-column + .text-column {
      padding-left: 0;
    }
    .text-columns--3 > .text-column + .text-column::before {
      content: none;
    }
    .text-columns--3 > .text-column:nth-child(even) {
      position: relative;
      padding-left: 26px;
    }
    .text-columns--3 > .text-column:nth-child(even)::before {
      content: "";
      position: absolute;
      left: 0;
      top: 10px;
      bottom: 10px;
      width: 1px;
      background: linear-gradient(
        180deg,
        rgba(88, 112, 134, 0) 0%,
        var(--site-column-divider) 14%,
        var(--site-column-divider) 86%,
        rgba(88, 112, 134, 0) 100%
      );
    }
  }

  @media (max-width: 1100px) {
    .text-columns,
    .info-columns {
      grid-template-columns: 1fr;
      gap: 14px;
    }
    .text-columns--2 > .text-column + .text-column,
    .text-columns--3 > .text-column + .text-column,
    .text-columns--3 > .text-column:nth-child(even),
    .info-columns > .info-column + .info-column {
      padding-left: 0;
    }
    .text-columns--2 > .text-column + .text-column::before,
    .text-columns--3 > .text-column + .text-column::before,
    .text-columns--3 > .text-column:nth-child(even)::before,
    .info-columns > .info-column + .info-column::before {
      content: none;
    }
  }
  
  .w3-sidebar {
    width: var(--site-sidebar-width);
    max-width: 80vw; /* prevent oversized sidebar on small screens */
  }

  .site-desktop-sidebar-toggle {
    display: none;
  }

.site-mobile-menu {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 999;
    border-radius: 8px;
    background: var(--site-accent);
    color: var(--site-on-accent) !important;
    box-shadow: 0 4px 10px rgba(39, 63, 89, 0.28);
  }
  .site-mobile-menu:hover,
  .site-mobile-menu:focus {
    background: var(--site-accent-dark) !important;
    color: #fff !important;
  }

  .site-sidebar,
  #mySidebar {
    background: var(--site-surface-2) !important;
    color: var(--site-text);
    border: 1px solid var(--site-widget-border);
    border-right: 4px solid var(--site-card-separator);
    border-left: 0;
    border-radius: 0 12px 12px 0;
    padding-top: 0;
    top: 0 !important;
    overflow: visible;
    transform: translateX(0);
    transition: transform 0.22s ease;
  }
  .site-sidebar .w3-container.w3-row,
  #mySidebar .w3-container.w3-row {
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .site-sidebar .site-sidebar-brand,
  #mySidebar .site-sidebar-brand {
    align-self: center;
    padding-right: 34px;
    box-sizing: border-box;
    overflow: visible;
  }
  .site-sidebar .site-sidebar-brand-text,
  #mySidebar .site-sidebar-brand-text {
    display: block;
    margin-top: 2px;
    padding-bottom: 2px;
    font-size: 1.24rem;
    font-weight: 800;
    line-height: 1.14;
    letter-spacing: 0.005em;
    color: var(--site-card-separator) !important;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
  }
  .site-sidebar .site-sidebar-brand-line,
  #mySidebar .site-sidebar-brand-line {
    display: block;
    margin: 0;
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
    -webkit-hyphens: manual;
    -ms-hyphens: manual;
    hyphens: manual;
  }
  .site-sidebar .w3-bar-block,
  #mySidebar .w3-bar-block {
    background: transparent !important;
  }
  .site-sidebar .w3-col,
  #mySidebar .w3-col {
    margin-top: 0;
  }
  .site-sidebar .w3-bar-item,
  .site-sidebar .w3-dropdown-clicker,
  .site-sidebar .w3-bar span,
  #mySidebar .w3-bar-item,
  #mySidebar .w3-dropdown-clicker,
  #mySidebar .w3-bar span {
    color: var(--site-text) !important;
  }
  .site-sidebar .w3-button:hover,
  .site-sidebar .w3-dropdown-clicker:hover,
  .site-sidebar .w3-dropdown-content .w3-bar-item:hover,
  #mySidebar .w3-button:hover,
  #mySidebar .w3-dropdown-clicker:hover,
  #mySidebar .w3-dropdown-content .w3-bar-item:hover {
    background-color: rgba(63, 83, 107, 0.16) !important;
    color: var(--site-text) !important;
  }
  .site-sidebar .w3-dropdown-content,
  #mySidebar .w3-dropdown-content {
    background-color: var(--site-widget-surface-soft);
    box-shadow: inset 0 0 0 1px var(--site-widget-border);
  }
  .site-sidebar .w3-dropdown-content .w3-bar-item,
  #mySidebar .w3-dropdown-content .w3-bar-item {
    color: var(--site-text) !important;
  }
  .site-sidebar hr,
  #mySidebar hr {
    border: 0;
    border-top: 1px solid var(--site-widget-border);
  }
  .site-sidebar .logo-img,
  #mySidebar .logo-img {
    box-shadow: 0 0 0 2px rgba(63, 83, 107, 0.24);
  }

  .site-sidebar .w3-bar-item > i.fa.fa-fw,
  .site-sidebar .w3-dropdown-clicker > i.fa.fa-fw,
  #mySidebar .w3-bar-item > i.fa.fa-fw,
  #mySidebar .w3-dropdown-clicker > i.fa.fa-fw {
    font-size: 1.52em;
    width: 1.35em;
    line-height: 1;
    vertical-align: middle;
    margin-right: 8px;
    text-align: center;
  }
  .site-sidebar .w3-bar-item i.fa:not(.fa-inverse),
  .site-sidebar .w3-dropdown-clicker i.fa:not(.fa-inverse),
  #mySidebar .w3-bar-item i.fa:not(.fa-inverse),
  #mySidebar .w3-dropdown-clicker i.fa:not(.fa-inverse) {
    color: var(--site-icon);
  }
  .site-sidebar .nav-icon-stack,
  #mySidebar .nav-icon-stack {
    display: inline-block;
    font-size: 1.08em;
    width: 2em;
    height: 2em;
    line-height: 2em;
    vertical-align: middle;
    margin-right: 8px;
  }
  .site-sidebar .nav-icon-wordcloud-core,
  #mySidebar .nav-icon-wordcloud-core {
    font-size: 1.06em;
    top: -1px;
  }
  .site-sidebar .nav-icon-stack .fa:not(.fa-inverse),
  #mySidebar .nav-icon-stack .fa:not(.fa-inverse) {
    color: var(--site-icon);
  }

  .w3-main > header.w3-container h5 > b > i.fa:first-child,
  .w3-main > header.w3-container h5 > b > span.fa-stack i.fa:not(.fa-inverse) {
    color: var(--site-icon);
  }

  @media screen and (min-width: 993px) {
    .site-desktop-sidebar-toggle {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      position: fixed;
      top: 50%;
      transform: translateY(-50%);
      left: calc(var(--site-sidebar-width) - 20px);
      z-index: 1003;
      width: 42px;
      height: 42px;
      min-width: 42px;
      padding: 0;
      border: 1px solid var(--site-accent-dark) !important;
      border-radius: 999px;
      background: var(--site-accent) !important;
      color: #fff !important;
      box-shadow: 0 4px 10px rgba(39, 63, 89, 0.28);
      transition: left 0.22s ease, background-color 0.14s ease, border-color 0.14s ease;
    }

    .site-desktop-sidebar-toggle:hover,
    .site-desktop-sidebar-toggle:focus {
      background: var(--site-accent-dark) !important;
      border-color: var(--site-accent-dark) !important;
      color: #fff !important;
      outline: none;
    }

    .site-desktop-sidebar-toggle:focus-visible {
      outline: 2px solid rgba(63, 83, 107, 0.42);
      outline-offset: 2px;
    }

    .site-desktop-sidebar-toggle > i {
      font-size: 1.15rem;
      line-height: 1;
      pointer-events: none;
    }

    body.site-sidebar-collapsed .site-sidebar,
    body.site-sidebar-collapsed #mySidebar {
      transform: translateX(calc(-1 * var(--site-sidebar-width)));
    }

    body.site-sidebar-collapsed .w3-main {
      margin-left: 0;
    }

    body.site-sidebar-collapsed .site-desktop-sidebar-toggle {
      left: 10px;
    }
  }
  
  .w3-row {
    display: flex;
    flex-wrap: wrap;
  }
  
  /* quarter columns (cards grid on home) */
  .w3-quarter { width: 25%; }
  
  /* ===== footer ===== */
  #siteFooter {
    width: 100%;
    margin: 0;
    margin-top: auto;
    flex-shrink: 0;
    background: var(--site-surface-2) !important;
    color: #465668;
    border-top: 1px solid var(--site-widget-border);
  }
  #siteFooter .footer-content {
    font-size: 13.5px;
    color: inherit;
    padding: 5px 12px;
  }
  #siteFooter a,
  #siteFooter a:visited {
    color: var(--site-link);
    text-decoration: none;
  }
  #siteFooter a:hover {
    color: var(--site-link-hover);
    text-decoration: underline;
  }
  #siteFooter span {
    color: inherit;
    opacity: 0.95;
  }

  /* ===== content links (main text) =====
     Goal: make links in page content clearly distinguishable, without affecting
     navigation items (sidebar/topbar). Navigation links are outside .w3-main
     or use button-like classes.
  */

  .w3-main a:not(.w3-button):not(.w3-btn):not(.w3-bar-item) {
    color: var(--site-link);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
  }
  .w3-main a:not(.w3-button):not(.w3-btn):not(.w3-bar-item):visited {
    color: var(--site-link-visited);
  }
  .w3-main a:not(.w3-button):not(.w3-btn):not(.w3-bar-item):hover {
    color: var(--site-link-hover);
  }
  .w3-main a:not(.w3-button):not(.w3-btn):not(.w3-bar-item):focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    border-radius: 2px;
  }

  /* ===== charts (cards + responsive canvases) ===== */
  .charts-wrapper {
    width: 100%;
    overflow: hidden;
  }
  .chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    padding: 20px;
  }
  .chart-container {
    background: var(--site-widget-surface);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border: 1px solid var(--site-widget-border);
    border-top: 4px solid var(--site-card-separator);
    text-align: center;
  }
  .chart-container h3 {
    margin-top: 0;
    font-size: 1.2em;
  }
  .chart-container p {
    margin-bottom: 15px;
    color: #666;
  }
  .chart-wrapper {
    position: relative;
    margin: 0 auto;
    width: 100%;
    max-width: 300px;
  }
  .chart-wrapper canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 300px;
  }
  
  /* interactive (large) chart */
  .interactive-chart-container {
    background: var(--site-widget-surface);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border: 1px solid var(--site-widget-border);
    border-top: 4px solid var(--site-card-separator);
    margin-bottom: 20px;
  }
  .interactive-chart-wrapper {
    height: 500px;
    margin-top: 20px;
  }
  
  /* ===== sdg legend ===== */
  .sdg-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
  }
  .sdg-legend-item {
    display: flex;
    align-items: center;
    margin-right: 10px;
    margin-bottom: 5px;
    font-size: 0.92em;
  }
  .sdg-color {
    width: 15px;
    height: 15px;
    margin-right: 5px;
    border-radius: 3px;
  }
  .sdg-code {
    font-weight: bold;
    margin-right: 5px;
  }
  
  /* ===== selectors ===== */
  .selector-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
  }
  .selector-box {
    width: 100%;
    margin-bottom: 15px; /* full width by default; override in horizontal layouts */
  }
  .selector-box label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
  }
  
  /* ===== degree info ===== */
  .degree-info {
    background-color: var(--site-widget-surface);
    padding: 15px;
    border-radius: 5px;
    border: 1px solid var(--site-widget-border);
    border-top: 4px solid var(--site-card-separator);
    margin-bottom: 20px;
  }
  .degree-info p { margin: 5px 0; }
  .degree-info strong { color: #333; }
  
  /* ===== courses table ===== */
  .courses-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
  }
  .courses-table th, .courses-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
  }
  .courses-table th { background-color: #f1f6fb; }
  .courses-table tr:nth-child(even) { background-color: #f8fbff; }
  
  .course-row {
    cursor: pointer;
    transition: background-color 0.3s;
  }
  .course-row:hover { background-color: #eef4fa !important; }
  
  .course-details-row { background-color: #f8fbff; }
  .course-details-cell { padding: 0 !important; }
  .course-details-cell .w3-container {
    padding: 16px;
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
  }
  
  .course-sdg {
    display: inline-block;
    width: 15px; height: 15px;
    border-radius: 3px;
    margin-right: 3px;
  }
  
  /* ===== course details panel ===== */
  .course-details {
    padding: 20px;
    background-color: var(--site-widget-surface);
    border-radius: 5px;
    border: 1px solid var(--site-widget-border);
    border-top: 4px solid var(--site-card-separator);
    min-height: 300px;
  }
  .course-details p { margin: 5px 0; }
  /* Links inside course details use the global content link styling above. */
  
  /* ===== feature chips ===== */
  .sdg-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
  }
  .feature-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
  }
  .feature-item {
    background-color: #edf3fa;
    color: #33485f;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.9em;
    display: inline-block;
    margin: 2px;
  }
  
  /* ===== dropdown (hover) ===== */
  .w3-dropdown-content {
    display: none;
    position: relative;
    background-color: var(--site-widget-surface);
    min-width: 160px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    z-index: 1;
  }
  .w3-dropdown-content a {
    color: var(--site-text);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
  }
  .w3-dropdown-content a:hover { background-color: #edf3fa; }
  .w3-dropdown-clicker:hover .w3-dropdown-content { display: block; }
  
  /* ===== filter tabs ===== */
  .filter-container {
    margin: 20px 0;
    padding: 15px;
    background: var(--site-widget-surface);
    border-radius: 8px;
    border: 1px solid var(--site-widget-border);
    border-top: 4px solid var(--site-card-separator);
  }
  .filter-title {
    font-weight: bold;
    margin-bottom: 10px;
  }
  .filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
  }
  .filter-tab {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    background: #ecf2f8;
    transition: all 0.3s;
    font-size: 0.98em;
  }
  .filter-tab:hover { background-color: #e1e9f2; }
  .filter-tab.active {
    background-color: var(--site-accent);
    color: #fff;
  }
  .filter-tab.active:hover { background-color: var(--site-accent-dark); }
  
  /* symbols used between tabs */
  .filter-symbol {
    font-size: 2.5em;
    color: #555;
    margin: 0;
    vertical-align: middle;
  }
  
  /* ===== specific adjustments (home cards) ===== */
  .w3-quarter img { width: 168.75px; } /* 25% smaller than original */
  .w3-quarter h4 {
    font-weight: bold;
    margin: 10px 0;
    text-align: left;
  }
  .w3-quarter p { margin-top: 10px; }
  .w3-quarter .w3-container { text-align: left; }
  
  /* sidebar header block alignment */
  .w3-sidebar .w3-col { margin-top: 0; }
  .w3-sidebar .w3-bar { text-align: left; margin-top: 0; }
  .w3-sidebar .w3-bar span { display: block; margin-top: 0; line-height: 1.36; }
  .w3-sidebar .site-sidebar-brand-text { line-height: 1.2; }

  /* active navigation item */
  .site-sidebar .nav-active,
  #mySidebar .nav-active {
    font-weight: 700;
    border-left: 4px solid var(--site-accent-dark) !important;
    background-color: rgba(63, 83, 107, 0.24) !important;
    color: var(--site-text) !important;
  }
  .site-sidebar .nav-active:hover,
  #mySidebar .nav-active:hover {
    background-color: rgba(63, 83, 107, 0.32) !important;
    color: var(--site-text) !important;
  }
  
  /* ===== horizontal layout (degree view) ===== */
  .horizontal-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
  }
  .horizontal-container h1 {
    width: 100%;
    text-align: left;
  }
  .horizontal-container .selector-container {
    width: 100%;
    justify-content: flex-start;
    gap: 40px;
  }
  .horizontal-container .selector-box {
    flex: 1;
    max-width: 300px;
  }
  .horizontal-container .degree-info {
    width: 100%;
    text-align: left;
  }
  .horizontal-container .degree-info p {
    display: inline-block;
    margin: 5px 10px;
  }
  
  /* ===== responsive ===== */
  @media screen and (max-width: 992px) {
    /* two columns for .w3-quarter at medium widths */
    .w3-quarter { width: 50%; }
  }

  @media screen and (max-width: 992px) {
    /* Reserve top space for the fixed mobile menu button (avoids overlap with breadcrumbs/title). */
    .w3-main {
      padding-top: var(--site-mobile-menu-clearance);
      border-left: 0;
    }
  }
  
  @media screen and (max-width: 600px) {
    /* collapse sidebar offset and reduce paddings */
    .w3-main {
      margin-left: 0;
      padding-left: 20px;
      padding-right: 20px;
      padding-top: var(--site-mobile-menu-clearance);
    }
  
    /* one column cards */
    .w3-quarter,
    .w3-col.m3,
    .w3-col.m6,
    .w3-col.m9 {
      width: 100%;
      padding: 0 !important;
    }
  
    /* footer text sizing */
    #siteFooter .footer-content {
      font-size: 12px;
      line-height: 1.5;
    }
    #siteFooter span {
      display: inline-block;
      margin: 0 3px;
    }

    .site-sidebar .site-sidebar-brand-text,
    #mySidebar .site-sidebar-brand-text {
      font-size: 1.16rem;
      line-height: 1.14;
    }
    .site-sidebar .site-sidebar-brand-line,
    #mySidebar .site-sidebar-brand-line {
      white-space: normal;
    }
  
    /* mobile: keep sidebar offcanvas-style (leave some backdrop visible) */
    .w3-sidebar {
      width: var(--site-sidebar-width);
      max-width: 85vw;
    }
  
    /* home logos slightly larger for readability on mobile */
    .w3-quarter img { width: 253.125px; }
  }

  /* === mobile sidebar overlay layering ===
     Goal: the overlay should darken the page content but NEVER sit above the sidebar,
     so sidebar links remain clickable.
  */
  #mySidebar { z-index: 1001; }
  #myOverlay { z-index: 1000; }
  

  /* layout: contenidor */
.interactive-chart-container{
    display:flex;
    flex-wrap:wrap;
    align-items:flex-start;
  }
  
  /* columnes en escriptori */
  .left-col{
    flex:0 0 30%;
    min-width:300px;
    padding-right:20px;
  }
  .right-col{
    flex:1 1 70%;
    min-width:420px;
  }
  
  /* caixa del canvas amb altura fixa; la llegenda va a sota */
  .chart-canvas-box{
    position:relative;
    height:500px;
    margin-bottom:12px;
  }
  
  /* llegenda en grid, amb topall d’alçada en escriptori */
  .sdg-legend{
    display:grid;
    grid-template-columns:repeat(auto-fit, minmax(180px, 1fr));
    gap:8px 16px;
    align-items:center;
    max-height:140px;
    overflow-y:auto;
    padding-bottom:4px;
  }
  .sdg-legend-item{ font-size:0.92em; }
  .sdg-color{ width:14px; height:14px; border-radius:3px; margin-right:6px; }
  
  /* controls: que ocupen ample complet si cal */
  .selector-container{ gap:12px; }
  .selector-box{ width:100%; }
  .selector-box .w3-select{ width:100%; min-width:0; }
  
  /* pestanyes de filtre: millor stacking en mòbil */
  .filter-tabs{ display:flex; flex-wrap:wrap; gap:10px; }
  @media (max-width: 992px){
    .left-col, .right-col{
      flex:1 0 100% !important;  /* mata qualsevol inline restant */
      min-width:0;
      padding-right:0;
    }
  }
  @media (max-width: 600px){
    .filter-tabs{ flex-direction:column; align-items:stretch; }
    .filter-tab{ width:100%; text-align:center; }
    .sdg-legend{ max-height:none; } /* que cresca en vertical en mòbil */
  }
  
  /* --- chart area fixes --- */
.chart-canvas-box{
    position: relative;
    height: 500px;       /* alçada del gràfic, canvia si cal */
    margin-bottom: 12px;
  }
  
  /* el canvas ha d'omplir la caixa anterior */
  .chart-canvas-box canvas{
    display: block;
    width: 100% !important;
    height: 100% !important;   /* <- clau perquè no es faça petit */
  }
  
  /* --- legend: cap scroll i s'ajusta a l'ample --- */
  .right-col .sdg-legend{
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px 16px;
    align-items: center;
    margin-top: 12px;
    max-height: none;      /* sense topall */
    overflow: visible;     /* sense scroll */
    padding-bottom: 4px;
  }
  .right-col .sdg-legend-item{
    display: inline-flex;
    align-items: center;
    font-size: 0.92em;
    line-height: 1.3;
  }
  .right-col .sdg-color{
    width: 14px;
    height: 14px;
    border-radius: 3px;
    margin-right: 6px;
  }
  
  /* mòbil: columnes més estretes si cal */
  @media (max-width: 600px){
    .right-col .sdg-legend{
      grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
  }
  

/* ------------------------------------------------------------------------- */
/* Back to top button                                                         */
/* File: assets/css/styles.css                                                */
/* Purpose: Style for the floating back-to-top button added in the default    */
/*          layout.                                                           */
/* Related files: _includes/back_to_top.html, assets/js/site.js               */
/* Safe edits: tweak size/position; keep high contrast.                        */
/* ------------------------------------------------------------------------- */
.back-to-top{
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: var(--site-accent-strong);
  color: #fff;
  display: none; /* shown by JS after scroll */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 850; /* below sidebar/overlay (1000+) */
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}
.back-to-top svg{
  width: 22px;
  height: 22px;
  fill: currentColor;
}
.back-to-top:focus{
  outline: 3px solid rgba(63, 83, 107, 0.35);
  outline-offset: 2px;
}
.back-to-top:hover{
  background: var(--site-accent-dark);
}

/* Doughnut comparison grid (1 chart = full width, 2 charts = side-by-side) */
.chart-grid{
  display: grid;
  gap: 16px;
}
.chart-grid.one{
  grid-template-columns: 1fr;
}
.chart-grid.two{
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 900px){
  .chart-grid.two{ grid-template-columns: 1fr; }
}

/* Make the doughnut chart larger when showing a single chart */
.chart-grid.one .chart-wrapper{
  max-width: 460px;
}
.chart-grid.one .chart-wrapper canvas{
  max-height: 420px;
}
