/* =========================================================================
   BPC-157 Clinic — bpc157clinic.com
   Archetype: brutalist-academic / manuscript-preprint
   Palette: ink #0B1410 / cream #F6F3EC / ochre #A8541F / forest #1F4F3A
   Type:    JetBrains Mono (headings) / Atkinson Hyperlegible (body) / EB Garamond (display)
   ========================================================================= */

:root {
  /* Palette */
  --primary: #0B1410;
  --primary-50: #EDEFEC;
  --primary-900: #050907;
  --secondary: #1F4F3A;
  --accent: #A8541F;
  --neutral-50: #F6F3EC;
  --neutral-200: #E3DED1;
  --neutral-500: #7C766B;
  --neutral-900: #1A1815;
  --bg: #F6F3EC;
  --surface: #FBF9F3;
  --text: #0B1410;
  --text-muted: #5E5A52;
  --success: #1F4F3A;
  --warning: #A8541F;
  --danger: #7A1F1F;

  /* Type families */
  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', 'Courier New', monospace;
  --font-display: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --font-body: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Scale */
  --fs-h1: clamp(2rem, 4.5vw, 3.25rem);
  --fs-h2: clamp(1.5rem, 3vw, 2.125rem);
  --fs-h3: 1.25rem;
  --fs-body: 1.0625rem;
  --fs-small: 0.8125rem;

  /* Layout */
  --max-width: 68rem;
  --container-px: clamp(1rem, 3vw, 2.25rem);

  /* Rules */
  --rule: 1px solid var(--primary);
  --rule-heavy: 4px solid var(--primary);
  --rule-double: 3px double var(--primary);
}

/* -------------------------------------------------------------------------
   Reset
   ------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
ul, ol { padding-left: 1.25rem; }
li { margin: 0.25rem 0; }
button { font: inherit; cursor: pointer; }

::selection { background: var(--accent); color: var(--neutral-50); }

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

/* -------------------------------------------------------------------------
   Typography
   ------------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-mono);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--primary);
}
h1 { font-size: var(--fs-h1); font-weight: 800; }
h2 { font-size: var(--fs-h2); font-weight: 700; margin-top: 2.5rem; }
h3 { font-size: var(--fs-h3); font-weight: 700; margin-top: 1.75rem; }

p { margin: 0.85em 0; }
strong, b { font-weight: 700; }
em, i { font-family: var(--font-display); font-style: italic; font-size: 1.06em; }

sup { font-family: var(--font-mono); font-size: 0.75em; vertical-align: super; line-height: 0; }
sup a { text-decoration: none; padding: 0 1px; }
sup a:hover { background: var(--accent); color: var(--neutral-50); }

code, pre, .mono {
  font-family: var(--font-mono);
  font-size: 0.93em;
}
code {
  background: var(--neutral-200);
  padding: 0.1em 0.35em;
  border-left: 1px solid var(--primary);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.subheadline {
  font-family: var(--font-display);
  font-size: clamp(1.125rem, 1.8vw, 1.375rem);
  font-style: italic;
  line-height: 1.45;
  color: var(--text);
  margin-top: 1rem;
  max-width: 48ch;
}

.disclaimer-italic, .caveat {
  font-family: var(--font-display);
  font-style: italic;
}

/* -------------------------------------------------------------------------
   Layout: container, sections
   ------------------------------------------------------------------------- */

.container {
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--container-px);
  padding-right: var(--container-px);
}

main {
  padding-bottom: 4rem;
}

main section {
  padding-top: 2rem;
  padding-bottom: 1rem;
}

main section + section {
  border-top: var(--rule);
  margin-top: 1.5rem;
  padding-top: 2.5rem;
}

main section h2 {
  border-top: var(--rule-heavy);
  padding-top: 1.25rem;
  margin-top: 0;
}

article > header.hero + section h2,
article > .hero-figure + section h2 {
  margin-top: 0;
}

/* -------------------------------------------------------------------------
   Header / masthead
   ------------------------------------------------------------------------- */

.site-header {
  border-top: var(--rule-double);
  border-bottom: var(--rule);
  background: var(--bg);
}

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.site-brand {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.9375rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
  text-decoration: none;
}
.site-brand:hover { color: var(--accent); }

