/* -----------------------------------------
   The Clinical Perspective — base styles
----------------------------------------- */

:root {
  --navy: #4a3222;
  --navy-light: #61452f;
  --maroon: #a54a24;
  --cream: #f7efe1;
  --paper: #fffdf6;
  --ink: #2b211a;
  --ink-soft: #5b4c40;
  --rule: #ede1cc;
  --serif: 'Lora', Georgia, 'Times New Roman', serif;
  --sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --max-width: 1120px;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 6px 24px rgba(74, 50, 34, 0.08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.6;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  color: var(--navy);
  margin: 0 0 0.5em;
  font-weight: 600;
}

p { margin: 0 0 1em; color: var(--ink-soft); }

a { color: var(--maroon); text-decoration: none; }
a:hover { text-decoration: underline; }

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

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

.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--navy);
}
.brand:hover { text-decoration: none; }

.brand-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex-shrink: 0;
  /* the PNG has a transparent background; the sepia/hue shift
     warms the navy mark toward the site's coffee brown */
  filter: sepia(0.55) hue-rotate(-15deg) saturate(1.15) brightness(1.06) contrast(1.05);
}

.brand-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.15;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  row-gap: 10px;
  column-gap: 22px;
}

.main-nav a {
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
}

.main-nav a:hover { color: var(--maroon); text-decoration: none; }

.nav-ig {
  border: 1px solid var(--navy);
  border-radius: 999px;
  padding: 7px 18px;
  color: var(--navy) !important;
}
.nav-ig:hover {
  background: var(--navy);
  color: var(--cream) !important;
}

.nav-spare-change {
  background: var(--maroon);
  border: 1px solid var(--maroon);
  border-radius: 999px;
  padding: 7px 18px;
  color: var(--cream) !important;
}
.nav-spare-change:hover {
  background: #8a3c1c;
  border-color: #8a3c1c;
  text-decoration: none;
}

.nav-account {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-account-name {
  font-size: 0.9rem;
  color: var(--ink-soft) !important;
}
.nav-account-name:hover {
  color: var(--maroon) !important;
}

.nav-signin, .nav-signout {
  border: 1px solid var(--navy);
  border-radius: 999px;
  padding: 7px 18px;
  color: var(--navy) !important;
}
.nav-signin:hover, .nav-signout:hover {
  background: var(--navy);
  color: var(--cream) !important;
  text-decoration: none;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--navy);
  width: 100%;
}

/* ---------- Hero ---------- */

.hero {
  padding: 96px 0 72px;
  /* slightly translucent so the background decor ghosts through */
  background: rgba(255, 253, 246, 0.88);
  border-bottom: 1px solid var(--rule);
}

.hero-inner { max-width: 760px; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--maroon);
  margin-bottom: 18px;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 2.85rem);
  line-height: 1.25;
  margin-bottom: 22px;
}

.hero-lede {
  font-size: 1.1rem;
  max-width: 620px;
}

.hero-actions {
  display: flex;
  gap: 16px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 13px 28px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.95rem;
  border: 1.5px solid transparent;
  border-radius: 999px;
  cursor: pointer;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--navy);
  color: var(--cream);
  border-color: var(--navy);
}
.btn-primary:hover { background: var(--navy-light); }

.btn-secondary {
  background: transparent;
  color: var(--navy);
  border-color: var(--navy);
}
.btn-secondary:hover { background: var(--navy); color: var(--cream); }

/* ---------- Section heading ---------- */

.section-heading {
  max-width: 640px;
  margin-bottom: 40px;
}

.section-heading h2 {
  font-size: 1.9rem;
  position: relative;
  padding-bottom: 16px;
}
.section-heading h2::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 56px;
  height: 3px;
  border-radius: 2px;
  background: var(--maroon);
}

/* ---------- Research ---------- */

.research { padding: 100px 0; }

.research-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 56px;
  align-items: start;
}

.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 36px;
}

.posts-loading, .posts-empty, .posts-error {
  color: var(--ink-soft);
  font-style: italic;
}

.post-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.post-card-meta {
  padding: 16px 18px 0;
}

.post-tag {
  display: inline-block;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--maroon);
  margin-bottom: 8px;
}

.post-card h3 {
  font-size: 1.05rem;
  margin-bottom: 6px;
  line-height: 1.35;
}

.post-date {
  font-size: 0.82rem;
  color: #8a8a8a;
  margin-bottom: 10px;
  display: block;
}

