/* Maxwell McEwan — art portfolio */

:root {
  /* Brights sampled from the banner artwork (images/header-*).
     FILL-ONLY, verified against WCAG: every one fails AA as text on paper
     (1.24-2.90:1) and white fails on all six (1.33-3.11:1). Ink on bright
     passes everywhere (5.57:1 worst case), so bright fills carry ink text.
     For coloured *text*, use --accent below. */
  --c-blue:   #38b6ff;
  --c-yellow: #ffde59;
  --c-purple: #e2a9f1;
  --c-green:  #7ed957;
  --c-coral:  #ff5757;
  --c-cyan:   #0cc0df;

  --paper:     #f7f7f5;
  --ink:       #1a1a1f;
  --ink-muted: #4a4a52;
  --accent:    #0b6f9e; /* text-safe blue, 5.18:1 on paper */
  --accent-hi: #075a80; /* hover,          7.03:1 */
  --line:      rgba(26, 26, 31, 0.12);

  --font: "Poppins", system-ui, sans-serif;

  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;

  --max-w: 68rem;
  --r-lg: 0.75rem;
  --r-2xl: 1.35rem;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--accent); text-decoration: none; text-underline-offset: 2px; }
a:hover { color: var(--accent-hi); text-decoration: underline; }

h1, h2 {
  font-family: var(--font);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.035em;
  color: var(--ink);
}

.container {
  width: min(100% - var(--space-8), var(--max-w));
  margin-inline: auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ----- Banner ----- */
.banner { width: 100%; }

.banner__img {
  width: 100%;
  height: auto;
  background: rgba(26, 26, 31, 0.06);
}

/* NO max-height here on purpose. Capping the height makes it crop vertically,
   and this artwork's type spans nearly the full height - a 7:1 crop sliced
   "MAXWELL" in half and cut "PORTFOLIO SITE + SHOP" off entirely. The banner
   is never cropped on desktop; the page is trimmed to fit around it instead. */

/* The artwork's type runs to its left edge, so narrow screens crop to a taller
   box anchored hard left. Any inset clips the "M" of MAXWELL. */
@media (max-width: 640px) {
  .banner__img {
    /* The 4:1 banner would be a 94px sliver on a phone. 2:1 keeps the left
       half, and the wordmark occupies the left 48% - so all the type survives. */
    aspect-ratio: 2 / 1;
    object-fit: cover;
    object-position: left center;
  }
}

/* ----- Link tiles ----- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-4);
  /* space-8 not space-12: with the 4:1 banner the page lands 29px over a
     1440x790 viewport, and trimming this plus the footer closes it so the
     whole page fits without scrolling. */
  padding-block: var(--space-8);
}

.tile {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.1rem;
  /* Fixed 2:1 so one background image crops the same way at every width.
     min-height is the floor: at the narrowest column (224px) 2:1 would give
     112px, which is less than the text needs. */
  aspect-ratio: 2 / 1;
  min-height: 7.5rem;
  padding: var(--space-6);
  border-radius: var(--r-2xl);
  color: var(--ink);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

/* Keep the label above the scrim. */
.tile > * { position: relative; z-index: 1; }
.tile:hover {
  color: var(--ink);
  text-decoration: none;
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(26, 26, 31, 0.16);
}
.tile:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.tile__kicker {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.75;
}
.tile__name {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.12;
}

/* Icons ship as 256x256 squares with their own background colour baked in
   (navy, amber, purple), so they read as a corner badge rather than a tinted
   glyph. Selector is .tile > .tile__icon so it outranks `.tile > *` above,
   which would otherwise force position: relative. */
.tile > .tile__icon {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 3rem;
  height: 3rem;
  border-radius: 0.6rem;
  object-fit: cover;
  z-index: 1;
}

/* Reserve room so a two-line name never runs under the badge. */
.tile:has(.tile__icon) .tile__kicker,
.tile:has(.tile__icon) .tile__name {
  padding-right: 3.9rem;
}

@media (max-width: 640px) {
  .tile > .tile__icon { width: 3.5rem; height: 3.5rem; }
  .tile:has(.tile__icon) .tile__kicker,
  .tile:has(.tile__icon) .tile__name { padding-right: 4.4rem; }
}

/* Flat colour keeps the verified ink-on-bright contrast (5.57:1 worst case).
   The colour also shows while a background image is still loading. */
.tile--blue   { background-color: var(--c-blue); }
.tile--yellow { background-color: var(--c-yellow); }
.tile--purple { background-color: var(--c-purple); }
.tile--green  { background-color: var(--c-green); }
.tile--coral  { background-color: var(--c-coral); }
.tile--cyan   { background-color: var(--c-cyan); }

/* ----- Tiles with a background image -----
   Added by script.js to any tile carrying data-bg. An arbitrary photo voids
   the ink-on-bright contrast guarantee entirely, so these flip to white text
   over a scrim rather than trusting the image to be dark. */
.tile--image {
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  color: #fff;
}

/* Weighted to stay dense across the whole label, not just the last line. The
   stops are set from a measured worst case: a pure-white image, sampled at the
   top row of the label where the scrim is thinnest. White text clears 7.6:1
   there, and ~13:1 at the bottom. An earlier, lighter ramp measured 4.94:1,
   which the kicker's own opacity would then have pushed under AA. */
.tile--image::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.88) 0%,
    rgba(0, 0, 0, 0.82) 60%,
    rgba(0, 0, 0, 0.45) 85%,
    rgba(0, 0, 0, 0.15) 100%
  );
}

