/* Matthew Boutros — shared styles. Values match the approved design-canvas pages. */

/* Geist Mono, served from this site (no Google Fonts). SIL OFL 1.1, see GeistMono-OFL.txt. */
@font-face {
  font-family: 'Geist Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/GeistMono-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/GeistMono-Medium.woff2') format('woff2');
}

:root {
  --ink: #000000;
  --ground: #FFFFFF;
  --hover: #6B6B6B;
  --soft: #6B6B6B;
  --font: 'Geist Mono', ui-monospace, Menlo, monospace;
}

html {
  background: var(--ground);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
}

a { color: var(--ink); }
a:hover { color: var(--hover); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  margin: 0;
}

/* ---------- Background blobs: 3 black + 2 white, each 3 soft lobes ---------- */

.blobs {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.blobs-field {
  position: absolute;
  inset: -15%;
  filter: blur(96px);
  opacity: 0.45;
}
.mb-blob { position: absolute; will-change: transform; }
.mb-b1 { width: 40vmax; height: 36vmax; left: 0%;  top: 4%;  color: #000000; animation: mb-d1 58s ease-in-out infinite alternate; }
.mb-b2 { width: 34vmax; height: 38vmax; left: 58%; top: -4%; color: #000000; animation: mb-d2 71s ease-in-out infinite alternate; }
.mb-b3 { width: 38vmax; height: 32vmax; left: 32%; top: 54%; color: #000000; animation: mb-d3 64s ease-in-out infinite alternate; }
.mb-w1 { width: 30vmax; height: 27vmax; left: 20%; top: 22%; color: #FFFFFF; animation: mb-d2 49s ease-in-out infinite alternate-reverse; }
.mb-w2 { width: 27vmax; height: 30vmax; left: 64%; top: 46%; color: #FFFFFF; animation: mb-d1 55s ease-in-out infinite alternate-reverse; }
.mb-l {
  position: absolute;
  display: block;
  background: radial-gradient(closest-side, currentColor 0%, currentColor 12%, transparent 100%);
  will-change: transform;
}
.mb-l1 { width: 82%; height: 44%; left: 2%;  top: 18%; animation: mb-o1 37s ease-in-out infinite alternate; }
.mb-l2 { width: 50%; height: 86%; left: 40%; top: 4%;  animation: mb-o2 43s ease-in-out infinite alternate; }
.mb-l3 { width: 64%; height: 38%; left: 20%; top: 56%; animation: mb-o3 31s ease-in-out infinite alternate; }
.mb-b2 .mb-l { animation-delay: -13s; }
.mb-b3 .mb-l { animation-delay: -27s; animation-direction: alternate-reverse; }
.mb-w1 .mb-l { animation-delay: -7s; }
.mb-w2 .mb-l { animation-delay: -19s; animation-direction: alternate-reverse; }
@keyframes mb-d1 { 0% { transform: translate(0,0) rotate(0deg) scale(1,1); } 50% { transform: translate(16vw,12vh) rotate(40deg) scale(1.25,0.8); } 100% { transform: translate(6vw,26vh) rotate(-20deg) scale(0.85,1.2); } }
@keyframes mb-d2 { 0% { transform: translate(0,0) rotate(0deg) scale(1,1); } 50% { transform: translate(-18vw,14vh) rotate(-35deg) scale(0.8,1.25); } 100% { transform: translate(-8vw,-6vh) rotate(25deg) scale(1.2,0.9); } }
@keyframes mb-d3 { 0% { transform: translate(0,0) rotate(0deg) scale(1,1); } 50% { transform: translate(14vw,-18vh) rotate(30deg) scale(1.3,0.85); } 100% { transform: translate(-14vw,-8vh) rotate(-30deg) scale(0.9,1.15); } }
@keyframes mb-o1 { 0% { transform: translate(0,0) rotate(0deg) scale(1,1); } 50% { transform: translate(12%,18%) rotate(35deg) scale(1.15,0.8); } 100% { transform: translate(-8%,6%) rotate(-25deg) scale(0.9,1.25); } }
@keyframes mb-o2 { 0% { transform: translate(0,0) rotate(0deg) scale(1,1); } 50% { transform: translate(-18%,10%) rotate(-40deg) scale(0.8,1.2); } 100% { transform: translate(10%,-12%) rotate(20deg) scale(1.25,0.9); } }
@keyframes mb-o3 { 0% { transform: translate(0,0) rotate(0deg) scale(1,1); } 50% { transform: translate(14%,-16%) rotate(50deg) scale(1.3,0.75); } 100% { transform: translate(-12%,8%) rotate(-15deg) scale(0.95,1.1); } }
@media (prefers-reduced-motion: reduce) {
  .mb-blob, .mb-l { animation: none; }
}

/* ---------- Color Blast (secret) ----------
   html.mb-blast  black page, white text          (hard cut)
   html.mb-glow   colour visible                   (added 0.8 s later when toggled on)
   html.mb-swell  colour fades in over 3 s         (only while toggling on)
   html.mb-nogl   no WebGL: show the blobs recoloured instead of the canvas */

.blast-canvas {
  position: fixed;
  left: -12%;
  top: -12%;
  z-index: 0;
  display: block;
  width: 124%;
  height: 124%;
  pointer-events: none;
  filter: blur(36px) saturate(1.8);
  opacity: 0;
  visibility: hidden;
}
.mb-blast {
  --ink: #FFFFFF;
  --ground: #000000;
  --hover: #BDBDBD;
  --soft: #FFFFFF;
}
.mb-blast body { text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55); }
.mb-blast .blast-canvas { visibility: visible; }
.mb-blast.mb-glow .blast-canvas { opacity: 1; }
.mb-blast.mb-nogl .blast-canvas { display: none; }
.mb-blast:not(.mb-nogl) .blobs { display: none; }
.mb-blast .blobs { opacity: 0; }
.mb-blast.mb-glow .blobs { opacity: 1; }
.mb-blast .blobs-field { opacity: 1; }
/* Only the swell-in is eased; the cut to black (and back to white) is always hard. */
.mb-swell.mb-glow .blast-canvas, .mb-swell.mb-glow .blobs { transition: opacity 3s ease-in; }
.mb-blast .mb-blob { mix-blend-mode: screen; }
.mb-blast .mb-b1 { color: #FF0A8A; }
.mb-blast .mb-b2 { color: #00E5FF; }
.mb-blast .mb-b3 { color: #FFE600; }
.mb-blast .mb-w1 { color: #7A00FF; }
.mb-blast .mb-w2 { color: #00FF5A; }

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

.site-header {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 24px;
  padding: 12px 24px;
  font-size: 11px;
  letter-spacing: 0.14em;
}
.site-header--landing {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  justify-content: flex-start;
}
.site-header a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
}
.site-header a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 5px;
}
.site-nav { display: flex; gap: 0 24px; }

/* ---------- Landing ---------- */

.landing {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 88px 16px;
}
.boxes {
  display: flex;
  align-items: flex-start;
  gap: clamp(12px, 2.4vw, 36px);
}
.box-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  /* 25% larger than the canvas design (Matt, Nov 18). On phones, capped so all three still fit. */
  width: min(clamp(125px, 18.75vw, 270px), calc((100vw - 56px) / 3));
  text-decoration: none;
}
.box {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  box-sizing: border-box;
  border: 1px solid currentColor;
  overflow: hidden;
}
.box-label { font-size: 11px; letter-spacing: 0.14em; }

.box--photo { background: #000000; }
.box--photo img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.box--photo.is-black img { visibility: hidden; }

.box--acad {
  background: #000000;
  color: #FFFFFF;
  font-family: var(--font);
  font-size: clamp(6px, 0.85vw, 12.5px);
  line-height: 1.15;
  text-shadow: none;
}
.acad-rows {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.acad-row {
  display: block;
  flex: 0 0 auto;
  width: max-content;
  white-space: pre;
  will-change: transform;
}

/* ---------- Inner pages ---------- */

.page {
  position: relative;
  z-index: 1;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Photos */
.page--photos { max-width: 1200px; padding: 72px 24px 120px; }
.photo-grid {
  --cell: 150px;
  --gap-x: 32px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--cell), 1fr));
  gap: 48px var(--gap-x);
}
/* Phones: two columns instead of one (not in the canvas design, which was desktop-only). */
@media (max-width: 520px) {
  .photo-grid { --cell: 120px; --gap-x: 20px; row-gap: 32px; }
}
/* Each photo keeps its shape inside a square cell, 88% of the cell on its long side.
   The img carries width/height attributes, so it has its real shape (and gets lazy-loaded)
   before the file arrives. */
.photo-cell {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
}
.photo-cell img {
  position: absolute;
  inset: 0;
  margin: auto;
  display: block;
  width: 88%;
  height: auto;
}
.photo-cell img.tall { width: auto; height: 88%; }
.photo-grid[hidden], .viewer[hidden] { display: none; }

.viewer {
  display: flex;
  flex-direction: column;
  gap: 24px;
  outline: none;
}
.viewer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  font-size: 11px;
  letter-spacing: 0.14em;
}
.plain-btn {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-shadow: inherit;
  cursor: pointer;
}
.plain-btn:hover { color: var(--hover); }
.back-btn { gap: 10px; min-height: 44px; }
.step-btn { justify-content: center; width: 44px; height: 44px; }
.viewer-steps { display: flex; align-items: center; gap: 4px; }
.viewer-count { margin: 0; min-width: 64px; text-align: center; }
.viewer-fig { display: table; margin: 0 auto; }
.viewer-img-btn { display: block; padding: 0; border: 0; background: transparent; cursor: pointer; }
.viewer-img {
  display: block;
  max-width: 100%;
  max-height: min(80vh, 920px);
  width: auto;
  height: auto;
}
.viewer-cap {
  display: table-caption;
  caption-side: bottom;
  padding-top: 24px;
  font-size: 11px;
  letter-spacing: 0.1em;
  line-height: 1.8;
}
.viewer-cap p { margin: 0; }
.viewer-cap p:empty { display: none; }
.viewer-cap .cap-title { font-weight: 500; letter-spacing: 0.14em; }
.viewer-cap .cap-blurb {
  margin-top: 16px;
  max-width: 46ch;
  font-size: 12px;
  letter-spacing: 0;
  line-height: 1.7;
}

/* Academia */
.page--text { max-width: 960px; padding: 96px 24px 120px; }
.works {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--ink);
  font-size: 11px;
  letter-spacing: 0.1em;
  line-height: 1.8;
}
.works li { border-bottom: 1px solid var(--ink); }
.work {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 40px;
  padding: 20px 0;
  text-decoration: none;
}
.work-n { flex: 0 0 32px; }
.work-main { flex: 999 1 360px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.work-title { font-weight: 500; letter-spacing: 0.12em; }
.work-desc { max-width: 60ch; font-size: 12px; letter-spacing: 0; line-height: 1.7; }
.work-type { flex: 0 1 200px; }
.work-status { flex: 0 0 110px; text-align: right; }
.disclaimer {
  margin: 56px 0 0;
  max-width: 64ch;
  font-size: 11px;
  letter-spacing: 0.04em;
  line-height: 1.8;
  color: var(--soft);
}

/* Me */
.page--me {
  max-width: 960px;
  padding: 96px 24px 120px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 48px 64px;
}
.portrait {
  flex: 0 0 auto;
  display: block;
  width: clamp(200px, 26vw, 300px);
  aspect-ratio: 3 / 4;
  height: auto;
  object-fit: cover;
}
.me-info {
  flex: 999 1 320px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 32px;
  font-size: 11px;
  letter-spacing: 0.1em;
  line-height: 1.8;
}
.me-info p { margin: 0; }
.me-name { margin: 0; font-size: 11px; font-weight: 500; letter-spacing: 0.14em; }
.me-bio { max-width: 46ch; font-size: 12px; letter-spacing: 0; line-height: 1.7; }
.me-bio p + p { margin-top: 12px; }
.me-links { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 24px; }
.me-links dd { margin: 0; }

/* 404 */
.page--404 { max-width: 960px; padding: 96px 24px 120px; font-size: 11px; letter-spacing: 0.14em; line-height: 1.8; }
.page--404 p { margin: 0; }

/* ---------- Reader (CV and Academia): page view + text view ---------- */

.page--doc { max-width: 1200px; padding: 24px 24px 120px; }
.doc-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  height: 1px;
  pointer-events: none;
}
.doc-progress span { display: block; width: 0; height: 1px; background: var(--ink); }
.doc-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px 16px;
  margin: 0 0 24px;
  font-size: 11px;
  letter-spacing: 0.14em;
}
.doc-back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  text-decoration: none;
}
.doc-views { display: flex; gap: 0 18px; }
.doc-views a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--soft);
  text-decoration: none;
}
.doc-views a:hover { color: var(--ink); }
.doc-views a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-underline-offset: 5px; }
.doc-bar .doc-steps, .doc-time { justify-self: end; }
.doc-time { margin: 0; color: var(--soft); }