.post-blurb {
  padding: 0 18px;
  font-size: 0.92rem;
}

.post-embed {
  padding: 0 18px 18px;
}

.post-embed iframe { width: 100% !important; border-radius: var(--radius-sm); }

.instagram-media {
  margin: 0 !important;
  min-width: unset !important;
  width: 100% !important;
}

.post-fallback-link {
  display: block;
  padding: 18px;
  border-top: 1px solid var(--rule);
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
}

.research-footer {
  margin-top: 48px;
  text-align: center;
}

/* ---------- Reader Queue ---------- */

.queue {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--maroon);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 32px;
  position: sticky;
  top: 96px;
}

.queue-title {
  font-size: 1.55rem;
  margin-bottom: 6px;
}

.queue-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--maroon);
  margin-bottom: 12px;
}

.queue-sub {
  font-size: 0.95rem;
  margin-bottom: 20px;
}

.queue-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 22px;
}

.queue-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--ink-soft);
}

.queue-form input {
  font-family: var(--sans);
  font-size: 0.9rem;
  padding: 11px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--cream);
  color: var(--ink);
}

.queue-form input:focus {
  outline: 2px solid var(--maroon);
  outline-offset: -1px;
}

.btn-small {
  padding: 10px 18px;
  font-size: 0.88rem;
  margin-top: 6px;
  align-self: flex-start;
}

.queue-msg {
  font-size: 0.82rem;
  margin: 0;
  min-height: 1.2em;
  color: #3e7a3e;
}

.queue-msg-error { color: var(--maroon); }

.queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.queue-empty {
  padding: 16px 0;
  font-size: 0.88rem;
  font-style: italic;
  color: var(--ink-soft);
}

.queue-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
}

.queue-rank {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--maroon);
  min-width: 22px;
  line-height: 1.6;
}

.queue-all-link {
  display: block;
  text-align: center;
  margin-top: 18px;
}

.queue-vote {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--cream);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  cursor: pointer;
  color: var(--ink-soft);
  font-family: var(--sans);
  flex-shrink: 0;
}

.queue-vote:hover:not(:disabled) {
  border-color: var(--maroon);
  color: var(--maroon);
}

.queue-vote.voted {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--cream);
  cursor: default;
}

.queue-arrow { font-size: 0.7rem; line-height: 1; }

.queue-count {
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1;
}

.queue-item-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.queue-item-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--navy);
}

.queue-item-title:hover { color: var(--maroon); }

.queue-item-host {
  font-size: 0.78rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-note {
  font-size: 0.78rem;
  font-style: italic;
  color: var(--ink-soft);
  margin: 14px 0 0;
}

/* ---------- Interior pages (about.html, legal.html) ---------- */

.page { padding: 90px 0; }

.page-inner { max-width: 780px; }

.prose {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 44px 48px;
}

.prose h3 {
  font-family: var(--serif);
  color: var(--navy);
  font-size: 1.3rem;
  margin: 34px 0 12px;
}

.prose h3:first-child { margin-top: 0; }

.prose p {
  color: var(--ink-soft);
  line-height: 1.75;
  margin: 0 0 16px;
}

.prose ul {
  margin: 0 0 16px;
  padding-left: 22px;
  color: var(--ink-soft);
  line-height: 1.75;
}

.prose li { margin-bottom: 10px; }

.prose a { text-decoration: underline; text-underline-offset: 3px; }

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 36px;
}

@media (max-width: 640px) {
  .prose { padding: 30px 24px; }
}

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

.notfound {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
}

.notfound-logo {
  width: 90px;
  margin-bottom: 24px;
  filter: sepia(0.55) hue-rotate(-15deg) saturate(1.15) brightness(1.06) contrast(1.05);
}

.notfound h1 {
  font-family: var(--serif);
  color: var(--navy);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin: 10px 0 14px;
  max-width: 560px;
}

.notfound-lede {
  color: var(--ink-soft);
  font-size: 1.05rem;
  margin: 0 0 28px;
  max-width: 460px;
}

.notfound .page-actions { justify-content: center; margin-top: 0; }

/* ---------- Archive page (queue.html) ---------- */

.archive { padding: 90px 0; }

.archive-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 56px;
  align-items: start;
}

.archive-list-wrap {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--maroon);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 32px;
}

.queue-list-archive { border-top: none; }

.queue-list-archive .queue-item { padding: 18px 0; }

.queue-list-archive .queue-item-title { font-size: 1.05rem; }

.queue-archive-form .btn-secondary { margin-top: 18px; display: block; text-align: center; }

