
/*
 * DaVinciRE Labs // Research
 * Shared stylesheet for the research homepage and articles.
 * Responsive, light/dark aware, no external dependencies.
 */

/* =========================================================
   1. COLOR SYSTEM
   ========================================================= */

:root {
  --bg: #fbfbf9;
  --fg: #1c1c1a;
  --muted: #6b6b66;
  --rule: #e4e4de;

  --accent: #7c2d12;
  --accent-fg: #fff;
  --link: #9a3412;

  --code-bg: #f3f2ed;
  --code-fg: #1c1c1a;
  --card: #f6f5f1;

  --t-measured: #166534;
  --t-static: #1e3a8a;
  --t-inferred: #6b21a8;
  --t-court: #9a3412;
  --t-context: #4b5563;
  --t-open: #854d0e;
}

/* Automatic dark mode */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16161a;
    --fg: #e7e7e2;
    --muted: #9a9a93;
    --rule: #2c2c31;

    --accent: #f97316;
    --accent-fg: #16161a;
    --link: #fdba74;

    --code-bg: #1e1e23;
    --code-fg: #e7e7e2;
    --card: #1c1c21;

    --t-measured: #4ade80;
    --t-static: #93c5fd;
    --t-inferred: #d8b4fe;
    --t-court: #fdba74;
    --t-context: #cbd5e1;
    --t-open: #fcd34d;
  }
}

/* Explicit dark-mode override */
:root[data-theme="dark"] {
  --bg: #16161a;
  --fg: #e7e7e2;
  --muted: #9a9a93;
  --rule: #2c2c31;

  --accent: #f97316;
  --accent-fg: #16161a;
  --link: #fdba74;

  --code-bg: #1e1e23;
  --code-fg: #e7e7e2;
  --card: #1c1c21;

  --t-measured: #4ade80;
  --t-static: #93c5fd;
  --t-inferred: #d8b4fe;
  --t-court: #fdba74;
  --t-context: #cbd5e1;
  --t-open: #fcd34d;
}

/* =========================================================
   2. BASE TYPOGRAPHY AND LAYOUT
   ========================================================= */

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);

  font: 17px/1.65
    "Iowan Old Style",
    "Palatino Linotype",
    Palatino,
    Georgia,
    serif;

  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px;
}

p,
li {
  overflow-wrap: break-word;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2rem 0;
}

/* =========================================================
   3. SITE HEADER AND BRANDING
   ========================================================= */

header.site {
  border-bottom: 1px solid var(--rule);
  margin: 0;
  padding: 1.4rem 0 1.1rem;
}

header.site .brand {
  font: 600 15px/1
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;

  letter-spacing: .02em;
  color: var(--muted);
  text-transform: lowercase;
}

header.site .brand b {
  color: var(--accent);
}

header.site .brand a {
  color: inherit;
  text-decoration: none;
}

header.site .brand a:hover {
  text-decoration: underline;
}

/* =========================================================
   4. ARTICLE TITLE AND METADATA
   ========================================================= */

h1.title {
  font-size: 2.05rem;
  line-height: 1.18;
  letter-spacing: -.01em;
  margin: .3em 0 .35em;
}

.standfirst {
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.5;
  margin: 0 0 1rem;
}

.byline {
  font: 500 13px/1.4
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;

  color: var(--muted);
  border-top: 1px solid var(--rule);
  padding-top: .8rem;
}

/* =========================================================
   5. HOMEPAGE
   ========================================================= */

.page-intro {
  margin: 2rem 0 2.5rem;
}

.page-intro h1 {
  font-size: 2.2rem;
  line-height: 1.2;
  letter-spacing: -.01em;
  margin: 0 0 .6rem;
}

.page-intro p {
  color: var(--muted);
  font-size: 1.08rem;
  margin: 0;
}

/* Research article listing */
.research-list {
  border-top: 1px solid var(--rule);
}

.research-item {
  padding: 2rem 0;
  border-bottom: 1px solid var(--rule);
}

.research-item h2 {
  font-size: 1.55rem;
  line-height: 1.3;
  letter-spacing: -.01em;

  margin: 0 0 .75rem;
  padding: 0;
  border: 0;
}

.research-item h2 a {
  color: var(--link);
  text-decoration: none;
}

.research-item h2 a:hover {
  text-decoration: underline;
}

.research-item .byline {
  border: 0;
  padding: 0;
  margin-bottom: 1rem;
}