.masthead-meta {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.site-nav { width: 100%; border-top: var(--rule); padding-top: 0.6rem; padding-bottom: 0.6rem; }
.site-nav ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}
.site-nav li {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.site-nav li + li::before {
  content: "";
  display: inline-block;
  width: 1px;
  height: 0.85em;
  background: var(--primary);
  margin: 0 0.85rem;
  vertical-align: middle;
}
.site-nav a {
  text-decoration: none;
  color: var(--primary);
  padding: 0.2rem 0;
  border-bottom: 1px solid transparent;
  transition: border-color 150ms ease-out;
}
.site-nav a:hover, .site-nav a[aria-current="page"] {
  border-bottom-color: var(--primary);
}
.site-nav a[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Mobile nav: stack */
@media (max-width: 720px) {
  .site-nav ul { flex-direction: column; gap: 0.5rem; }
  .site-nav li + li::before { display: none; }
}

/* -------------------------------------------------------------------------
   Hero / manuscript title block
   ------------------------------------------------------------------------- */

.hero {
  padding-top: 3.25rem;
  padding-bottom: 1.75rem;
}

.hero h1 {
  max-width: 22ch;
}

.hero .subheadline {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: var(--rule);
  max-width: 56ch;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
  margin-top: 1.75rem;
}

/* -------------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------------- */

.btn {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--primary);
  border-radius: 0;
  transition: border-color 200ms ease-out;
}
.btn-primary {
  background: var(--primary);
  color: var(--neutral-50);
}
.btn-primary:hover {
  background: var(--accent);
  color: var(--neutral-50);
  border-color: var(--accent);
}
.btn-secondary {
  background: transparent;
  color: var(--primary);
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* -------------------------------------------------------------------------
   Figure / plate
   ------------------------------------------------------------------------- */

.hero-figure, figure.plate {
  margin: 2rem 0 1.5rem;
  border: var(--rule);
  background: var(--surface);
}
.hero-figure img, figure.plate img {
  width: 100%;
  height: auto;
  border-bottom: var(--rule);
  background: var(--neutral-200);
}
figcaption {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
}
figcaption .fig-num {
  font-family: var(--font-mono);
  font-style: normal;
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-right: 0.5rem;
}

/* -------------------------------------------------------------------------
   Callout
   ------------------------------------------------------------------------- */

.callout {
  margin: 1.5rem 0;
  padding: 1.25rem 1.25rem 1rem;
  border-top: var(--rule-heavy);
  border-left: var(--rule);
  border-right: var(--rule);
  border-bottom: var(--rule);
  background: var(--surface);
}
.callout .label {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

/* -------------------------------------------------------------------------
   References list
   ------------------------------------------------------------------------- */

.references-list {
  list-style: none;
  padding: 0;
  margin-top: 1.5rem;
  counter-reset: refnum;
}
.references-list li {
  position: relative;
  padding: 1rem 0 1rem 3.5rem;
  border-top: var(--rule);
  font-size: 0.98rem;
}
.references-list li:last-child { border-bottom: var(--rule); }
.references-list li::before {
  counter-increment: refnum;
  content: "[" counter(refnum) "]";
  position: absolute;
  left: 0;
  top: 1rem;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--accent);
}
.references-list li .doi {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  display: block;
  margin-top: 0.25rem;
  word-break: break-all;
}
.references-list li:target {
  background: var(--neutral-200);
}

/* -------------------------------------------------------------------------
   Article body content
   ------------------------------------------------------------------------- */

article {
  margin-top: 1rem;
}

article p, article li {
  max-width: 68ch;
}

article ul, article ol {
  margin: 0.75rem 0;
  padding-left: 1.4rem;
}

article h2 + p:first-letter,
.drop-cap {
  /* applied only on first paragraph of first section */
}

article > section:first-of-type p:first-of-type:first-letter {
  font-family: var(--font-display);
  float: left;
  font-size: 3.25em;
  line-height: 0.85;
  padding: 0.05em 0.1em 0 0;
  font-weight: 700;
  color: var(--primary);
}

/* -------------------------------------------------------------------------
   Footer
   ------------------------------------------------------------------------- */

.site-footer {
  border-top: var(--rule-double);
  background: var(--primary);
  color: var(--neutral-50);
  padding-top: 2.5rem;
  padding-bottom: 2rem;
  margin-top: 4rem;
}
.site-footer a { color: var(--neutral-50); }
.site-footer a:hover { color: var(--accent); }

.footer-cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}
@media (min-width: 720px) {
  .footer-cols { grid-template-columns: repeat(3, 1fr); }
}

.footer-col h4 {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--neutral-50);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--neutral-500);
}
.footer-col ul { list-style: none; padding: 0; }
.footer-col li { font-size: 0.9375rem; line-height: 1.5; margin: 0.4rem 0; }

.site-footer .disclaimer {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.5;
  padding-top: 1.5rem;
  border-top: 1px solid var(--neutral-500);
  max-width: 60ch;
}

.site-footer .copyright {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  letter-spacing: 0.06em;
  color: var(--neutral-200);
  margin-top: 1rem;
}

/* -------------------------------------------------------------------------
   404
   ------------------------------------------------------------------------- */

.error-page {
  padding: 4rem 0;
  text-align: left;
}
.error-page .code {
  font-family: var(--font-mono);
  font-size: clamp(4rem, 12vw, 8rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--accent);
}

/* -------------------------------------------------------------------------
   Motion: respect reduced motion
   ------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

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

/* -------------------------------------------------------------------------
   Small utilities
   ------------------------------------------------------------------------- */

.text-muted { color: var(--text-muted); }
.small { font-size: var(--fs-small); }
.mono { font-family: var(--font-mono); }
.no-wrap { white-space: nowrap; }

.divider {
  height: 1px;
  background: var(--primary);
  border: 0;
  margin: 2.5rem 0;
}
.divider-heavy {
  height: 4px;
  background: var(--primary);
  border: 0;
  margin: 2.5rem 0;
}
