/* ============================================================
   COLOURS AND FONTS
   Change the colours of each theme here.
   ============================================================ */

:root {
  --bg: #ffffff;
  --fg: #000000;
  --line: #000000;
  --tab-active-bg: #c4ff4e;    /* lime green "work" tab */
  --tab-active-fg: #000000;
  --tile: #d9d9d9;             /* grey placeholder squares */
  --tile-dark: #777777;        /* placeholder square when its project is hovered */
  --tile-label: #ffffff;
  --pill-bg: #c4ff4e;
  --pill-fg: #000000;

  --font-display: "Inter Tight", "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-nav: "Courier Prime", "Courier New", Courier, monospace;
  --nav-spacing: 0.12em;

  /* Text sizes (each is the mockup size + 8px) */
  --size-name: 76px;   /* mockup + 8px + 10px */
  --size-title: 38px;
  --size-list: 38px;
  --size-nav: 24px;
  --size-label: 14px;
  --size-pill: 14px;          /* "learn more": 10px smaller than the nav */
  --size-body: 22px;          /* about page text */
}

/* "my eyes" theme: olive and pink */
html[data-theme="dark"] {
  --bg: #363d1d;
  --fg: #ffb3e8;
  --line: #ffb3e8;
  --tab-active-bg: #ffb3e8;
  --tab-active-fg: #363d1d;
  --tile-label: #ffb3e8;
  --pill-bg: #ffb3e8;
  --pill-fg: #363d1d;
}

/* ============================================================
   PAGE LAYOUT
   ============================================================ */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
}

body { transition: background-color .5s ease, color .5s ease; }

.page {
  display: grid;
  grid-template-columns: minmax(420px, 37%) 1fr;
  height: 100vh;
  height: 100dvh;
}

/* ---------- Left column ---------- */

.side {
  position: relative;
  display: flex;
  flex-direction: column;
  border-right: 2px solid var(--line);
  min-height: 0;
  overflow-y: auto;
}

.name {
  margin: 28px 24px 0;
  font-size: var(--size-name);
  font-weight: 400;
  line-height: 0.88;
  letter-spacing: -0.055em;
}

.list-title {
  margin: 40px 24px 10px;
  font-size: var(--size-title);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.045em;
}

.project-list {
  list-style: none;
  margin: 0 0 32px;
  padding: 0 24px 0 16px;
  counter-reset: item;
}

.project-list li {
  counter-increment: item;
  font-size: var(--size-list);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.project-list button {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  gap: 0.32em;
}

.project-list button::before {
  content: counter(item) ".";
  min-width: 1.5em;
  flex-shrink: 0;
  text-align: right;
  font-weight: 400;
  font-style: normal;
  letter-spacing: 0;
}

/* Hovering a title: bold + italic */
.project-list button:hover .t,
.project-list button:focus-visible .t,
.project-list li.is-active .t {
  font-weight: 700;
  font-style: italic;
  letter-spacing: var(--hover-spacing, -0.06em);
}

.project-list button:focus-visible { outline: 2px solid var(--line); outline-offset: 2px; }

/* ---------- Nav tabs ---------- */

.nav {
  margin-top: auto;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border-top: 2px solid var(--line);
  flex-shrink: 0;
  position: sticky;   /* stays visible even if the list is long enough to scroll */
  bottom: 0;
  background: var(--bg);
}

.nav-tab {
  all: unset;
  cursor: pointer;
  text-align: center;
  padding: 14px 4px;
  font-family: var(--font-nav);
  font-size: var(--size-nav);
  font-weight: 700;
  letter-spacing: var(--nav-spacing);
  color: var(--fg);
  border-left: 2px solid var(--line);
  transition: background-color .2s ease;
}

.nav-tab:first-child { border-left: 0; }
.nav-tab:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); }
.nav-tab:focus-visible { outline: 2px solid var(--line); outline-offset: -6px; }

