:root {
  --ink: #111;
  --muted: #58595b;
  --line: #e7e7e5;
  --glass: rgba(255, 255, 255, 0.55);
  --glass-edge: rgba(255, 255, 255, 0.7);
  --glass-shadow: 0 1px 0 rgba(0, 0, 0, 0.06), 0 10px 30px rgba(0, 0, 0, 0.06);
  --header-h: 72px;
  --gutter: max(16px, 4.41vw); /* the PDF's 54pt margin on a 1224pt page */
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Glass header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px var(--gutter);
  background: var(--glass);
  border-bottom: 1px solid var(--glass-edge);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(20px) saturate(170%);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
}

.contact {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 15px;
}
.contact a {
  position: relative;
  padding: 6px 0;
  color: #222;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease, opacity 0.15s ease;
}
.contact a:hover { color: #000; opacity: 0.65; }
.contact a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.contact .short { display: none; }

.brand {
  text-align: right;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.15;
}
.brand-name {
  display: block;
  font-size: clamp(18px, 1.8vw, 26px);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.brand-sub {
  display: block;
  margin-top: 3px;
  font-size: clamp(12px, 0.95vw, 14px);
}

/* On the portfolio the name starts on the cover and slides into the header once you scroll past it */
.site-header .brand { transition: opacity 0.3s ease, transform 0.3s ease; }
.site-header.brand-hidden .brand {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

.cover-brand {
  position: absolute;
  right: 4.41%;
  top: 18%;
  z-index: 1;
  margin: 0;
  text-align: right;
  font-weight: 400;
  line-height: 1.15;
}
.cover-brand .brand-name { font-size: 2cqw; font-weight: 600; letter-spacing: 0.01em; }
.cover-brand .brand-sub { margin-top: 0.5em; font-size: 1.1cqw; }

/* ---------- Pages ---------- */

.page {
  position: relative;
  width: 100%;
  container-type: inline-size;
  scroll-margin-top: var(--header-h);
}
.page + .page { border-top: 1px solid var(--line); }

.sheet { position: relative; }
.sheet > img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

/* Project titles, rebuilt as real text and set larger than in the PDF */
.page-head {
  position: absolute;
  left: 4.41%;
  top: 1.5%;
  max-width: 58%;
  z-index: 1;
}
.page-head h2 {
  margin: 0;
  font-size: 2.6cqw;
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: 0.005em;
  text-wrap: balance;
}
.page-head > p {
  margin: 0.45em 0 0;
  font-size: 1.3cqw;
  line-height: 1.3;
}
/* Project write-ups, moved from the inner pages into the cover page's white space */
.page-head.has-text { max-width: 60%; }
.project-text {
  margin-top: 2cqw;
  padding: 1.8cqw 2.1cqw;
  border: 1px solid #232021;
  background: #fbfbfa;
  columns: 2;
  column-gap: 2.8cqw;
  column-rule: 1px solid #e3e3e0;
  font-size: 1cqw;
  line-height: 1.55;
  color: #2b2b2b;
  orphans: 2;
  widows: 2;
}
.project-text p { margin: 0 0 0.85em; }
.project-text p:last-child { margin-bottom: 0; }

.page-head.compact h2 { font-size: 2cqw; }
.page-head.compact > p { font-size: 1.15cqw; margin-top: 0.3em; }

/* ---------- Table of contents ---------- */

.page.toc { aspect-ratio: 1224 / 792; }

.toc-item {
  position: absolute;
  left: calc(13.233% + var(--col) * 26.471%);
  top: calc(18.08% + var(--row) * 36.441%);
  width: 20.588%;
  color: var(--ink);
  text-decoration: none;
}
.toc-art {
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid #232021;
  background: #f2f2f2;
}
.toc-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1), filter 0.3s ease;
}
.toc-item:hover .toc-art img,
.toc-item:focus-visible .toc-art img { transform: scale(1.06); filter: contrast(1.08); }
.toc-item:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }

