/* micahjohnson.co — minimal, text-centric */

:root {
  --bg: #f2f0ed;
  --fg: #151515;
  --muted: #6b6b66;
  --rule: #e4e4df;
  --accent: #2f4fd8;
  --pos: #1f9d55;
  --mixed: #d4a300;
  --neg: #d64545;

  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: var(--sans);

  --step--1: clamp(0.8rem, 0.78rem + 0.1vw, 0.85rem);
  --step-0: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  --step-1: clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
  --step-2: clamp(1.75rem, 1.4rem + 1.6vw, 2.75rem);

  --measure: 44rem;
  --gutter: clamp(1rem, 5vw, 3rem);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110;
    --fg: #ecece8;
    --muted: #93938c;
    --rule: #2a2a28;
    --accent: #8ea2ff;
    --pos: #4cc27f;
    --mixed: #e3c04a;
    --neg: #f07070;
  }
}

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

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

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

.wrap {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---- Header / footer ---- */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding-block: clamp(2rem, 6vw, 4rem) 0;
  font-size: var(--step--1);
}

.site-header .name {
  font-size: 1.5em;
  font-weight: 300;
  text-decoration: none;
  color: var(--fg);
  white-space: nowrap;
}

.site-header nav {
  display: flex;
  gap: 1.25rem;
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-header nav .resume {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
}

.site-header nav .icon {
  width: 0.9em;
  height: 0.9em;
}

.site-header nav a:hover,
.site-header nav a[aria-current="page"] {
  color: var(--fg);
}

.menu-toggle {
  display: none;
  align-self: center;
  margin: -0.5rem -0.5rem -0.5rem 0;
  padding: 0.5rem;
  border: 0;
  background: none;
  color: var(--fg);
  cursor: pointer;
}

.menu-toggle svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.menu-toggle .close,
.site-header.is-open .menu-toggle .bars {
  display: none;
}

.site-header.is-open .menu-toggle .close {
  display: inline;
}

@media (max-width: 40rem) {
  .site-header.has-menu .menu-toggle {
    display: block;
  }

  .site-header.has-menu nav {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    gap: 0;
    margin-top: 0.5rem;
    border-top: 1px solid var(--rule);
    font-size: var(--step-0);
  }

  .site-header.has-menu.is-open nav {
    display: flex;
  }

  .site-header.has-menu nav a {
    padding-block: 0.75rem;
    border-bottom: 1px solid var(--rule);
  }
}

.site-footer {
  margin-top: clamp(4rem, 12vw, 8rem);
  padding-block: 2rem clamp(2rem, 6vw, 4rem);
  border-top: 1px solid var(--rule);
  font-size: var(--step--1);
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

.site-footer a {
  color: inherit;
}

/* ---- Typography ---- */

main {
  padding-top: clamp(3.5rem, 12vw, 7rem);
}

main:last-child {
  padding-bottom: clamp(2rem, 6vw, 4rem);
}

h1,
h2,
h3 {
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0;
}

h1 {
  font-size: var(--step-2);
  letter-spacing: -0.03em;
}

.lede {
  font-size: calc(var(--step-1) * 1.5);
  font-weight: 300;
  line-height: 1.45;
  letter-spacing: -0.01em;
  margin: 0;
  max-width: 32ch;
}

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

p {
  margin: 0 0 1.1em;
}

a {
  color: var(--fg);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--rule);
  text-underline-offset: 0.2em;
  transition: text-decoration-color 0.15s ease, color 0.15s ease;
}

a:hover {
  text-decoration-color: currentColor;
}

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

.label {
  font-family: var(--mono);
  font-size: var(--step--1);
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
  text-transform: lowercase;
  margin: 0 0 1.25rem;
}

section {
  margin-top: clamp(4rem, 12vw, 7rem);
}

/* ---- Work index ---- */

.work-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.work-list li {
  border-bottom: 1px solid var(--rule);
}

.work-list a {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "title year"
    "desc  desc";
  column-gap: 1rem;
  padding: 1rem 0;
  text-decoration: none;
}

.work-list .title {
  grid-area: title;
  font-weight: 400;
}

.work-list .desc {
  grid-area: desc;
  color: inherit;
  font-size: 16px;
  font-weight: 300;
}

.work-list .year {
  grid-area: year;
  font-family: var(--mono);
  font-size: var(--step--1);
  font-weight: 300;
  color: inherit;
  align-self: center;
}

.work-list a:hover .title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

@media (min-width: 40rem) {
  .work-list a {
    grid-template-columns: minmax(9rem, 14rem) 1fr auto;
    grid-template-areas: "title desc year";
    align-items: baseline;
  }
}

/* ---- Definition lists (contact, meta) ---- */

.links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

.meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1.5rem;
  margin: 1.75rem 0 0;
  font-size: var(--step--1);
}

.meta dt {
  font-family: var(--mono);
  color: var(--muted);
  text-transform: lowercase;
}

.meta dd {
  margin: 0;
}

/* ---- Project page ---- */

.prose {
  margin-top: clamp(2.5rem, 8vw, 4rem);
  font-size: 1rem;
}

.prose h2 {
  font-size: calc(var(--step-0) * 1.5);
  font-weight: 300;
  margin: 3.333em 0 0.5em;
}

.prose figure {
  margin: 2.5rem 0;
}