.nav-tab.is-active {
  background: var(--tab-active-bg);
  color: var(--tab-active-fg);
}

.eyes-corner {
  all: unset;
  cursor: pointer;
  position: absolute;
  top: 24px;
  right: 20px;
  z-index: 5;
  padding: 8px 14px;
  border: 1.5px solid var(--fg);   /* empty pill with a thin outline */
  border-radius: 999px;
  background: transparent;
  font-family: var(--font-nav);
  font-size: calc(var(--size-nav) - 4px);
  font-weight: 700;
  letter-spacing: 0;
  color: var(--fg);
}

/* The corner button reads "my eyes" in the light theme and "your eyes" in the dark one */
.eyes-corner .your { display: none; }
html[data-theme="dark"] .eyes-corner .my { display: none; }
html[data-theme="dark"] .eyes-corner .your { display: inline; }

/* ============================================================
   THE SLIDING IMAGE WALL
   ============================================================ */

.wall {
  position: relative;
  overflow: hidden;
  container-type: inline-size;   /* lets tile sizes follow the column width */
}

/* Pinterest-style wall: equal columns and equal gaps, images of different heights.
   Each column slides down on its own, at the same speed. */
.wall-columns {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), 1fr);
  gap: var(--gap);
  padding: 0 var(--gap);
  --gap: 3cqw;
}

.col {
  position: relative;
  overflow: visible;
}

.col-track {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  animation: slide-down var(--slide-time, 120s) linear infinite;
  will-change: transform;
}

/* Each column holds its tiles twice, so moving it by half loops seamlessly.
   The extra half-gap keeps the spacing even where the two copies meet. */
@keyframes slide-down {
  from { transform: translateY(calc(-50% - var(--gap) / 2)); }
  to   { transform: translateY(0); }
}

.wall.is-paused .col-track { animation-play-state: paused; }

.tile {
  all: unset;
  position: relative;
  display: block;
  width: 100%;
  background: var(--tile);
  cursor: pointer;
  overflow: hidden;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* the dark veil + project title shown over a hovered project's tiles */
.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity .3s ease;
}

.tile.is-placeholder::after { background: var(--tile-dark); }

.tile-label {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--size-label);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--tile-label);
  opacity: 0;
  transition: opacity .3s ease;
}

.tile.is-lit::after,
.tile.is-lit .tile-label { opacity: 1; }

.tile:focus-visible { outline: 2px solid var(--line); outline-offset: 2px; }

/* ============================================================
   THE PROJECT VIEWER (opens on click)
   ============================================================ */

.viewer {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  cursor: zoom-out;
}

.viewer[hidden] { display: none; }

/* The box hugs the picture, whatever its shape */
.viewer-box {
  position: relative;
  max-width: 100%;
  cursor: default;
  animation: viewer-in .35s ease;
}

@keyframes viewer-in {
  from { opacity: 0; transform: scale(.97); }
  to   { opacity: 1; transform: scale(1); }
}

.viewer-image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 80px);
  max-height: calc(100dvh - 80px);
  width: auto;
  height: auto;
  outline: 2px solid var(--line);
  cursor: pointer;
}

.viewer-image[hidden] { display: none; }

.viewer-empty {
  width: min(600px, 80cqw);
  aspect-ratio: 4 / 5;
  background: var(--tile-dark);
  padding: 32px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: var(--size-title);
  letter-spacing: -0.05em;
}

.viewer-empty[hidden] { display: none; }

.learn-more {
  position: absolute;
  right: 18px;
  bottom: 20px;
  padding: 15px 24px;      /* pill is 10px shorter than before */
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--pill-fg);
  font-family: var(--font-nav);
  font-size: var(--size-pill);
  font-weight: 700;
  letter-spacing: var(--nav-spacing);
  text-decoration: none;
  transition: transform .2s ease;
}

.learn-more:hover { transform: scale(1.05); }

/* ============================================================
   SMALL SCREENS (phones): stack the columns, shrink the text a bit
   ============================================================ */