.toc-caption {
  display: flex;
  justify-content: space-between;
  gap: 0.5em;
  margin-top: 0.3cqw;
  font-size: 0.92cqw;
  white-space: nowrap;
}
.toc-caption span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}
.toc-item:hover .toc-caption span:first-child { color: var(--ink); }

/* ---------- Clickable hotspots laid over page images ---------- */

.hot {
  position: absolute;
  display: block;
  border-radius: 2px;
  color: var(--ink);
  text-decoration: none;
  transition: background-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.hot:hover { background: rgba(17, 17, 17, 0.08); }
.hot:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- Last page: contact, social and resume links ---------- */

.about-links {
  position: absolute;
  left: 4.41%;
  top: 11%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 2.6cqw;
}
.link-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.55cqw;
}
.link-group h3 {
  margin: 0 0 0.2cqw;
  font-size: 0.95cqw;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.link-group a {
  position: relative;
  font-size: 1.55cqw;
  line-height: 1.25;
  color: var(--ink);
  text-decoration: none;
  text-underline-offset: 0.22em;
  text-decoration-thickness: 1px;
}
.link-group a:hover { text-decoration-line: underline; }
.link-group a:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.link-group .arrow {
  display: inline-block;
  color: var(--muted);
  transition: transform 0.15s ease, color 0.15s ease;
}
.link-group a:hover .arrow { color: var(--ink); transform: translate(2px, -2px); }

/* ---------- Resume hover preview (the card itself is clickable) ---------- */

.peek {
  position: absolute;
  width: calc(clamp(150px, 15vw, 210px) + 14px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 30;
}
.peek.side { left: 100%; top: 0; padding-left: 14px; }
.peek.below { left: -8px; top: 100%; padding-top: 10px; }
a:hover > .peek,
a:focus-visible > .peek { opacity: 1; visibility: visible; transform: none; }

.peek-card {
  display: block;
  padding: 8px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.peek-card img { display: block; width: 100%; height: auto; aspect-ratio: 1700 / 2200; }
.peek-label {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: 0.02em;
}

/* ---------- Phones: titles and contents move out of the page art ---------- */

@media (max-width: 700px) {
  .site-header {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 16px;
  }
  .brand { text-align: left; }
  /* Phones keep the name in the header; the cover is too narrow for it */
  .site-header.brand-hidden .brand { opacity: 1; transform: none; pointer-events: auto; }
  .cover-brand { display: none; }
  .contact { gap: 18px; font-size: 13px; }
  .contact .full { display: none; }
  .contact .short { display: inline; }

  .page-head,
  .page-head.compact {
    position: static;
    max-width: none;
    padding: 18px 16px 12px;
  }
  .page-head h2,
  .page-head.compact h2 { font-size: 18px; }
  .page-head > p,
  .page-head.compact > p { font-size: 12px; }
  .page-head.has-text { max-width: none; }
  .project-text {
    columns: 1;
    margin-top: 14px;
    padding: 16px;
    font-size: 14px;
    line-height: 1.55;
  }

  .page.toc { aspect-ratio: auto; padding-bottom: 24px; }
  .toc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 14px;
    padding: 0 16px;
  }
  .toc-item { position: static; width: auto; }
  .toc-caption {
    flex-direction: column;
    gap: 2px;
    margin-top: 6px;
    font-size: 11px;
    white-space: normal;
  }

  .about-links {
    position: static;
    gap: 22px;
    padding: 4px 16px 20px;
  }
  .link-group { gap: 8px; }
  .link-group h3 { font-size: 11px; margin-bottom: 0; }
  .link-group a { font-size: 17px; }

  .peek { display: none; }
}

/* ---------- Resume page ---------- */

.doc-page { background: #f3f3f1; }
.doc {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 24px 16px 48px;
}
.doc .page {
  width: min(100%, 860px);
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 10px 30px rgba(0, 0, 0, 0.08);
}
.doc .page + .page { border-top: 0; }
