/* @file_purpose Web stylesheet for the AI News static site — Cortex-IT dark-blue tech theme (matches ~/cortexit main site), with a light "bright" variant. */

/* ---- Design tokens ---- */
:root {
  /* Default = Cortex-IT dark blue */
  --bg:            #0e1420;  /* deep navy */
  --surface:       #1a2438;  /* card / article surface */
  --text:          #e8edf5;  /* near-white */
  --text-muted:    #9fb0c8;  /* secondary text */
  --accent:        #4da3ff;  /* Cortex-IT sky blue */
  --accent-hover:  #7cbcff;  /* lighter on hover (dark bg) */
  --border:        #26344e;
  --code-bg:       #131c2c;
  --on-accent:     #0e1420;  /* text on accent-filled buttons (contrast >= 4.5, ticket 1630) */

  /* Cortex-IT uses a single system sans stack; no serif. Titles are bold sans. */
  --font-serif: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-sans:  system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --maxw: 720px;
  --radius: 14px;

  --font-size-base: 18px;
}

/* Static export / no explicit choice: bright variant when the OS prefers light. */
@media (prefers-color-scheme: light) {
  :root {
    --bg:            #f4f7fb;  /* airy blue-tinted white */
    --surface:       #ffffff;
    --text:          #0e1420;
    --text-muted:    #4a5a72;
    --accent:        #1f66c0;  /* Cortex-IT strong blue, darkened for AA contrast (ticket 1630) */
    --accent-hover:  #174f99;
    --on-accent:     #ffffff;
    --border:        #d3ddea;
    --code-bg:       #eaf0f8;
  }
}

/* ---- Theme selection (dynamic server; html.theme-<name>) ----
   html.theme-auto (the dynamic default, ticket 1610) has no rules of its own: it keeps
   the :root tokens above, i.e. the OS/browser color scheme via prefers-color-scheme
   (no script, no flash); only the chart colors below need an extra rule.
   Classes live on <html> (not <body>) so --font-size-base set here reaches the
   `html { font-size: … }` rule; custom properties set on <body> would not
   propagate up to <html>. Theme color vars then inherit down to <body>. */
html.theme-bright {
  --bg:            #f4f7fb;
  --surface:       #ffffff;
  --text:          #0e1420;
  --text-muted:    #4a5a72;
  --accent:        #1f66c0;
  --accent-hover:  #174f99;
  --on-accent:     #ffffff;
  --border:        #d3ddea;
  --code-bg:       #eaf0f8;
}

html.theme-dark {
  --bg:            #0e1420;
  --surface:       #1a2438;
  --text:          #e8edf5;
  --text-muted:    #9fb0c8;
  --accent:        #4da3ff;
  --accent-hover:  #7cbcff;
  --border:        #26344e;
  --code-bg:       #131c2c;
  --on-accent:     #0e1420;
}

html.theme-ebook {
  --bg:           #ffffff;
  --surface:      #ffffff;
  --text:         #000000;
  --text-muted:   #3a3a3a;
  --accent:       #000000;
  --accent-hover: #000000;
  --border:       #cccccc;
  --code-bg:      #f0f0f0;
  --on-accent:    #ffffff;
}
html.theme-ebook a { text-decoration: underline; }

/* ---- Font size selection (dynamic server; html.size-<name>) ---- */
html.size-small  { --font-size-base: 15px; }
html.size-medium { --font-size-base: 18px; }
html.size-large  { --font-size-base: 21px; }

/* ---- Base ---- */
* { box-sizing: border-box; }

html {
  font-size: var(--font-size-base);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Site header ---- */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 28px 0;
  margin-bottom: 36px;
}
.site-header .wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.site-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.site-title a { color: inherit; }
.site-tagline { color: var(--text-muted); font-size: 0.95rem; }

