/* Patrick Anthony portfolio
   Engineering notebook layout: warm paper, ruled lines, mono labels, photos first. */

/* ---------- Fonts (self-hosted, IBM Plex, SIL OFL) ---------- */
@font-face {
  font-family: "IBM Plex Sans";
  src: url("../assets/fonts/ibm-plex-sans-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../assets/fonts/ibm-plex-mono-400-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../assets/fonts/ibm-plex-mono-500-latin.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --bg: #F6F5F2;
  --surface: #FFFFFF;
  --text: #161616;
  --muted: #5A5A5A;
  --rule: #D8D5CE;
  --accent: #B4441F;

  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --max: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
  --gap: 24px;
  --measure: 68ch;
  --header-h: 64px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-kerning: normal;
  overflow-wrap: break-word;
}

@media (min-width: 1024px) {
  body { font-size: 1.125rem; }
}

img { display: block; max-width: 100%; height: auto; }
picture { display: block; }
figure { margin: 0; }

h1, h2, h3, h4 {
  margin: 0 0 0.5em;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
h1 { font-size: clamp(2.375rem, 1.6rem + 3.4vw, 4rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.75rem, 1.45rem + 1.4vw, 2.375rem); }
h3 { font-size: 1.3125rem; line-height: 1.3; }
h4 { font-size: 1.0625rem; line-height: 1.4; }

p, ul, ol, dl { margin: 0 0 1em; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { text-decoration-thickness: 2px; }

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

strong { font-weight: 600; }

.icon { flex: none; }

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

.container {
  width: 100%;
  max-width: calc(var(--max) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.label {
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.lede {
  max-width: var(--measure);
  font-size: clamp(1.125rem, 1.05rem + 0.35vw, 1.25rem);
  line-height: 1.55;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--gutter);
  z-index: 100;
  padding: 12px 16px;
  background: var(--text);
  color: var(--surface);
  text-decoration: none;
}
.skip-link:focus { top: 8px; }

/* ---------- Header and navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 16px;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text);
  font-weight: 600;
  font-size: 1.0625rem;
  text-decoration: none;
}
.brand:hover { text-decoration: underline; text-decoration-color: var(--accent); }

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  color: var(--text);
  font-size: 0.9375rem;
  text-decoration: none;
}
.site-nav a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.site-nav a[aria-current] { box-shadow: inset 0 -2px 0 var(--accent); }

.nav-toggle { display: none; }

@media (max-width: 767px) {
  .js .nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 14px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 2px;
    color: var(--text);
    font: inherit;
    font-size: 0.9375rem;
    cursor: pointer;
  }
  .js .site-nav { display: none; width: 100%; }
  .js .site-nav.is-open { display: block; }
  .js .site-nav ul { flex-direction: column; padding-bottom: 12px; }
  .js .site-nav a { width: 100%; padding: 0; border-top: 1px solid var(--rule); }
  .js .site-nav a[aria-current] { box-shadow: inset 2px 0 0 var(--accent); padding-left: 12px; }
}

/* ---------- Sections ---------- */
.section {
  padding-block: clamp(56px, 3rem + 4vw, 112px);
  border-top: 1px solid var(--rule);
}

.section-head {
  margin-bottom: clamp(28px, 4vw, 48px);
}
.section-head .label { margin-bottom: 8px; }
.section-head h2 { margin-bottom: 0.35em; }
.section-head p { margin-bottom: 0; }

/* ---------- Buttons ---------- */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 1em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  background: transparent;
  border: 1px solid var(--text);
  border-radius: 2px;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--text); color: var(--surface); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--surface);
}
.btn-primary:hover { background: var(--text); border-color: var(--text); }

/* ---------- Hero ---------- */
.hero { padding-block: clamp(40px, 6vw, 88px) clamp(56px, 6vw, 104px); }

.hero-grid { display: grid; gap: 40px; }

.hero-sub {
  max-width: 40ch;
  font-size: clamp(1.1875rem, 1.05rem + 0.6vw, 1.375rem);
  line-height: 1.5;
}

.availability {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 28px 0;
  padding: 14px 0;
  border-block: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.5;
}
.availability::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  background: var(--accent);
  transform: translateY(-1px);
}

.hero-note { font-size: 0.9375rem; color: var(--muted); }
.hero-note a { color: var(--text); }

@media (min-width: 1024px) {
  .hero-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--gap);
    align-items: center;
  }
  .hero-text { grid-column: 1 / span 5; }
  .hero-figure { grid-column: 6 / span 7; }
}

/* ---------- Figures ---------- */
.fig img { width: 100%; background: var(--rule); }

