/* ---------------------------------------------------------------------------
   site.css: the server-rendered public pages (backend/app/site/).

   Linked by base.html on every SSR page (ssr=true): language homes, the
   "Learn German" hub, blog, articles, CMS pages, 404/503, and the shared
   pieces of the tool page (breadcrumbs, footer, FAQ). Word pages add
   word-page.css on top.

   Rules:
   - theme variables only (--bg --surface --surface-2 --border --border-2
     --text --muted --accent --accent-2 --accent-text --chip --radius), so
     light and dark both follow <html data-theme>;
   - mobile first; nothing may push the page sideways at 360px (long German
     compounds break with overflow-wrap, tables scroll inside .st-table);
   - logical properties (margin-inline, padding-inline-start, text-align:
     start) so a dir="rtl" block (Persian) mirrors itself;
   - everything is namespaced .st-* (plus .crumbs / .site-footer from
     base.html) so nothing here can touch the app's own pages.
   --------------------------------------------------------------------------- */

/* ---- layout -------------------------------------------------------------- */
.st-wrap { max-width: 480px; }
@media (min-width: 720px) {
  .st-wrap { max-width: 760px; padding-top: 32px; }
}
.st-main { overflow-wrap: anywhere; }
.st-main[dir="rtl"] { text-align: start; }

