/* ═══════════════════════════════════════════════════════════
   Physiological Rights — stylesheet
   Editorial warm-serif design
   ═══════════════════════════════════════════════════════════ */

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

:root {
  --bg:         #F5F2EC;
  --bg-warm:    #EDE9E1;
  --ink:        #1C1A16;
  --ink-mid:    #4A4640;
  --ink-light:  #7A756D;
  --accent:     #2D6A4F;
  --accent-2:   #40916C;
  --rule:       #C8C2B6;
  --draft:      #8B4513;
  --serif:      'Cormorant Garamond', Georgia, serif;
  --body:       'Crimson Pro', Georgia, serif;
  --ui:         'Outfit', system-ui, sans-serif;
  --col-width:  680px;
}

html { font-size: 18px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── DRAFT BANNER ── */
.draft-banner {
  background: var(--bg-warm);
  border-bottom: 1px solid var(--rule);
  text-align: center;
  padding: 0.6rem 1rem;
  font-family: var(--ui);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--draft);
}

.draft-banner a {
  color: var(--draft);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── HEADER / NAV ── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245,242,236,0.94);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(8px);
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 3rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 58px;
}

.nav-brand {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  padding-right: 2rem;
  border-right: 1px solid var(--rule);
  flex-shrink: 0;
}

.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.mobile-menu-toggle span {
  width: 22px;
  height: 2px;
  background-color: var(--ink);
  margin: 3px 0;
  border-radius: 1px;
  transition: 0.3s;
  display: block;
}

.main-navigation {
  flex: 1;
  display: flex;
  align-items: center;
}

.main-nav {
  list-style: none;
  display: flex;
  gap: 0;
  align-items: center;
}

.main-nav > li {
  position: relative;
}

.main-nav > li > a {
  font-family: var(--ui);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mid);
  text-decoration: none;
  padding: 0 1.1rem;
  height: 58px;
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-bottom-color 0.2s;
  cursor: pointer;
}

.main-nav > li > a:hover {
  color: var(--ink);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

/* Dropdowns */
.has-dropdown { position: relative; }

.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--accent);
  min-width: 200px;
  list-style: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all 0.2s ease;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(28,26,22,0.08);
}

.has-dropdown:hover .dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown li a {
  display: block;
  padding: 0.75rem 1.25rem;
  font-family: var(--ui);
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--ink-mid);
  text-decoration: none;
  border-bottom: 1px solid var(--bg-warm);
  transition: color 0.15s, background 0.15s;
}

.dropdown li:last-child a { border-bottom: none; }

.dropdown li a:hover {
  color: var(--accent);
  background: var(--bg-warm);
  text-decoration: none;
}

.nav-github {
  font-family: var(--ui);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-light);
  text-decoration: none;
  border: 1px solid var(--rule);
  padding: 0.35rem 0.85rem;
  border-radius: 3px;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-github:hover {
  color: var(--ink);
  border-color: var(--ink-mid);
  text-decoration: none;
}

/* ── PAGE WRAP GRID ── */
.page-wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 3rem;
  display: grid;
  grid-template-columns: 1fr 260px;
  grid-template-areas:
    "breadcrumb ."
    "content aside";
  gap: 0 4rem;
}

.page-wrap--full {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 3rem 6rem;
  display: block;
}

/* ── BREADCRUMB ── */
.breadcrumb {
  grid-area: breadcrumb;
  font-family: var(--ui);
  font-size: 0.73rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ink-light);
  padding: 2rem 0 0;
  background: none;
  border: none;
}

.breadcrumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
}

.breadcrumb li {
  display: flex;
  align-items: center;
}

.breadcrumb li:not(:last-child)::after {
  content: '›';
  margin: 0 0.5rem;
  opacity: 0.5;
}

.breadcrumb a {
  color: var(--ink-light);
  text-decoration: none;
}

.breadcrumb a:hover { color: var(--accent); }

.breadcrumb li[aria-current="page"] { color: var(--ink-mid); }

/* ── MAIN CONTENT ── */
.content {
  grid-area: content;
  padding-bottom: 6rem;
}