/* Page view: the real pages, one at a time once reader.js is running (all stacked without it). */
.doc-pages { display: flex; flex-direction: column; align-items: center; gap: 32px; }
.doc-page {
  position: relative;
  margin: 0;
  width: min(820px, 100%);
  background: #FFFFFF;
  outline: 1px solid var(--ink);
  cursor: pointer;
}
.doc-page img { display: block; width: 100%; height: auto; }
.doc-pages.is-flip .doc-page { display: none; }
.doc-pages.is-flip .doc-page.is-current { display: block; }
.text-layer { position: absolute; inset: 0; overflow: hidden; line-height: 1; text-shadow: none; white-space: pre; }
.text-layer span {
  position: absolute;
  white-space: pre;
  color: transparent;
  transform-origin: 0 0;
  font-family: Arial, Helvetica, sans-serif;
  cursor: text;
}
.text-layer ::selection { background: rgba(0, 80, 255, 0.25); color: transparent; }
.doc-cap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 24px;
  font-size: 11px;
  letter-spacing: 0.1em;
  line-height: 1.8;
  text-align: center;
}
.doc-cap p { margin: 0; }
.doc-cap-title { letter-spacing: 0.14em; }
.doc-cap-meta, .doc-end { color: var(--soft); }
.doc-cap-meta a, .doc-end a { color: var(--ink); text-underline-offset: 4px; }
.doc-steps--bottom { margin-top: 8px; }

