/*
 * SEAD Lab — Academic Article CSS
 * Derived from Distill template.v2.js (distill.pub)
 * Adapted to use plain CSS classes instead of Web Components
 *
 * Usage:
 *   <article class="sead-article"> ... </article>
 *   See sead-nca.github.io for structure reference
 */

/* ==========================================================================
   1. BASE — Reset & Typography
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;0,8..60,700;1,8..60,400&display=swap');

html {
  font-size: 14px;
  line-height: 1.6em;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

@media (min-width: 768px) {
  html { font-size: 16px; }
}

body {
  margin: 0;
  background: #fff;
}

a { color: #004276; }
figure { margin: 0; }
table { border-collapse: collapse; border-spacing: 0; }
table th { text-align: left; }
table thead { border-bottom: 1px solid rgba(0,0,0,0.05); }
table thead th { padding-bottom: 0.5em; }
table tbody :first-child td { padding-top: 0.5em; }
pre { overflow: auto; max-width: 100%; }
p { margin-top: 0; margin-bottom: 1em; }

sup, sub { vertical-align: baseline; position: relative; top: -0.4em; line-height: 1em; }
sub { top: 0.4em; }

figure { position: relative; margin-bottom: 2.5em; margin-top: 1.5em; }
figure img { width: 100%; }

figcaption, .figcaption {
  color: rgba(0,0,0,0.6);
  font-size: 12px;
  line-height: 1.5em;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
@media (min-width: 1024px) {
  figcaption, .figcaption { font-size: 13px; }
}
figcaption b, figcaption strong { font-weight: 600; color: rgba(0,0,0,1); }


/* ==========================================================================
   2. GRID — 16-Column Responsive Layout (Distill Grid System)
   ========================================================================== */

.sead-grid,
.sead-header,
.sead-title,
.sead-abstract,
.sead-article,
.sead-appendix,
.sead-byline,
.sead-footer {
  display: grid;
  justify-items: stretch;
  grid-template-columns:
    [screen-start] 8px
    [page-start kicker-start text-start gutter-start middle-start]
    1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr
    [text-end page-end gutter-end kicker-end middle-end]
    8px [screen-end];
  grid-column-gap: 8px;
}

@media (min-width: 768px) {
  .sead-grid, .sead-header, .sead-title, .sead-abstract,
  .sead-article, .sead-appendix, .sead-byline, .sead-footer {
    grid-template-columns:
      [screen-start] 1fr
      [page-start kicker-start middle-start text-start]
      45px 45px 45px 45px 45px 45px 45px 45px
      [kicker-end text-end gutter-start] 45px
      [middle-end] 45px
      [page-end gutter-end] 1fr [screen-end];
    grid-column-gap: 16px;
  }
}

@media (min-width: 1000px) {
  .sead-grid, .sead-header, .sead-title, .sead-abstract,
  .sead-article, .sead-appendix, .sead-byline, .sead-footer {
    grid-template-columns:
      [screen-start] 1fr
      [page-start kicker-start] 50px
      [middle-start] 50px
      [text-start kicker-end] 50px 50px 50px 50px 50px 50px 50px 50px
      [text-end gutter-start] 50px
      [middle-end] 50px
      [page-end gutter-end] 1fr [screen-end];
    grid-column-gap: 16px;
  }
}

@media (min-width: 1180px) {
  .sead-grid, .sead-header, .sead-title, .sead-abstract,
  .sead-article, .sead-appendix, .sead-byline, .sead-footer {
    grid-template-columns:
      [screen-start] 1fr
      [page-start kicker-start] 60px
      [middle-start] 60px
      [text-start kicker-end] 60px 60px 60px 60px 60px 60px 60px 60px
      [text-end gutter-start] 60px
      [middle-end] 60px
      [page-end gutter-end] 1fr [screen-end];
    grid-column-gap: 32px;
  }
}

/* Layout classes */
.l-text, .l-body { grid-column: text; }
.l-page { grid-column: page; }
.l-middle, .l-body-outset { grid-column: middle; }
.l-screen { grid-column: screen; }
.l-screen-inset { grid-column: screen; padding-left: 16px; padding-right: 16px; }
.l-gutter { grid-column: gutter; }


