/* @file_purpose Web stylesheet for the AI News static site — Anthropic-inspired warm, minimal theme. */

/* ---- Design tokens ---- */
:root {
  --bg:            #f5f4ef;  /* warm ivory */
  --surface:       #fbfaf7;  /* card / article surface */
  --text:          #1a1a18;  /* near-black */
  --text-muted:    #6b6660;  /* secondary text */
  --accent:        #cc785c;  /* Anthropic clay / terracotta */
  --accent-hover:  #b5634a;
  --border:        #e3e0d8;
  --code-bg:       #efece4;

  --font-serif: ui-serif, Georgia, "Times New Roman", serif;
  --font-sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                Helvetica, Arial, sans-serif;

  --maxw: 720px;
  --radius: 10px;

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

/* Static export / no explicit choice: keep following the OS preference. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:         #1f1e1b;
    --surface:    #26241f;
    --text:       #ece9e2;
    --text-muted: #a8a299;
    --accent:     #d98c6f;
    --accent-hover:#e7a489;
    --border:     #3a372f;
    --code-bg:    #2d2a24;
  }
}

/* ---- Theme selection (dynamic server; html.theme-<name>) ----
   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:            #f5f4ef;
  --surface:       #fbfaf7;
  --text:          #1a1a18;
  --text-muted:    #6b6660;
  --accent:        #cc785c;
  --accent-hover:  #b5634a;
  --border:        #e3e0d8;
  --code-bg:       #efece4;
}

html.theme-dark {
  --bg:         #1f1e1b;
  --surface:    #26241f;
  --text:       #ece9e2;
  --text-muted: #a8a299;
  --accent:     #d98c6f;
  --accent-hover:#e7a489;
  --border:     #3a372f;
  --code-bg:    #2d2a24;
}

html.theme-ebook {
  --bg:           #ffffff;
  --surface:      #ffffff;
  --text:         #000000;
  --text-muted:   #3a3a3a;
  --accent:       #000000;
  --accent-hover: #000000;
  --border:       #cccccc;
  --code-bg:      #f0f0f0;
}
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: #fff;
  font-size: 1rem;
  cursor: pointer;
}
.search-form button:hover { background: var(--accent-hover); }
.search-empty, .search-count { color: var(--text-muted); }

/* ---- 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); }

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 56px;
  padding: 28px 0;
  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 (header controls) ---- */
.display-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.85rem;
}
.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(--surface);
  font-size: 0.85rem;
  cursor: pointer;
}
.display-controls .apply-display:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
