:root {
  --bg:         #F5F0E6;
  --bg-alt:     #EDE6D6;
  --text:       #1A1A1A;
  --text-muted: #6B6B6B;
  --accent:     #c8924a;
  --border:     rgba(0,0,0,0.12);
  --max-w:      640px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --font-mono:    ui-monospace, SFMono-Regular, Menlo, monospace;
}

:root[data-theme="dark"] {
  --bg:         #0f0f10;
  --bg-alt:     #17171a;
  --text:       #e8e4d8;
  --text-muted: #8a8680;
  --accent:     #d9a35f;
  --border:     rgba(255,255,255,0.12);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

img,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

#site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  pointer-events: none;
}

.nav-logo {
  pointer-events: auto;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1;
  text-decoration: none;
}

/* Social rail: desktop-only vertical sidebar on the left edge */
#social-rail {
  position: fixed;
  top: 50%;
  left: 1.25rem;
  transform: translateY(-50%);
  z-index: 5;
}

#social-rail ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#social-rail a {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--text-muted);
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

#social-rail a:hover,
#social-rail a:focus-visible {
  color: var(--accent);
  background: var(--bg-alt);
  transform: translateY(-1px);
}

#social-rail svg {
  width: 20px;
  height: 20px;
}

/* Hide the sidebar on tablet/mobile; Elsewhere section in body takes over */
@media (max-width: 900px) {
  #social-rail { display: none; }
}

/* Hide the in-body Elsewhere list on desktop where the rail is present */
@media (min-width: 901px) {
  .elsewhere-mobile { display: none; }
}

/* About Me: full-width intro paragraph, then two-column row below
   where the second paragraph sits next to the headshot circle. The
   circle is sized off the text column's natural height so the two
   are visually height-matched. */
.about-me {
  margin: 0 0 3rem;
}

.about-intro {
  margin: 0 0 1.5rem;
}

.about-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  align-items: center;
}

@media (min-width: 640px) {
  .about-columns {
    grid-template-columns: 1.6fr 1fr;
    gap: 2.5rem;
    align-items: start;
  }
}

.about-text p:first-child { margin-top: 0; }
.about-text p:last-child  { margin-bottom: 0; }

.about-photo {
  display: flex;
  justify-content: center;
  align-self: center;
}

.about-photo img {
  /* Circle diameter tracks the row height on desktop so the photo
     matches the height of the paragraph beside it. On mobile the
     row collapses and the circle falls back to a comfortable size. */
  width: 220px;
  height: 220px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--border);
}

@media (min-width: 640px) {
  .about-columns { position: relative; }

  /* Anchor the photo to the row so it fills the available height */
  .about-photo {
    align-self: stretch;
    align-items: center;
  }

  .about-photo img {
    width: auto;
    height: 100%;
    max-height: 260px;
    min-height: 180px;
    aspect-ratio: 1 / 1;
  }
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#theme-toggle {
  pointer-events: auto;
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
}

#theme-toggle svg {
  width: 20px;
  height: 20px;
}

:root[data-theme="light"] .icon-sun,
:root[data-theme="dark"] .icon-moon {
  display: none;
}

main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 4rem 1.5rem 6rem;
}

h1,
h2,
h3 {
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.25;
}

h1 {
  margin: 2.75rem 0 1.5rem;
  font-size: 1.75rem;
}

/* Site title: SVG that stretches text to exactly the column width */
.site-title {
  margin: 3.5rem 0 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.site-title svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.site-title text {
  fill: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

h2 {
  margin: 3rem 0 1rem;
  font-size: 1.25rem;
}

h3 {
  margin: 2rem 0 0.75rem;
  font-size: 1.1rem;
}

p {
  margin: 0 0 1rem;
}

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

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

section {
  margin-top: 2.5rem;
}

dl {
  margin: 0;
}

dt {
  margin-top: 1.4rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
}

dd {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
}

/* Education credential line: less muted than the detail below it */
dd.edu-credential {
  color: var(--text);
  font-size: 0.95rem;
  margin-top: 0.15rem;
  margin-bottom: 0.35rem;
}

ul,
ol {
  margin: 0 0 1.25rem 1.4rem;
  padding: 0;
}

ul {
  list-style: "— ";
}

li {
  margin: 0.45rem 0;
  padding-left: 0.2rem;
}

.muted {
  color: var(--text-muted);
}

.motto {
  margin-top: 3.5rem;
  margin-bottom: 0;
  padding-left: 0;
  border-left: none;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.5;
}

.motto p { margin: 0; }

.motto-attr {
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-style: normal;
}

.motto-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

/* Article figure: full column width, natural aspect ratio */
.article-figure {
  margin: 2.5rem 0;
}

.article-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.article-figure figcaption {
  margin-top: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-style: italic;
  text-align: center;
}

/* Article body: inline images match figure treatment */
.article-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 2rem auto;
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* Interactive iframe embed (Streamlit dashboards, etc.) */
.embed-frame {
  position: relative;
  width: 100%;
  height: 640px;
  margin: 2rem 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-alt);
}

.embed-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

@media (max-width: 700px) {
  .embed-frame { height: 480px; }
}

.article-list {
  margin-top: 1.5rem;
}

.article-list li {
  margin-bottom: 1.2rem;
}

.article-list p {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
}

.article-header {
  margin-bottom: 2rem;
}

.article-meta {
  margin-bottom: 0.6rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

figure {
  margin: 2rem 0;
}

figure img,
.article-body img {
  width: 100%;
  border: 1px solid var(--border);
}

figcaption,
.article-body img + em {
  display: block;
  margin-top: 0.6rem;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-style: italic;
  text-align: center;
}

.article-body h2 {
  margin-top: 3rem;
}

.article-body p {
  margin-bottom: 1.25rem;
}

.article-body ul,
.article-body ol {
  margin-bottom: 1.5rem;
}

.article-body blockquote {
  margin: 2rem 0;
  padding-left: 1rem;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
}

.article-body code {
  padding: 0.1em 0.3em;
  background: var(--bg-alt);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.article-body pre {
  overflow-x: auto;
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
}

.article-body pre code {
  padding: 0;
  background: transparent;
}

@media (max-width: 520px) {
  #site-nav {
    padding-left: 1rem;
  }

  .nav-logo {
    font-size: 0.95rem;
  }

  main {
    padding-inline: 1.25rem;
  }
}