/* ==========================================================================
   3. HEADER — Site-wide navigation bar
   ========================================================================== */

.sead-header {
  min-height: 64px;
  align-items: center;
  background: #14444a;
}

.sead-header-content {
  grid-column: page;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
}

.sead-header-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: 'Inter', sans-serif;
  font-weight: 300;
  font-size: 1.05rem;
  color: #fff;
  text-decoration: none;
  border-bottom: none;
  letter-spacing: 0.02em;
}
.sead-header-logo:hover { color: rgba(255,255,255,0.85); }

.sead-logo-img {
  height: 40px;
  width: auto;
  position: relative;
  top: -2px;
}

.sead-header-nav {
  display: flex;
  gap: 1.5rem;
  margin-left: auto;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sead-header-nav a {
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  border-bottom: none;
}
.sead-header-nav a:hover { color: rgba(255,255,255,0.9); }


/* ==========================================================================
   4. TITLE — Article title block
   ========================================================================== */

.sead-title {
  padding: 2rem 0 1.5rem;
  overflow-x: hidden;
}

@media (min-width: 768px) {
  .sead-title { padding: 4rem 0 1.5rem; }
}

.sead-title h1 {
  grid-column: text;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 40px;
  font-weight: 700;
  line-height: 1.1em;
  margin: 0 0 0.5rem;
}

@media (min-width: 768px) {
  .sead-title h1 { font-size: 50px; }
}

.sead-title p {
  font-family: 'Inter', sans-serif;
  font-weight: 300;
  font-size: 1.2rem;
  line-height: 1.55em;
  grid-column: text;
}


/* ==========================================================================
   5. BYLINE — Author / date / affiliation
   ========================================================================== */

.sead-byline {
  overflow: hidden;
  border-top: 1px solid rgba(0,0,0,0.1);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.8rem;
  line-height: 1.8em;
  padding: 1.5rem 0;
  min-height: 1.8em;
}

.sead-byline-content {
  grid-column: text;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

@media (min-width: 768px) {
  .sead-byline-content {
    grid-template-columns: 1fr 1fr 1fr 1fr;
  }
}

.sead-byline h3 {
  font-size: 0.6rem;
  font-weight: 400;
  color: rgba(0,0,0,0.5);
  margin: 0;
  text-transform: uppercase;
}

.sead-byline p {
  margin: 0;
}

.sead-byline a {
  color: rgba(0,0,0,0.8);
  text-decoration: none;
  border-bottom: none;
}


/* ==========================================================================
   6. ARTICLE — Main body content
   ========================================================================== */

.sead-article {
  overflow-x: hidden;
  border-top: 1px solid rgba(0,0,0,0.1);
  padding-top: 2rem;
  color: rgba(0,0,0,0.8);
}

.sead-article > * {
  grid-column: text;
}

@media (min-width: 768px) {
  .sead-article { font-size: 16px; }
}

@media (min-width: 1024px) {
  .sead-article { font-size: 0.95rem; line-height: 1.7em; }
}

/* Headings */

.sead-article h2 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  font-size: 24px;
  line-height: 1.25em;
  margin: 2rem 0 1.5rem 0;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  padding-bottom: 1rem;
}

@media (min-width: 1024px) {
  .sead-article h2 { font-size: 36px; }
}

.sead-article h3 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  font-size: 18px;
  line-height: 1.4em;
  margin-bottom: 1em;
  margin-top: 2em;
}

@media (min-width: 1024px) {
  .sead-article h3 { font-size: 20px; }
}

.sead-article h4 {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 14px;
  line-height: 1.4em;
}

/* Body text */

.sead-article a { color: inherit; }

.sead-article p,
.sead-article ul,
.sead-article ol,
.sead-article blockquote {
  margin-top: 0;
  margin-bottom: 1em;
  margin-left: 0;
  margin-right: 0;
}

.sead-article blockquote {
  border-left: 2px solid rgba(0,0,0,0.2);
  padding-left: 2em;
  font-style: italic;
  color: rgba(0,0,0,0.6);
}

