/*!
 * FMCE Node Status - application stylesheet
 * Based on the FMCE Design System v1.0 (tokens, Poppins, cryptcoin brand).
 * Theme: <html data-theme="dark|light">, brand: <html data-brand="cryptcoin">.
 * Fonts are self-hosted in /fonts (no Google CDN, GDPR).
 *
 * Copyright 2023-2026 FMCE Concept UG - SPDX-License-Identifier: Apache-2.0
 * CoAuthor: Claude / Claude Code - Opus 5.5
 */

/* ---------- Fonts (Poppins, SIL Open Font License) ---------- */
@font-face { font-family: "Poppins"; font-weight: 300; font-style: normal; font-display: swap; src: url("../fonts/Poppins-Light.woff") format("woff"); }
@font-face { font-family: "Poppins"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/Poppins-Regular.woff") format("woff"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/Poppins-Medium.woff") format("woff"); }
@font-face { font-family: "Poppins"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/Poppins-Bold.woff") format("woff"); }

/* ---------- Tokens: dark theme (default) ---------- */
:root {
  color-scheme: dark;
  /* surfaces */
  --bg: #0b1a24;
  --surface: #10232f;
  --surface-raised: #163041;
  --surface-sunken: #08131b;
  --border: #213a4b;
  --border-strong: #35546b;
  /* text */
  --text: #e6eef4;
  --text-muted: #9cb2c2;
  --text-subtle: #7590a5;
  /* brand */
  --primary: #4da6e8;
  --primary-hover: #78bcee;
  --on-primary: #06121a;
  --chip: #1479c4;
  --accent: #f7963a;
  --accent-text: #f7963a;
  --on-accent: #1a0f05;
  --focus: #f7963a;
  --brand-fmce: #4da6e8;
  --brand-cryptcoin: #2bb5b5;
  --brand-coinware: #3cbc72;
  /* status */
  --success: #3cbc72;
  --warning: #e3b341;
  --danger: #f2867d;
  --info: #4da6e8;
  /* elevation */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-2: 0 10px 30px rgba(0, 0, 0, .40);

  /* type */
  --font-sans: "Poppins", Arial, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  /* spacing (4px base) */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px; --space-5: 24px;
  --space-6: 32px; --space-7: 48px; --space-8: 64px; --space-9: 96px;
  /* radius */
  --radius-sm: 3px; --radius-md: 5px; --radius-lg: 8px; --radius-pill: 999px;
  /* layout */
  --container: 1200px;
  --gutter: 24px;

  --brand: var(--brand-fmce);
}

/* ---------- Tokens: light theme ---------- */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-sunken: #e9eff3;
  --border: #d3dde4;
  --border-strong: #a7b8c5;
  --text: #0f2230;
  --text-muted: #4b6273;
  --text-subtle: #5a6f80;
  --primary: #0066a6;
  --primary-hover: #00548a;
  --on-primary: #ffffff;
  --chip: #0066a6;
  --accent: #f28c28;
  --accent-text: #b35400;
  --on-accent: #1a0f05;
  --focus: #b35400;
  --brand-fmce: #0066a6;
  --brand-cryptcoin: #00838a;
  --brand-coinware: #1f8a4c;
  --success: #1a7a43;
  --warning: #8a6100;
  --danger: #b3261e;
  --info: #0066a6;
  --shadow-1: 0 1px 2px rgba(15, 34, 48, .08);
  --shadow-2: 0 10px 30px rgba(15, 34, 48, .10);
}

/* ---------- Brand switch (connector-line colour of each site) ---------- */
[data-brand="fmce"]      { --brand: var(--brand-fmce); }
[data-brand="cryptcoin"] { --brand: var(--brand-cryptcoin); }
[data-brand="coinware"]  { --brand: var(--brand-coinware); }