figcaption {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--muted);
}
.fig-num { flex: none; color: var(--text); font-weight: 500; }

.fig--portrait { max-width: 28rem; }

.fig-pair {
  display: grid;
  gap: var(--gap);
  align-items: start;
}
@media (min-width: 640px) {
  .fig-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.placeholder-box {
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--surface);
  border: 1px dashed var(--muted);
  font-family: var(--mono);
  font-size: 0.875rem;
  color: var(--muted);
  text-align: center;
}

/* ---------- Project cards ---------- */
.projects-grid { display: grid; gap: var(--gap); }

@media (min-width: 768px) {
  .projects-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 2px;
}

.card-media img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--rule);
}

.card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  padding: 20px 24px 16px;
}
.card-body h3 { margin: 0; }
.card-body p { margin: 0; }

.card-link {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-height: 44px;
  margin-top: auto;
  font-weight: 500;
}

@media (min-width: 768px) {
  .card--small { flex-direction: row; }
  .card--small .card-media { flex: 0 0 40%; }
  .card--small .card-media picture,
  .card--small .card-media img { height: 100%; }
  .card--small .card-media img { aspect-ratio: auto; min-height: 260px; }
  .card--small h3 { font-size: 1.1875rem; }
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tags li {
  padding: 5px 8px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.2;
  color: var(--muted);
}

/* ---------- Experience ---------- */
.timeline {
  margin: 0 0 1.5em;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--rule);
}
.timeline li {
  display: grid;
  gap: 4px 32px;
  padding: 20px 0;
  border-bottom: 1px solid var(--rule);
}
.timeline h3 { margin: 0; font-size: 1.0625rem; }
.timeline .org { color: var(--muted); font-weight: 400; }
.timeline p { margin: 4px 0 0; max-width: var(--measure); }

@media (min-width: 768px) {
  .timeline li { grid-template-columns: 12rem minmax(0, 1fr); }
  .timeline .label { padding-top: 3px; }
}

/* ---------- Tables ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--rule);
}
.data-table th,
.data-table td {
  padding: 14px 20px;
  border-top: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}
.data-table thead th {
  border-top: 0;
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.data-table tbody th { width: 32%; font-weight: 600; }
.data-table td a { white-space: nowrap; }

@media (max-width: 639px) {
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .data-table tr { display: block; padding: 14px 16px; border-top: 1px solid var(--rule); }
  .data-table tbody tr:first-child { border-top: 0; }
  .data-table th,
  .data-table td { display: block; width: auto; padding: 0; border: 0; }
  .data-table tbody th { width: auto; margin-bottom: 4px; }
  .data-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-top: 8px;
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
  }
}

/* ---------- About ---------- */
.split { display: grid; gap: 8px 24px; }
.split > .prose p:last-child { margin-bottom: 0; }

@media (min-width: 1024px) {
  .split { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .split > .split-head { grid-column: 1 / span 4; }
  .split > .split-body { grid-column: 5 / span 8; }
}

.prose { max-width: var(--measure); }

/* ---------- Resume ---------- */
.resume-frame {
  display: block;
  width: 100%;
  max-width: 920px;
  height: min(1180px, 130vw);
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--rule);
}
.resume-mobile-note { display: none; }

@media (max-width: 767px) {
  .resume-frame { display: none; }
  .resume-mobile-note { display: block; color: var(--muted); font-size: 0.9375rem; }
}

/* ---------- Contact ---------- */
.contact-list {
  max-width: 760px;
  margin: 0 0 1.5em;
  border-top: 1px solid var(--rule);
}
.contact-list div {
  display: grid;
  gap: 2px 24px;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
}
.contact-list dt { padding-top: 3px; }
.contact-list dd { margin: 0; }

@media (min-width: 640px) {
  .contact-list div { grid-template-columns: 14rem minmax(0, 1fr); }
}

/* ---------- Case study pages ---------- */
.case-head { padding-block: clamp(40px, 6vw, 80px) clamp(32px, 4vw, 48px); }

.case-grid { display: grid; gap: 32px; }
.case-intro .label { margin-bottom: 12px; }
.case-intro .lede { margin-bottom: 0; }

@media (min-width: 1024px) {
  .case-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--gap);
    align-items: start;
  }
  .case-intro { grid-column: 1 / span 7; }
  .spec { grid-column: 9 / span 4; }
}

