/* =========================================================
   PeterBjoerk.com — site styles
   Fonts: League Gothic (headings/nav), Nunito (body text).
   ========================================================= */

:root {
  /* Colours. Dark mode (below) swaps these, so use --fg / --bg rather than fixed colours. */
  --fg: #000;             /* text, lines, icons */
  --bg: #fff;             /* page background */
  --grey: #6b6b6b;
  --glass: rgba(255, 255, 255, .6);   /* frosted homepage header */
  --glass-edge: rgba(0, 0, 0, .08);
  --light-only: block;    /* things shown only in light mode (black logo, moon icon) */
  --dark-only: none;      /* things shown only in dark mode (white logo, sun icon) */
  color-scheme: light;
  /* iPhone screen edges (Dynamic Island / notch / rounded corners). 0 on other devices. */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --gutter: 3vw;          /* page side margin */
  --gap: 2.2vw;           /* space between photos */
  --max: 1500px;          /* max content width */
  --heading: "League Gothic", "Oswald", Impact, sans-serif;
  --body: "Nunito", "Omnes", "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Dark mode ----------
   Follows the visitor's device setting, unless they chose with the sun/moon button
   (saved on their device; the small script at the top of each page sets data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fg: #f2f2f2; --bg: #0e0e0e; --grey: #9b9b9b;
    --glass: rgba(14, 14, 14, .55); --glass-edge: rgba(255, 255, 255, .1);
    --light-only: none; --dark-only: block;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fg: #f2f2f2; --bg: #0e0e0e; --grey: #9b9b9b;
  --glass: rgba(14, 14, 14, .55); --glass-edge: rgba(255, 255, 255, .1);
  --light-only: none; --dark-only: block;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.6;
  transition: background-color .3s, color .3s;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }

h1, h2, h3, h4 {
  font-family: var(--heading);
  font-weight: 400;
  text-transform: uppercase;
  line-height: 1.2;
  margin: 0 0 .6em;
  letter-spacing: .01em;
}
h1, h2 { font-size: clamp(34px, 3.6vw, 52px); }
h3 { font-size: clamp(24px, 2.4vw, 34px); }
h4 { font-size: clamp(20px, 1.8vw, 26px); }

.center { text-align: center; }
/* Main page headings (h1) that should look like smaller headings */
h1.as-h3 { font-size: clamp(24px, 2.4vw, 34px); }
h1.as-h4 { font-size: clamp(20px, 1.8vw, 26px); }
/* Read by Google and screen readers, but not shown on screen */
.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;
}

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px var(--gutter);
  max-width: calc(var(--max) + 2 * var(--gutter));
  margin: 0 auto;
}
.logo img { height: 76px; width: auto; }
/* Two versions of the see-through logo: black for light mode, white for dark mode */
.logo .logo-light { display: var(--light-only); }
.logo .logo-dark { display: var(--dark-only); }
.site-nav { display: flex; align-items: center; gap: 28px; }
.site-nav a {
  font-family: var(--heading);
  text-transform: uppercase;
  text-decoration: none;
  font-size: 14px;
  letter-spacing: .04em;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 3px; }

.social {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--fg); color: var(--bg);
}
.social svg { width: 18px; height: 18px; }
/* Instagram + light/dark button, side by side */
.nav-icons { display: inline-flex; align-items: center; gap: 10px; margin-left: 18px; }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; padding: 0; border-radius: 50%; cursor: pointer;
  background: transparent; color: var(--fg); border: 2px solid var(--fg);
  transition: background-color .2s, color .2s;
}
@media (hover: hover) { .theme-toggle:hover { background: var(--fg); color: var(--bg); } }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .moon { display: var(--light-only); }  /* light mode: tap the moon to go dark */
.theme-toggle .sun { display: var(--dark-only); }    /* dark mode: tap the sun to go light */

.menu-toggle {
  display: none; background: none; border: 0; padding: 8px; cursor: pointer;
}
.menu-toggle span { display: block; width: 26px; height: 2px; background: var(--fg); margin: 6px 0; }

