/*
 * FOSSWire shared stylesheet: design tokens, header, footer and article pages.
 * The home page and the article pages generated by crawler_engine/compiler.py
 * link this file, so every page shares one header, footer and set of colors.
 */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --header-bg: #090d13;
  --card-bg: #161b22;
  --border: #30363d;
  --text-main: #c9d1d9;
  --text-strong: #f0f6fc;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-soft: rgba(88, 166, 255, 0.12);
  --hover-bg: rgba(177, 186, 196, 0.08);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --header-bg: #ffffff;
  --card-bg: #f6f8fa;
  --border: #d0d7de;
  --text-main: #1f2328;
  --text-strong: #0d1117;
  --text-muted: #59636e;
  --accent: #0969da;
  --accent-soft: rgba(9, 105, 218, 0.08);
  --hover-bg: rgba(208, 215, 222, 0.32);
}
:root {
  --font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --max-width: 900px;
  --measure: 680px;
  --radius: 8px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: break-word;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd, pre { font-family: var(--font-mono); font-size: 0.9em; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* Off screen until focused; clipped rather than moved, so right-to-left pages get no stray scroll. */
.skip-link { position: absolute; top: 0; inset-inline-start: 1rem; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }
.skip-link:focus { clip-path: none; width: auto; height: auto; top: 0.5rem; z-index: 10; padding: 0.4rem 0.8rem; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); }

/* Header (same as the home page) */
.site-header { background: var(--header-bg); border-bottom: 1px solid var(--border); }
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.site-title { margin: 0; font-size: 1.25rem; line-height: 1.2; }
.brand { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 700; color: var(--text-main); letter-spacing: -0.02em; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; flex: none; }
.brand .brand-word { color: inherit; }
.brand .brand-word span, .footer-brand-title span { color: var(--accent); }
.brand:hover { text-decoration: none; color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 0.5rem; }
.icon-btn, .lang-select {
  height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-main);
  cursor: pointer;
}
.icon-btn { width: 2.25rem; display: inline-grid; place-items: center; padding: 0; }
.icon-btn:hover, .lang-select:hover { border-color: var(--text-muted); }
.lang-select { padding: 0 0.5rem; font-size: 0.875rem; }
:root[data-theme="dark"] .icon-moon, :root:not([data-theme="dark"]) .icon-sun { display: none; }

/* Article page: plain page with a comfortable reading width */
.page { flex: 1; width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 2rem 1rem 3rem; }
.article { max-width: var(--measure); margin: 0 auto; }
.article-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.meta-tag {
  color: var(--accent);
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.meta-tag:hover { text-decoration: none; }
.article h1 {
  margin: 0 0 0.9rem;
  color: var(--text-strong);
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.15rem);
  line-height: 1.2;
  letter-spacing: -0.015em;
  font-weight: 700;
}
.byline {
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
}
.byline p { margin: 0; }
.byline-source { margin-bottom: 0.2rem !important; }
.byline-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; }
.byline-sep { opacity: 0.6; }
/* Each byline item keeps its own direction, so a translated date stays in order. */
.byline-meta > *, .byline-source > * { unicode-bidi: isolate; }
.byline time { unicode-bidi: plaintext; }
.byline a { color: var(--text-main); font-weight: 600; }
.byline .impact { color: var(--accent); font-weight: 600; }
.share-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.share-btn:hover { border-color: var(--accent); color: var(--accent); }
.share-toast {
  position: fixed;
  bottom: 2rem;
  right: 1.5rem;
  background: var(--card-bg);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.6rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  z-index: 1000;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s ease;
  pointer-events: none;
}
.share-toast.show { opacity: 1; transform: translateY(0); }

.takeaway-box {
  margin: 0 0 1.75rem;
  padding: 1rem 1.25rem;
  background: var(--accent-soft);
  border-inline-start: 3px solid var(--accent);
  border-start-end-radius: var(--radius);
  border-end-end-radius: var(--radius);
}
.takeaway-label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.takeaway-text { margin: 0; color: var(--text-strong); font-size: 1.08rem; font-weight: 600; line-height: 1.5; }

.article-text { font-size: 1.0625rem; line-height: 1.75; }
.article-text h2 {
  margin: 2rem 0 0.6rem;
  color: var(--text-strong);
  font-size: 1.25rem;
  line-height: 1.3;
}
.article-text p { margin: 0 0 1.1rem; }
.article-text ul { margin: 0 0 1.1rem; padding-inline-start: 1.3rem; }
.article-text li { margin-bottom: 0.35rem; }
.article-text a { text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.article-text code { background: var(--card-bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 0.25em; }
.article-text strong { color: var(--text-strong); }

.fw-trans-note {
  margin: 0 0 1.25rem;
  padding: 0.55rem 0.8rem;
  border: 1px dashed var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.fw-trans-note[data-state="loading"]::before {
  content: "";
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  margin-right: 0.5rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: fwspin 0.8s linear infinite;
  vertical-align: -1px;
}
@keyframes fwspin { to { transform: rotate(360deg); } }
span.notranslate { display: inline; }

.source-note {
  margin: 2rem 0 0;
  padding: 0.9rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.9rem;
}
.source-note a { font-weight: 600; }

.related-section { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.related-heading { margin: 0 0 0.75rem; color: var(--text-strong); font-size: 1rem; }
.related-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.85rem; }
.related-item { display: flex; flex-direction: column; gap: 0.1rem; }
.related-link { color: var(--text-main); font-weight: 600; line-height: 1.4; }
.related-link:hover { color: var(--accent); }
.related-meta { font-size: 0.8rem; color: var(--text-muted); }

/* Footer (same as the home page) */
footer { border-top: 1px solid var(--border); background: var(--header-bg); color: var(--text-muted); font-size: 0.85rem; }
.footer-inner { max-width: var(--max-width); margin: 0 auto; padding: 1.25rem 1rem 1.5rem; }
.footer-unified-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.6rem; }
.footer-endpoints { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.6rem; }
.footer-brand-title { font-weight: 700; color: var(--text-main); letter-spacing: -0.02em; }
.footer-sep { opacity: 0.5; }
.footer-endpoints a, .footer-sub-line a { color: var(--text-muted); }
.footer-endpoints a:hover, .footer-sub-line a:hover { color: var(--accent); }
.footer-sub-line { margin-top: 0.6rem; }

@media (max-width: 600px) {
  .page { padding-top: 1.25rem; }
  .article-text { font-size: 1rem; line-height: 1.7; }
  .takeaway-text { font-size: 1rem; }
  .footer-unified-line > .footer-sep { display: none; }
  .footer-unified-line { flex-direction: column; align-items: flex-start; }
}

/* Pages with their own layout (about, digests, CVE radar...) keep normal block flow. */
body.static-page { display: block; }
