/* =============================================
   HEC - light and dark themes
   hec_theme.css (loaded after hec.css / hec2.css / sec.css / scrollable.css)
   The theme follows the system preference; the button at the top right
   (hec_theme.js) switches it, and the choice is saved in the browser.
   Selected by the data-hec-theme attribute of <html> ("light" or "dark").
   ============================================= */

:root, :root[data-hec-theme="light"] {
  color-scheme: light;
  --hec-bg: #ffffff;
  --hec-text: #1a1a1a;
  --hec-muted: #5f6b7a;
  --hec-link: #1f4f8a;
  --hec-link-hover: #c62828;
  --hec-title: #c62828;
  --hec-rule: #d5dbe3;
  --hec-th-bg: #dfe9f6;
  --hec-th-text: #1f3b5c;
  --hec-border: #a9bdd6;
  --hec-row: #ffffff;
  --hec-row-alt: #f4f7fb;
  --hec-cell-border: #e3e8ef;
  --hec-cell-plain: #ffffff;
  --hec-popup-bg: #fdfde8;
  --hec-button-bg: #f5f7fa;
  --hec-button-hover: #e6ecf4;
  --hec-track: #e3e8ef;
}

:root[data-hec-theme="dark"] {
  color-scheme: dark;
  --hec-bg: #000000;
  --hec-text: #e8e8e8;
  --hec-muted: #a8a8a8;
  --hec-link: #8ab4f8;
  --hec-link-hover: #ff7070;
  --hec-title: #ff5252;
  --hec-rule: #444444;
  --hec-th-bg: #27466b;
  --hec-th-text: #ffffff;
  --hec-border: #5e7ea5;
  --hec-row: #1e1e1e;
  --hec-row-alt: #2a2a2a;
  --hec-cell-border: #3a3a3a;
  --hec-cell-plain: #121212;
  --hec-popup-bg: #3a3a1e;
  --hec-button-bg: #2a2a2a;
  --hec-button-hover: #3a3a3a;
  --hec-track: #2a2a2a;
}

/* --- page ---------------------------------------------------------------- */
html, body { background-color: var(--hec-bg); color: var(--hec-text); }
table, td, th, TABLE { color: var(--hec-text); }
TR.head { color: var(--hec-text); background-color: var(--hec-bg); }
hr { border: 0; border-top: 1px solid var(--hec-rule); }
a:link, a:visited, A:link, A:visited { color: var(--hec-link); }
a:hover, A:hover { color: var(--hec-link-hover); }
h1, H1 { color: var(--hec-title); }
font[color="red"], font[color="#FF0000"], font[color="#ff0000"] { color: var(--hec-title); }

/* cells and tables coloured with HTML attributes (bgcolor) */
[bgcolor] { background-color: var(--hec-cell-plain); }
td[bgcolor="#D3D1D1"], tr[bgcolor="D3D1D1"], tr[bgcolor="#D3D1D1"] { background-color: var(--hec-row); }
table[bgcolor="#F8FDBA"], table[bgcolor="yellow"] { background-color: var(--hec-popup-bg); }

/* --- scrollable catalogue table (scrollable.css) ------------------------- */
div.tableContainer { border-color: var(--hec-border); }
thead.fixedHeader th {
  background: var(--hec-th-bg);
  color: var(--hec-th-text);
  border-color: var(--hec-border);
}
tbody.scrollContent td, tbody.scrollContent tr.normalRow td {
  background: var(--hec-row);
  border-right-color: var(--hec-cell-border);
  border-top-color: var(--hec-cell-border);
}
tbody.scrollContent tr.alternateRow td { background: var(--hec-row-alt); }

/* --- form controls ------------------------------------------------------- */
input[type="button"], input[type="submit"], input[type="reset"], button {
  background-color: var(--hec-button-bg);
  color: var(--hec-text);
  border: 1px solid var(--hec-border);
  border-radius: 3px;
  padding: 2px 8px;
  cursor: pointer;
}
input[type="button"]:hover, input[type="submit"]:hover, button:hover { background-color: var(--hec-button-hover); }
/* the Reset (yellow) and Submit (green) buttons keep their colours, with dark text */
input[type="button"][style*="background-color"] { border-color: #808080; }
input[type="text"], input:not([type]), select, textarea {
  background-color: var(--hec-bg);
  color: var(--hec-text);
  border: 1px solid var(--hec-border);
}

/* logos with a white background stay readable on the dark background */
:root[data-hec-theme="dark"] img[src$=".gif"], :root[data-hec-theme="dark"] img[src$=".jpg"] {
  background-color: #ffffff;
  border-radius: 3px;
}

/* --- theme switch button (hec_theme.js) ---------------------------------- */
#hec-theme-toggle {
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 1000;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--hec-text);
  cursor: pointer;
}
#hec-theme-toggle:hover { background-color: var(--hec-button-hover); }
#hec-theme-toggle:focus-visible { outline: 2px solid var(--hec-link); outline-offset: 2px; }
#hec-theme-toggle svg { display: block; width: 24px; height: 24px; fill: currentColor; }

/* --- footer: dates of the last update (hec_lastupdate.php) --------------- */
div.hec-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
div.hec-footer table { margin-left: auto; }
.hec-updated { font-size: 8pt; color: var(--hec-muted); }

/* --- link shown as a button (e.g. "Catalogue content") ------------------- */
a.hec-button, a.hec-button:link, a.hec-button:visited {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--hec-border);
  border-radius: 3px;
  background-color: var(--hec-button-bg);
  color: var(--hec-text);
  text-decoration: none;
  vertical-align: middle;
}
a.hec-button:hover { background-color: var(--hec-button-hover); color: var(--hec-text); }

