/*
  Every page: a centred header ("Eder Beldad | Series", links below), then the content.
  Collection pages are a scrollable grid; click a photo for full screen.
  Two layouts: mobile (default) and desktop (min-width: 900px).
*/

@font-face {
  font-family: 'Romano Revival';
  src: url('/fonts/romano-revival.otf') format('opentype');
  font-display: swap;
}

:root {
  /* --bg, --fg, --soft and --accent come from [colors] in portfolio.toml (set inline by build.py). */
  --muted: color-mix(in srgb, var(--fg) 76%, var(--bg)); /* secondary text: at least 5:1 contrast on --bg */
  --serif: Georgia, serif; /* overridden by the font chosen in portfolio.toml (set inline by build.py) */
  --caps: none;            /* 'uppercase' for fonts that only have capitals */
  --tracking: 0;           /* letter spacing for titles */
  --sans: 'Jost', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --side: 32px;     /* left/right margin of the page */
  --gap: 12px;     /* space between grid photos (0 = photos touch) */
  --cols: 2;       /* photos per row */
  --cell: 4 / 5;   /* shape of every grid cell: width / height (try 1 / 1 for squares) */
  --edge: 48px;    /* room beside the full-screen photo for the < > buttons */

  /* One spacing scale (multiples of 8) for everything outside the photo grid. */
  --s1: 4px; --s2: 8px; --s3: 24px; --s4: 32px; --s5: 48px; --s6: 64px; --s7: 96px;
}

::selection { background: var(--accent); color: var(--fg); }

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* The whole page (header included) scrolls inside .scroll. */
.scroll {
  height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--fg) 25%, transparent) transparent;
}

a { color: inherit; text-decoration: none; }
.link { text-decoration: underline; text-underline-offset: 3px; }

/* Keyboard focus is always visible. */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 4px;
}
main:focus { outline: none; }

/* "Skip to content": hidden until a keyboard user tabs to it. */
.skip {
  position: absolute;
  left: var(--side);
  top: -100px;
  z-index: 20;
  padding: 10px 16px;
  background: var(--fg);
  color: var(--bg);
  font-size: 12px;
}
.skip:focus { top: 12px; }
p { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

h1, h2, .title {
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: var(--tracking);
  text-transform: var(--caps);
  margin: 0;
}

.meta {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

/* ── header: "Eder Beldad | Series", then the links to the series ── */

.top { padding: var(--s6) var(--side) var(--s5); text-align: center; }

.top h1 {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  column-gap: .6em;
  --fs: 28px;
  font-size: var(--fs);
  line-height: 1.2;
}
/* The divider is drawn, not typed: same height and weight everywhere, centred on the text. */
.top h1 .sep {
  width: 1px;
  height: calc(var(--fs) * .8);
  background: currentColor;
  opacity: .3;
  font-size: 0;          /* hides the "|" character kept for screen readers */
  overflow: hidden;
}

/* On a collection page the page is split in the middle: the name ends just left of the centre line,
   and the collection's name is a block in the inverse colours that starts exactly on it and runs to
   the right edge of the window. */
.top:has(.series) { padding-inline: 0; }
.top:has(.series) h1 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 0;
  align-items: center;
}
.top:has(.series) h1 > a { justify-self: end; padding: 0 .6em 0 var(--side); text-align: right; }
.top:has(.series) h1 .sep { display: none; }
.top:has(.series) h1 { --fs: 24px; white-space: nowrap; }
.top:has(.series) h1 > a { padding-left: var(--s3); }
.top h1 .series {
  padding: .3em var(--side) .3em .6em;
  background: var(--fg);
  color: var(--bg);
  text-align: left;
}
.top:has(.series) .index { padding-inline: var(--side); }

.index {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 14px;
  margin-top: var(--s2);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.index a {
  padding: 12px 0 8px;        /* tap target at least 24px tall */
  border-bottom: 1px solid transparent;
  color: color-mix(in srgb, var(--fg) 72%, var(--bg));
  transition: color .3s, border-color .3s;
}
.index a:hover { color: var(--fg); }
.index a[aria-current] { color: var(--fg); border-bottom-color: var(--fg); }  /* where you are */

.foot { padding: var(--s7) var(--side) var(--s5); text-align: center; }

/* ── collection page ── */

/* Short description: small label on the left, text on the right, a hairline above. */
.intro {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s2) var(--s4);
  margin: 0 var(--side) var(--s4);
  padding-top: var(--s3);
  border-top: 1px solid color-mix(in srgb, var(--fg) 25%, transparent);
}
.blurb { font-size: 17px; line-height: 1.55; max-width: 34em; justify-self: end; text-align: right; }

.page { padding: 0 var(--side); }

/* A regular grid: every cell has the same size, and photos of other shapes are cropped to fit.
   (Full screen always shows the whole photo.) */
.gallery {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: var(--gap);
}
.gallery a {
  position: relative;
  display: block;
  aspect-ratio: var(--cell);
  overflow: hidden;
  cursor: pointer;
}
.gallery img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;      /* crop, don't stretch */
  object-position: center;
  transition: opacity .5s ease;
}
.gallery a:focus-visible { outline: none; }
.gallery a:focus-visible::after {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 3px var(--bg), inset 0 0 0 6px var(--fg);
}