@media (max-width: 800px) {
  :root {
    --size-name: 56px;
    --size-title: 26px;
    --size-list: 26px;
    --size-nav: 18px;
    --size-label: 12px;
    --size-pill: 13px;
    --size-body: 18px;
  }

  .page {
    grid-template-columns: 1fr;
    grid-template-rows: auto 70vh;
    height: auto;
  }

  .side { border-right: 0; border-bottom: 2px solid var(--line); overflow: visible; }
  .name { margin: 20px 16px 0; }
  .list-title { margin: 28px 16px 8px; }
  .project-list { padding: 0 16px 0 8px; }
  .viewer { padding: 20px; }
  .viewer-image { max-height: calc(70vh - 40px); }
}

@media (prefers-reduced-motion: reduce) {
  .wall-track { animation-duration: 600s; }
}

/* ============================================================
   ABOUT PAGE
   ============================================================ */

.about {
  display: grid;
  grid-template-columns: 54% 1fr;
  height: 100vh;
  height: 100dvh;
}

/* In the "my eyes" theme the text side turns pink with olive text */
html[data-theme="dark"] .about-text {
  background: var(--fg);
  color: var(--bg);
}

.about-text {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 24px;
}

.bio {
  margin: 36px 24px 0;
  max-width: 34em;
  font-size: var(--size-body);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.bio p { margin: 0 0 1.1em; }

.portrait {
  margin: 0;
  min-height: 0;
  background: var(--tile);
  overflow: hidden;
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;   /* keeps the face in frame, like the mockup */
  filter: grayscale(1);
  display: block;
}

@media (max-width: 800px) {
  .about { grid-template-columns: 1fr; grid-template-rows: auto 80vh; height: auto; }
  .about-text { overflow: visible; }
  .bio { margin: 28px 16px 0; }
  .portrait { height: 80vh; }
}

.eyes-corner:hover { background: var(--fg); color: var(--bg); }
.eyes-corner:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }

/* ============================================================
   "BACK" PILL (about, project and contact pages)
   ============================================================ */

.back-pill {
  display: block;
  width: max-content;
  flex-shrink: 0;
  margin: 28px 24px 0;
  padding: 10px 36px;
  border: 1.5px solid currentColor;
  border-radius: 999px;
  color: inherit;
  font-family: var(--font-nav);
  font-size: calc(var(--size-nav) - 4px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: transform .2s ease;
}

.back-pill:hover { transform: translateX(-4px); }
.back-pill:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

/* ============================================================
   CONTACT PAGE
   ============================================================ */

.contact-page {
  --contact-bg: #c4ff4e;
  --card: #f0ece0;
  --card-text: #000000;
  background: var(--contact-bg);
}

html[data-theme="dark"] .contact-page {
  --contact-bg: #363d1d;
  --card: #f3a5cf;
  --card-text: #363d1d;
}

.contact {
  position: relative;
  display: grid;
  place-items: center;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--contact-bg);
}

.contact .back-pill { position: absolute; top: 0; left: 0; }

.card {
  position: relative;
  width: min(58vw, 110vh);
  aspect-ratio: 401 / 235;
  container-type: inline-size;   /* text and corners scale with the card */
  color: var(--card-text);
}

/* the solid shadow, down and to the right */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 5.8cqw;
  background: color-mix(in srgb, var(--contact-bg) 75%, #000);
  transform: translate(3.6%, 6.4%);
}

.card-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 5.8cqw;
  background: var(--card);
  isolation: isolate;
}

/* paper grain, drawn in code */
.card-face::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: .3;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='p' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.06' numOctaves='4' stitchTiles='stitch'/%3E%3CfeDiffuseLighting lighting-color='white' surfaceScale='2' diffuseConstant='1.35'%3E%3CfeDistantLight azimuth='45' elevation='45'/%3E%3C/feDiffuseLighting%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23p)'/%3E%3C/svg%3E");
}