/* --- catalogue content page (hec_content.php) ---------------------------- */
div.hec-content { width: 96%; margin: 0 auto; text-align: left; }
div.hec-content-bar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; }
div.hec-content-bar h2 { margin: 4px 0; font-size: 14pt; }
.hec-content-summary, .hec-content-help { color: var(--hec-muted); font-size: 9pt; }
#hc-filter { min-width: 260px; padding: 3px 6px; border-radius: 3px; }
div.hec-content-scroll { max-height: 70vh; overflow: auto; border: 1px solid var(--hec-border); }
table.hec-content-table { border-collapse: collapse; width: 100%; font-size: 9pt; }
table.hec-content-table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--hec-th-bg); color: var(--hec-th-text);
  padding: 5px 6px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--hec-border);
}
table.hec-content-table th.hc-sortable { cursor: pointer; }
table.hec-content-table th.hc-sortable::after { content: " \2195"; opacity: 0.4; }
table.hec-content-table th[data-sort="asc"]::after { content: " \25B2"; opacity: 1; }
table.hec-content-table th[data-sort="desc"]::after { content: " \25BC"; opacity: 1; }
table.hec-content-table td { padding: 4px 6px; border-top: 1px solid var(--hec-cell-border); text-align: left; vertical-align: top; }
table.hec-content-table tbody tr:nth-child(even) td { background: var(--hec-row-alt); }
table.hec-content-table tbody tr:hover td { background: var(--hec-button-hover); }
.hc-name { color: var(--hec-muted); font-size: 8pt; font-family: monospace; }
td.hc-num, td.hc-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
td.hc-num { text-align: right; }
td.hc-links { white-space: nowrap; }
td.hc-status.hc-active { color: #2e9d4f; font-weight: bold; }
:root[data-hec-theme="dark"] td.hc-status.hc-active { color: #5fd38a; }
td.hc-bar { min-width: 160px; vertical-align: middle; }
.hc-cover { position: relative; display: block; height: 8px; border-radius: 4px; background: var(--hec-track); }
.hc-span { position: absolute; top: 0; height: 8px; border-radius: 4px; background: #8a96a6; }
.hc-span.hc-active, .hc-legend.hc-active { background: #2e9d4f; }
.hc-legend { display: inline-block; width: 18px; height: 8px; border-radius: 4px; vertical-align: middle; }
.hc-span.hc-cut { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.hc-span.hc-cut::before { content: "\25C0"; position: absolute; left: -11px; top: -5px; font-size: 9px; color: var(--hec-muted); }
td.hc-bar { padding-left: 14px; }

/* --- charts of the content page (hec_content.js) ------------------------- */
div.hc-charts-bar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; margin-top: 18px; }
div.hc-charts-bar h2 { margin: 4px 0; font-size: 14pt; }
div.hc-charts-bar button { margin-right: 2px; }
div.hc-chart { width: 100%; height: 340px; margin: 8px 0 14px; border: 1px solid var(--hec-border); border-radius: 3px; }

/* --- footer credits: HELIO and FP7 (moved from the page header) ---------- */
div.hec-credits { display: flex; flex-direction: column; gap: 4px; text-align: left; font-size: 9pt; }
div.hec-credits div { display: flex; align-items: center; gap: 8px; }
div.hec-credits img { vertical-align: middle; }
div.hec-footer-dates { text-align: left; margin-top: 6px; }

/* --- page title (header), in the colours of the HELIO logo -------------- */
/* gradient of the logo: orange #eb952f, purple #875184, blue #1308f0
   (lighter in the dark theme, to stay readable on black) */
:root, :root[data-hec-theme="light"] {
  --hec-heading-grad: linear-gradient(90deg, #e3862a 0%, #b9684f 28%, #875184 52%, #5a33b0 76%, #2416d6 100%);
  --hec-heading: #5a33b0;
}
:root[data-hec-theme="dark"] {
  --hec-heading-grad: linear-gradient(90deg, #f5a645 0%, #e08a6a 28%, #c07ac0 52%, #9d86f0 76%, #7d8cff 100%);
  --hec-heading: #9d86f0;
}
h1.hec-title {
  position: relative;
  display: inline-block;
  margin: 0;
  line-height: 1.15;
  /* the font of the page (hec.css: helvetica) */
  font-family: Helvetica, Arial, sans-serif;
  font-size: 24pt;
  font-weight: bold;
  letter-spacing: 0.01em;
  color: var(--hec-heading);                  /* without background-clip support */
  background-image: var(--hec-heading-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
h1.hec-title::after {                         /* outside the box: the logo is centred on the text */
  content: "";
  position: absolute;
  left: 15%;
  right: 15%;
  bottom: -9px;
  height: 3px;
  border-radius: 2px;
  background-image: var(--hec-heading-grad);
}

/* --- page header: HELIO logo on the left, centred title ------------------ */
/* logo, title and an empty cell as wide as the logo: the title stays centred
   on the page and the logo is centred on the line of the title */
div.hec-header { display: flex; align-items: center; padding: 8px 6px 14px; }
a.hec-header-logo, div.hec-header::after { flex: 0 0 110px; }
div.hec-header::after { content: ""; }
a.hec-header-logo img { display: block; }
div.hec-header h1.hec-title { flex: 0 1 auto; margin: 0 auto; text-align: center; }
