:root {
  --bg: #f7f5ef;
  --ink: #151515;
  --muted: #60605c;
  --line: rgba(21, 21, 21, 0.12);
  --accent: #1f6f61;
  --accent-dark: #164d45;
  --surface: #ffffff;
  --soft-bg: #e9eee5;
  --shadow: 0 24px 80px rgba(24, 31, 27, 0.14);
  --media-bg: #e5e6df;
  --media-border: rgba(21, 21, 21, 0.18);
  --media-shadow: 0 18px 44px rgba(24, 31, 27, 0.14),
    0 1px 0 rgba(255, 255, 255, 0.78) inset;
  --base-font-scale: 1;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: calc(100% * var(--base-font-scale));
}

html.font-large {
  --base-font-scale: 1.08;
}

html.font-larger {
  --base-font-scale: 1.16;
}

html.colour-deuteranopia {
  --bg: #f8f5ea;
  --accent: #1864ab;
  --accent-dark: #0b4f8a;
  --soft-bg: #e8f1f8;
  --line: rgba(21, 21, 21, 0.16);
  --media-bg: #e2e8ec;
  --media-border: rgba(11, 79, 138, 0.2);
}

html.colour-protanopia {
  --bg: #f7f6ee;
  --accent: #006d77;
  --accent-dark: #004f57;
  --soft-bg: #e7f1f2;
  --line: rgba(21, 21, 21, 0.16);
  --media-bg: #e2eaeb;
  --media-border: rgba(0, 79, 87, 0.2);
}

html.colour-tritanopia {
  --bg: #f6f4f1;
  --accent: #8a5a00;
  --accent-dark: #5f3e00;
  --soft-bg: #f2eee5;
  --line: rgba(21, 21, 21, 0.16);
  --media-bg: #ebe6db;
  --media-border: rgba(95, 62, 0, 0.2);
}

html.colour-high-contrast {
  --bg: #ffffff;
  --ink: #000000;
  --muted: #242424;
  --line: rgba(0, 0, 0, 0.35);
  --accent: #0047ff;
  --accent-dark: #002d9c;
  --surface: #ffffff;
  --soft-bg: #f2f2f2;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
  --media-bg: #ededed;
  --media-border: rgba(0, 0, 0, 0.5);
  --media-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
}