.my-activity {
  margin-top: 48px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
}

.my-activity-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-top: 12px;
}

.my-activity .queue-list { border-top: none; }
.my-activity .queue-item { padding: 10px 0; }

@media (max-width: 1000px) {
  .my-activity-columns { grid-template-columns: 1fr; }
}

@media (max-width: 1000px) {
  .archive-layout { grid-template-columns: 1fr; }
}

/* ---------- About ---------- */

.about { padding: 80px 0; background: rgba(255, 253, 246, 0.88); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }

.about-content { max-width: 720px; }
.about-content p { font-size: 1.02rem; }

/* ---------- Newsletter ---------- */

.newsletter {
  background: var(--navy);
  padding: 72px 0;
}

.newsletter-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 1fr);
  gap: 48px;
  align-items: center;
}

.eyebrow-light { color: #d9a566; }

.newsletter h2 {
  color: var(--cream);
  font-size: 1.8rem;
  margin-bottom: 14px;
}

.newsletter-lede {
  color: #e6d7c3;
  font-size: 1rem;
  margin: 0;
}

.newsletter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.newsletter-form input {
  flex: 1 1 220px;
  font-family: var(--sans);
  font-size: 1rem;
  padding: 14px 20px;
  border: 1px solid #61452f;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
}

.newsletter-form input:focus {
  outline: 2px solid #d9a566;
  outline-offset: -1px;
}

.btn-cream {
  background: var(--cream);
  color: var(--navy);
  border-color: var(--cream);
}

.btn-cream:hover { background: #efe3cc; }

.newsletter-msg {
  width: 100%;
  font-size: 0.88rem;
  color: #b8dcb8;
  margin: 0;
  min-height: 1.2em;
}

.newsletter-msg-error { color: #f0b9a2; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 820px) {
  .newsletter-inner { grid-template-columns: 1fr; gap: 28px; }
}

/* ---------- Submit ---------- */

.submit { padding: 80px 0; }

.submit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 32px;
  margin-bottom: 48px;
}

.submit-step {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--navy);
  border-radius: 50%;
  color: var(--navy);
  font-family: var(--serif);
  font-weight: 700;
  margin-bottom: 14px;
}

.submit-step h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.submit-step p { font-size: 0.92rem; margin: 0; }

.submit-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

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

.site-footer {
  background: var(--navy);
  color: #e6d7c3;
  padding: 40px 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  color: var(--cream);
  font-weight: 600;
}
.brand-logo-footer {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  /* dark footer: the mark is navy, so keep a cream badge behind it */
  background: var(--cream);
  border: 1px solid #61452f;
  padding: 4px;
}

/* ---------- Scrolling background decor ---------- */

.bg-decor {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.decor {
  position: absolute;
  color: var(--navy);
  opacity: 0.09;
  will-change: transform;
}

.decor svg {
  width: 100%;
  height: auto;
  display: block;
  animation: decor-float 9s ease-in-out infinite alternate;
}

.decor:nth-child(even) svg { animation-duration: 12s; animation-delay: -4s; }

@keyframes decor-float {
  from { transform: translateY(-8px) rotate(-2deg); }
  to   { transform: translateY(10px) rotate(2deg); }
}

@media (prefers-reduced-motion: reduce) {
  .decor svg { animation: none; }
}

/* ---------- Scroll reveal ----------
   .reveal elements start hidden only when JS is running
   (body gets .js-reveal), so content is never lost without JS */

.js-reveal .reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s cubic-bezier(0.22, 0.61, 0.36, 1),
              transform 0.7s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.js-reveal .reveal.visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .js-reveal .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

.footer-links {
  display: flex;
  gap: 24px;
}
.footer-links a { color: #e6d7c3; font-size: 0.9rem; }
.footer-links a:hover { color: var(--cream); }

.footer-note {
  width: 100%;
  font-size: 0.8rem;
  color: #b59d82;
  margin: 0;
  padding-top: 20px;
  border-top: 1px solid #61452f;
}

/* ---------- Responsive ---------- */

@media (max-width: 1000px) {
  .research-layout { grid-template-columns: 1fr; }
  .queue { position: static; }
}

@media (max-width: 820px) {
  .main-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    flex-direction: column;
    align-items: flex-start;
    padding: 20px 24px;
    gap: 16px;
    display: none;
  }
  .main-nav.open { display: flex; }
  .nav-toggle { display: flex; }
  .hero { padding: 64px 0 56px; }
}
