/* =========================================================
   Piteas — Wikipedia-style article theme
   Pure white background, sticky left TOC, right infobox
   ========================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 16px;
}

body {
  margin: 0;
  background: #ffffff;
  color: #202122;
  font-family: "Charter", "Georgia", "Times New Roman", Times, serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: #3366cc;
  text-decoration: none;
}

a:hover,
a:focus {
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid #3366cc;
  outline-offset: 2px;
}

/* ---------- Skip link (a11y) ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: #000;
  color: #fff;
  padding: 8px 12px;
  z-index: 100;
}
.skip-link:focus {
  left: 8px;
  top: 8px;
}

/* ---------- Top bar ---------- */
.topbar {
  border-bottom: 1px solid #c8ccd1;
  background: #ffffff;
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
.topbar-title {
  font-size: 14px;
  color: #202122;
  font-weight: 500;
}
.topbar-search {
  font-size: 12px;
  color: #fff;
  background: #54595d;
  padding: 4px 10px;
  border-radius: 2px;
}

/* ---------- Layout grid ---------- */
.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
  align-items: start;
}

/* ---------- Sticky TOC ---------- */
.toc {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13px;
  padding: 12px 14px 16px;
  border: 1px solid #a2a9b1;
  background: #f8f9fa;
  border-radius: 2px;
}

.toc-title {
  font-weight: 700;
  font-size: 14px;
  margin: 0 0 8px;
  color: #000;
}

.toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: section;
}

.toc > ol > li {
  counter-increment: section;
  margin: 6px 0;
}

.toc > ol > li > a::before {
  content: counter(section) ". ";
  font-weight: 600;
}

.toc ol ol {
  counter-reset: subsection;
  margin: 4px 0 8px 14px;
}

.toc ol ol li {
  counter-increment: subsection;
  margin: 3px 0;
}

.toc ol ol li > a::before {
  content: counter(section) "." counter(subsection) " ";
  color: #54595d;
}

.toc a {
  color: #3366cc;
  display: block;
  line-height: 1.4;
  padding: 1px 2px;
  border-radius: 2px;
}

.toc a:hover {
  text-decoration: underline;
}

.toc a.active {
  background: #eaf3ff;
  color: #0645ad;
  font-weight: 600;
}

/* ---------- Main article ---------- */
.article {
  min-width: 0;
  font-family: "Charter", "Georgia", "Times New Roman", Times, serif;
}

.article h1 {
  font-family: "Linux Libertine", "Georgia", serif;
  font-size: 2.1rem;
  font-weight: 400;
  margin: 0 0 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid #a2a9b1;
  color: #000;
}

.last-updated {
  font-size: 13px;
  color: #54595d;
  margin: 0 0 18px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

.article h2 {
  font-family: "Linux Libertine", "Georgia", serif;
  font-size: 1.55rem;
  font-weight: 400;
  margin: 32px 0 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid #a2a9b1;
  color: #000;
}

.article h3 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 22px 0 8px;
  color: #000;
}

.article h4 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 1rem;
  font-weight: 700;
  margin: 16px 0 6px;
}

.article p {
  margin: 0 0 14px;
}

.article ul,
.article ol {
  margin: 0 0 14px 24px;
  padding: 0;
}

.article li {
  margin-bottom: 4px;
}

.article strong {
  font-weight: 700;
}

/* ---------- Lead block (with infobox) ---------- */
.lead {
  margin-bottom: 16px;
}

.lead p:first-of-type {
  margin-top: 0;
}

/* ---------- Infobox ---------- */
.infobox {
  float: right;
  width: 22em;
  margin: 0 0 16px 24px;
  border: 1px solid #a2a9b1;
  background: #f8f9fa;
  border-collapse: collapse;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: #202122;
}

.infobox caption {
  background: #cedff2;
  font-weight: 700;
  padding: 6px 8px;
  border-bottom: 1px solid #a2a9b1;
  text-align: center;
  font-size: 14px;
}

.infobox th,
.infobox td {
  text-align: left;
  vertical-align: top;
  padding: 6px 8px;
  border-top: 1px solid #eaecf0;
}

.infobox th {
  width: 38%;
  font-weight: 700;
  background: transparent;
}

.infobox .full-width {
  text-align: center;
  background: #eaf3ff;
  border-top: 1px solid #a2a9b1;
  font-weight: 700;
}

/* ---------- Mobile TOC toggle (hidden on desktop) ---------- */
.toc-toggle {
  display: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  padding: 10px 14px;
  margin: 0 0 16px;
  background: #f8f9fa;
  border: 1px solid #a2a9b1;
  border-radius: 2px;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

/* ---------- Footer ---------- */
.site-footer {
  max-width: 1280px;
  margin: 32px auto 24px;
  padding: 18px 24px;
  border-top: 1px solid #c8ccd1;
  font-size: 12px;
  color: #54595d;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }

  .toc-toggle {
    display: block;
  }

  .toc {
    position: static;
    max-height: none;
    display: none;
  }

  .toc.open {
    display: block;
  }

  .infobox {
    float: none;
    width: 100%;
    margin: 0 0 16px 0;
  }

  .article h1 {
    font-size: 1.7rem;
  }

  .article h2 {
    font-size: 1.3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
