/* fhoto.se — Fredrik Härenstam Photography */
@font-face { font-family: "Jost"; src: url("jost-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Jost"; src: url("jost-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #ffffff;
  --ink: #8b8b8b;        /* wordmark, titles */
  --ink-soft: #9d9d9d;   /* descriptions, captions */
  --ink-strong: #3c3c3c;
  --gap: 12px;
  --side: clamp(16px, 3vw, 40px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.55 "Jost", "Futura", "Century Gothic", system-ui, sans-serif;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; height: auto; }
/* Make saving photos harder: no dragging, no long-press menu on phones */
.ph img, .cover img, .lb img { -webkit-user-drag: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(6px);
  padding: 22px var(--side) 18px;
}
.site-header .bar { margin: 0 auto; }
.wordmark { font-weight: 700; font-size: 17px; letter-spacing: .01em; color: var(--ink); transition: color .2s; white-space: nowrap; }
.wordmark:hover, .wordmark:focus-visible { color: var(--ink-strong); }

/* Front page: a bigger, more present name */
.is-index .site-header { padding-top: 30px; padding-bottom: 24px; }
.is-index .wordmark { font-size: clamp(21px, 2.3vw, 27px); color: #777; }

/* Story pages: name lines up with the left edge of the photos */
.is-story .site-header .bar { max-width: calc(1140px - 2 * var(--side)); }

/* Folding name: "Fredrik Härenstam Photography" <-> "FHoto" */
.wm-x { display: inline-grid; grid-template-columns: 1fr; opacity: 1;
        transition: grid-template-columns .9s cubic-bezier(.65, 0, .25, 1), opacity .7s ease; }
.wm-x > span { overflow: hidden; white-space: pre; min-width: 0; }
.wm.short .wm-x { grid-template-columns: 0fr; opacity: 0; }
.wm.short:hover .wm-x, .wm.short:focus-visible .wm-x { grid-template-columns: 1fr; opacity: 1; }
.wm.no-anim .wm-x { transition: none; }
@media (prefers-reduced-motion: reduce) { .wm-x { transition: none; } }

/* Index: cover grid */
.covers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
  padding: 8px var(--side) 0;
}
.cover { position: relative; display: block; overflow: hidden; aspect-ratio: 3 / 2; background: #f2f2f2; }
.cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s ease, opacity .5s ease; }
.cover-title {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 1rem;
  color: #fff; font-weight: 700; font-size: 19px; line-height: 1.3;
  background: rgba(0,0,0,.45);
  opacity: 0; transition: opacity .3s ease;
}
.cover:hover .cover-title, .cover:focus-visible .cover-title { opacity: 1; }
.cover:hover img { transform: scale(1.03); }

@media (hover: none) {
  .cover { aspect-ratio: auto; background: none; }
  .cover img { aspect-ratio: 3 / 2; height: auto; }
  .cover-title { position: static; display: block; opacity: 1; background: none; color: var(--ink); padding: 8px 0 6px; text-align: left; font-size: 17px; }
}
@media (max-width: 900px) { .covers { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .covers { grid-template-columns: 1fr; } }

/* Project page */
.project { max-width: 1140px; margin: 0 auto; padding: 0 var(--side); }
.project-header { text-align: center; padding: 48px 0 52px; max-width: 620px; margin: 0 auto; }
.project-header h1 { margin: 0; font-weight: 700; font-size: clamp(24px, 3.2vw, 32px); line-height: 1.2; color: var(--ink); }
.desc { margin: 14px 0 0; color: var(--ink-soft); font-size: 15px; }

.photos { display: flex; flex-direction: column; gap: var(--gap); }
.ph { margin: 0; }
.ph a { display: block; cursor: zoom-in; background: #f4f4f4; }
.ph img { width: 100%; transition: opacity .6s ease; }
.js .ph img:not(.in) { opacity: 0; }
.single .ph img { width: auto; max-height: 92vh; margin: 0 auto; }
.single .ph a { background: none; }
figcaption { color: var(--ink-soft); font-size: 14px; padding: 8px 0 18px; }

/* Justified rows: each photo grows in proportion to its aspect ratio */
.grid { display: flex; flex-wrap: wrap; gap: var(--gap); }
.grid .ph { flex: var(--r) 1 calc(var(--r) * 250px); }
.grid::after { content: ""; flex: 999 1 0; }
@media (max-width: 560px) { .grid .ph { flex-basis: calc(var(--r) * 150px); } }
/* site.js sets exact widths per row once it runs */
.grid.jl { justify-content: center; }
.grid.jl .ph { flex: none; }
.grid.jl::after { display: none; }

.project-nav {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 16px;
  padding: 64px 0 24px; font-size: 14px;
}
.project-nav a { transition: color .2s; }
.project-nav a:hover { color: var(--ink-strong); }
.project-nav span { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: #b8b8b8; }
.project-nav .next { text-align: right; }
.to-top { font-size: 13px; }
@media (max-width: 560px) {
  .project-nav { grid-template-columns: 1fr 1fr; }
  .to-top { display: none; }
}

/* Footer */
.site-footer { text-align: center; padding: 40px var(--side) 48px; font-size: 14px; }
.copyright { margin: 6px 0 0; font-size: 12px; color: #b0b0b0; }
.site-footer a:hover { color: var(--ink-strong); }

.notfound { text-align: center; padding: 15vh var(--side); }
.notfound h1 { font-size: 28px; }

/* Lightbox */
.lb { position: fixed; inset: 0; z-index: 100; background: rgba(12,12,12,.97); display: none; }
.lb.open { display: block; }
.lb figure { position: absolute; inset: 56px 64px 56px; margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.lb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb figcaption { color: #aaa; padding: 10px 0 0; }
.lb button {
  position: absolute; background: none; border: 0; color: #ddd; cursor: pointer;
  font: 300 34px/1 "Jost", system-ui, sans-serif; padding: 14px; opacity: .7; transition: opacity .2s;
}
.lb button:hover { opacity: 1; }
.lb .close { top: 6px; right: 10px; font-size: 30px; }
.lb .prev { left: 6px; top: 50%; transform: translateY(-50%); }
.lb .next { right: 6px; top: 50%; transform: translateY(-50%); }
.lb .count { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); color: #888; font-size: 13px; }
.lb .lb-mark { position: absolute; top: 15px; left: 22px; font-weight: 700; font-size: 16px; color: #fff; opacity: .3; transition: opacity .3s; cursor: default; white-space: nowrap; }
.lb .lb-mark:hover { opacity: .6; }
@media (max-width: 560px) {
  .lb figure { inset: 52px 8px 40px; }
  .lb .prev, .lb .next { top: auto; bottom: 0; transform: none; }
}
body.lb-open { overflow: hidden; }

/* Fixed rows: photos share one height and fill the full width */
.row { display: flex; gap: var(--gap); }
.row .ph { flex: var(--r) 1 0; min-width: 0; }