/* ---------- App-specific tokens ---------- */
:root {
  --out: var(--success);
  --in: var(--danger);
  --alert-bg: rgba(242, 134, 125, .12);
}
:root[data-theme="light"] { --alert-bg: #fdecea; }

/* Chart colours (read by js/charts.js). Every series colour has at least 3:1
   contrast to --chart-bg, title and axis text at least 4.5:1 (WCAG). */
:root {
  --chart-bg: var(--surface);
  --chart-title: var(--text);
  --chart-text: var(--text-muted);
  --chart-grid: var(--border-strong);
  --chart-accent: #f7963a;   /* fixed series colour, e.g. the price */
  --chart-1: #4da6e8; --chart-2: #f2867d; --chart-3: #3cbc72; --chart-4: #e3b341;
  --chart-5: #c3a5f0; --chart-6: #2bb5b5; --chart-7: #f7963a;
}
:root[data-theme="light"] {
  --chart-grid: var(--border);
  --chart-accent: #b35400;
  --chart-1: #0066a6; --chart-2: #b3261e; --chart-3: #1a7a43; --chart-4: #8a6100;
  --chart-5: #6f42c1; --chart-6: #00838a; --chart-7: #b35400;
}

/* ========== Base ========== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  font-weight: 400;
}
img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }
a { color: var(--primary); font-weight: 500; text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--primary); color: var(--on-primary); }
h1, h2 { margin: 0; color: var(--text); text-wrap: balance; }
h2 { margin-bottom: var(--space-3); font-size: 22px; line-height: 30px; font-weight: 500; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.small { font-size: 14px; line-height: 22px; }
/* Shortened text (e.g. peer user agent): full text as tooltip */
.shortened { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }

/* ========== Header ========== */
.page { width: min(100% - 2 * var(--space-4), 100rem); margin: 0 auto var(--space-5); }
.site-header {
  position: relative;
  margin: 0 0 var(--space-5);
  padding: var(--space-4) 0 var(--space-5);
  border-bottom: 1px solid var(--border);
}
.header-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr);
  align-items: center; gap: var(--space-4); min-height: 56px;
}
.site-logo { display: inline-flex; grid-column: 1; justify-self: start; }
.site-logo img { display: block; height: 48px; width: auto; }
.site-header h1 {
  grid-column: 2;
  min-width: 0;
  text-align: center;
  font-size: 22px; line-height: 30px; font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--text-muted);
}
.theme-toggle { grid-column: 3; justify-self: end; }
.intro, .donation { text-align: center; font-size: 14px; line-height: 22px; font-weight: 500; }
.intro { margin: var(--space-4) 0 0; color: var(--text-muted); }
@media (max-width: 900px) {
  /* Narrow: logo and button on the first row, centred title below */
  .header-bar { grid-template-columns: minmax(0, 1fr) auto; }
  .site-logo { grid-column: 1; grid-row: 1; }
  .theme-toggle { grid-column: 2; grid-row: 1; }
  .site-header h1 { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 640px) {
  .site-logo img { height: 36px; }
  .site-header h1 { font-size: 16px; line-height: 22px; }
}

/* ========== Buttons (Top / Dark-Light share this look) ========== */
.btn, .back-to-top, .theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 var(--space-5);
  border: 0; border-radius: var(--radius-md);
  font-family: inherit; font-size: 15px; font-weight: 500; line-height: 1;
  color: var(--on-primary); background: var(--primary);
  cursor: pointer; transition: background-color .15s ease;
}
.btn:hover, .back-to-top:hover, .theme-toggle:hover { background: var(--primary-hover); }
.back-to-top { position: fixed; right: var(--space-5); bottom: var(--space-5); z-index: 99; box-shadow: var(--shadow-2); }

/* ========== Pages of the peer table (js/peer-pager.js) ========== */
.pager {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: var(--space-2); margin: var(--space-3) 0 0;
}
.pager-btn {
  min-width: 40px; min-height: 40px; padding: 0 var(--space-3);
  font: inherit; font-size: 18px; line-height: 1; color: var(--text);
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md);
  cursor: pointer;
}
.pager-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pager-btn:disabled { opacity: .35; cursor: default; }
.pager-status { padding: 0 var(--space-2); font-size: 14px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pager-size { margin-left: var(--space-3); font-size: 14px; color: var(--text-muted); }
@media (max-width: 640px) {
  /* Small screens: status text on its own line above the buttons */
  .pager-status { order: -1; flex-basis: 100%; text-align: center; }
  .pager-size { margin-left: var(--space-2); }
}
.pager-size select {
  min-height: 40px; padding: 0 var(--space-2); font: inherit; color: var(--text);
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md);
}

/* ========== Cookie notice (bottom right; the Top button moves above it) ========== */
.cookie-notice {
  position: fixed; right: var(--space-5); bottom: var(--space-5); z-index: 100;
  display: flex; align-items: center; gap: var(--space-4);
  max-width: min(26rem, calc(100% - 2 * var(--space-5)));
  padding: var(--space-4);
  background: var(--surface-raised);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
}
.cookie-notice p { margin: 0; font-size: 14px; line-height: 20px; color: var(--text); }
.cookie-notice .btn { flex: none; }

/* ========== Layout ========== */
.node-layout { display: grid; gap: var(--space-5); align-items: start; }
@media (min-width: 48em) { .node-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 64em) { .node-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); } }
.node-side, .node-main { min-width: 0; }
.node-side {
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}