html.colour-dark {
  --bg: #101512;
  --ink: #f4f2ea;
  --muted: #c5c7bf;
  --line: rgba(244, 242, 234, 0.18);
  --accent: #72d6bd;
  --accent-dark: #9ee8d6;
  --surface: #18211d;
  --soft-bg: #151d19;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --media-bg: #202822;
  --media-border: rgba(244, 242, 234, 0.22);
  --media-shadow: 0 22px 58px rgba(0, 0, 0, 0.38),
    0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

section[id] {
  scroll-margin-top: 96px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(20px, 5vw, 72px);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(18px);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.site-header.is-scrolled {
  border-color: var(--line);
  box-shadow: 0 10px 35px rgba(24, 31, 27, 0.08);
}

.brand {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: clamp(14px, 3vw, 32px);
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

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

.nav-cv-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  line-height: 1;
  transition: background-color 180ms ease, border-color 180ms ease,
    color 180ms ease, transform 180ms ease;
}

.nav-cv-link:hover {
  border-color: rgba(31, 111, 97, 0.36);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent-dark);
}

.nav-cv-link:active,
.nav-cv-link.is-pressed {
  transform: translateY(1px) scale(0.97);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.download-icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
  min-height: calc(100vh - 76px);
  padding: clamp(42px, 7vw, 96px) clamp(20px, 5vw, 72px);
}

.hero-copy {
  max-width: 680px;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 22px;
  font-size: clamp(3rem, 7.4vw, 6.8rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.hero-text {
  max-width: 610px;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
}

.hero-actions,
.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  color: inherit;
  font: inherit;
  font-weight: 800;
  line-height: 1.1;
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease,
    border-color 180ms ease, transform 180ms ease;
  text-align: center;
  white-space: nowrap;
}

.button.primary {
  background: var(--ink);
  color: #fff;
}

html.colour-dark .button.primary {
  background: var(--accent);
  color: #000;
}

.button.secondary {
  background: transparent;
}

.button.subtle {
  border-color: rgba(21, 21, 21, 0.18);
  background: rgba(255, 255, 255, 0.32);
  color: var(--muted);
}

.button.subtle:hover,
.button.subtle.is-copied {
  border-color: rgba(31, 111, 97, 0.36);
  background: rgba(255, 255, 255, 0.62);
  color: var(--accent-dark);
}

.button:hover {
  transform: translateY(-1px);
}

.hero-image,
.project-media {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-image img {
  width: 100%;
  height: auto;
  min-height: 360px;
  object-fit: cover;
}

.hero-portrait {
  justify-self: end;
  width: min(100%, 520px);
}

.hero-portrait img {
  aspect-ratio: 4 / 5;
  max-height: min(680px, calc(100vh - 150px));
  object-position: center top;
}

.intro-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 0 clamp(20px, 5vw, 72px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.intro-strip div {
  padding: clamp(18px, 3vw, 30px);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  color: var(--muted);
  font-weight: 700;
}

.intro-strip span {
  display: block;
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 800;
}

.section-heading {
  max-width: 760px;
  padding: clamp(88px, 12vw, 150px) clamp(20px, 5vw, 72px) 32px;
}

.section-heading h2,
.about h2,
.contact h2 {
  margin-bottom: 16px;
  font-size: clamp(2.1rem, 4.8vw, 4.4rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.about-heading span {
  display: block;
}

.section-heading p,
.about p,
.contact p {
  color: var(--muted);
  font-size: 1.05rem;
}

.projects {
  display: grid;
  gap: clamp(72px, 11vw, 140px);
  padding: 28px clamp(20px, 5vw, 72px) clamp(90px, 10vw, 140px);
}

.project-block {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: clamp(26px, 5vw, 70px);
  align-items: center;
}

.reveal-on-scroll {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 600ms ease, transform 600ms ease;
}

.reveal-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.project-block.reverse .project-media {
  order: 2;
}

.project-media {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 11;
  --project-media-inset: clamp(10px, 1.4vw, 16px);
  padding: 0;
  border-color: var(--media-border);
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
  background: var(--media-bg);
  box-shadow: var(--media-shadow);
}

.project-media img {
  position: absolute;
  inset: var(--project-media-inset);
  width: calc(100% - var(--project-media-inset) - var(--project-media-inset));
  height: calc(100% - var(--project-media-inset) - var(--project-media-inset));
  object-fit: contain;
  filter: drop-shadow(0 7px 16px rgba(24, 31, 27, 0.1));
}

.project-media:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 72%, white);
  outline-offset: 5px;
}

.gallery-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: clamp(18px, 4vw, 42px);
  background: rgba(18, 22, 20, 0.46);
  backdrop-filter: blur(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.gallery-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

body.gallery-open {
  overflow: hidden;
}

.gallery-widget {
  width: min(1120px, 100%);
  max-height: calc(100vh - clamp(36px, 8vw, 84px));
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--surface) 62%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 92%, var(--bg));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.28);
  color: var(--ink);
}

.gallery-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: clamp(16px, 3vw, 26px);
  border-bottom: 1px solid var(--line);
}

.gallery-header .eyebrow {
  margin-bottom: 8px;
}

.gallery-header h2 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 3vw, 2.6rem);
  line-height: 1;
}

.gallery-close,
.gallery-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.44);
  background: color-mix(in srgb, var(--ink) 58%, transparent);
  color: #fff;
  backdrop-filter: blur(12px) saturate(120%);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  transition: background-color 180ms ease, transform 180ms ease,
    border-color 180ms ease;
}

