/* TJG Online: mobile-first, no web fonts, no layout-shifting assets. */
:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-card: #ffffff;
  --ink: #16202e;
  --ink-soft: #4a5768;
  --ink-faint: #6b7889;
  --line: #e3e7ec;
  --accent: #14508c;
  --accent-soft: #eaf1f9;
  --accent-ink: #0e3c6b;
  --warn-bg: #fff8e8;
  --warn-line: #e8d29a;
  --radius: 12px;
  --maxw: 1140px;
  --measure: 70ch;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1621;
    --bg-soft: #151f2c;
    --bg-card: #16202e;
    --ink: #e8edf4;
    --ink-soft: #b3bfcf;
    --ink-faint: #93a1b4;
    --line: #27354a;
    --accent: #7db6f0;
    --accent-soft: #17293f;
    --accent-ink: #a9cef7;
    --warn-bg: #241f12;
    --warn-line: #4e4225;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  text-rendering: optimizeLegibility;
}
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 1rem; }
img, svg { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 50;
  background: var(--accent); color: #fff; padding: .6rem 1rem; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

/* ---------- header ---------- */
.site-head {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.head-inner {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "brand nav" "search search";
  gap: .5rem .75rem;
  align-items: center;
  padding-top: .6rem; padding-bottom: .6rem;
}
.brand {
  grid-area: brand;
  display: inline-flex; align-items: center; gap: .5rem;
  font-weight: 700; font-size: 1.1rem; letter-spacing: -.01em;
  color: var(--ink); text-decoration: none;
}
.brand-mark { color: var(--accent); flex: none; }
.head-nav {
  grid-area: nav;
  display: flex; gap: .85rem; justify-content: flex-end; flex-wrap: wrap;
  font-size: .95rem;
}
.head-nav a { color: var(--ink-soft); text-decoration: none; padding: .2rem 0; }
.head-nav a:hover, .head-nav a[aria-current] { color: var(--accent); text-decoration: underline; }
.head-search { grid-area: search; display: flex; gap: .4rem; }
.head-search input {
  flex: 1 1 auto; min-width: 0;
  padding: .55rem .75rem; font: inherit; font-size: .95rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-soft); color: var(--ink);
}
.head-search button {
  flex: none; padding: .55rem 1rem; font: inherit; font-size: .95rem; font-weight: 600;
  border: 0; border-radius: 999px; background: var(--accent); color: #fff; cursor: pointer;
}
.head-search button:hover { background: var(--accent-ink); }
@media (min-width: 760px) {
  .head-inner {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "brand nav search";
    gap: 1.25rem;
  }
  .head-search input { width: 15rem; }
}

/* ---------- breadcrumbs ---------- */
.crumbs { border-bottom: 1px solid var(--line); background: var(--bg-soft); }
.crumbs ol {
  max-width: var(--maxw); margin: 0 auto; padding: .5rem 1rem;
  list-style: none; display: flex; flex-wrap: wrap; gap: .35rem;
  font-size: .85rem; color: var(--ink-faint);
}
.crumbs li::after { content: "›"; margin-left: .35rem; color: var(--line); }
.crumbs li:last-child::after { content: ""; }
.crumbs a { color: var(--ink-soft); }

/* ---------- layout ---------- */
main { padding-top: 1.5rem; padding-bottom: 3rem; }
.layout { display: grid; gap: 2.5rem; }
@media (min-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr) 19rem; align-items: start; }
  .rail { position: sticky; top: 6.5rem; }
}
h1 { font-size: 1.75rem; line-height: 1.25; letter-spacing: -.02em; margin: 0 0 .5rem; }
h2 { font-size: 1.3rem; line-height: 1.3; letter-spacing: -.01em; margin: 2.25rem 0 .75rem; }
h3 { font-size: 1.08rem; margin: 1.5rem 0 .5rem; }
@media (min-width: 760px) { h1 { font-size: 2.15rem; } h2 { font-size: 1.45rem; } }
p { margin: 0 0 1.1rem; }