.research-item p {
  margin: 0;
}

/* =========================================================
   6. ARTICLE CONTENT
   ========================================================= */

.article-content {
  margin-top: 0;
}

.article-content > :first-child {
  margin-top: 0;
}

article h2 {
  font-size: 1.5rem;
  letter-spacing: -.01em;

  margin: 2rem 0 .7rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.6rem;
}

article h3 {
  font-size: 1.18rem;
  margin: 1.8rem 0 .5rem;
}

article h4 {
  font-size: 1rem;
  margin: 1.4rem 0 .4rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

blockquote {
  margin: 1.2rem 0;
  padding: .1rem 1rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

/* =========================================================
   7. INLINE CODE AND CODE BLOCKS
   ========================================================= */

code {
  font: .86em/1.5
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;

  background: var(--code-bg);
  color: var(--code-fg);

  padding: .12em .36em;
  border-radius: 4px;
}

pre {
  background: var(--code-bg);
  color: var(--code-fg);

  padding: 1rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 8px;

  overflow-x: auto;
  max-width: 100%;

  font-size: .82rem;
  line-height: 1.55;
  tab-size: 4;
}

pre code {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  line-height: inherit;
}

/* =========================================================
   8. TECHNICAL TABLES
   ========================================================= */

table {
  border-collapse: collapse;
  width: 100%;
  max-width: 100%;
  margin: 1.3rem 0;

  font-size: .93rem;
  display: block;
  overflow-x: auto;
}

th,
td {
  border: 1px solid var(--rule);
  padding: .5rem .7rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--card);
  font-weight: 600;
}

/* =========================================================
   9. EVIDENCE CLASSIFICATION BADGES
   ========================================================= */

.tag {
  display: inline-block;

  font: 700 10.5px/1
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;

  letter-spacing: .06em;
  padding: .28em .5em;

  border-radius: 4px;
  border: 1px solid currentColor;

  vertical-align: baseline;
  white-space: nowrap;
}

.tag-measured {
  color: var(--t-measured);
}

.tag-static {
  color: var(--t-static);
}

.tag-inferred {
  color: var(--t-inferred);
}

.tag-court {
  color: var(--t-court);
}

.tag-context {
  color: var(--t-context);
}

.tag-open {
  color: var(--t-open);
}

/* =========================================================
   10. SECTION-LEVEL EVIDENCE FOOTERS
   ========================================================= */

.evline {
  text-align: right;
  margin: 1rem 0 0;
  border-top: 1px dotted var(--rule);
  padding-top: .5rem;
}

.evlabel {
  font: 600 10.5px/1
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;

  letter-spacing: .06em;
  color: var(--muted);
  text-transform: uppercase;
  margin-right: .4rem;
}

/* =========================================================
   11. SITE FOOTER
   ========================================================= */

footer.site {
  border-top: 1px solid var(--rule);
  margin-top: 4rem;
  padding: 1.4rem 0 3rem;

  color: var(--muted);
  font-size: .85rem;
  text-align: center;
}

/* =========================================================
   12. RESPONSIVE DESIGN
   ========================================================= */

@media (max-width: 768px) {
  .wrap {
    padding: 24px 20px;
  }

  .page-intro h1 {
    font-size: 1.9rem;
  }

  .research-item {
    padding: 1.5rem 0;
  }

  .research-item h2 {
    font-size: 1.4rem;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 16px;
  }

  .wrap {
    padding: 20px 16px;
  }

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

  .page-intro h1 {
    font-size: 1.75rem;
  }

  .standfirst {
    font-size: 1.05rem;
  }

  .research-item h2 {
    font-size: 1.3rem;
  }

  pre {
    padding: .8rem;
    font-size: .78rem;
  }

  th,
  td {
    padding: .4rem .5rem;
  }
}

/* Shared article introduction, aligned with the homepage heading. */
.article-intro .standfirst {
  font-size: 1.12rem;
  line-height: 1.5;
  margin: 0 0 1rem;
}
.article-intro .byline {
  margin-top: 1rem;
}
/* The first section does not need a second divider immediately after metadata. */
.article-content > h2:first-child {
  border-top: 0;
  padding-top: 0;
}
/* Homepage and list footer: avoid a redundant second horizontal rule. */
main:has(.research-list) + footer.site {
  border-top: 0;
  margin-top: 2rem;
}
