/* ============================================================
   Colors live in one place. Light mode is the default set;
   [data-theme="dark"] overrides them. Change a color here and
   it changes everywhere.
   ============================================================ */
:root {
  --bg: #F4F5F7;          /* light gray page */
  --text: #1B1F24;        /* near-black text */
  --muted: #1B1F24;       /* secondary text: same as main text, per Eli */
  --accent: #24477A;      /* links: muted navy */
  --border: #D9DDE3;
  --tag-bg: #E3E7EE;
  --ph-bg: #FFF8E1;       /* placeholder boxes: pale yellow, easy to spot */
  --ph-border: #D9B44A;
  --ph-text: #6B5310;
}

:root[data-theme="dark"] {
  --bg: #0F1B2D;          /* deep navy page */
  --text: #E6EAF0;
  --muted: #E6EAF0;
  --accent: #9DBCE6;
  --border: #24344D;
  --tag-bg: #1C2B43;
  --ph-bg: #2A2614;
  --ph-border: #8C7430;
  --ph-text: #E3CF8F;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
  /* Sizes use rem (a multiple of the page's base size), so the
     text-size buttons can scale everything by changing one number. */
  font-size: 1.125rem;
  line-height: 1.6;
  transition: background-color 0.25s ease, color 0.25s ease;
  /* Page is at least one screen tall, stacked top to bottom, so the
     footer sits at the bottom of the screen even on short pages */
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.topbar, main, .footer { width: 100%; }
main { flex: 1 0 auto; }   /* main stretches to fill the space above the footer */

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3 { font-weight: 600; line-height: 1.25; }

/* ---------- Top bar ---------- */
.topbar {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}
.brand:hover { text-decoration: none; }

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

.nav a {
  color: var(--muted);
  padding-bottom: 2px;
  border-bottom: 1.5px solid transparent;
}
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Research menu.
   Computers: hovering Research reveals it (holds "Workflow").
   Phones/iPads (no hover): the first tap on Research opens it, and it
   also lists "Projects"; a second tap on Research goes to Projects.
   padding-top bridges the gap so the menu doesn't close as the mouse moves down. */
.has-menu { position: relative; display: inline-flex; align-items: center; }
.nav-menu {
  position: absolute;
  top: 100%;
  left: -14px;
  padding-top: 8px;
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}
.has-menu.open .nav-menu {
  opacity: 1;
  visibility: visible;
  transform: none;
}
/* Computers only: hovering, or tabbing to it with the keyboard, also opens it.
   (On phones a tapped item can keep focus, which would hold the menu open.) */
@media (hover: hover) {
  .has-menu:hover .nav-menu,
  .has-menu:focus-within .nav-menu { opacity: 1; visibility: visible; transform: none; }
}
.nav-menu-box {
  display: block;
  min-width: 130px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}
.nav-menu a {
  display: block;
  padding: 7px 12px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 0.95rem;
}
.nav-menu a:hover { color: var(--text); background: var(--tag-bg); text-decoration: none; }

.touch-only { display: none !important; }
@media (hover: none) {
  .nav-menu a.touch-only { display: block !important; }
}

/* Text-size buttons: two small joined buttons, styled like the theme toggle */
.text-size { display: inline-flex; }
.size-btn {
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 15px;          /* fixed px so the buttons themselves don't grow */
  cursor: pointer;
}
.size-btn span { font-size: 12px; margin-left: 1px; }
.size-btn:first-child { border-radius: 8px 0 0 8px; }
.size-btn:last-child  { border-radius: 0 8px 8px 0; border-left: none; }
.size-btn:hover { color: var(--text); }
.size-btn:disabled { opacity: 0.35; cursor: default; }

/* ---------- Vertical text-size slider (wide screens only) ---------- */
.size-slider {
  position: fixed;
  right: 22px;
  top: 26px;                  /* top-right corner, level with the nav bar */
  display: none;             /* turned on in the wide-screen rule below */
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0.55;
  transition: opacity 0.2s ease;
}
.size-slider:hover,
.size-slider:focus-within { opacity: 1; }

.slider-end {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 17px;            /* fixed px: the control itself never resizes */
  line-height: 1;
  cursor: pointer;
}
.slider-end.small { font-size: 11px; }
.slider-end:hover { color: var(--text); }

/* The box the track and ticks sit in. Height = length of the track. */
.slider-box {
  position: relative;
  width: 24px;
  height: 140px;
}

/* Tick marks: 5 short horizontal lines spread evenly down the track.
   Inset 7px top and bottom = half the thumb, so ticks line up with
   where the thumb's center actually stops. */
.ticks {
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}
.ticks i {
  display: block;
  width: 12px;
  height: 1.5px;
  background: var(--muted);
  opacity: 0.6;
}

/* The slider is a normal horizontal range input, rotated -90deg so
   its low end is at the bottom. Rotation works in every browser. */
.slider-input {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 140px;
  height: 24px;
  margin: 0;
  transform: translate(-50%, -50%) rotate(-90deg);
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.slider-input:focus { outline: none; }
.slider-input:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }

/* track (Chrome/Safari, then Firefox) */
.slider-input::-webkit-slider-runnable-track { height: 1.5px; background: var(--muted); }
.slider-input::-moz-range-track { height: 1.5px; background: var(--muted); }

/* thumb */
.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -6.25px;        /* centers the thumb on the 1.5px track */
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}
.slider-input::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-sizing: border-box;
}