/* ---------- article ---------- */
.article-head { border-bottom: 1px solid var(--line); padding-bottom: 1rem; margin-bottom: 1.5rem; }
.kicker {
  display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent); text-decoration: none; margin-bottom: .6rem;
}
.kicker:hover { text-decoration: underline; }
.byline {
  display: flex; flex-wrap: wrap; gap: .3rem .9rem;
  font-size: .85rem; color: var(--ink-faint); margin: .5rem 0 0;
}
.byline time { white-space: nowrap; }
.prose { max-width: var(--measure); font-size: 1.075rem; }
.prose .lead { font-size: 1.2rem; line-height: 1.55; color: var(--ink); font-weight: 450; }
.prose p:last-child { margin-bottom: 0; }
.answer-box {
  background: var(--accent-soft); border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.1rem; margin: 0 0 1.5rem; max-width: var(--measure);
}
.answer-box h2 {
  margin: 0 0 .4rem; font-size: .8rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent-ink);
}
.answer-box p { margin: 0; font-size: 1.05rem; }
.notice {
  background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius);
  padding: .85rem 1rem; font-size: .92rem; color: var(--ink-soft);
  margin: 2rem 0 0; max-width: var(--measure);
}
.notice strong { color: var(--ink); }

/* ---------- cards & lists ---------- */
.card-grid { display: grid; gap: .85rem; padding: 0; margin: 0; list-style: none; }
@media (min-width: 620px) { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .card-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.card {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.card h2, .card h3 { margin: 0 0 .35rem; font-size: 1.05rem; line-height: 1.35; }
.card h2 a, .card h3 a { color: var(--ink); text-decoration: none; }
.card h2 a:hover, .card h3 a:hover { color: var(--accent); text-decoration: underline; }
.card p { margin: 0; font-size: .92rem; color: var(--ink-soft); }
.card .meta { margin-top: .5rem; font-size: .8rem; color: var(--ink-faint); }

.q-list { list-style: none; padding: 0; margin: 0; }
.q-list li { border-bottom: 1px solid var(--line); }
.q-list li:first-child { border-top: 1px solid var(--line); }
.q-list a {
  display: block; padding: .8rem .25rem; text-decoration: none; color: var(--ink);
  font-weight: 500;
}
.q-list a:hover { color: var(--accent); background: var(--bg-soft); }
.q-list .snippet { display: block; font-weight: 400; font-size: .88rem; color: var(--ink-faint); margin-top: .2rem; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; margin: 1rem 0 0; list-style: none; }
.chips a {
  display: inline-block; padding: .35rem .75rem; border: 1px solid var(--line);
  border-radius: 999px; background: var(--bg-soft); color: var(--ink-soft);
  text-decoration: none; font-size: .88rem;
}
.chips a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- rail ---------- */
.rail section { margin-bottom: 1.75rem; }
.rail h2 { font-size: .82rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); margin: 0 0 .6rem; }
.rail ul { list-style: none; margin: 0; padding: 0; font-size: .95rem; }
.rail li { margin-bottom: .55rem; line-height: 1.4; }
.rail a { text-decoration: none; }
.rail a:hover { text-decoration: underline; }

/* ---------- pagination ---------- */
.pager { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 2.5rem 0 0; }
.pager a, .pager span {
  padding: .5rem .85rem; border: 1px solid var(--line); border-radius: 8px;
  text-decoration: none; font-size: .92rem;
}
.pager .current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pager .gap { border: 0; padding: .5rem .2rem; color: var(--ink-faint); }

.prev-next { display: grid; gap: .75rem; margin-top: 2rem; }
@media (min-width: 620px) { .prev-next { grid-template-columns: 1fr 1fr; } }
.prev-next a {
  display: block; border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem 1rem; text-decoration: none; color: var(--ink);
}
.prev-next a:hover { border-color: var(--accent); }
.prev-next span { display: block; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); margin-bottom: .2rem; }
.prev-next .to-next { text-align: right; }