.gallery-close {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 999px;
}

.gallery-close svg,
.gallery-nav svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gallery-close:hover,
.gallery-nav:hover,
.gallery-close:focus-visible,
.gallery-nav:focus-visible {
  border-color: rgba(255, 255, 255, 0.72);
  background: color-mix(in srgb, var(--ink) 72%, transparent);
  transform: translateY(-1px);
}

.gallery-stage {
  position: relative;
  padding: clamp(14px, 2.4vw, 24px);
}

.gallery-viewport {
  overflow: hidden;
  border-radius: 8px;
  background: #0d1110;
}

.gallery-track {
  display: flex;
  align-items: center;
  gap: 18px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  padding: clamp(14px, 2vw, 22px);
  scrollbar-width: thin;
}

.gallery-slide {
  flex: 0 0 min(84vw, 760px);
  margin: 0;
  scroll-snap-align: center;
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 92%, var(--soft-bg));
}

.gallery-slide img {
  width: 100%;
  height: clamp(330px, 58vh, 590px);
  object-fit: contain;
  border-radius: 6px;
  background: transparent;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: clamp(44px, 6vw, 58px);
  height: clamp(54px, 8vw, 74px);
  border-radius: 8px;
  transform: translateY(-50%);
}

.gallery-nav:hover,
.gallery-nav:focus-visible {
  transform: translateY(calc(-50% - 1px));
}

.gallery-prev {
  left: clamp(22px, 3vw, 38px);
}

.gallery-next {
  right: clamp(22px, 3vw, 38px);
}

.gallery-counter {
  min-height: 26px;
  margin: 0;
  padding: 0 clamp(16px, 3vw, 26px) clamp(14px, 2.4vw, 22px);
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 800;
}

.project-content {
  max-width: 620px;
  min-width: 0;
}

.project-number {
  margin-bottom: 8px;
  color: var(--accent);
  font-weight: 800;
}

.project-title {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.project-logo {
  flex: 0 0 auto;
  width: clamp(118px, 11vw, 156px);
  height: clamp(48px, 5vw, 64px);
  padding: 8px;
  object-fit: contain;
  object-position: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.project-logo-badge {
  width: clamp(102px, 10vw, 140px);
  padding: 9px;
  background: #fff;
}

.project-logo-wide {
  width: clamp(132px, 13vw, 184px);
  background: #f2f2f0;
}

.project-logo-extra-wide {
  width: clamp(150px, 15vw, 220px);
  background: #fff;
}

.project-content h3 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 0.95;
}

.project-content p {
  color: var(--muted);
  font-size: 1.02rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 24px 0;
}

.tag-list span {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 66%, transparent);
  color: var(--accent-dark);
  font-size: 0.88rem;
  font-weight: 800;
}

.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-weight: 800;
}

.project-links a {
  border-bottom: 2px solid currentColor;
  color: var(--ink);
}

.about,
.contact {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(280px, 0.8fr);
  gap: clamp(24px, 6vw, 86px);
  align-items: start;
  padding: clamp(80px, 10vw, 130px) clamp(20px, 5vw, 72px);
  border-top: 1px solid var(--line);
}

.about {
  grid-template-columns: minmax(260px, 0.9fr) minmax(220px, 360px) minmax(
      280px,
      0.85fr
    );
  gap: clamp(28px, 4vw, 56px);
  align-items: center;
}

.about-intro,
.about-profile {
  min-width: 0;
}

.about-profile {
  display: contents;
  gap: 24px;
}

.about-profile img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.about-profile p {
  max-width: 48ch;
  margin-bottom: 0;
}

.contact {
  display: block;
  min-height: 48vh;
  background: var(--soft-bg);
}

.contact h2 {
  max-width: 820px;
}

.contact-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.95rem;
}

.accessibility-widget {
  position: fixed;
  right: clamp(16px, 3vw, 28px);
  bottom: clamp(16px, 3vw, 28px);
  z-index: 40;
}