@media (max-width: 767px) {
  .logo img { height: 56px; }
  .menu-toggle { display: block; position: relative; z-index: 30; }
  .site-nav {
    position: fixed; inset: 0; z-index: 20;
    background: var(--bg);
    flex-direction: column; justify-content: center; gap: 22px;
    opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  .site-nav a { font-size: 34px; }
  .site-nav .nav-icons { margin: 14px 0 0; gap: 16px; }
  .site-nav .social, .theme-toggle { width: 48px; height: 48px; }
  body.menu-open .site-nav { opacity: 1; pointer-events: auto; }
  body.menu-open { overflow: hidden; }
}

/* ---------- Frosted-glass header that stays at the top (every page) ----------
   The header floats over the page; once you scroll, a blurred see-through
   background fades in and the header gets slimmer (site.js adds .scrolled).
   On iPhones the page runs up behind the Dynamic Island / notch (viewport-fit=cover),
   and the header's top padding grows by that amount so the glass covers it too. */
.site-header.glass {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  max-width: none;
  padding-top: calc(28px + var(--safe-top));
  padding-left: max(var(--gutter), calc((100% - var(--max)) / 2), var(--safe-left));
  padding-right: max(var(--gutter), calc((100% - var(--max)) / 2), var(--safe-right));
  transition: padding .35s ease;
}
.site-header.glass::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  backdrop-filter: blur(24px) saturate(170%);
  border-bottom: 1px solid var(--glass-edge);
  opacity: 0; transition: opacity .35s ease;
}
.site-header.glass .logo img { transition: height .35s ease; }
.site-header.glass.scrolled { padding-top: calc(12px + var(--safe-top)); padding-bottom: 12px; }
.site-header.glass.scrolled::before { opacity: 1; }
.site-header.glass.scrolled .logo img { height: 52px; }
/* room for the floating header: 28px + 76px logo + 28px, plus the usual 20px */
.site-header.glass + main { padding-top: calc(152px + var(--safe-top)); }
@media (max-width: 767px) {
  .site-header.glass + main { padding-top: calc(132px + var(--safe-top)); }
  .site-header.glass.scrolled { padding-top: calc(8px + var(--safe-top)); padding-bottom: 8px; }
  .site-header.glass.scrolled .logo img { height: 42px; }
  /* the full-screen phone menu covers the glass */
  body.menu-open .site-header.glass::before { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .site-header.glass, .site-header.glass::before, .site-header.glass .logo img { transition: none; }
}

/* ---------- Main content ---------- */
main {
  max-width: calc(var(--max) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 20px var(--gutter) 60px;
  /* iPhone on its side: keep photos clear of the notch */
  padding-left: max(var(--gutter), var(--safe-left));
  padding-right: max(var(--gutter), var(--safe-right));
}
.narrow { max-width: 700px; margin-left: auto; margin-right: auto; }
.text-block { margin: 60px auto; }
.text-block p { margin: 0 0 1em; }

/* ---------- Footer ---------- */
.site-footer { text-align: center; padding: 40px 0 60px; }

/* ---------- Homepage masonry gallery ---------- */
.masonry { display: flex; gap: var(--gap); align-items: flex-start; }
.masonry-col { flex: 1; display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.masonry img { width: 100%; cursor: zoom-in; }
/* Before JS arranges the columns (or if JS is off) show a simple 3-column layout */
.masonry:not(.ready) { display: block; columns: 3; column-gap: var(--gap); }
.masonry:not(.ready) img { margin-bottom: var(--gap); break-inside: avoid; }
@media (max-width: 767px) {
  .masonry { --gap: 8px; }
  .masonry:not(.ready) { columns: 2; }
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: none; align-items: center; justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 92vw; max-height: 90vh; width: auto; height: auto; object-fit: contain; }
.lightbox button {
  position: absolute; background: none; border: 0; cursor: pointer;
  font-size: 34px; line-height: 1; padding: 16px; color: var(--fg);
}
.lightbox .lb-close { top: 10px; right: 14px; }
.lightbox .lb-prev { left: 8px; top: 50%; transform: translateY(-50%); }
.lightbox .lb-next { right: 8px; top: 50%; transform: translateY(-50%); }
@media (max-width: 767px) {
  /* Phones: arrows below the photo instead of on top of it (swiping also works) */
  .lightbox .lb-prev, .lightbox .lb-next { top: auto; bottom: 18px; transform: none; font-size: 40px; }
  .lightbox .lb-prev { left: 22%; }
  .lightbox .lb-next { right: 22%; }
  /* Phones: photo uses the full screen width */
  .lightbox img { max-width: 100vw; max-height: 80vh; }
}

/* ---------- Projects index ---------- */
.project-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 40px var(--gap);
}
.project-grid a { text-decoration: none; display: block; }
.project-grid img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; transition: opacity .2s; }
.project-grid a:hover img { opacity: .85; }
.project-grid .project-title { font-size: 18px; margin-top: 14px; }
@media (max-width: 767px) { .project-grid { grid-template-columns: 1fr; } }

/* ---------- Commissions (client work): cover photo with the client's logo bottom-right ---------- */
.commission-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 48px var(--gap); }
.commission-card { display: block; text-decoration: none; }
.commission-media { position: relative; display: block; overflow: hidden; }
.commission-photo { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; object-position: 50% 30%; transition: transform .6s ease; }  /* crop a little high: keeps faces in portrait photos */
.commission-logo {
  position: absolute; right: 4%; bottom: 5%;
  width: auto; height: auto; max-width: 30%; max-height: 24%;
  filter: drop-shadow(0 1px 8px rgba(0, 0, 0, .35));   /* keeps light logos readable on bright photos */
  pointer-events: none;
}
.commission-client { font-size: 24px; margin: 14px 0 0; }
.commission-job { margin: 0; color: var(--grey); }
.commission-subtitle { color: var(--grey); text-transform: uppercase; letter-spacing: .1em; font-size: 13px; margin-top: -.4em; }
.commission-logo.logo-dark { filter: drop-shadow(0 0 4px rgba(255, 255, 255, .9)) drop-shadow(0 0 10px rgba(255, 255, 255, .5)); }  /* dark logos: soft white glow instead */
@media (hover: hover) { .commission-card:hover .commission-photo { transform: scale(1.03); } }
@media (max-width: 767px) { .commission-grid { grid-template-columns: 1fr; gap: 36px; } }
@media (prefers-reduced-motion: reduce) { .commission-photo { transition: none; } }