/* ── ASIDE ── */
.aside {
  grid-area: aside;
  padding-top: 3rem;
  position: sticky;
  top: 80px;
  height: fit-content;
  align-self: start;
}

.aside-section {
  border-top: 2px solid var(--ink);
  padding-top: 1rem;
  margin-bottom: 2rem;
}

.aside-section h3 {
  font-family: var(--ui);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-light);
  margin-bottom: 1rem;
}

.aside-section p {
  font-family: var(--ui);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--ink-mid);
  margin-bottom: 0;
}

.aside-edit {
  font-family: var(--ui);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ink-light);
  text-decoration: none;
  display: inline-block;
  border: 1px solid var(--rule);
  padding: 0.35rem 0.85rem;
  border-radius: 3px;
  transition: all 0.2s;
}

.aside-edit:hover {
  color: var(--ink);
  border-color: var(--ink-mid);
  text-decoration: none;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.toc-list a {
  font-family: var(--ui);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-mid);
  text-decoration: none;
  padding: 0.25rem 0.75rem;
  display: block;
  border-left: 2px solid transparent;
  transition: all 0.15s;
}

.toc-list a:hover {
  color: var(--accent);
  border-left-color: var(--accent);
  text-decoration: none;
}

/* ── TYPOGRAPHY ── */

.content h1 {
  font-family: var(--serif);
  font-weight: 300;
  font-size: 3.2rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 3rem 0 1.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--rule);
  max-width: var(--col-width);
}

.content h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2.1rem;
  line-height: 1.2;
  color: var(--ink);
  margin: 3.5rem 0 1.25rem;
  padding-top: 3rem;
  border-top: 1px solid var(--rule);
  max-width: var(--col-width);
}

.content h3 {
  font-family: var(--ui);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 2.5rem 0 0.75rem;
}

.content h4 {
  font-family: var(--ui);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-mid);
  margin: 1.5rem 0 0.5rem;
}

.content p {
  font-size: 1.05rem;
  color: var(--ink);
  margin-bottom: 1.4rem;
  max-width: var(--col-width);
}

.content strong { font-weight: 600; color: var(--ink); }
.content em { font-style: italic; }

.content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s;
}

.content a:hover { color: var(--accent-2); }

/* ── BLOCKQUOTE (epigraph style) ── */
.content blockquote {
  border-left: 3px solid var(--accent);
  padding: 1.5rem 1.75rem;
  margin: 0 0 2.5rem;
  background: var(--bg-warm);
  max-width: var(--col-width);
}

.content blockquote p {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--ink);
  margin-bottom: 0.75rem;
  max-width: 100%;
}

/* Citation line (last paragraph in blockquote) */
.content blockquote p:last-child {
  font-family: var(--ui);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--ink-light);
  font-style: normal;
  margin-bottom: 0;
}

/* ── LISTS ── */
.content ul,
.content ol {
  margin: 0 0 1.4rem 1.5rem;
  max-width: var(--col-width);
}

.content li {
  font-size: 1.05rem;
  color: var(--ink);
  margin-bottom: 0.4rem;
  line-height: 1.65;
}

/* ── HORIZONTAL RULE ── */
.content hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 3rem 0;
  max-width: var(--col-width);
}

/* ── TABLES ── */
.content table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  font-family: var(--ui);
  font-size: 0.88rem;
  margin: 2rem 0;
}

.content table th {
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--ink-light);
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--ink);
  text-align: left;
}

.content table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  line-height: 1.5;
  vertical-align: top;
}

.content table tr:last-child td { border-bottom: none; }
.content table td strong { color: var(--ink); }

/* ── FOOTNOTES ── */
.content sup {
  font-family: var(--ui);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--accent);
  vertical-align: super;
  margin-left: 1px;
}

.content sup a { color: var(--accent); text-decoration: none; }
.content sup a:hover { text-decoration: underline; }

.content .footnotes {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}

.content .footnotes ol {
  font-family: var(--ui);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--ink-mid);
  max-width: var(--col-width);
  margin-left: 1.25rem;
}

.content .footnotes li {
  font-size: 0.82rem;
  color: var(--ink-mid);
  margin-bottom: 0.5rem;
}