/* ========== Donation block & links ========== */
.donation { overflow-wrap: anywhere; }
.qr { display: block; margin: 0 auto var(--space-4); padding: var(--space-3); background: #fff; border-radius: var(--radius-md); }
.logo { display: block; margin: 0 auto; }
.node-links h2 { text-align: center; }
.node-links ul {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: var(--space-4) var(--space-5); margin: 0; padding: var(--space-3); list-style: none;
}
.node-links img { display: block; }

/* ========== Charts & statistics ========== */
.charts {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  margin: 0 0 var(--space-5);
}
.chart {
  width: 100%; height: 16rem; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.stats { margin: 0 0 var(--space-5); }
.stat {
  display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2);
  margin: 0 0 var(--space-2); padding: var(--space-3) var(--space-4);
  font-size: 15px; line-height: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-md);
}
.stat dt { font-weight: 500; color: var(--text-muted); }
.stat dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* ========== Peers table ========== */
.peers { margin-top: var(--space-6); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); }
.section-head h2 { margin: 0 0 var(--space-3); }
.link-button {
  padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; font-weight: 500; color: var(--primary);
  text-decoration: underline; text-underline-offset: 3px;
}
.link-button:hover { color: var(--primary-hover); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.flag { display: inline-block; vertical-align: middle; }   /* size/sprite: flags.css */

table { width: 100%; margin: 0 auto; border-collapse: collapse; background: var(--surface); }
th, td { padding: var(--space-3) var(--space-4); font-size: 14px; line-height: 22px; text-align: left; border-bottom: 1px solid var(--border); }
th {
  background: var(--surface-raised);
  font-size: 12px; line-height: 16px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted);
  border-bottom: 1px solid var(--border-strong);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-raised) 45%, transparent); }
tbody tr:hover td { background: var(--surface-raised); }
td { font-variant-numeric: tabular-nums; }
.ip { white-space: nowrap; }   /* flag and address (also IPv6) stay on one line */
.dir { text-align: center; }
.dir-out { color: var(--out); }
.dir-in  { color: var(--in); }

/* Mobile: rows as cards, labels from data-label */
@media (max-width: 760px) {
  .table-wrap { border: 0; border-radius: 0; }
  table, thead, tbody, tr, th, td { display: block; }
  table { background: none; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tr { margin-bottom: var(--space-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
  td {
    position: relative; min-height: 2.2em;
    padding: var(--space-2) var(--space-3) var(--space-2) 50%;
    border: 0; border-bottom: 1px solid var(--border);
    text-align: left;
  }
  tbody tr:nth-child(even) td, tbody tr:hover td { background: none; }
  .sort-hint { display: none; }   /* cards have no column headers to click */
  .dir { text-align: left; }      /* the label (td::before) must not be centred */
  .ip { white-space: normal; }    /* narrow cards: long IPv6 addresses may wrap */
  td::before {
    content: attr(data-label);
    position: absolute; top: var(--space-2); left: var(--space-3);
    width: 45%; padding-right: var(--space-2);
    font-weight: 500; color: var(--text-muted); white-space: nowrap;
  }
}

/* ========== Notices (used by PHP) ========== */
/* Collector notices: missing or outdated data */
.notice-warn {
  margin: 0 0 var(--space-4); padding: var(--space-3) var(--space-4);
  color: var(--text);
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  border: 1px solid var(--warning); border-left-width: 4px; border-radius: var(--radius-md);
}
.notice-warn p { margin: var(--space-1) 0; font-size: 14px; line-height: 22px; }
.notice-empty { margin: 0 0 var(--space-4); color: var(--text-muted); }
.chart-notices { margin: calc(-1 * var(--space-3)) 0 var(--space-5); padding-left: var(--space-5); color: var(--text-muted); }

p.cache {
  margin: var(--space-3) 0; padding: var(--space-3) var(--space-4);
  color: var(--danger); text-align: center;
  background: var(--alert-bg); border: 1px solid var(--danger); border-radius: var(--radius-md);
}

/* ========== Footer ========== */
#footer {
  margin-top: var(--space-6); padding: var(--space-5) var(--space-4);
  background: var(--surface-sunken);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
#footer p { margin: var(--space-1) 0; color: var(--text-muted); text-align: center; font-size: 13px; line-height: 20px; }
#footer a { color: var(--text-muted); font-weight: 400; }
#footer a:hover { color: var(--text); }
/* Narrow screens: room below the footer, so the fixed Top button covers no text */
@media (max-width: 640px) {
  #footer { padding-bottom: calc(44px + 2 * var(--space-5)); }
}