/* ---------- home ---------- */
.hero { padding: .5rem 0 2rem; border-bottom: 1px solid var(--line); margin-bottom: 2rem; }
.hero p { max-width: 62ch; color: var(--ink-soft); font-size: 1.1rem; }
.hero .stat-row { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-top: 1.25rem; padding: 0; list-style: none; }
.hero .stat-row b { display: block; font-size: 1.35rem; color: var(--ink); }
.hero .stat-row span { font-size: .85rem; color: var(--ink-faint); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem; }
.section-head h2 { margin-bottom: .35rem; }
.section-head p { margin: 0 0 .75rem; color: var(--ink-faint); font-size: .92rem; }

/* ---------- footer ---------- */
.site-foot { border-top: 1px solid var(--line); background: var(--bg-soft); padding: 2.5rem 0 2rem; font-size: .92rem; }
.foot-grid { display: grid; gap: 1.5rem; }
@media (min-width: 620px) { .foot-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .foot-grid { grid-template-columns: repeat(4, 1fr); } }
.foot-col h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); margin: 0 0 .5rem; }
.foot-col ul { list-style: none; margin: 0; padding: 0; }
.foot-col li { margin-bottom: .35rem; }
.foot-col a { color: var(--ink-soft); text-decoration: none; }
.foot-col a:hover { color: var(--accent); text-decoration: underline; }
.foot-bar { border-top: 1px solid var(--line); margin-top: 2rem; padding-top: 1.25rem; }
.foot-about { color: var(--ink-soft); max-width: 70ch; }
.foot-links { display: flex; flex-wrap: wrap; gap: .35rem 1rem; margin: .75rem 0; }
.foot-links a { color: var(--ink-soft); }
.copy { color: var(--ink-faint); font-size: .85rem; margin: .5rem 0 0; }

/* ---------- static pages ---------- */
.page-prose { max-width: var(--measure); }
.page-prose h2 { margin-top: 2rem; }
.page-prose ul, .page-prose ol { padding-left: 1.25rem; margin: 0 0 1.1rem; }
.page-prose li { margin-bottom: .4rem; }
.page-prose dl { margin: 0 0 1.1rem; }
.page-prose dt { font-weight: 600; margin-top: .9rem; }
.page-prose dd { margin: .15rem 0 0; color: var(--ink-soft); }
.page-prose table { width: 100%; border-collapse: collapse; margin: 0 0 1.25rem; font-size: .95rem; }
.page-prose th, .page-prose td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.page-prose th { color: var(--ink-faint); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- search / empty states ---------- */
.result-count { color: var(--ink-faint); font-size: .95rem; margin-bottom: 1.25rem; }
.empty { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; max-width: var(--measure); }

/* ---------- ad placements ------------------------------------------------
   Reserved, layout-stable slots. They occupy no space until a unit is
   placed inside them, so an empty slot can never shift content or leave a
   blank gap. Reserve height per unit when filling them.                    */
.slot { display: block; margin: 2rem 0; }
.slot:empty { display: none; }
.slot > * { margin-inline: auto; }

/* ---------- print ---------- */
@media print {
  .site-head, .site-foot, .rail, .pager, .prev-next, .slot, .skip, .crumbs { display: none !important; }
  body { font-size: 11pt; color: #000; background: #fff; }
  .layout { display: block; }
  .prose, .page-prose { max-width: none; }
  .answer-box { border: 1px solid #999; background: none; }
  a { color: #000; text-decoration: underline; }
  .q-list a::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; }
  h1, h2, h3 { page-break-after: avoid; }
  p { orphans: 3; widows: 3; }
}

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- rich article structure ---------- */
.takeaways {
  background: var(--accent-soft); border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.2rem; margin: 0 0 1.5rem; max-width: var(--measure);
}
.takeaways h2 {
  margin: 0 0 .5rem; font-size: .8rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent-ink);
}
.takeaways ul { margin: 0; padding-left: 1.15rem; }
.takeaways li { margin-bottom: .4rem; }
.takeaways li:last-child { margin-bottom: 0; }

.toc {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1.1rem; margin: 0 0 1.75rem; max-width: var(--measure);
  background: var(--bg-soft);
}
.toc h2 {
  margin: 0 0 .5rem; font-size: .8rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-faint);
}
.toc ol { margin: 0; padding-left: 1.2rem; font-size: .95rem; }
.toc li { margin-bottom: .3rem; }
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }

