/* ==========================================================================
   Editorial Academic Theme — Warm Minimalism
   ========================================================================== */

:root {
  --bg: #FAF9F6;
  --surface: #F2F0EA;
  --text: #1A1A1A;
  --text-muted: #5C5C5C;
  --border: #E5E3DD;
  --accent: #2C4A3E;
  --accent-hover: #1E352C;
  --accent-soft: rgba(44, 74, 62, 0.08);
  --danger: #9B2C2C;

  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --measure: 70ch;
  --max-width: 820px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413;
    --surface: #1D1D1B;
    --text: #EAE8E3;
    --text-muted: #9E9B93;
    --border: #2C2B27;
    --accent: #82B39E;
    --accent-hover: #A1CEBA;
    --accent-soft: rgba(130, 179, 158, 0.12);
    --danger: #E07A7A;
  }
}

:root[data-theme="dark"] {
  --bg: #141413;
  --surface: #1D1D1B;
  --text: #EAE8E3;
  --text-muted: #9E9B93;
  --border: #2C2B27;
  --accent: #82B39E;
  --accent-hover: #A1CEBA;
  --accent-soft: rgba(130, 179, 158, 0.12);
  --danger: #E07A7A;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.edit-mode {
  padding-bottom: 5.5rem;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 1000;
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

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

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

/* Header & Single-Level Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.site-brand {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.site-nav::-webkit-scrollbar {
  display: none;
}

.site-nav a {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  padding: 0.2rem 0;
}

.site-nav a:hover {
  color: var(--text);
}

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.icon-sun { display: none; }
.icon-moon { display: block; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

/* Main Layout */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 4rem 1.5rem 5rem;
}

/* Hero */
.hero {
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(2.25rem, 5vw, 3.1rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 0.6rem;
}

.hero-role {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 0.02em;
  margin: 0 0 1.5rem;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.4rem;
  align-items: center;
  margin-top: 1.5rem;
}

.hero-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 2px;
}

.hero-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.hero-link svg {
  width: 14px;
  height: 14px;
  opacity: 0.75;
}

/* Sections */
.content-section {
  padding: 3.5rem 0;
  border-bottom: 1px solid var(--border);
}

.content-section:last-of-type {
  border-bottom: none;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 400;
  margin: 0;
  letter-spacing: -0.01em;
}

.section-index {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.subsection {
  margin-top: 2.5rem;
}

.subsection:first-of-type {
  margin-top: 0;
}

.subsection-title {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 1.25rem;
}

/* Entries & Typography */
.entry-block {
  margin-bottom: 2.25rem;
  max-width: var(--measure);
}

.entry-block:last-child {
  margin-bottom: 0;
}

.entry-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.25rem 1rem;
  margin-bottom: 0.5rem;
}

.entry-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 500;
  margin: 0;
  line-height: 1.35;
}

.entry-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.entry-submeta {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.entry-intro {
  margin: 0 0 1rem;
  color: var(--text);
}

.detail-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 1px solid var(--border);
  padding-left: 1.25rem;
}

.detail-item {
  margin-bottom: 1rem;
}

.detail-item:last-child {
  margin-bottom: 0;
}

.detail-label {
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0 0 0.2rem;
  color: var(--text);
}

.detail-body {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Citations & Papers */
.citation-text {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  line-height: 1.5;
  margin: 0 0 0.55rem;
  color: var(--text);
}

.citation-summary {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Compact Lists (Degrees, Certificates) */
.compact-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: var(--measure);
}

.compact-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.25rem 1.25rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

.compact-item:last-child {
  border-bottom: none;
}

.compact-primary {
  font-size: 0.96rem;
  font-weight: 500;
  color: var(--text);
  flex: 1 1 280px;
}

.compact-secondary {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.back-to-top {
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

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

/* ==========================================================================
   On-Page Edit Mode UI (?edit=true)
   ========================================================================== */

body.edit-mode [contenteditable="true"] {
  border-radius: 3px;
  transition: background-color 0.15s ease, outline-color 0.15s ease;
  outline: 1px dashed transparent;
  outline-offset: 2px;
}

body.edit-mode [contenteditable="true"]:hover {
  outline-color: var(--border);
  background-color: var(--accent-soft);
}

body.edit-mode [contenteditable="true"]:focus {
  outline: 1.5px dashed var(--accent);
  background-color: var(--accent-soft);
}

.edit-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.edit-mini-btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
}

.edit-mini-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.edit-mini-btn.danger:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.edit-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  background: transparent;
  color: var(--accent);
  border: 1px dashed var(--accent);
  border-radius: 4px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}

.edit-add-btn:hover {
  background: var(--accent-soft);
}

.edit-link-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  margin-bottom: 0.5rem;
}

.edit-url-input {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.25rem 0.45rem;
  min-width: 210px;
}

/* Floating Bottom Toolbar */
.edit-toolbar {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(94vw, 760px);
  background: var(--text);
  color: var(--bg);
  border-radius: 10px;
  padding: 0.75rem 1.1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
  z-index: 200;
}

.edit-toolbar[hidden] {
  display: none;
}

.edit-toolbar-status {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.85rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #68D391;
  flex-shrink: 0;
}

.status-dot.dirty {
  background: #F6AD55;
}

.status-dot.error {
  background: #FC8181;
}

.edit-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toolbar-btn {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  border: 1px solid transparent;
}

.toolbar-btn-primary {
  background: #FAF9F6;
  color: #1A1A1A;
}
:root[data-theme="dark"] .toolbar-btn-primary {
  background: #141413;
  color: #FAF9F6;
}

.toolbar-btn-secondary {
  background: transparent;
  color: inherit;
  border-color: color-mix(in srgb, currentColor 35%, transparent);
}

.toolbar-btn-ghost {
  background: transparent;
  color: inherit;
  opacity: 0.8;
}
.toolbar-btn-ghost:hover {
  opacity: 1;
}

@media (max-width: 640px) {
  .header-inner {
    flex-wrap: wrap;
    padding: 0.75rem 1.1rem;
  }
  .site-nav {
    order: 3;
    width: 100%;
    padding-top: 0.35rem;
    border-top: 1px solid var(--border);
  }
  .container {
    padding: 2.5rem 1.1rem 4rem;
  }
}
