/* Mara Ellis — personal site
   Crimson + Computer Modern. Two themes: light (white, default) and dark (crimson field). */

@import url('https://cdn.jsdelivr.net/gh/dreampulse/computer-modern-web-font@master/fonts.css');

:root {
  --ground: #FFFFFF;
  --panel: #FFFFFF;
  --panel-2: #FBEEE2;
  --ink: #2B1B22;
  --head: #7E1F30;
  --muted: #8A4553;
  --rule: rgba(126, 31, 48, 0.20);
  --rule-strong: rgba(126, 31, 48, 0.34);
  --hover: rgba(126, 31, 48, 0.04);
  --accent: #B93348;
  --accent-hi: #7E1F30;
  --btn-ink: #FFFFFF;
}

/* Dark theme, toggled by the #theme-switch checkbox — no JavaScript. */
:root:has(#theme-switch:checked) {
  --ground: #7E1F30;
  --panel: #9E2639;
  --panel-2: #B93348;
  --ink: #FBEEE2;
  --head: #FFFFFF;
  --muted: #E8D3BE;
  --rule: rgba(251, 238, 226, 0.18);
  --rule-strong: rgba(251, 238, 226, 0.34);
  --hover: rgba(251, 238, 226, 0.05);
  --accent: #F0A05A;
  --accent-hi: #F6BC84;
  --btn-ink: #2B1B22;
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
.section { scroll-margin-top: 24px; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: 'Computer Modern Serif', 'Latin Modern Roman', Georgia, serif;
  font-size: 19px;
  line-height: 1.7;
  letter-spacing: 0.01em;
  font-feature-settings: 'liga' 1, 'onum' 1;
  transition: background-color 260ms ease-out, color 260ms ease-out;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent-hi); }