/* Fade photos in as they load (the average colour shows meanwhile). */
.js .gallery img:not(.loaded) { opacity: 0; }
@media (hover: hover) {
  .gallery:has(a:hover) a:not(:hover) img { opacity: .6; }
}

/* ── full screen ── */

.lightbox {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 24px var(--edge) 64px;
  border: 0;
  background: var(--bg);
  color: var(--fg);
}
.lightbox[open] {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr); /* gives the photo a definite box to fit in */
  place-items: center;
}
.lightbox::backdrop { background: var(--bg); }

/* While the viewer is open the page behind it is hidden (its layout still exists, so the scroll
   position is kept). Otherwise you would see it re-flow when the browser switches to full screen. */
body:has(.lightbox[open]) .scroll { visibility: hidden; }

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: opacity .15s ease;
  cursor: pointer;
}

/* Previous / next: round "<" and ">" buttons in their own column beside the photo.
   The whole column is clickable; --btn is the size of the visible ring. */
.arrow {
  --btn: 40px;
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--edge);
  cursor: pointer;
}
/* arrows show their focus as a filled ring (see below) */
.arrow:focus-visible { outline: none; }
.arrow.prev { left: 0; }
.arrow.next { right: 0; }

.arrow::before {            /* the ring */
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--btn);
  height: var(--btn);
  transform: translate(-50%, -50%);
  border: 1px solid color-mix(in srgb, var(--fg) 35%, transparent);
  border-radius: 50%;
  transition: background .3s, border-color .3s;
}
.arrow::after {             /* the chevron */
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(var(--btn) * .26);
  height: calc(var(--btn) * .26);
  border: solid var(--fg);
  border-width: 0 0 1.5px 1.5px;
  transition: border-color .3s;
}
.arrow.prev::after { transform: translate(-30%, -50%) rotate(45deg); }
.arrow.next::after { transform: translate(-70%, -50%) rotate(-135deg); }
.arrow:hover::before,
.arrow:focus-visible::before { background: var(--fg); border-color: var(--fg); }
.arrow:hover::after,
.arrow:focus-visible::after { border-color: var(--bg); }

/* Full: the photo gets the whole window; the bar fades out and returns when you point at it. */
.lightbox.full { padding: 0; }
.lightbox.full .bar { opacity: 0; transition: opacity .3s; }
.lightbox.full .bar:hover,
.lightbox.full .bar:focus-within { opacity: 1; }

/* Bottom bar:  ‹ PREV   03 OF 10   NEXT ›   VIEW ALL */
.lightbox .bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px 28px;
  padding: 0 var(--side) 8px;
}
.lightbox .bar button,
.lightbox .bar .counter { padding: 14px 4px; font: inherit; letter-spacing: inherit; text-transform: inherit; }
.lightbox .bar button { transition: color .3s; }
.lightbox .bar button:hover { color: var(--fg); }
.lightbox .counter { font-variant-numeric: tabular-nums; }
.lightbox .close { margin-left: var(--s3); }
@media (max-width: 899px) { .lightbox .prev-text, .lightbox .next-text { display: none; } }

/* ── home (about) ── */

.about { padding: 16px var(--side) 0; }
.about h2 { font-size: 32px; max-width: 14em; }
.about .text { margin: 24px 0 12px; font-size: 17px; max-width: 34em; }
.about .meta { text-transform: none; letter-spacing: .06em; font-size: 12px; }

/* The portrait sits under the text on mobile, beside it on desktop. */
.portrait { margin: 40px 0 0; width: 62%; }
.portrait img,
.placeholder { display: block; width: 100%; aspect-ratio: var(--ratio); }
.placeholder { border: 1px solid color-mix(in srgb, var(--fg) 22%, transparent); }

/* ── desktop ── */

@media (min-width: 900px) {
  :root { --side: 12vw; --cols: 3; --gap: 24px; --edge: 88px; }

  .top { padding: var(--s7) var(--side) var(--s6); }
  .top h1 { --fs: 36px; }
  .top:has(.series) h1 { --fs: 36px; }
  .top:has(.series) h1 > a { padding-left: var(--side); }
  .index { gap: 0 var(--s6); margin-top: var(--s3); font-size: 12px; letter-spacing: .16em; }

  .arrow { --btn: 52px; }

  .intro { grid-template-columns: 1fr 1fr; margin-bottom: var(--s5); padding-top: var(--s4); }
  .blurb { font-size: 19px; }

  .about {
    display: grid;
    grid-template-columns: minmax(0, 36em) auto;
    justify-content: center;
    align-items: center;
    gap: 8vw;
    padding: 24px var(--side) 0;
  }
  .about h2 { font-size: 52px; max-width: 14em; }
  .portrait { margin: 0; width: auto; }
  .portrait img,
  .placeholder { height: min(62vh, 560px); width: auto; }
}


@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
