:root {
  --bg: #fcfaf6;
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --rule: #e6e2d8;
  --accent: #7c1f1f;
  --accent-hover: #5a1515;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Iowan Old Style", "Apple Garamond", Baskerville,
               "Source Serif Pro", "Times New Roman", Times, serif;
  font-size: 18px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 5rem;
}

nav.top {
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3rem;
  display: flex;
  gap: 1.25rem;
}
nav.top a { color: var(--muted); text-decoration: none; }
nav.top a:hover { color: var(--accent); }
nav.top a.current { color: var(--ink); }

h1 {
  font-size: 2rem;
  font-weight: 500;
  margin: 0 0 0.25rem;
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--muted);
  font-size: 1rem;
  font-style: italic;
  margin: 0 0 2.5rem;
}

h2 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 3rem 0 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}

h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.5rem 0 0.25rem;
  color: var(--ink);
}

p { margin: 0 0 1rem; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(124, 31, 31, 0.25);
  transition: border-color 0.15s, color 0.15s;
}
a:hover {
  color: var(--accent-hover);
  border-bottom-color: var(--accent-hover);
}

.lead {
  font-size: 1.1rem;
  line-height: 1.65;
}

.project {
  margin: 1.75rem 0;
}
.project .meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
  font-style: italic;
}
.project p { margin: 0.5rem 0; }
.project .links {
  font-size: 0.85rem;
  margin-top: 0.5rem;
}
.project .links a { margin-right: 1rem; }

ul.interests {
  list-style: none;
  padding: 0;
  margin: 0;
}
ul.interests li {
  padding: 0.6rem 0;
  border-bottom: 1px dotted var(--rule);
}
ul.interests li:last-child { border-bottom: none; }
ul.interests strong {
  font-weight: 600;
  color: var(--ink);
}

footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.85rem;
  color: var(--muted);
}
footer a { color: var(--muted); border-bottom-color: rgba(107, 107, 107, 0.3); }
footer a:hover { color: var(--accent); border-bottom-color: var(--accent); }
footer .row {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

/* Interactive math toys (random per visit) */
.toy { min-height: 480px; }
.fractal, .lifebox, .fluidbox {
  position: relative;
  max-width: 640px;
  margin: 1.5rem auto 0.75rem;
  line-height: 0;
}
.fractal #mandel, #life, #fluid {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--rule);
}
.fractal #mandel { background: #16100c; cursor: grab; touch-action: none; }
.fractal #mandel:active { cursor: grabbing; }
#life { background: #fcf8f0; cursor: crosshair; touch-action: none; }
#fluid { background: #16100c; cursor: crosshair; touch-action: none; }
.fractal .julia-inset {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 130px;
  height: 130px;
  border: 1px solid rgba(252, 248, 240, 0.65);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
#fractal-reset, .toy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  font-family: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  color: #fcf8f0;
  background: rgba(22, 16, 12, 0.6);
  border: 1px solid rgba(252, 248, 240, 0.4);
  border-radius: 4px;
  padding: 3px 9px;
  cursor: pointer;
}
#fractal-reset:hover, .toy-btn:hover { background: rgba(124, 31, 31, 0.8); }
.toy-cap {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  text-align: center;
  line-height: 1.5;
  margin: 0 auto 1rem;
  max-width: 540px;
}
@media (max-width: 600px) {
  .fractal .julia-inset { width: 96px; height: 96px; bottom: 8px; right: 8px; }
  .toy { min-height: 380px; }
}

.todo {
  background: #fff8e1;
  border-left: 3px solid #d4a017;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  font-size: 0.9rem;
  color: #6b5400;
  font-style: italic;
}

/* Art page */
.art-section { margin: 3rem 0; }

.streaming-links {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-size: 0.95rem;
  margin: 1rem 0 1.5rem;
}

ul.album-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}
ul.album-list li {
  padding: 0.75rem 0;
  border-bottom: 1px dotted var(--rule);
}
ul.album-list li:last-child { border-bottom: none; }
ul.album-list .album-title { font-weight: 600; color: var(--ink); }
ul.album-list .album-meta {
  color: var(--muted);
  font-style: italic;
  font-size: 0.9rem;
  margin-left: 0.4rem;
}
ul.album-list .album-links {
  display: block;
  font-size: 0.85rem;
  margin-top: 0.25rem;
}
ul.album-list .album-links a { margin-right: 1rem; }

ul.album-list li.earlier {
  font-size: 0.92rem;
  padding: 0.4rem 0;
}
ul.album-list li.earlier .album-title { font-weight: 500; color: var(--muted); }
ul.album-list li.earlier .album-meta { color: var(--muted); }

ul.album-list li.more {
  font-style: italic;
  color: var(--muted);
  font-size: 0.9rem;
}

.gallery.single { grid-template-columns: 1fr; max-width: 560px; margin-left: auto; margin-right: auto; }
.gallery.triple { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 600px) {
  .gallery.triple { grid-template-columns: repeat(2, 1fr); }
}
.gallery video {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--rule);
}

.spotify-embed {
  margin: 1.5rem 0;
  border-radius: 12px;
  overflow: hidden;
}
.spotify-embed iframe {
  width: 100%;
  border: 0;
  display: block;
  border-radius: 12px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin: 1.5rem 0;
}
.gallery figure { margin: 0; }
.gallery img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--rule);
}
.gallery figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 0.4rem;
}
@media (max-width: 600px) {
  .gallery { grid-template-columns: 1fr; }
}

/* CV page */
.cv-section { margin: 2.5rem 0; }
.cv-entry { margin: 1.25rem 0; }
.cv-entry .head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
.cv-entry .head strong { font-weight: 600; }
.cv-entry .head .date { color: var(--muted); font-size: 0.9rem; font-style: italic; white-space: nowrap; }
.cv-entry .where { color: var(--muted); font-size: 0.95rem; font-style: italic; margin: 0.1rem 0 0.4rem; }
.cv-courses { font-size: 1.05rem; font-style: italic; color: #3a3a3a; }
.cv-entry ul { margin: 0.3rem 0 0 1.1rem; padding: 0; }
.cv-entry ul li { margin: 0.2rem 0; }
.cv-skills { font-size: 0.95rem; }
.cv-skills .label {
  font-weight: 600;
  display: inline-block;
  min-width: 7rem;
}

/* Mobile */
@media (max-width: 600px) {
  body { font-size: 17px; }
  .wrap { padding: 2rem 1.25rem 3rem; }
  h1 { font-size: 1.65rem; }
  nav.top { margin-bottom: 2rem; gap: 1rem; }
  .cv-entry .head { flex-direction: column; gap: 0.1rem; }
  .cv-entry .head .date { font-size: 0.85rem; }
}

/* Print (for /cv page) */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .wrap { max-width: none; padding: 0.5in; }
  nav.top, footer { display: none; }
  a { color: #000; border-bottom: none; }
  h2 { border-color: #999; }
}