::selection { background: var(--accent); color: var(--btn-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.mono {
  font-family: 'Computer Modern Typewriter', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.sans { font-family: 'Computer Modern Sans', system-ui, sans-serif; }

.justify { text-align: justify; hyphens: auto; }

/* ---------- shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 20rem minmax(0, 1fr) 12rem;
  min-height: 100vh;
  max-width: 78rem;
  margin: 0 auto;
}

/* ---------- sidebar ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  position: sticky;
  top: 0;
  align-self: start;
  padding: 64px 40px 40px;
  background: var(--panel);
  border-right: 1px solid var(--rule);
}

.portrait {
  margin: 0 0 28px;
  border: 1px solid var(--rule);
  background: var(--panel-2);
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

.portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.05);
  transition: filter 400ms ease-out;
}

.portrait:hover img { filter: none; }

.sidebar h1 {
  margin: 0 0 16px;
  font-weight: 400;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--head);
}

.tagline {
  margin: 0 0 32px;
  font-family: 'Computer Modern Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
}

.meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}

.meta .spaced { margin-top: 16px; }
.meta a,
.links a {
border-bottom: 1px solid var(--accent); }

/* Visually hidden, still focusable by keyboard. */
.theme-switch,
.sub-switch {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.rail {
  padding: 64px 24px 40px 32px;
  border-left: 1px solid var(--rule);
}

.toc {
  position: sticky;
  top: 64px;
}

.toc-label {
  margin-bottom: 12px;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.toc ul { margin: 0; padding: 0; list-style: none; }
.toc li + li { margin-top: 8px; }

.toc a {
  display: block;
  color: var(--muted);
  border-bottom: 0;
  transition: color 150ms ease-out;
}

.toc a:hover,
.toc a:focus-visible { color: var(--accent-hi); }
.toc a.active { color: var(--accent); }

.toc .sub {
  margin-top: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--rule);
  font-size: 13px;
}

/* The caret only exists on the mobile dropdown; the rail shows .sub inline. */
.sub-toggle { display: none; }
.sub-switch:focus-visible ~ .sub-toggle { outline: 2px solid var(--accent); outline-offset: 2px; }

.section:target .section-label { color: var(--accent); }

.theme-toggle {
  display: inline-block;
  font-family: 'Computer Modern Typewriter', monospace;
  font-size: 13px;
  letter-spacing: 0.04em;
  line-height: 1;
  padding: 11px 16px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 150ms ease-out, border-color 150ms ease-out;
}

.theme-toggle:hover { color: var(--accent-hi); border-color: var(--accent); }
.theme-switch:focus-visible + .theme-toggle { outline: 2px solid var(--accent); outline-offset: 2px; }

.theme-toggle .on-dark { display: none; }
:root:has(#theme-switch:checked) .theme-toggle .on-light { display: none; }
:root:has(#theme-switch:checked) .theme-toggle .on-dark { display: inline; }

/* ---------- main column ---------- */

.main { padding: 64px 64px 0; max-width: 52rem; }

.section { padding-bottom: 96px; }

.section-label {
  margin-bottom: 24px;
  font-family: 'Computer Modern Typewriter', monospace;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.section-label.ruled {
  position: relative;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule-strong);
}

.section-label.ruled::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 2.5rem;
  height: 1px;
  background: var(--accent);
}

.lede {
  position: relative;
  margin: 0 0 28px;
  padding-bottom: 20px;
  max-width: 44rem;
  text-wrap: balance;
  font-size: clamp(22px, 2.4vw, 26px);
  line-height: 1.35;
  letter-spacing: -0.012em;
  color: var(--head);
}

/* Hairline that fades out under the opening line. */
.lede::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 8rem;
  height: 1px;
  background: linear-gradient(to right, var(--accent), transparent);
}

.body { margin: 0 0 16px; max-width: 32rem; }
.body:last-child { margin-bottom: 0; }
.result { margin: 0 0 20px; max-width: 32rem; font-size: 17px; color: var(--muted); }

/* ---------- stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
}

.stat {
  padding: 24px 20px;
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
}

.stat-figure { margin-bottom: 8px; font-size: 40px; line-height: 1; color: var(--head); }
.stat-label { font-family: 'Computer Modern Typewriter', monospace; font-size: 13px; line-height: 1.5; color: var(--muted); }

/* ---------- ledger rows ---------- */

.entries { list-style: none; margin: 0; padding: 0; }

.entry {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0 32px;
  padding: 32px 20px;
  margin: 0 -20px;
  border-bottom: 1px solid var(--rule);
  transition: background-color 160ms ease-out, box-shadow 300ms ease-out;
}

.entry:hover {
  background-color: var(--hover);
  box-shadow: 0 18px 40px -26px rgba(0, 0, 0, 0.45);
}

.entry-date {
  padding-top: 0.5em;
  font-family: 'Computer Modern Typewriter', monospace;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
}

.entry h2 {
  margin: 0 0 6px;
  font-weight: 700;
  font-size: 26px;
  line-height: 1.3;
  color: var(--head);
}

.entry-role {
  margin-bottom: 16px;
  font-family: 'Computer Modern Typewriter', monospace;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- tags ---------- */

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

.tags li {
  padding: 6px 13px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  font-family: 'Computer Modern Typewriter', monospace;
  font-size: 13px;
  line-height: 1.35;
  color: var(--muted);
}

/* ---------- project links + shots ---------- */

.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: baseline;
  font-family: 'Computer Modern Sans', system-ui, sans-serif;
  font-size: 15px;
}

.project-links a { border-bottom: 1px solid var(--accent); padding-bottom: 1px; }
.project-links a.site { white-space: nowrap; }
.project-links .stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: 'Computer Modern Typewriter', monospace;
  font-size: 13px;
  color: var(--muted);
}

.shots {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 0 0 24px;
  max-width: 32rem;
}

.shot {
  border: 1px solid var(--rule);
  background: var(--panel-2);
  aspect-ratio: 16 / 10;
  overflow: hidden;
}

.shot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.05);
  transition: filter 400ms ease-out;
  will-change: transform;
}

.shot:hover img { filter: none; }

/* ---------- quote ---------- */

.pull {
  margin: 0;
  padding: 40px 40px 40px 24px;
  border-left: 2px solid var(--accent);
  background: var(--panel-2);
}

.pull p { margin: 0 0 16px; max-width: 32rem; font-size: 24px; line-height: 1.5; color: var(--head); }
.pull footer { font-family: 'Computer Modern Typewriter', monospace; font-size: 14px; color: var(--muted); }

/* ---------- toolkit ---------- */

.toolkit { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 32px; }
.toolkit dt { margin-bottom: 12px; font-family: 'Computer Modern Typewriter', monospace; font-size: 13px; letter-spacing: 0.06em; color: var(--muted); }
.toolkit dd { margin: 0; font-size: 17px; line-height: 1.6; }
.tool-list { margin: 0; padding: 0; list-style: none; }
.tool { display: flex; align-items: center; gap: 10px; }
.tool-logo { flex: none; color: var(--muted); transition: color 200ms ease-out, transform 200ms ease-out; }
.tool:hover .tool-logo { color: var(--accent); transform: translateY(-1px); }

/* ---------- contact ---------- */

.actions { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }

.btn {
  display: inline-block;
  padding: 14px 28px;
  border-radius: 8px;
  font-family: 'Computer Modern Sans', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1;
  transition: background-color 150ms ease-out;
}

.btn-solid { background: var(--accent); color: var(--btn-ink); }
.btn-solid:hover { background: var(--accent-hi); color: var(--btn-ink); }
.btn-outline { border: 1.5px solid var(--ink); color: var(--ink); }
.btn-outline:hover { background: var(--panel-2); }

/* ---------- colophon ---------- */

.colophon {
  padding: 32px 0 48px;
  border-top: 1px solid var(--rule);
  font-family: 'Computer Modern Typewriter', monospace;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

.colophon p { margin: 0; max-width: 34rem; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  p, .justify { text-align: left; hyphens: none; }

  /* Flex column, not grid: a grid item's row track is its own height, so
     position: sticky has nowhere to travel. */
  .shell {
    display: flex;
    flex-direction: column;
  }
  .sidebar {
    position: static;
    display: block;
    padding: 48px 24px 32px;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }
  .theme-switcher { margin-top: 32px; }

  /* Order on a phone: portrait and name, then the TOC, then the sections. */
  .sidebar { order: 1; }
  .rail { order: 2; }
  .main { order: 3; }

  .rail {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 12px 24px;
    background: var(--ground);
    border-left: 0;
    border-bottom: 1px solid var(--rule-strong);
  }

  .toc { position: static; }
  .toc-label { display: none; }
  .toc ul {
    display: flex;
    flex-wrap: nowrap;
    gap: 20px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .toc ul::-webkit-scrollbar { display: none; }
  .toc li + li { margin-top: 0; }

  /* Projects becomes a dropdown: the link still jumps, the caret opens the list. */
  .toc-projects { position: relative; display: flex; align-items: center; gap: 4px; }

  .sub-toggle {
    display: inline-block;
    padding: 0 4px;
    color: var(--muted);
    cursor: pointer;
    transition: transform 200ms ease-out, color 150ms ease-out;
  }

  .toc-projects:has(.sub-switch:checked) .sub-toggle {
    transform: rotate(180deg);
    color: var(--accent);
  }

  /* The row scrolls sideways, which would clip the panel; stop clipping while open. */
  .toc:has(.sub-switch:checked) ul { overflow: visible; }

  .toc .sub {
    display: none;
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    z-index: 2;
    min-width: 13rem;
    margin: 0;
    padding: 12px 16px;
    background: var(--panel);
    border: 1px solid var(--rule-strong);
    box-shadow: 0 18px 40px -26px rgba(0, 0, 0, 0.45);
  }

  .toc-projects:has(.sub-switch:checked) .sub { display: block; }
  .toc .sub li + li { margin-top: 8px; }
  .entry { scroll-margin-top: 64px; }
  .toc a { white-space: nowrap; }

  .main { padding: 40px 24px 0; max-width: none; }
  /* Clear the sticky TOC strip when jumping to a section. */
  .section { scroll-margin-top: 64px; }
  .entry { grid-template-columns: 1fr; gap: 8px; }
  .entry-date { padding-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}

@media print {
  .theme-switcher,
  .toc { display: none; }
  .shell { grid-template-columns: 16rem 1fr; }
  .rail { display: none; }
  .sidebar { position: static; }
}