.tile--image:hover { color: #fff; }
/* Full opacity, not the 0.75 used on flat tiles: dimmed white over the scrim
   loses more contrast than the ramp has to spare. */
.tile--image .tile__kicker { opacity: 1; }
.tile--image:focus-visible { outline-color: #fff; }

/* Flagged by script.js when an href is still a placeholder, so an unfinished
   link is impossible to miss instead of silently shipping broken. */
.tile.is-todo {
  outline: 2px dashed var(--ink);
  outline-offset: 3px;
  opacity: 0.85;
}
.tile.is-todo .tile__kicker::after {
  content: " · link needed";
  font-weight: 800;
}

/* ----- Sections ----- */
.section { padding-bottom: var(--space-16); }

.section__title {
  margin: 0 0 var(--space-6);
  font-size: clamp(1.75rem, 5vw, 2.5rem);
}

/* ----- Art ----- */
.art-grid {
  columns: 3 18rem;
  column-gap: var(--space-4);
}

.art-grid__item {
  display: block;
  /* min-height matters: uploaded art has no known dimensions, so an unloaded
     <img> has zero intrinsic size and collapses to height 0. A zero-area box
     never trips native lazy-loading's intersection check, so the image would
     never load at all. Reserving space breaks that deadlock. */
  min-height: 8rem;
  margin-bottom: var(--space-4);
  break-inside: avoid;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: rgba(26, 26, 31, 0.06);
  transition: transform 0.18s var(--ease);
}
.art-grid__item:hover { transform: scale(1.015); }
.art-grid__item:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.art-grid__item img { width: 100%; height: auto; }

.art-grid__caption {
  padding: var(--space-2) var(--space-3);
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

/* ----- Writing ----- */
.writing-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}

.writing-list li {
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line);
}

.writing-list__title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.writing-list__note {
  margin: 0.1rem 0 0;
  font-size: 0.875rem;
  color: var(--ink-muted);
}

/* ----- Footer ----- */
.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding-block: var(--space-4);
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
}
.footer p { margin: 0; color: var(--ink-muted); }

/* ----- Sub-page header (art.html) -----
   index.html needs no header because the banner is the header. A gallery
   scrolls, so it gets a slim sticky bar with a way back instead. */
.pagehead {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(247, 247, 245, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.pagehead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 3.5rem;
}

.pagehead__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  color: var(--ink);
}
.pagehead__brand:hover { color: var(--accent); text-decoration: none; }

.pagehead__mark {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--r-lg);
  background: var(--c-yellow);
  color: var(--ink);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.pagehead__back {
  font-size: 0.875rem;
  font-weight: 600;
}

/* ----- Sub-page body ----- */
.page { padding-block: var(--space-8) var(--space-16); }

.page__title {
  margin: 0 0 var(--space-8);
  font-size: clamp(2.25rem, 7vw, 3.5rem);
}

.page__empty {
  margin: var(--space-16) 0;
  text-align: center;
  color: var(--ink-muted);
  font-size: 1.05rem;
}

/* ----- Lightbox -----
   [hidden] must win over display:grid, hence the explicit rule. */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--space-8);
  background: rgba(10, 10, 12, 0.95);
}
.lightbox[hidden] { display: none; }

.lightbox__figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  max-width: 100%;
}

.lightbox__img {
  max-width: min(92vw, 1400px);
  max-height: 80vh;
  width: auto;
  height: auto;
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.06);
}

.lightbox__caption {
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.9rem;
  text-align: center;
  max-width: 60ch;
}

.lightbox__btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--ease) 0.15s;
}
.lightbox__btn:hover { background: rgba(255, 255, 255, 0.28); }
.lightbox__btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.lightbox__close { top: var(--space-4); right: var(--space-4); }
.lightbox__prev  { left: var(--space-4);  top: 50%; transform: translateY(-50%); }
.lightbox__next  { right: var(--space-4); top: 50%; transform: translateY(-50%); }

/* Only one image: the arrows would be dead controls. */
.lightbox.is-single .lightbox__prev,
.lightbox.is-single .lightbox__next { display: none; }

@media (max-width: 640px) {
  .lightbox { padding: var(--space-3); }
  .lightbox__btn { width: 2.5rem; height: 2.5rem; font-size: 1.4rem; }
  .lightbox__prev { left: var(--space-2); }
  .lightbox__next { right: var(--space-2); }
}

/* Stop the page behind the lightbox scrolling under it. */
body.lb-open { overflow: hidden; }