/* Wide screens: show the side slider, hide the A−/A+ nav buttons.
   Tablet widths keep the nav buttons, since a fixed slider would
   sit on top of the text. Phones get neither (see the phone rules
   at the bottom); they have pinch-to-zoom. */
@media (min-width: 1000px) {
  .size-slider { display: flex; }
  .nav .text-size { display: none; }
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }
/* Show the moon in light mode, the sun in dark mode */
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* ---------- Main column ---------- */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 24px 24px;
}

/* Tab fade: when a tab becomes visible it fades in quickly */
.tab { animation: fade-in 0.2s ease-out; }
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .tab { animation: none; }
  body { transition: none; }
}

/* ---------- Home ---------- */
.intro {
  display: flex;
  gap: 40px;
  align-items: flex-start;
}

.headshot {
  width: 220px;
  height: auto;
  flex-shrink: 0;
  border-radius: 14px;         /* rounded square */
  object-fit: cover;
}

.intro-text { flex: 1; min-width: 0; }
.intro-text h1 { margin: 0 0 6px; font-size: 2rem; }

.intro-text h1 { margin-bottom: 16px; }

.bio p { margin: 0 0 14px; }

.contact {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
}

/* ---------- Placeholders (to be replaced with real text) ---------- */
.placeholder {
  margin: 12px 0;
  padding: 10px 14px;
  border: 1px dashed var(--ph-border);
  border-radius: 8px;
  background: var(--ph-bg);
  color: var(--ph-text);
  font-size: 0.92rem;
}
.ph-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Research ---------- */
.page-title { font-size: 1.7rem; margin: 0 0 8px; }
.section-title {
  font-size: 1.35rem;
  margin: 48px 0 8px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.meta { margin: 0 0 10px; color: var(--muted); font-size: 0.92rem; }
.tag {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--text);
  font-size: 0.78rem;
}


/* Research list: each project is one clickable card */
.project-card {
  display: block;
  margin: 0 -14px;               /* lets the hover background extend past the text */
  padding: 20px 14px;
  border-bottom: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  transition: background-color 0.2s ease;
}
.project-card:hover { background: var(--tag-bg); text-decoration: none; }
.project-card h3 { margin: 0 0 6px; font-size: 1.15rem; }
.project-card h3::after {        /* small arrow that slides right on hover */
  content: "→";
  margin-left: 6px;
  color: var(--accent);
  display: inline-block;
  transition: transform 0.2s ease;
}
.project-card:hover h3::after { transform: translateX(4px); }

/* Two-line preview of the overview, cut off with "…" */
.preview {
  margin: 0;
  font-size: 0.95rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.preview.empty { font-style: italic; opacity: 0.7; }

/* Project pages */
.research-list,
.project-page { animation: fade-in 0.2s ease-out; }   /* same quick fade as the tabs */

.back {
  display: inline-block;
  margin-bottom: 18px;
  font-size: 0.95rem;
}
.project-title { font-size: 1.6rem; margin: 0 0 8px; }
.sub-title { font-size: 1.2rem; margin: 36px 0 10px; }
.note { margin: 0 0 16px; font-size: 0.92rem; }

/* Key facts strip: one row of short facts under the title.
   Columns wrap automatically on narrow screens. */
.facts {
  margin: 18px 0 0;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px 24px;
}
.facts dt {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.7;
}
.facts dd { margin: 2px 0 0; font-size: 0.95rem; line-height: 1.35; }

/* Longer details lower on the page: "Label  value" rows */
.details { margin: 16px 0 18px; font-size: 0.92rem; }
.details div { display: grid; grid-template-columns: 8em 1fr; gap: 12px; margin-bottom: 4px; }
.details dt { font-weight: 600; }
.details dd { margin: 0; }

/* Research list: one-line pointer to the Workflow page */
.workflow-pointer {
  margin: 36px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
}

/* Workflow page */
.lede { margin: 8px 0 14px; font-size: 1.05rem; }
.lede + .steps { margin-top: 28px; }

/* Numbered steps: a small circled number beside each step */
.steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 22px;
}
.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 46px;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 30px;
  height: 30px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.steps h3 { margin: 2px 0 4px; font-size: 1.05rem; }
.steps p { margin: 0; }