.accessibility-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(21, 21, 21, 0.18);
  border-radius: 999px;
  background: var(--ink);
  color: var(--surface);
  box-shadow: 0 14px 36px rgba(24, 31, 27, 0.18);
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.accessibility-icon {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.accessibility-icon path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.accessibility-toggle:hover,
.accessibility-toggle:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 44px rgba(24, 31, 27, 0.22);
}

.accessibility-panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  width: min(320px, calc(100vw - 32px));
  max-height: calc(100vh - 112px);
  overflow-y: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 96%, var(--bg));
  box-shadow: var(--shadow);
  color: var(--ink);
}

.accessibility-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.accessibility-panel h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.accessibility-close,
.accessibility-reset {
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
}

.accessibility-group {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.accessibility-group legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.accessibility-group label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
}

.accessibility-group input {
  accent-color: var(--accent);
}

.accessibility-reset {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

@media (max-width: 900px) {
  .hero,
  .project-block,
  .about {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .hero-copy,
  .project-content {
    max-width: 760px;
  }

  .hero-portrait {
    justify-self: center;
  }

  .project-block.reverse .project-media {
    order: 0;
  }

  .intro-strip {
    grid-template-columns: 1fr;
  }

  .about-profile {
    display: grid;
  }

  .about-profile img {
    width: min(100%, 360px);
  }
}

@media (max-width: 760px) {
  .section-heading h2,
  .about h2,
  .contact h2 {
    line-height: 1.04;
  }

  .projects {
    gap: 64px;
  }
}

@media (max-width: 620px) {
  section[id] {
    scroll-margin-top: 132px;
  }

  .site-header {
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
    padding-block: 14px;
  }

  .nav-links {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.9rem;
  }

  .hero {
    min-height: auto;
    padding-top: 34px;
  }

  h1 {
    font-size: clamp(2.8rem, 14vw, 3.4rem);
    line-height: 0.96;
  }

  .hero-image img {
    min-height: 260px;
  }

  .intro-strip {
    margin-inline: 16px;
  }

  .section-heading,
  .projects,
  .about,
  .contact,
  .hero {
    padding-left: 16px;
    padding-right: 16px;
  }

  .contact-actions,
  .hero-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .contact-note {
    text-align: center;
  }

  .about-profile img {
    justify-self: center;
  }

  .button {
    width: 100%;
    white-space: normal;
  }

  .accessibility-widget {
    right: 14px;
    bottom: 14px;
  }

  .accessibility-toggle {
    width: 50px;
    height: 50px;
  }

  .accessibility-panel {
    bottom: 62px;
  }

  .gallery-overlay {
    padding: 12px;
  }

  .gallery-widget {
    max-height: calc(100vh - 24px);
  }

  .gallery-slide {
    flex-basis: calc(100vw - 76px);
  }

  .gallery-slide img {
    height: min(58vh, 460px);
  }

  .gallery-nav {
    width: 42px;
    height: 56px;
  }

  .gallery-prev {
    left: 18px;
  }

  .gallery-next {
    right: 18px;
  }
}

@media (max-width: 380px) {
  .nav-links {
    font-size: 0.84rem;
  }

  .eyebrow {
    font-size: 0.72rem;
  }

  .project-content h3,
  .section-heading h2,
  .about h2,
  .contact h2 {
    font-size: 2rem;
  }

  .project-title {
    align-items: flex-start;
    flex-direction: column;
  }
}

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

  .button,
  .project-media img,
  .reveal-on-scroll,
  .site-header {
    transition: none;
  }

  .accessibility-toggle {
    transition: none;
  }

  .gallery-overlay,
  .gallery-close,
  .gallery-nav,
  .gallery-track {
    scroll-behavior: auto;
    transition: none;
  }

  .reveal-on-scroll {
    opacity: 1;
    transform: none;
  }
}