/* ---------- Slideshow (Sacred Geometry, Auto-Biographies) ---------- */
.slideshow { position: relative; margin: 30px auto; }
.slides { position: relative; height: 72vh; }
.slides img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; opacity: 0; transition: opacity .5s;
}
.slides img.active { opacity: 1; }
.slideshow .prev, .slideshow .next {
  position: absolute; top: 36vh; transform: translateY(-50%);
  background: none; border: 0; cursor: pointer; font-size: 30px; padding: 10px; z-index: 2; color: var(--fg);
}
.slideshow .prev { left: -10px; }
.slideshow .next { right: -10px; }
.thumbs { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.thumbs img { width: 70px; height: 56px; object-fit: cover; cursor: pointer; opacity: .55; }
.thumbs img.active, .thumbs img:hover { opacity: 1; }
@media (max-width: 767px) {
  /* Phones: the slide area fits each photo's shape (set in site.js); arrows sit below the photo */
  .slideshow { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; margin: 20px 0; }
  .slides { order: 1; width: 100%; height: 60vh; transition: height .3s; }
  .slideshow .prev, .slideshow .next { order: 2; position: static; transform: none; font-size: 34px; padding: 6px 14px; }
  .thumbs { order: 3; width: 100%; }
  .thumbs img { width: 48px; height: 40px; }
}

/* ---------- Photo story (On The Waterfront) ---------- */
.story figure { margin: 0 0 70px; }
.story figure.bleed { margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter)); }
.story figcaption { font-size: 13px; margin-top: 8px; color: var(--fg); }
.story figure.bleed figcaption { padding-left: var(--gutter); }
.story .pair { display: flex; gap: var(--gap); margin-bottom: 70px; }
.story .pair figure { flex: 1; margin: 0; }
.story .pair img { width: 100%; }
.story .text-block { max-width: 660px; text-align: center; }
@media (max-width: 767px) { .story .pair { flex-direction: column; } }

/* ---------- Two-column photo grid (5 Kilometres) ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.grid-2 img { width: 100%; aspect-ratio: 7 / 5; object-fit: cover; cursor: zoom-in; }
@media (max-width: 767px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Video page ---------- */
.video-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6vw; align-items: center;
  margin: 40px 0 80px;
}
.video-row.reverse .video-text { order: 2; }
.video-embed { position: relative; aspect-ratio: 16 / 9; }
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
@media (max-width: 767px) {
  .video-row { grid-template-columns: 1fr; gap: 20px; }
  .video-row.reverse .video-text { order: 0; }
}

/* ---------- About page ---------- */
.about-portrait { width: 300px; margin: 20px auto 50px; }
.about-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 50px; }
@media (max-width: 767px) { .about-cols { grid-template-columns: 1fr; } }

/* ---------- Contact (email button) ---------- */
.contact-email { text-align: center; margin: 50px auto 0; max-width: 560px; }
.button, .copy-email {
  display: inline-block; font: inherit; cursor: pointer; text-decoration: none;
  background: var(--bg); color: var(--fg); border: 2px solid var(--fg);
}
.button { font-family: var(--heading); text-transform: uppercase; letter-spacing: .05em; font-size: 22px; padding: 14px 44px; }
.button:hover, .copy-email:hover { background: var(--fg); color: var(--bg); }
.email-address { margin: 28px 0 8px; display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; }
.copy-email { font-size: 12px; padding: 8px 14px; border-width: 1px; }
.email-note { color: var(--grey); }

/* ---------- Phone readability ---------- */
@media (max-width: 767px) {
  body { font-size: 15px; }
  .button { display: block; }
  .copy-email { padding: 10px 16px; }
  /* Bigger tap areas for stacked links */
  .about-cols a { display: inline-block; padding: 6px 0; }
}
