:root {
  --ink: #060606;
  --muted: #8b8b8b;
  --paper: #ffffff;
  --header-height: 156px;
  /* name sits just right of the agency flip Back control (arrow tip 32px, text ends ~94px),
     with a clear gap so they don't collide */
  --header-left: 124px;
  --rail-pad: 32px;
  /* The grid: every image hangs from the same top line (the header's bottom edge)
     and reserves the same caption band below, so tops and bottoms align like
     prints on a gallery wall. */
  --cap-h: 86px;
  --rail-bottom: 40px;
  --img-h: calc(100vh - var(--header-height) - var(--cap-h) - var(--rail-bottom));
}

/* ═══════════════════════════════════════════
   OSKAR HALLGRÍMSSON — Photography Portfolio
   Typography: oskarhallgrimsson.agency
   ═══════════════════════════════════════════ */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: Helvetica, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.3;
}

img { display: block; }
button { font: inherit; cursor: pointer; background: none; border: none; color: inherit; }

.page { display: none; }
.page.active { display: block; animation: page-in 280ms ease; }

@keyframes page-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Images fade in as they finish loading (site.js adds .is-loaded) */
.h-track img,
.gallery-track img {
  opacity: 0;
  transition: opacity 350ms ease;
}

.h-track img.is-loaded,
.gallery-track img.is-loaded {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .page.active { animation: none; }
  .h-track img,
  .gallery-track img { opacity: 1; transition: none; }
}

/* ═══ BARS ═══ */

.top-bar,
.gallery-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--rail-pad) 0 var(--header-left);
  background: var(--paper);
}

.top-bar-left {
  display: flex;
  flex-direction: column;   /* name on top, title on the next line */
  align-items: flex-start;  /* name + title both left-aligned */
  gap: 8px;
  min-width: 0;
}

.site-title {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1;
  white-space: nowrap;
}

.site-sub {
  display: flex;                  /* per-char spans (site.js fitSubToTitle) */
  justify-content: space-between; /* distributed to exactly the name's width */
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Folio — live counter, top right, magazine page-number style */
.folio {
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 4px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ═══ GALLERY BAR ═══ */

.gallery-bar-left {
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 0;
}

.back-btn {
  position: relative;
  flex-shrink: 0;
  font-size: 0.8125rem;
  font-weight: 900;
  color: var(--muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: color 0.15s ease;
}

.back-btn:hover { color: var(--ink); }

/* same rule-draw as the cards */
.back-btn::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 360ms cubic-bezier(0.2, 0.74, 0.18, 1);
}

.back-btn:hover::after,
.back-btn:focus-visible::after {
  transform: scaleX(1);
}

.gallery-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.gallery-title {
  font-size: 2rem;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-meta {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 4px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ═══ HORIZONTAL RAIL ═══ */

.h-scroll {
  position: fixed;
  inset: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  /* no scroll-snap: it fights the wheel handler (each tick snaps back,
     which reads as "scrolling is broken"); arrow keys align precisely */
}

.h-scroll::-webkit-scrollbar { height: 2px; }
.h-scroll::-webkit-scrollbar-track { background: transparent; }
.h-scroll::-webkit-scrollbar-thumb { background: #d5d2cc; border-radius: 2px; }

.h-track,
.gallery-track {
  display: flex;
  align-items: flex-start;          /* every image hangs from the grid line */
  height: 100%;
  padding: var(--header-height) var(--rail-pad) 0 var(--header-left);
  gap: 16px;
}

/* ═══ STRIP ITEMS (shared figure grid) ═══ */

.strip-item {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
}

.strip-item.is-link { cursor: pointer; }

.strip-item img {
  height: var(--img-h);
  width: auto;
  max-width: 80vw;
  object-fit: contain;
  object-position: left top;
}

.strip-item figcaption {
  height: var(--cap-h);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;       /* captions sit under the image, left-aligned */
  gap: 6px;
  text-align: left;
}

/* Overview covers are buttons; uniform cropped cards */
.strip-link {
  display: block;
  padding: 0;
}

/* Cards: same height, per-cover width from the admin-set crop.
   The img inside is positioned by percentages (inline styles), so the
   window scales with the card on any screen. */
.cover-window {
  position: relative;
  overflow: hidden;
  height: var(--img-h);
}

.cover-window img {
  position: absolute;
  height: auto;
  max-width: none;
}

.strip-link:focus-visible,
.back-btn:focus-visible {
  outline: 3px solid #155cff;
  outline-offset: 6px;
}

/* Hover = the card's double rules drawing themselves under the photo.
   The image itself is never dimmed or filtered. */
.strip-rules {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
}

.strip-rules span {
  display: block;
  height: 2px;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 420ms cubic-bezier(0.2, 0.74, 0.18, 1);
}

.strip-rules span:nth-child(2) {
  height: 1px;
  transition-delay: 60ms;
}

.strip-item.is-link:hover .strip-rules span,
.strip-item.is-link:focus-within .strip-rules span {
  transform: scaleX(1);
}

.strip-title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.strip-index {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}

.strip-title {
  font-size: 1rem;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: -0.01em;
}


.strip-meta {
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 4px;
  text-transform: uppercase;
}

/* Gallery photo captions — magazine style: under the image, left-aligned */
.img-cap {
  font-size: 0.75rem;
  font-style: italic;
  color: #6b6b6b;
  line-height: 1.45;
  letter-spacing: 0.2px;
  max-width: min(100%, 64ch);
}

/* ─── Mobile: vertical scroll ───
   Under 641px the horizontal rail becomes a vertical stack — phones
   scroll down, not sideways. The agency card on mobile opens this page
   in a new tab (no embedded Back control), so the left gutter reserved
   for it on desktop is dropped. */

@media (max-width: 640px) {
  :root {
    --header-height: 96px;
    --header-left: 16px;
    --rail-pad: 16px;
  }

  .top-bar-left { gap: 7px; }

  /* embedded in the agency card: its Back pill overlays top-left, so the
     name lockup moves to the right edge instead */
  body.embedded .top-bar {
    justify-content: flex-end;
    padding-left: 84px;
  }

  body.embedded .top-bar-left {
    align-items: flex-end;
  }

  .site-title { font-size: 1.6rem; }
  .site-sub { font-size: 0.5rem; letter-spacing: 3.2px; }
  .gallery-title { font-size: 1.25rem; }
  .gallery-head { gap: 6px; }
  .gallery-meta {
    font-size: 0.5625rem;
    letter-spacing: 2.5px;
    white-space: normal;
    line-height: 1.6;
  }
  .back-btn { font-size: 0.6875rem; }

  .folio { display: none; }

  .h-scroll {
    overflow-x: hidden;
    overflow-y: auto;
    scroll-snap-type: none;
  }

  .h-track,
  .gallery-track {
    flex-direction: column;
    align-items: stretch;
    height: auto;
    min-height: 100%;
    padding: calc(var(--header-height) + 4px) 14px 40px;
    gap: 26px;
  }

  .strip-item img {
    height: auto;
    width: 100%;
    max-width: none;
  }

  .cover-window {
    width: 100%;
    height: auto; /* the crop's aspect-ratio drives the height */
  }

  .cover-window img {
    width: auto;
    height: auto;
  }

  .strip-item figcaption {
    height: auto;
    min-height: 0;
    padding-top: 10px;
    gap: 4px;
  }

  .strip-link { width: 100%; }
  .strip-link img { width: 100%; }

  .strip-title { font-size: 1.05rem; }
  .strip-meta { letter-spacing: 3px; }

  .img-cap { padding: 0 2px; }
}