.spec {
  margin: 0;
  padding: 8px 20px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 2px;
}
.spec div { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.spec div:last-child { border-bottom: 0; }
.spec dt { margin-bottom: 2px; font-size: 0.75rem; }
.spec dd { margin: 0; font-size: 0.9375rem; line-height: 1.5; }

.case-lead { padding-bottom: clamp(48px, 6vw, 80px); }

.case-section {
  padding-block: clamp(48px, 2.5rem + 3vw, 88px);
  border-top: 1px solid var(--rule);
}

.case-section-grid { display: grid; gap: 8px var(--gap); }
.case-section-grid > .rail h2 { margin-bottom: 0.6em; }
.case-section-grid > .rail .label { margin-bottom: 8px; }
.content > p,
.content > ul,
.content > ol:not(.steps),
.content > .note { max-width: var(--measure); }
.content > figure,
.content > .fig-pair,
.content > .compare,
.content > .table-wrap { margin-block: 32px; }

@media (min-width: 1024px) {
  .case-section-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .case-section-grid > .rail { grid-column: 1 / span 3; }
  .case-section-grid > .content { grid-column: 4 / span 9; }
  .case-section-grid > .rail h2 { position: sticky; top: calc(var(--header-h) + 24px); font-size: 1.625rem; }
}

.content ul:not(.tags) { padding-left: 1.2em; }
.content li + li { margin-top: 0.4em; }

.steps { margin: 0; padding: 0; list-style: none; }
.steps > li { padding-block: 8px 24px; }
.steps > li + li { margin-top: 0; padding-top: 32px; border-top: 1px solid var(--rule); }
.steps > li > .label { margin-bottom: 6px; }
.steps > li > p,
.steps > li > .note { max-width: var(--measure); }
.steps > li > figure,
.steps > li > .fig-pair,
.steps > li > .compare { margin-block: 28px; }

.role {
  margin-block: 8px 40px;
  padding: 24px clamp(20px, 3vw, 32px) 8px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 2px;
}
.role > .label { margin-bottom: 6px; }
.role > p,
.role > dl { max-width: var(--measure); }
.role dt { font-weight: 600; }
.role dd { margin: 0 0 1em; }
.role figure { margin-block: 24px; }

.note {
  padding: 4px 0 4px 16px;
  border-left: 2px solid var(--accent);
  font-size: 0.9375rem;
}

.piece + .piece { margin-top: 48px; padding-top: 40px; border-top: 1px solid var(--rule); }
.piece .label { margin-bottom: 6px; }

/* ---------- Before / after comparison ---------- */
.compare-frame { display: grid; gap: var(--gap); }
.compare-item { position: relative; }
.compare-item img { width: 100%; background: var(--rule); }

.compare-tag {
  position: absolute;
  top: 12px;
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text);
}
.compare-before .compare-tag { left: 12px; }
.compare-after .compare-tag { right: 12px; }

.compare-handle { display: none; }

@media (min-width: 640px) {
  .compare-frame { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.compare.is-ready .compare-frame {
  --pos: 50%;
  position: relative;
  display: block;
  overflow: hidden;
  touch-action: pan-y;
  cursor: ew-resize;
  user-select: none;
  -webkit-user-select: none;
}
.compare.is-ready .compare-after {
  position: absolute;
  inset: 0;
  clip-path: inset(0 0 0 var(--pos));
}
.compare.is-ready .compare-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  display: block;
  width: 2px;
  margin-left: -1px;
  background: var(--surface);
  pointer-events: none;
}
.compare-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 1px solid var(--text);
  border-radius: 2px;
  color: var(--text);
}
.compare-range:focus-visible ~ .compare-handle .compare-knob {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.compare-help { margin-top: 6px; font-size: 0.875rem; color: var(--muted); }

/* ---------- Next project ---------- */
.next-project { border-top: 1px solid var(--rule); }
.next-project a {
  display: block;
  padding-block: clamp(40px, 6vw, 72px);
  color: var(--text);
  text-decoration: none;
}
.next-project .label { display: block; margin-bottom: 8px; }
.next-title {
  font-size: clamp(1.625rem, 1.3rem + 1.5vw, 2.5rem);
  font-weight: 600;
  line-height: 1.15;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.15em;
}
.next-project a:hover .next-title { text-decoration-color: var(--accent); }

/* ---------- Simple pages (legal, contact, 404) ---------- */
.page { padding-block: clamp(40px, 6vw, 88px) clamp(56px, 7vw, 112px); }
.page .label { margin-bottom: 12px; }
.page .prose h2 { margin-top: 1.6em; font-size: 1.375rem; }
.page .prose ul { padding-left: 1.2em; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--rule);
  background: var(--surface);
  font-size: 0.9375rem;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 24px;
  padding-block: 20px;
}
.footer-inner p { margin: 0; }
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 20px;
  margin: 0 0 0 auto;
  padding: 0;
  list-style: none;
}
.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text);
}
@media (max-width: 639px) {
  .footer-links { margin-left: 0; width: 100%; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