.prose ul.bullets, .prose ol.steps { max-width: var(--measure); padding-left: 1.3rem; margin: 0 0 1.1rem; }
.prose ul.bullets li, .prose ol.steps li { margin-bottom: .5rem; }
.prose ol.steps li { padding-left: .2rem; }

.table-wrap { overflow-x: auto; margin: 0 0 1.25rem; max-width: var(--measure); }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table-wrap th, .table-wrap td {
  text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top;
}
.table-wrap th {
  color: var(--ink-faint); font-size: .8rem; text-transform: uppercase;
  letter-spacing: .04em; background: var(--bg-soft);
}
.table-wrap tr:last-child td { border-bottom: 0; }

.faq { max-width: var(--measure); }
.faq details { border-bottom: 1px solid var(--line); padding: .25rem 0; }
.faq details:first-child { border-top: 1px solid var(--line); }
.faq summary {
  cursor: pointer; padding: .8rem .25rem; font-weight: 600; list-style: none;
  display: flex; justify-content: space-between; gap: 1rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-weight: 700; flex: none; }
.faq details[open] summary::after { content: "\2212"; }
.faq summary:hover { color: var(--accent); }
.faq details > .prose { padding: 0 .25rem .8rem; }
.faq details > .prose p { margin: 0; }

/* ---------- mobile corrections ----------------------------------------
   Written after the rich article structures landed. Tables, the table of
   contents and the FAQ all behave differently on a narrow screen than they
   do in a desktop preview.                                              */

/* Long Latvian compound terms and Latin names must never push the page
   sideways. */
body { overflow-wrap: break-word; }
.prose, .page-prose, .takeaways, .toc, .faq, .q-list, .card { min-width: 0; }
h1, h2, h3, .card h2, .card h3, .faq summary { overflow-wrap: anywhere; }

/* A 4 or 5 column table squashes to unreadable width on a phone. Give it a
   floor and let the wrapper scroll instead, with a visible edge so it is
   obvious there is more to see. */
.table-wrap {
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: var(--radius);
}
.table-wrap table { min-width: 32rem; margin: 0; }
.table-wrap th, .table-wrap td { padding: .55rem .65rem; }
.table-wrap th:first-child, .table-wrap td:first-child { position: sticky; left: 0; background: var(--bg); }
.table-wrap th:first-child { background: var(--bg-soft); }
@media (max-width: 560px) {
  .table-wrap table { font-size: .88rem; }
  .table-wrap::after {
    content: "Tabulu var ritināt uz sāniem";
    display: block; padding: .4rem .65rem; font-size: .78rem;
    color: var(--ink-faint); border-top: 1px solid var(--line);
  }
}

/* The header is sticky, so an anchor jump from the table of contents lands
   with the heading hidden underneath it. */
:target, section[id], #faq { scroll-margin-top: 5.5rem; }
@media (min-width: 760px) { section[id], #faq { scroll-margin-top: 4.5rem; } }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Comfortable tap targets and tighter gutters on small screens. */
@media (max-width: 560px) {
  .wrap { padding: 0 .85rem; }
  .faq summary { padding: .95rem .25rem; min-height: 44px; }
  .toc { padding: .8rem .9rem; }
  .toc li { margin-bottom: .45rem; }
  .takeaways { padding: .9rem 1rem; }
  .head-nav { gap: .7rem; font-size: .9rem; }
  .q-list a { padding: .95rem .25rem; }
  .chips a { padding: .45rem .8rem; }
  h1 { font-size: 1.55rem; }
  .prose { font-size: 1.02rem; }
  .answer-box { padding: .9rem 1rem; }
  .answer-box p { font-size: 1rem; }
}

/* Very narrow phones: stop the header nav from crowding the brand. */
@media (max-width: 380px) {
  .brand-text { font-size: 1rem; }
  .head-nav { gap: .55rem; font-size: .85rem; }
}
