/* ============================================================
   Jonathan Wilson — Personal Site
   Single stylesheet. All design lives here.
   ============================================================ */

/* --- Custom properties --- */
:root {
  --font-heading: Georgia, 'Times New Roman', Times, serif;
  --font-body: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;

  --color-bg: #FFFFFF;
  --color-text: #1A1A1A;
  --color-text-muted: #6B6B6B;
  --color-link: #1A1A1A;
  --color-link-underline: #CCCCCC;
  --color-link-hover: #000000;
  --color-border: #E5E5E5;
  --color-blockquote-border: #D0D0D0;
  --color-code-bg: #F5F5F5;
  --color-selection: rgba(0, 100, 255, 0.15);
  --color-toggle-bg: #E0E0E0;
  --color-toggle-knob: #1A1A1A;
}

html.dark-mode {
  --color-bg: #161616;
  --color-text: #D4D4D4;
  --color-text-muted: #888888;
  --color-link: #D4D4D4;
  --color-link-underline: #444444;
  --color-link-hover: #FFFFFF;
  --color-border: #2A2A2A;
  --color-blockquote-border: #3A3A3A;
  --color-code-bg: #222222;
  --color-selection: rgba(100, 160, 255, 0.25);
  --color-toggle-bg: #333333;
  --color-toggle-knob: #D4D4D4;
}

/* --- Reset & base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

::selection {
  background: var(--color-selection);
}

html {
  font-size: 16px;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.15s ease, color 0.15s ease;
}

/* --- Layout --- */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* --- Header --- */
.header {
  padding: 2.5rem 0 1rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 2.5rem;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-name {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.header-name:hover {
  color: var(--color-link-hover);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.header-archive-link {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-decoration: none;
}

.header-archive-link:hover {
  color: var(--color-text);
}

/* --- Dark/light toggle --- */
.toggle-switch {
  display: flex;
  align-items: center;
}

.toggle-checkbox {
  display: none;
}

.toggle-label {
  display: block;
  width: 36px;
  height: 18px;
  background: var(--color-toggle-bg);
  border-radius: 9px;
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
}

.toggle-label::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--color-toggle-knob);
  border-radius: 50%;
  transition: transform 0.15s ease, background 0.15s ease;
}

.toggle-checkbox:checked + .toggle-label::after {
  transform: translateX(18px);
}

/* --- Main content --- */
main {
  padding-bottom: 4rem;
}

/* --- Bio section --- */
.bio {
  margin-bottom: 2.5rem;
}

.bio p {
  margin-bottom: 1.25rem;
}

.bio-expand {
  display: none;
}

.bio-more-link {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px solid var(--color-link-underline);
}

.bio-more-link:hover {
  color: var(--color-text);
}

/* --- Section headings (homepage) --- */
.section {
  margin-bottom: 2.5rem;
}

.section-title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

/* --- Bullet lists (homepage & archive) --- */
.link-list {
  list-style: none;
}

.link-list li {
  font-size: 0.95rem;
  padding: 0.25rem 0;
  padding-left: 1.1rem;
  position: relative;
}

.link-list li::before {
  content: '\2022';
  position: absolute;
  left: 0;
  color: var(--color-text-muted);
}

.link-list a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-color: var(--color-link-underline);
  text-underline-offset: 2px;
  transition: color 0.1s ease, text-decoration-color 0.1s ease;
}

.link-list a:hover {
  color: var(--color-link-hover);
  text-decoration-color: var(--color-text);
}

.link-list .annotation {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-left: 0.4rem;
}

.link-list .muted {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

/* --- Essay page --- */
.essay-header {
  margin-bottom: 2.5rem;
}

.essay-title {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.essay-date {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* --- Rich text (essay body) --- */
.rich-text p {
  margin-bottom: 1.25rem;
}

.rich-text h2 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 400;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.rich-text h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 400;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.rich-text h4,
.rich-text h5,
.rich-text h6 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 400;
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
}

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

.rich-text a:hover {
  color: var(--color-link-hover);
  text-decoration-color: var(--color-text);
}

.rich-text blockquote {
  border-left: 2px solid var(--color-blockquote-border);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--color-text-muted);
  font-style: italic;
}

.rich-text blockquote p {
  margin-bottom: 0;
}

.rich-text code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--color-code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

.rich-text pre {
  background: var(--color-code-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.rich-text pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.875rem;
  line-height: 1.6;
}

/* Dinkus: replace <hr> with ⁂ */
.rich-text hr {
  border: none;
  text-align: center;
  color: var(--color-text-muted);
  margin: 2rem 0;
}

.rich-text hr::after {
  content: '\2042';
  font-size: 1.25rem;
}

.rich-text ul,
.rich-text ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}

.rich-text li {
  margin-bottom: 0.25rem;
}

.rich-text strong {
  font-weight: 600;
}

.rich-text em {
  font-style: italic;
}

.rich-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

.rich-text th,
.rich-text td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.rich-text th {
  font-weight: 600;
  border-bottom: 2px solid var(--color-border);
}

/* --- Back link --- */
.back-link {
  display: inline-block;
  margin-top: 3rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--color-text);
}

/* --- Archive year heading --- */
.archive-year {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 400;
  color: var(--color-text-muted);
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

/* --- 404 page --- */
.not-found-text {
  color: var(--color-text-muted);
  font-size: 1.05rem;
  margin-bottom: 1.5rem;
}

/* --- Responsive --- */
@media (max-width: 480px) {
  html {
    font-size: 15px;
  }

  .container {
    padding: 0 1.25rem;
  }
}

/* ============================================================
   Research page additions (convergence test and future entries)
   Additive only — no existing rules modified.
   ============================================================ */

/* Italic subtitle used between essay-title and essay-date */
.essay-subtitle {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 400;
  font-style: italic;
  color: var(--color-text-muted);
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

/* Download list — reset bullets/padding from .rich-text ul defaults */
.rich-text .download-list {
  list-style: none;
  padding-left: 0;
  margin: 1.5rem 0;
}

.rich-text .download-list li {
  margin-bottom: 0.5rem;
}

/* Single clickable row: text label + download icon, inline-flex for alignment */
.download-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.download-icon {
  color: var(--color-text-muted);
  transition: color 0.2s ease;
  flex-shrink: 0;
}

.download-link:hover .download-icon,
.download-link:focus-visible .download-icon {
  color: var(--color-text);
}