.content .footnotes a {
  color: var(--accent-2);
  word-break: break-all;
  overflow-wrap: break-word;
}

/* ── CODE ── */
.content code {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.85em;
  background: var(--bg-warm);
  border: 1px solid var(--rule);
  padding: 0.1em 0.35em;
  border-radius: 2px;
  color: var(--ink);
}

.content pre {
  background: var(--bg-warm);
  border: 1px solid var(--rule);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 0 0 1.4rem;
  max-width: var(--col-width);
  border-radius: 2px;
}

.content pre code { border: none; background: none; padding: 0; font-size: 0.85rem; }

/* ── COMMENTS SECTION ── */
.comments-section {
  margin-top: 5rem;
  padding-top: 3rem;
  border-top: 1px solid var(--rule);
  max-width: var(--col-width);
}

.comments-section h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.8rem;
  color: var(--ink);
  margin: 0 0 0.75rem;
  padding-top: 0;
  border-top: none;
}

.comment-intro {
  font-family: var(--ui);
  font-size: 0.85rem;
  color: var(--ink-light);
  margin-bottom: 2rem;
  max-width: var(--col-width);
}

/* ── INDEX CARDS (used on listing pages) ── */
.card {
  background: var(--bg-warm);
  border-top: 2px solid var(--accent);
  padding: 1.25rem 1.5rem;
  margin: 0 0 1px;
  max-width: var(--col-width);
  transition: background 0.2s;
}

.card:hover { background: #E5E1D8; }

.card h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.4rem;
  color: var(--ink);
  margin: 0 0 0.4rem;
  text-transform: none;
  letter-spacing: 0;
}

.card h3 a {
  color: var(--ink);
  text-decoration: none;
}

.card h3 a:hover { color: var(--accent); }

.card p {
  font-family: var(--ui);
  font-size: 0.88rem;
  color: var(--ink-mid);
  line-height: 1.5;
  margin-bottom: 0;
  max-width: 100%;
}

/* ── FOOTER ── */
footer {
  background: var(--ink);
  color: var(--bg);
  padding: 2.5rem 3rem;
  margin-top: 0;
}

.footer-content {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-content p {
  font-family: var(--ui);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  color: rgba(245,242,236,0.65);
  margin-bottom: 0;
}

.footer-links { font-family: var(--ui); font-size: 0.8rem; }

.footer-links a {
  color: rgba(245,242,236,0.65);
  text-decoration: none;
  margin: 0 0.75rem;
  transition: color 0.2s;
}

.footer-links a:hover { color: var(--bg); text-decoration: none; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }

/* ══════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════ */

@media (max-width: 960px) {
  .page-wrap {
    grid-template-columns: 1fr;
    grid-template-areas:
      "breadcrumb"
      "content";
    padding: 0 2rem;
  }

  .page-wrap--full { padding: 0 2rem 6rem; }

  .aside { display: none; }

  .header-inner { padding: 0 2rem; }
}

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

  .mobile-menu-toggle { display: flex; }

  .main-navigation {
    position: absolute;
    top: 58px;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    flex-direction: column;
    align-items: flex-start;
    z-index: 99;
  }

  .main-navigation.active { max-height: 600px; }

  .main-nav {
    flex-direction: column;
    width: 100%;
    padding: 0.5rem 0;
  }

  .main-nav > li {
    width: 100%;
    border-bottom: 1px solid var(--bg-warm);
  }

  .main-nav > li > a {
    height: auto;
    padding: 0.85rem 1.5rem;
    border-bottom: none;
    width: 100%;
    justify-content: space-between;
  }

  .dropdown {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    background: var(--bg-warm);
    border: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }

  .has-dropdown.active .dropdown { max-height: 400px; }

  .dropdown li a { padding: 0.65rem 2.5rem; }

  .nav-github { display: none; }

  .content h1 { font-size: 2.4rem; }

  .content h2 {
    font-size: 1.75rem;
    padding-top: 2rem;
    margin-top: 2.5rem;
  }

  .footer-content { flex-direction: column; gap: 0.75rem; text-align: center; }

  .footer-links a { display: inline; }
}