.sead-article a {
  border-bottom: 1px solid rgba(0,0,0,0.4);
  text-decoration: none;
}
.sead-article a:hover {
  border-bottom: 1px solid rgba(0,0,0,0.8);
}

.sead-article ul,
.sead-article ol { padding-left: 24px; }

.sead-article li {
  margin-bottom: 1em;
  margin-left: 0;
  padding-left: 0;
}
.sead-article li:last-child { margin-bottom: 0; }

.sead-article pre { font-size: 14px; margin-bottom: 20px; }

.sead-article hr {
  grid-column: screen;
  width: 100%;
  border: none;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  margin-top: 60px;
  margin-bottom: 60px;
}

/* Code */
.sead-article code {
  font-family: Menlo, Monaco, "Ubuntu Mono", Consolas, monospace;
  font-size: 0.85em;
  background: rgba(0,0,0,0.04);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

.sead-article pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

/* Tables */

.sead-article table {
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(0,0,0,0.2);
}

.sead-article table th {
  border-bottom: 1px solid rgba(0,0,0,0.2);
}

.sead-article table td {
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.sead-article table tr:last-of-type td {
  border-bottom: none;
}

.sead-article table th,
.sead-article table td {
  font-size: 15px;
  padding: 2px 8px;
}

/* Aside (margin notes) */

.sead-article aside {
  font-size: 12px;
  line-height: 1.6em;
  color: rgba(0,0,0,0.6);
}

@media (min-width: 768px) {
  .sead-article aside { grid-column: gutter; }
}


/* ==========================================================================
   7. CONTENTS — Table of contents (sidebar)
   ========================================================================== */

.sead-contents {
  grid-column: kicker;
  position: sticky;
  top: 2rem;
  align-self: start;
  padding-bottom: 2rem;
}

@media (max-width: 999px) {
  .sead-contents { display: none; }
}

.sead-contents h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 0 0.8rem;
  color: rgba(0,0,0,0.65);
}

.sead-contents ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sead-contents li {
  margin-bottom: 0.4em;
}

.sead-contents a {
  font-size: 0.75rem;
  color: rgba(0,0,0,0.45);
  text-decoration: none;
  border-bottom: none;
  line-height: 1.5;
}

.sead-contents a:hover {
  color: rgba(0,0,0,0.8);
}


/* ==========================================================================
   8. ABSTRACT
   ========================================================================== */

.sead-abstract {
  font-size: 1.25rem;
  line-height: 1.6em;
  color: rgba(0,0,0,0.7);
  -webkit-font-smoothing: antialiased;
}

.sead-abstract > * {
  grid-column: text / middle-end;
}


/* ==========================================================================
   9. APPENDIX
   ========================================================================== */

.sead-appendix {
  font-size: 0.8em;
  border-top: 1px solid rgba(0,0,0,0.1);
  background: rgb(250,250,250);
  padding-top: 2rem;
  padding-bottom: 2rem;
  color: rgba(0,0,0,0.5);
}

.sead-appendix > * {
  grid-column: text;
}

.sead-appendix h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
  color: rgba(0,0,0,0.65);
}

.sead-appendix a {
  color: rgba(0,0,0,0.6);
}


/* ==========================================================================
   10. FOOTER
   ========================================================================== */

.sead-footer {
  border-top: 1px solid rgba(0,0,0,0.08);
  padding: 2rem 0;
  color: rgba(0,0,0,0.3);
  font-size: 0.75rem;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.sead-footer > * {
  grid-column: text;
}


/* ==========================================================================
   11. KATEX — Math display
   ========================================================================== */

span.katex-display {
  text-align: left;
  padding: 8px 0;
  margin: 0.5em 0 0.5em 1em;
}

span.katex {
  -webkit-font-smoothing: antialiased;
  color: rgba(0,0,0,0.8);
  font-size: 1.18em;
}


/* ==========================================================================
   12. PRINT
   ========================================================================== */

@media print {
  @page { size: 8in 11in; }
  p, code { page-break-inside: avoid; }
  h2, h3 { page-break-after: avoid; }
  .sead-header, .sead-footer { display: none; }
}