/* ---- Search form ---- */
.search-form { display: flex; gap: 8px; margin-bottom: 18px; }
.search-form input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}
.search-form button {
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1rem;
  cursor: pointer;
}
.search-form button:hover { background: var(--accent-hover); }
.search-empty, .search-count { color: var(--text-muted); }
.header-search { display: flex; gap: 8px; margin-top: 12px; max-width: 520px; }
.header-search input[type="search"] {
  flex: 1; min-width: 0; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 1rem;
}
.header-search button {
  padding: 6px 14px; border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent); color: var(--on-accent); font-size: 1rem; cursor: pointer;
}
.header-search button:hover { background: var(--accent-hover); }
mark { background: #ffe58a; color: #000; padding: 0 1px; border-radius: 2px; }
html.theme-ebook mark { background: #ddd; color: #000; text-decoration: underline; }

/* ---- Index: article cards ---- */
.card-list { list-style: none; margin: 0; padding: 0; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover { border-color: var(--accent); }
.card h2 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  line-height: 1.25;
  margin: 0 0 8px;
  overflow-wrap: break-word;   /* break long unbreakable tokens (e.g. non-breaking hyphens) */
  hyphens: auto;               /* nicer breaks; pages are lang="de" */
}
.card h2 a { color: var(--text); }
.card h2 a:hover { color: var(--accent); text-decoration: none; }
.card .excerpt { color: var(--text-muted); margin: 10px 0 0; }

/* meta row (date + categories) */
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
        font-size: 0.85rem; color: var(--text-muted); }
.cats { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.cat {
  display: inline-block;
  background: var(--code-bg);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.78rem;
}

/* ---- Article page ---- */
.article-nav { margin-bottom: 24px; font-size: 0.9rem; }
article { background: transparent; }

/* The scraper-produced body uses these t-* classes. */
.t-title {
  font-family: var(--font-serif);
  font-size: 2.1rem;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 14px;
  overflow-wrap: break-word;   /* break long unbreakable tokens (e.g. non-breaking hyphens) */
  hyphens: auto;               /* nicer breaks; pages are lang="de" */
}
.t-date { color: var(--text-muted); font-size: 0.9rem; }
.t-cats { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: 4px; }
.t-h2 { font-family: var(--font-serif); font-size: 1.5rem; margin: 2em 0 0.5em; }
.t-h3 { font-family: var(--font-serif); font-size: 1.25rem; margin: 1.6em 0 0.4em; }
.t-p  { margin: 0 0 1.1em; }
.t-a  { color: var(--accent); }
.t-bq {
  margin: 1.4em 0;
  padding: 0.4em 1.1em;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
  font-style: italic;
}
.t-code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--code-bg);
  border-radius: 6px;
  padding: 0.1em 0.4em;
}
pre.t-code, pre .t-code {
  display: block;
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.45;
}

/* article header meta block */
.article-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
                margin: 0 0 28px; padding-bottom: 20px;
                border-bottom: 1px solid var(--border); }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 28px 0;
  font-size: 0.95rem;
}
/* Nav links styled as buttons, matching the "Suchen" button. */
.pagination a {
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
}
.pagination a:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
.page-indicator { color: var(--text-muted); }
/* .page-jump (index) and .page-goto (search) are the same "jump to page" control. */
.page-jump, .page-goto { display: inline-flex; gap: 8px; align-items: center; }
.page-jump input, .page-goto input {
  width: 5.5em;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}
.page-jump button, .page-goto button {
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1rem;
  cursor: pointer;
}
.page-jump button:hover, .page-goto button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 56px;
  padding: 28px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.site-footer .legal-links, .site-footer .footer-nav { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px 20px; }
.site-footer .legal-links a, .site-footer .footer-nav a { display: inline-block; padding: 8px 0; }

/* ---- About page (ticket 1780) ---- */
.about p, .about li { line-height: 1.6; }
.about .about-harnesses { columns: 2 14em; padding-left: 1.2em; }
.about .about-source { color: var(--text-muted); font-size: 0.85rem; }

/* ---- Responsive ---- */
@media (max-width: 600px) {
  html { font-size: calc(var(--font-size-base) - 1px); }
  .t-title { font-size: 1.7rem; }
  .site-header .wrap { flex-direction: column; gap: 4px; }
}

/* ---- Theme & font-size selectors (collapsible header controls) ---- */
.display-details {
  font-size: 0.85rem;
}
.display-details > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
  user-select: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.display-details > summary::-webkit-details-marker { display: none; }
/* arrow drawn with borders, not a font glyph: e-readers (Kindle) have no glyph for the gear/triangle characters */
.display-details > summary::after {
  content: "";
  display: inline-block;
  width: 0.4em;
  height: 0.4em;
  margin-left: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}