.st-sr {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- app bar: room for the slots JS fills after the first paint ----------
   theme.js puts a 70x36 switch into #theme-slot and account.js a 38x37 icon
   button into #account-slot (same size signed in or out). Reserving that
   size keeps the bar, and everything under it, from jumping; on a narrow
   phone the tool page's bar wraps at first paint instead of a moment later. */
.site-bar > #theme-slot:empty { display: inline-block; width: 70px; height: 36px; }
.site-bar > #account-slot:empty { display: inline-block; width: 38px; height: 37px; }

/* ---- breadcrumbs (base.html: nav.crumbs > ol > li) ------------------------ */
.crumbs { margin: -6px 0 18px; font-size: 13px; color: var(--muted); }
.crumbs ol {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0;
}
.crumbs li { display: inline-flex; align-items: center; min-width: 0; }
.crumbs li + li::before {
  content: "›"; margin-inline: 7px; color: var(--muted); opacity: .7;
}
.crumbs[dir="rtl"] li + li::before { content: "‹"; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs [aria-current="page"] {
  color: var(--text); overflow-wrap: anywhere;
}
.crumbs a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---- hero / headings ------------------------------------------------------ */
.st-hero { margin: 4px 0 20px; }
.st-h1 {
  margin: 0 0 10px; font-size: 26px; line-height: 1.25; font-weight: 750;
  letter-spacing: -.015em; color: var(--text);
}
@media (min-width: 720px) { .st-h1 { font-size: 32px; } }
.st-lead { margin: 0; font-size: 16px; line-height: 1.7; color: var(--muted); }
.st-h2 { margin: 0 0 12px; font-size: 19px; line-height: 1.3; font-weight: 700; color: var(--text); }
.st-sec { margin: 34px 0 0; }
.st-more { margin: 12px 0 0; font-size: 14px; }
.st-more a { color: var(--accent); text-decoration: none; }
.st-more a:hover { text-decoration: underline; }
.st-empty { color: var(--muted); margin: 18px 0; }

/* ---- search form ---------------------------------------------------------- */
.st-search {
  display: flex; gap: 8px; margin: 0 0 22px;
  padding: 6px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border);
}
.st-search:focus-within { border-color: var(--accent); }
.st-search-in {
  flex: 1 1 auto; min-width: 0; width: 100%;
  font: inherit; font-size: 16px; color: var(--text);
  background: transparent; border: 0; outline: 0; padding: 10px 10px;
  direction: ltr; text-align: left;
}
.st-search-in::placeholder { color: var(--muted); opacity: 1; }
/* Persian page: the placeholder reads RTL; typed German stays LTR. */
.lang-fa .st-search-in:placeholder-shown { direction: rtl; text-align: right; }
.st-search-btn {
  flex: none; font: inherit; font-size: 15px; font-weight: 650; cursor: pointer;
  border: 0; border-radius: 12px; padding: 10px 18px;
  background: var(--accent); color: var(--accent-text);
}
.st-search-btn:hover { background: var(--accent-2); }
.st-search-btn:focus-visible, .st-search-in:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.st-search-in::-webkit-search-cancel-button { display: none; }

/* ---- tool cards ----------------------------------------------------------- */
.st-cards { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 0 0 8px; }
@media (min-width: 560px) { .st-cards { grid-template-columns: 1fr 1fr; } }
.st-card {
  display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 3px;
  align-items: start; padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
  transition: border-color .16s ease, transform .16s ease;
}
.st-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.st-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.st-card-ico { grid-row: span 2; font-size: 22px; line-height: 1.2; }
.st-card-t { font-weight: 700; font-size: 16px; line-height: 1.35; }
.st-card-d { font-size: 14px; line-height: 1.55; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .st-card { transition: none; } .st-card:hover { transform: none; } }

/* ---- word list (popular words) ------------------------------------------- */
.st-wordlist { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.st-wordlist a {
  display: inline-block; padding: 6px 12px; border-radius: 999px;
  font-size: 14.5px; line-height: 1.4; color: var(--text); text-decoration: none;
  background: var(--chip); border: 1px solid var(--border);
  overflow-wrap: anywhere;
}
.st-wordlist a:hover { border-color: var(--accent); color: var(--accent); }
.st-wordlist a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.st-art { color: var(--muted); }

/* ---- prose (page/article bodies, from Markdown) --------------------------- */
.st-body { margin: 26px 0 0; font-size: 16.5px; line-height: 1.8; color: var(--text); }
.st-art .st-body { margin-top: 22px; }
.st-body > :first-child { margin-top: 0; }
.st-body h2 { font-size: 22px; line-height: 1.35; margin: 36px 0 10px; font-weight: 700; scroll-margin-top: 16px; }
.st-body h3 { font-size: 18px; line-height: 1.4; margin: 26px 0 8px; font-weight: 650; scroll-margin-top: 16px; }
.st-body h4 { font-size: 16px; margin: 22px 0 6px; font-weight: 650; }
.st-body p { margin: 0 0 16px; }
.st-body ul, .st-body ol { margin: 0 0 16px; padding-inline-start: 22px; }
/* Persian blocks count in Persian digits (۱. ۲. ۳.), like the dates. */
[dir="rtl"] .st-body ol, [dir="rtl"] .st-toc ol, .st-body ol[dir="rtl"] { list-style-type: persian; }
.st-body li { margin-bottom: 7px; }
.st-body a { color: var(--accent); text-underline-offset: 2px; }
.st-body strong { font-weight: 700; }
.st-body blockquote {
  margin: 20px 0; padding: 2px 0; padding-inline-start: 16px;
  border-inline-start: 3px solid var(--accent); color: var(--muted);
}
.st-body code {
  font-size: .9em; padding: 1px 6px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.st-body pre {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; direction: ltr; text-align: left;
}
.st-body pre code { background: none; border: 0; padding: 0; }
.st-body img { max-width: 100%; height: auto; border-radius: 12px; }
.st-body hr { border: 0; border-top: 1px solid var(--border); margin: 30px 0; }
.st-body bdi { unicode-bidi: isolate; }
.st-table { overflow-x: auto; margin: 0 0 18px; -webkit-overflow-scrolling: touch; }
.st-table table { border-collapse: collapse; width: 100%; font-size: 15px; }
.st-table th, .st-table td { border: 1px solid var(--border); padding: 8px 11px; text-align: start; vertical-align: top; }
.st-table th { background: var(--surface); font-weight: 650; }

/* ---- table of contents ([toc]) -------------------------------------------- */
.st-toc {
  margin: 4px 0 24px; padding: 14px 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
}
.st-toc-h { margin: 0 0 6px !important; font-weight: 700; font-size: 15px; color: var(--text); }
.st-toc ol { margin: 0; padding-inline-start: 20px; font-size: 15px; line-height: 1.6; }
.st-toc ol ol { margin-top: 4px; }
.st-toc li { margin: 3px 0; }
.st-toc a { color: var(--text); text-decoration: none; }
.st-toc a:hover { color: var(--accent); text-decoration: underline; }

/* ---- callouts (:::tip / :::warn / :::note) ------------------------------- */
.st-callout {
  margin: 20px 0; padding: 12px 16px; border-radius: 12px;
  border: 1px solid var(--border); border-inline-start: 4px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}
.st-callout > :last-child { margin-bottom: 0; }
.st-callout-h { margin: 0 0 4px !important; font-weight: 700; font-size: 14.5px; }
.st-callout-tip .st-callout-h::before { content: "💡 "; }
.st-callout-warn {
  border-inline-start-color: var(--pos-det, var(--accent));
  background: color-mix(in srgb, var(--pos-det, var(--accent)) 9%, transparent);
}
.st-callout-warn .st-callout-h::before { content: "⚠️ "; }
.st-callout-note {
  border-inline-start-color: var(--muted);
  background: var(--surface-2);
}

/* ---- FAQ (visible; FAQPage JSON-LD only when the page asks for it) -------- */
.st-faq { margin: 34px 0 0; }
.st-faq-item {
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  margin: 0 0 8px; padding: 0;
}
.st-faq-item > summary {
  cursor: pointer; list-style: none; padding: 12px 16px; font-weight: 650;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.st-faq-item > summary::-webkit-details-marker { display: none; }
.st-faq-item > summary::after {
  content: "+"; flex: none; color: var(--muted); font-weight: 400; font-size: 18px; line-height: 1.2;
}
.st-faq-item[open] > summary::after { content: "−"; }
.st-faq-item > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 12px; }
.st-faq-a { padding: 0 16px 12px; color: var(--text); line-height: 1.7; }
.st-faq-a > :last-child { margin-bottom: 0; }
.st-faq-a p { margin: 0 0 10px; }
.st-faq-a a { color: var(--accent); }

/* ---- article lists ----------------------------------------------------- */
.st-postlist { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 16px; }
.st-post {
  padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
}
.st-post-link { display: block; color: var(--text); text-decoration: none; }
.st-post-link:hover .st-post-t { color: var(--accent); }
.st-post-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
.st-post-img {
  display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: 10px; margin: 0 0 12px; background: var(--surface-2);
}
.st-post-t { display: block; margin: 0 0 6px; font-size: 18px; line-height: 1.4; font-weight: 700; }
.st-post-x { margin: 0 0 6px; font-size: 15px; line-height: 1.65; color: var(--muted); }
.st-postlist--compact { gap: 10px; }
.st-postlist--compact .st-post-t { font-size: 16px; }
/* Home/hub "latest articles": small cards side by side, never one huge cover. */
@media (min-width: 560px) {
  .st-postlist--compact { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
}
@media (min-width: 720px) {
  .st-postlist:not(.st-postlist--compact) .st-post:has(.st-post-img) {
    display: grid; grid-template-columns: 240px 1fr; column-gap: 18px; align-items: start;
  }
  .st-postlist:not(.st-postlist--compact) .st-post:has(.st-post-img) .st-post-link {
    display: contents;
  }
  .st-postlist:not(.st-postlist--compact) .st-post:has(.st-post-img) .st-post-img {
    grid-row: 1 / span 3; margin: 0;
  }
}

/* ---- meta line (dates, author, reading time) ----------------------------- */
.st-meta { margin: 10px 0 0; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.st-post .st-meta { margin: 0; }
.st-dot { opacity: .7; }

/* ---- article ------------------------------------------------------------- */
.st-art-head { margin: 4px 0 0; }
.st-cover { margin: 18px 0 0; }
.st-cover img {
  display: block; width: 100%; height: auto; border-radius: var(--radius);
  background: var(--surface-2);
}
.st-tags { margin: 26px 0 0; font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.st-tag {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--chip); border: 1px solid var(--border); color: var(--text);
}
.st-otherlangs {
  margin: 26px 0 0; font-size: 14px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center;
}
.st-otherlangs a { color: var(--accent); text-decoration: none; }
.st-otherlangs a:hover { text-decoration: underline; }

/* ---- video (click to load) ---------------------------------------------- */
.st-video { margin: 20px 0 0; }
.st-vbtn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 9px 16px;
}
.st-vbtn span { color: var(--accent); font-size: 12px; }
.st-vbtn:hover { border-color: var(--accent); }
.st-video.is-on {
  border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; background: var(--surface);
}
.st-video iframe { display: block; width: 100%; height: 100%; border: 0; }

/* ---- 404 / 503 ------------------------------------------------------------ */
.st-errbox { padding-top: 6px; }
.st-code {
  margin: 0 0 4px; font-size: 13px; font-weight: 700; letter-spacing: .14em;
  color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.st-errbox .st-lead { margin-bottom: 22px; }
.st-links { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 8px; font-size: 15px; }
.st-links a { color: var(--accent); text-decoration: none; }
.st-links a:hover { text-decoration: underline; }

/* ---- site footer (base.html, when site_footer is given) ------------------ */
.site-footer {
  position: relative; z-index: 1;
  max-width: 760px; margin: 8px auto 0; padding: 22px 16px 40px;
  border-top: 1px solid var(--border);
  font-size: 13.5px; line-height: 1.6; color: var(--muted);
  overflow-wrap: anywhere;
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); text-decoration: underline; }
.site-footer a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.site-footer-links, .site-footer-langs {
  display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 10px;
}
.site-footer-langs a { padding: 2px 10px; border: 1px solid var(--border); border-radius: 999px; }
.site-footer-langs a[aria-current="true"] { color: var(--text); border-color: var(--border-2); }
.site-footer-meta { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; }