/* the photo, larger than the card and cropped by it, as in the mockup */
.card-photo {
  position: absolute;
  left: -16.5%;
  bottom: 0;
  width: 139.8%;
  height: auto;
  filter: grayscale(1);
  opacity: .28;
}

.card-links {
  position: absolute;
  right: 4%;
  bottom: 6.5%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 8.2cqw;
  line-height: 1.17;
  letter-spacing: -0.05em;
}

.card-links a { color: inherit; text-decoration: none; }

.card-links .email,
.card-links a:hover {
  text-decoration: underline;
  text-decoration-thickness: .05em;
  text-underline-offset: .14em;
  text-decoration-skip-ink: none;
}

.card-links a:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

/* "email address copied" note */
.copied {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 24px;
  margin: 0;
  text-align: center;
  font-family: var(--font-nav);
  font-size: 18px;
  font-weight: 700;
}

@media (max-width: 800px) {
  .back-pill { margin: 20px 16px 0; padding: 8px 24px; }
  .card { width: min(84vw, 110vh); }
}

/* ============================================================
   PROJECT PAGE
   ============================================================ */

.project-page { height: auto; min-height: 100%; }

.project-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 2.2vw;
  background: var(--bg);
  transition: background-color .5s ease;
}

.project-bar .back-pill { margin: 0; }

.project-arrows { display: flex; gap: 32px; }
.project-arrows a { display: flex; color: var(--fg); transition: transform .2s ease; }
.project-arrows #prev:hover { transform: translateX(-4px); }
.project-arrows #next:hover { transform: translateX(4px); }
.project-arrows a:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }

.project {
  display: grid;
  grid-template-columns: 55fr 39.2fr;
  gap: 1.8vw;
  align-items: start;
  padding: 0 2.2vw;
}

.project-images,
.project-info {
  position: sticky;   /* js/project.js sets how far each column sticks */
  min-width: 0;
  padding-bottom: 2.2vw;
}

.project-images { display: flex; flex-direction: column; align-items: flex-start; gap: 1.5vw; }
.project-images img { display: block; width: 100%; height: auto; }

/* Vertical (A4-like) images: the whole image fits in the window, left-aligned.
   --ratio (width / height) and --bar (top bar height) come from js/project.js */
@media (min-width: 801px) {
  .project-images img.is-vertical {
    width: min(100%, max(120px, (100vh - var(--bar, 102px) - 2.2vw) * var(--ratio)));
  }
}

.project-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 1.7vw;
}

.project-head h1,
.project-head p {
  margin: 0;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.project-head h1 { font-size: clamp(30px, 3.2vw, 60px); }
.project-head p { font-size: clamp(22px, 2.7vw, 50px); white-space: nowrap; }

.project-text {
  font-size: clamp(16px, 1.95vw - 5px, 31px);
  line-height: 1.07;
  letter-spacing: -0.03em;
  white-space: pre-line;   /* keeps the line breaks from js/projects.js */
  overflow-wrap: break-word;
}

.project-info a { color: inherit; text-decoration-thickness: .05em; text-underline-offset: .14em; }

@media (max-width: 800px) {
  .project-bar { padding: 16px; }
  .project-arrows { gap: 24px; }
  .project { display: flex; flex-direction: column; align-items: stretch; gap: 20px; padding: 4px 16px 32px; }
  .project-info { display: contents; }
  .project-images { position: static; order: 1; gap: 12px; padding: 0; }
  .project-head { order: 0; margin: 0; }
  .project-text { order: 2; line-height: 1.2; }
}

/* ============================================================
   HOME PAGE LIST: scrolls by itself, the name and tabs stay put
   ============================================================ */

.learn-more[hidden] { display: none; }

@media (min-width: 801px) {
  .side > :not(.project-list):not(.eyes-corner) { flex-shrink: 0; }
  .project-list {
    flex: 1 1 0;
    min-height: 160px;
    margin-bottom: 0;
    padding-bottom: 24px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
  }
}