.prose img,
.prose video {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: clamp(3rem, 10vw, 5rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: var(--step--1);
}

.pager a {
  text-decoration: none;
}

.pager span {
  display: block;
  font-family: var(--mono);
  color: var(--muted);
}

.pager .next {
  text-align: right;
  margin-left: auto;
}

/* ---- Case study elements ---- */

article > h1 {
  font-size: clamp(1.875rem, 1.425rem + 2.25vw, 3rem);
  font-weight: 200;
  line-height: 1.1;
}

.subtitle {
  /* --step-1 scaled so it tops out at 20px (1.25rem) on desktop */
  font-size: calc(var(--step-1) * 5 / 6);
  line-height: 1.4;
  color: var(--muted);
  margin-top: 0.75rem;
  max-width: none;
}

.meta .note {
  color: var(--muted);
}

.stat {
  font-size: var(--step-1);
  line-height: 1.4;
}

.stat strong {
  display: block;
  font-size: var(--step-2);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.flow {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0;
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--muted);
}

.flow li:not(:last-child)::after {
  content: "→";
  margin: 0 0.6rem;
}

.pull {
  margin: 2rem 0;
  padding-left: 1.25rem;
  border-left: 2px solid var(--rule);
}

.pull.pos { border-color: var(--pos); }
.pull.neg { border-color: var(--neg); }

.pull p {
  font-size: var(--step-1);
  line-height: 1.4;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
}

.pull footer {
  font-size: var(--step--1);
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  margin: 2rem 0;
}

.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}

.data caption {
  text-align: left;
  font-family: var(--mono);
  color: var(--muted);
  text-transform: lowercase;
  padding-bottom: 0.5rem;
}

.data th,
.data td {
  text-align: left;
  vertical-align: baseline;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--rule);
}

.data .group th {
  padding-top: 1.75rem;
  font-weight: 600;
}

.data tbody:first-of-type .group th {
  padding-top: 0.75rem;
}

.data .n {
  width: 5.5rem;
  padding-right: 1rem;
  font-family: var(--mono);
  white-space: nowrap;
}

.dot {
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  margin-right: 0.5em;
  vertical-align: 0.05em;
  background: var(--muted);
}

.dot.pos { background: var(--pos); }
.dot.mixed { background: var(--mixed); }
.dot.neg { background: var(--neg); }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stats {
  list-style: none;
  margin: 2rem 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1.5rem 2rem;
  font-size: var(--step--1);
  color: var(--muted);
}

.stats li {
  padding-top: 0.75rem;
  border-top: 1px solid var(--rule);
}

.stats strong {
  display: block;
  font-size: var(--step-2);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--fg);
  margin-bottom: 0.4rem;
  font-variant-numeric: tabular-nums;
}

p.note {
  font-size: var(--step--1);
  color: var(--muted);
  margin-top: -1rem;
}

.prose ul {
  padding-left: 1.2em;
}

.prose li + li {
  margin-top: 0.35em;
}

.prose ul.stats {
  padding-left: 0;
}

.prose .stats li + li {
  margin-top: 0;
}

.options {
  margin: 1.5rem 0 2rem;
}

.options dt {
  font-weight: 600;
  margin-top: 1.25rem;
}

.options dd {
  margin: 0.25rem 0 0;
}

.chosen {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0 0.45em;
  border: 1px solid var(--pos);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: var(--step--1);
  font-weight: 400;
  color: var(--pos);
  text-transform: lowercase;
  vertical-align: 0.1em;
}

.gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 2rem 0;
}

.gallery figure {
  margin: 0;
}

@media (min-width: 40rem) {
  .gallery:not(.stacked) {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

/* Pure white page, light palette in both color schemes. */
.page-white {
  --bg: #fff;
  --fg: #151515;
  --muted: #6b6b66;
  --rule: #e4e4df;
  --accent: #2f4fd8;
  --pos: #1f9d55;
  --mixed: #d4a300;
  --neg: #d64545;
  color-scheme: light;
}

:root:has(.page-white) {
  color-scheme: light;
}

/* ---- Ambient background (home) ---- */

/* Slowly drifting topographic contours drawn by assets/flow.js.
   --flow-amount is the opacity of the fine lines; index lines are double. */
.ambient {
  --flow-amount: 0.07;
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

/* The home page keeps the lighter ground behind the contours. */
@media (prefers-color-scheme: light) {
  :root:has(.ambient) {
    --bg: #fafaf8;
  }
}

/* Rules are nudged darker so row dividers read apart from the contours. */
.ambient.has-flow ~ .wrap {
  --rule: #d6d6d1;
}

@media (prefers-color-scheme: dark) {
  .ambient {
    --flow-amount: 0.08;
  }

  .ambient.has-flow ~ .wrap {
    --rule: #353533;
  }
}

/* ---- Utilities ---- */

.placeholder {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 2px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  margin: 0;
  padding: 0.5rem 1rem;
  background: var(--fg);
  color: var(--bg);
  border-radius: 4px;
  font-size: var(--step--1);
  opacity: 0;
  transform: translate(-50%, 0.5rem);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

a[data-zoom] {
  display: block;
  cursor: zoom-in;
}

.zoom-layer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  cursor: zoom-out;
  outline: none;
}

.zoom-img {
  position: fixed;
  max-width: none;
  margin: 0;
  border-radius: 4px;
  transform-origin: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08), 0 12px 32px rgba(0, 0, 0, 0.16);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.35s ease;
  will-change: transform, opacity;
}

.zoom-layer.is-closing .zoom-img {
  opacity: 0;
}

::selection {
  background: var(--fg);
  color: var(--bg);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
