/* Earl McGhee — portfolio surfaces
   Surround is a neutral mid-dark grey, not black: black crushes a viewer's
   read of shadow detail and tints perceived colour. This is the same
   convention a print viewing booth and Lightroom's own canvas use. */

:root {
  --surround: #1d1d1d;
  --surround-deep: #151515;
  --rule: #343434;
  --ink: #e7e5e1;
  --ink-dim: #8e8b86;
  --focus: #d1620f;
  --gutter: clamp(0.75rem, 2.5vw, 2.25rem);
  --chrome-h: 3.25rem;
  --face: ui-sans-serif, system-ui, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--surround);
  color: var(--ink);
  font-family: var(--face);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

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

/* ---------- shared chrome ---------- */

.chrome {
  position: fixed;
  left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: var(--chrome-h);
  padding: 0 var(--gutter);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  transition: opacity 320ms ease;
}

.chrome--top { top: 0; }
.chrome--bottom { bottom: 0; border-top: 1px solid transparent; }

.chrome a:hover,
.chrome button:hover { color: var(--ink); }

.mark {
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
}

.mark span {
  color: var(--ink-dim);
  margin-left: 0.5rem;
}

.chrome .spacer { flex: 1 1 auto; }

.chrome nav a {
  text-decoration: none;
  padding: 0.35rem 0;
  border-bottom: 1px solid transparent;
}

.chrome nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--focus);
}

.counter {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.filename {
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.ctl {
  appearance: none;
  background: none;
  border: 0;
  color: var(--ink-dim);
  font: inherit;
  letter-spacing: 0.06em;
  padding: 0.5rem 0.25rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  cursor: pointer;
  transition: color 160ms ease;
}

/* ---------- slideshow ---------- */

.stage {
  position: fixed;
  inset: 0;
  padding: calc(var(--chrome-h) + var(--gutter)) var(--gutter);
  touch-action: pan-y;
}

.stage .layer {
  position: absolute;
  inset: calc(var(--chrome-h) + var(--gutter)) var(--gutter);
  width: calc(100% - 2 * var(--gutter));
  height: calc(100% - 2 * (var(--chrome-h) + var(--gutter)));
  margin: 0;
  object-fit: contain;
  object-position: center;
  opacity: 0;
  transition: opacity var(--dissolve, 3000ms) linear;
  will-change: opacity;
}

.stage .layer { background: var(--surround); }
.stage .layer img { width: 100%; height: 100%; object-fit: contain; display: block; }
.stage .layer.is-visible { opacity: 1; }
[hidden] { display: none !important; }
.photo-error {
  inset: auto var(--gutter) calc(var(--chrome-h) + 1rem);
  z-index: 2;
  background: #1d1d1ddd;
}
button:disabled { opacity: 0.45; cursor: default; }
.chrome nav { display: flex; gap: 1rem; }
.idle .chrome:focus-within { opacity: 1; pointer-events: auto; }
.lightbox-open { overflow: hidden; }

.idle .chrome { opacity: 0; pointer-events: none; }
.idle { cursor: none; }

.notice {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 0.5rem;
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  padding: var(--gutter);
}

.notice strong {
  display: block;
  color: var(--ink);
  font-weight: 500;
  font-size: 0.9375rem;
  letter-spacing: 0;
}

/* ---------- gallery ---------- */

.gallery-body { background: var(--surround-deep); height: auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(120px, 18vw, 230px), 1fr));
  gap: 2px;
  padding: calc(var(--chrome-h) + 2px) 2px 2px;
  margin: 0;
  list-style: none;
}

.cell {
  position: relative;
  margin: 0;
  background: var(--surround);
  aspect-ratio: 1 / 1;
}

.cell a {
  display: block;
  width: 100%; height: 100%;
  text-decoration: none;
}

.cell img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  opacity: 0;
  transition: opacity 280ms ease;
}

.cell img.is-loaded { opacity: 1; }

.cell .fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  font-size: 0.6875rem;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
  padding: 0.5rem;
  text-align: center;
}

/* ---------- lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--surround);
  color: var(--ink);
  border: 0;
  width: 100%; height: 100%;
  max-width: none; max-height: none;
  margin: 0;
  display: none;
  padding: calc(var(--chrome-h) + var(--gutter)) var(--gutter);
}

.lightbox::backdrop { background: var(--surround); }

.lightbox[open],
.lightbox.is-open { display: block; }

.lightbox img {
  position: absolute;
  inset: calc(var(--chrome-h) + var(--gutter)) var(--gutter);
  width: calc(100% - 2 * var(--gutter));
  height: calc(100% - 2 * (var(--chrome-h) + var(--gutter)));
  margin: 0;
  object-fit: contain;
}

@media (prefers-reduced-motion: reduce) {
  .stage .layer { transition-duration: 0ms !important; }
  .cell img { transition-duration: 1ms; }
  .chrome { transition-duration: 1ms; }
}

@media (max-width: 640px) {
  .filename { display: none; }
  :root { --chrome-h: 3rem; }
}