/* Text view: one column in the site's type; footnotes in the margin on wide screens,
   tap the number to open them in place on narrow ones (no script needed). */
.doc-article { max-width: 600px; margin: 0 auto; }
.doc-head { margin: 24px 0 32px; }
.doc-title { margin: 0 0 4px; font-size: 11px; font-weight: 500; letter-spacing: 0.14em; line-height: 1.8; }
.doc-byline { margin: 0; font-size: 11px; letter-spacing: 0.12em; color: var(--soft); }
.doc-body { font-size: 13px; line-height: 1.75; letter-spacing: 0; }
.doc-body p { margin: 0 0 1.1em; }
.doc-body .c { text-align: center; }
.doc-body h2, .doc-body h3, .doc-body h4 {
  margin: 2.4em 0 1em;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  line-height: 1.8;
  text-transform: uppercase;
}
.doc-body h3 { font-weight: 400; }
.doc-body h4 { font-weight: 400; letter-spacing: 0.06em; text-transform: none; }
.doc-body .doc-h1 { margin-top: 0; }
.doc-body .doc-sub { color: var(--soft); }
.doc-body blockquote { margin: 0 0 1.1em; padding-left: 2.5em; }
.doc-body .sc { font-variant: small-caps; letter-spacing: 0.04em; }
.doc-body a { text-underline-offset: 3px; }
.doc-table { overflow-x: auto; margin: 0 0 1.1em; }
.doc-table table { border-collapse: collapse; font-size: 12px; }
.doc-table td { padding: 6px 12px 6px 0; border-top: 1px solid var(--ink); vertical-align: top; }
.doc-end { margin: 48px 0 0; font-size: 11px; letter-spacing: 0.1em; }
.fn-ref {
  padding: 0 1px;
  font-size: 10px;
  line-height: 0;
  vertical-align: super;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.fn-toggle { display: none; }
.sidenote { display: none; }
.fn-n { font-weight: 500; }
.fn-toggle:checked + .sidenote {
  display: block;
  margin: 8px 0;
  padding: 6px 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  font-size: 11px;
  line-height: 1.6;
  letter-spacing: 0.02em;
}
@media (min-width: 1100px) {
  .doc-article { margin-left: max(0px, calc(50% - 430px)); }
  .fn-ref { text-decoration: none; cursor: default; }
  .sidenote, .fn-toggle:checked + .sidenote {
    display: block;
    position: relative;
    float: right;
    clear: right;
    width: 220px;
    margin: 0.2em -260px 12px 0;
    padding: 0;
    border: 0;
    font-size: 11px;
    line-height: 1.6;
    letter-spacing: 0.02em;
  }
}
@media (max-width: 640px) {
  .doc-bar { grid-template-columns: 1fr auto; }
  .doc-bar .doc-views { grid-column: 2; grid-row: 1; justify-self: end; }
  .doc-bar .doc-steps, .doc-bar .doc-time { grid-column: 1 / -1; justify-self: center; }
}