.practice-links { margin: 8px 0 0; padding-left: 20px; }
.practice-links li { margin-bottom: 6px; }

.overview p { margin: 0 0 14px; }
.overview .in-progress-note { font-size: 0.9rem; font-style: italic; opacity: 0.8; }

/* Slides: stacked down the page, each fades up as it scrolls into view */
.slides { display: grid; gap: 28px; }
.slide { margin: 0; cursor: zoom-in; }
.slide img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}
.slide figcaption { margin-top: 8px; font-size: 0.88rem; }

/* Only hide slides when JavaScript is running, so they still show without it */
.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.js .reveal.is-visible { opacity: 1; transform: none; }

.link-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; }

/* Section headings: leave a little room above when jumped to */
.sub-title { scroll-margin-top: 24px; }

/* Photos: two side by side (one column on phones) */
.photos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.photo { margin: 0; cursor: zoom-in; }
.photo img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}
.photo figcaption { margin-top: 6px; font-size: 0.85rem; }
.photo-credit { margin: -6px 0 16px; font-size: 0.75rem; font-style: italic; opacity: 0.75; }

/* Section map ("on this page"), fixed left of the main column.
   Only on wide screens, where there's empty space beside the text. */
.page-map {
  position: fixed;
  top: 140px;
  /* 430px = half the main column; 230px = map width + gap.
     max() keeps it at least 24px from the window edge. */
  left: max(24px, calc(50% - 430px - 230px));
  width: 170px;
  display: none;
  font-size: 14.5px;                   /* fixed px: doesn't grow with the text-size slider */
  line-height: 1.4;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}
.page-map:hover { opacity: 1; }
.page-map ol {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}
.page-map button {
  display: block;
  width: 100%;
  margin-left: -1px;                  /* sits on top of the list's left line */
  padding: 6px 0 6px 14px;
  border: none;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.page-map button:hover { color: var(--text); }
.page-map button.is-current {
  color: var(--text);
  border-left-color: var(--accent);
}
@media (min-width: 1340px) {      /* wide enough for the map beside the text */
  .page-map:not([hidden]) { display: block; }
}

/* Lightbox: dark overlay with the enlarged slide */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 14, 24, 0.88);
  cursor: zoom-out;
  animation: fade-in 0.2s ease-out;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .research-list, .project-page, .lightbox { animation: none; }
}

/* ---------- Résumé ---------- */
.resume-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.resume-head .page-title { margin: 0; }

.button {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: 0.92rem;
}
.button:hover { background: var(--accent); color: var(--bg); text-decoration: none; }

.resume-mobile { display: none; }     /* shown on phones only (see bottom) */
.resume-mobile p { margin: 0 0 14px; }
.button-solid { background: var(--accent); color: var(--bg); padding: 10px 18px; font-size: 1rem; }
.button-solid:hover { opacity: 0.9; }

.resume-frame {
  display: block;
  width: 100%;
  height: 85vh;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

/* ---------- Footer ---------- */
.footer {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 24px 40px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  body { font-size: 1.0625rem; }
  .topbar { padding: 20px 16px 0; }
  .nav { gap: 16px; }
  .nav .text-size { display: none; }   /* no text-size control on phones */
  .details div { grid-template-columns: 1fr; gap: 0; margin-bottom: 8px; }   /* label above value */
  /* Fact strip on phones: one tight line per fact (label left, value right)
     so it stays small and the Overview starts near the top of the screen */
  .facts { margin-top: 14px; padding: 8px 0; gap: 4px; grid-template-columns: 1fr; }
  .facts div { display: grid; grid-template-columns: 5.2rem 1fr; gap: 10px; align-items: baseline; }
  .facts dt { font-size: 0.62rem; }
  .facts dd { margin: 0; font-size: 0.85rem; }
  .project-title { font-size: 1.4rem; }
  .slides { gap: 20px; }
  .photos { grid-template-columns: 1fr; }
  main { padding: 28px 16px 16px; }
  .intro { flex-direction: column; gap: 20px; }
  .headshot { width: 160px; }
  .resume-frame { display: none; }              /* phones: no embedded viewer... */
  .resume-mobile { display: block; }            /* ...a button instead */
  .resume-head .button { display: none; }       /* the big button replaces it */
  .footer { padding: 20px 16px 32px; }
}

/* "Next project" link at the bottom of each project page */
.next-project {
  display: block;
  margin-top: 48px;
  padding: 18px 0 4px;
  border-top: 1px solid var(--border);
  font-size: 1.05rem;
  font-weight: 600;
}
.next-project span {
  display: block;
  margin-bottom: 2px;
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.7;
}
.next-project::after { content: "→"; margin-left: 6px; display: inline-block; transition: transform 0.2s ease; }
.next-project:hover { text-decoration: none; }
.next-project:hover::after { transform: translateX(4px); }