.display-details[open] > summary::after { transform: rotate(45deg); }
.display-details > summary:hover { border-color: var(--accent); color: var(--accent); }
.display-details[open] > summary { border-color: var(--accent); color: var(--accent); }

.display-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.85rem;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.display-controls fieldset {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.display-controls legend {
  padding: 0 4px;
  color: var(--text-muted);
  font-size: 0.78rem;
}
.display-controls label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.display-controls .apply-display {
  padding: 6px 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.85rem;
  cursor: pointer;
}
.display-controls .apply-display:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ---- News articles (ticket 1420) ---- */
.list-heading { font-size: 1.5rem; margin: 0 0 20px; }
.section-title { font-size: 1.15rem; margin: 28px 0 12px; color: var(--text-muted); }
.section-title .more { font-size: 0.85rem; margin-left: 8px; }
.empty { color: var(--text-muted); }
.site-header .site-nav { display: flex; flex-wrap: wrap; justify-content: flex-start; align-items: baseline; gap: 6px 16px; margin-top: 14px; font-size: 0.9rem; }
.nav-harnesses summary { cursor: pointer; color: var(--accent); }
.nav-harnesses a { display: inline-block; margin: 4px 14px 4px 0; }
.article-body { margin: 18px 0 28px; }
.article-body p { margin: 0 0 1.1em; }
.article-body h3, .article-body h4 { font-family: var(--font-serif); margin: 1.6em 0 0.5em; }
.article-body ul, .article-body ol { padding-left: 1.4em; margin: 0 0 1.1em; }
.article-body li { margin-bottom: 0.6em; }
.article-body code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.article-pager { display: flex; justify-content: space-between; gap: 16px; margin: 24px 0; font-size: 0.95rem; }
.article-pager .pager-next { margin-left: auto; }

/* ---- Visitors page (ticket 1440): chart colors validated for light/dark, ebook = black + gray ---- */
html { --chart-1: #2a78d6; --chart-2: #eb6834; }
html.theme-dark { --chart-1: #3987e5; --chart-2: #d95926; }
@media (prefers-color-scheme: dark), (prefers-color-scheme: no-preference) {
  html.theme-auto { --chart-1: #3987e5; --chart-2: #d95926; }
}
html.theme-ebook { --chart-1: #000000; --chart-2: #8a8a8a; }
.viz { margin: 16px 0 24px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.viz-legend { display: flex; gap: 18px; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px; }
.viz-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; }
.viz-swatch-1 { background: var(--chart-1); }
.viz-swatch-2 { background: var(--chart-2); }
.viz-chart { display: block; width: 100%; height: auto; }
.viz-grid { stroke: var(--border); stroke-width: 1; }
.viz-axis { fill: var(--text-muted); font-size: 11px; font-family: var(--font-sans); }
.viz-bar-1 { fill: var(--chart-1); }
.viz-bar-2 { fill: var(--chart-2); }
.viz-hit { fill: transparent; }
.viz-day:hover .viz-hit { fill: var(--border); opacity: 0.4; }
.viz-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; margin-bottom: 8px; }
.viz-table th, .viz-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; font-weight: normal; }
.viz-table thead th, .viz-table tfoot th, .viz-table tfoot td { font-weight: 600; }
.viz-table tfoot th, .viz-table tfoot td { border-top: 2px solid var(--border); }
.viz-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.viz-table tbody th { overflow-wrap: anywhere; }
.viz-note, .viz-meta, .viz-ranges { color: var(--text-muted); font-size: 0.9rem; }
.viz-ranges a[aria-current="page"] { font-weight: 700; text-decoration: underline; }

/* related articles (ticket 1620): day -> month/trend links, trend -> months */
.article-related, .article-sources { margin: 24px 0 0; font-size: 0.95rem; }
.article-related ul, .article-sources ul { margin: 0; padding-left: 1.2em; }

/* ---- Tap targets (ticket 1630): at least 44x44 CSS px for links and buttons ---- */
.site-title a, .site-tagline a { display: inline-block; padding: 10px 0; }
.site-header .site-nav { gap: 0 16px; }
.site-nav > a, .nav-harnesses a, .nav-harnesses summary, .article-pager a, .article-related a, .article-sources a,
.pagination a { display: inline-flex; align-items: center; min-height: 44px; }
.nav-harnesses a { margin: 0 14px 0 0; }
.display-details > summary, .apply-display, .search-form button, .header-search button,
.page-jump button, .page-goto button, .header-search input[type="search"],
.page-jump input, .page-goto input { min-height: 44px; }
.display-controls label { min-height: 44px; }
.display-controls input[type="radio"] { width: 20px; height: 20px; }

/* ---- Spacing without flexbox `gap` (Kindle browser ignores it: links were glued together) ----
   Margins replace the gaps of the rules above; same look in modern browsers. Later rules win. */
.site-header .wrap { gap: 0; }
.site-title, .site-tagline { margin-right: 16px; }
.site-header .site-nav { gap: 0; }
.site-nav > a, .site-nav > .nav-harnesses { margin-right: 16px; }
.nav-harnesses a { margin-right: 14px; }
.display-controls, .display-controls fieldset, .display-controls label { gap: 0; }
.display-controls fieldset, .display-controls .apply-display { margin-right: 12px; margin-bottom: 4px; }
.display-controls label { margin-right: 10px; }
.display-controls input[type="radio"] { margin-right: 4px; }
.pagination { gap: 0; }
.pagination > * { margin: 0 8px 8px 0; }
.site-footer .legal-links, .site-footer .footer-nav { gap: 0; }
.site-footer .legal-links a, .site-footer .footer-nav a { margin-right: 20px; }
.meta, .article-meta { gap: 0; }
.meta > *, .article-meta > * { margin-right: 10px; }
.cats, .t-cats { gap: 0; }
.cats > *, .t-cats > * { margin-right: 6px; }
.search-form, .header-search, .page-jump, .page-goto { gap: 0; }
.search-form > *, .header-search > *, .page-jump > *, .page-goto > * { margin-right: 8px; }
.search-form > :last-child, .header-search > :last-child, .page-jump > :last-child, .page-goto > :last-child { margin-right: 0; }

/* ---- Header on narrow/e-reader screens: title, tagline and Display stack instead of breaking mid-phrase ---- */
.site-tagline, .site-tagline a { white-space: nowrap; }
.site-header > .wrap:first-child { flex-wrap: wrap; }
@media (max-width: 820px) {
  .site-header > .wrap:first-child { flex-direction: column; align-items: flex-start; }
  .site-title, .site-tagline { margin-right: 0; }
  .site-header .display-details { margin-top: 4px; }
}

/* ---- GitHub stats page /repos (ticket 2003): table sorter styles (rewritten from tofsjonas/sortable with the theme variables) ---- */
.wrap.repos { max-width: 1600px; }
.repos-glossary { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 0.9rem; margin: 0 0 8px; }
.repos-glossary dt { font-weight: 700; }
.repos-glossary dd { margin: 0; }
.repos-source, .repos-notes { color: var(--text-muted); font-size: 0.85rem; }
.table-scroll { overflow: auto; max-height: 80vh; margin: 12px 0 28px; border: 1px solid var(--border); border-radius: 8px; }
table.sortable { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.sortable th, .sortable td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.sortable th.num, .sortable td.num { text-align: right; }
.sortable thead th { background: var(--surface); color: var(--text); font-weight: 700; }
.sortable.sticky thead th { position: sticky; top: 0; z-index: 1; }
.sortable tbody th { font-weight: 600; background: var(--bg); position: sticky; left: 0; }
.sortable tbody tr:nth-child(odd) td { background: var(--code-bg); }
.sortable thead th:not(.no-sort) { cursor: pointer; }
.sortable thead th:not(.no-sort)::after { content: "\25B8"; margin-left: 3px; font-size: 1.1em; color: transparent; transition: color .1s ease-in-out; }
.sortable thead th:not(.no-sort):hover::after, .sortable thead th:not(.no-sort):focus-visible::after { color: inherit; }
.sortable thead th:not(.no-sort)[aria-sort="descending"]::after { content: "\25BE"; color: inherit; }
.sortable thead th:not(.no-sort)[aria-sort="ascending"]::after { content: "\25B4"; color: inherit; }
.repos-notes { padding-left: 1.2em; line-height: 1.5; }
