/* ==========================================================================
   Ivan — public site
   Editorial light theme: cream ground, near-black ink, photography carries the page.
   A dark "darkroom" theme swaps the colour tokens only (see :root[data-theme="dark"]).
   Every colour, size and rhythm value is a token below; nothing is hardcoded further down.
   ========================================================================== */

:root {
  /* ---- colour ---- */
  --paper:        #faf8f5;
  --paper-sunk:   #f2eee8;
  --ink:          #14110f;
  --ink-soft:     #4a443e;
  --ink-mute:     #8c837a;
  --line:         #e2dcd3;
  --danger:       #a4342a;
  --on-dark:      #fdfbf8;   /* text laid over photographs — constant in both themes */
  --on-ink:       #fdfbf8;   /* text on an --ink fill (buttons) — flips with the theme */
  --night:        #0b0908;   /* stage behind heroes and the lightbox */
  color-scheme: light;

  /* ---- type ---- */
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  --step--1: clamp(.78rem, .76rem + .1vw, .84rem);
  --step-0:  clamp(.95rem, .92rem + .16vw, 1.05rem);
  --step-1:  clamp(1.15rem, 1.08rem + .35vw, 1.4rem);
  --step-2:  clamp(1.5rem, 1.3rem + .9vw, 2.1rem);
  --step-3:  clamp(2rem, 1.5rem + 2.2vw, 3.4rem);
  --step-4:  clamp(2.6rem, 1.5rem + 4.6vw, 6rem);

  /* ---- space ---- */
  --gutter:    clamp(1.25rem, .6rem + 2.6vw, 3.5rem);
  --section:   clamp(4rem, 2rem + 8vw, 9rem);
  --measure:   66ch;
  --wide:      1680px;
  --content:   1200px;

  --ease: cubic-bezier(.22, .61, .36, 1);
}

/* Dark: a darkroom wall. Near-neutral charcoal so prints read true — no colour cast
   competing with the work — and warm paper-white ink, like a caption card under a frame.
   Set on <html> by the inline script in _Layout before first paint. */
:root[data-theme="dark"] {
  --paper:        #0f0e0d;
  --paper-sunk:   #1a1816;
  --ink:          #ece6dd;
  --ink-soft:     #b3aba1;
  --ink-mute:     #7d756c;
  --line:         #2a2724;
  --danger:       #e0786c;
  --on-ink:       #0f0e0d;
  color-scheme: dark;
}

/* ==========================================================================
   Reset
   ========================================================================== */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Only runs when the reader flips the switch — the theme is set before first paint. */
  transition: background-color .6s var(--ease), color .6s var(--ease);
}

img, picture, video { display: block; max-width: 100%; height: auto; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -.02em;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0 0 1.1em; }
p:last-child { margin-bottom: 0; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .22em; }

button { font: inherit; color: inherit; }

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--ink);
  color: var(--on-ink);
  padding: .8rem 1.2rem;
}
.skip-link:focus { left: 0; }

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

/* ==========================================================================
   Layout primitives
   ========================================================================== */

.wrap       { width: min(100% - var(--gutter) * 2, var(--content)); margin-inline: auto; }
.wrap--wide { width: min(100% - var(--gutter) * 2, var(--wide));    margin-inline: auto; }
.wrap--text { width: min(100% - var(--gutter) * 2, var(--measure)); margin-inline: auto; }

.section { padding-block: var(--section); }
.section--tight { padding-block: calc(var(--section) * .55); }

.eyebrow {
  font-size: var(--step--1);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-family: var(--font-body);
  font-weight: 500;
  margin: 0 0 1.4rem;
}

.rule { border: 0; border-top: 1px solid var(--line); margin: 0; }

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  transition: background .35s var(--ease), border-color .35s var(--ease), color .35s var(--ease);
}

/* Over a hero the bar floats transparently until the page scrolls. */
.site-header[data-overlay="true"]:not(.is-scrolled) {
  position: fixed;
  inset-inline: 0;
  background: transparent;
  border-bottom-color: transparent;
  color: var(--on-dark);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 4.5rem;
}

.brand {
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: -.01em;
  text-decoration: none;
}

.nav { display: flex; align-items: center; gap: clamp(1rem, 2.2vw, 2.4rem); }

.nav a {
  font-size: var(--step--1);
  letter-spacing: .12em;
  text-transform: uppercase;
  text-decoration: none;
  padding-block: .4rem;
  position: relative;
}

.nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s var(--ease);
}
.nav a:hover::after,
.nav a[aria-current="page"]::after { transform: scaleX(1); }

.nav-toggle {
  display: none;
  background: none;
  border: 0;
  padding: .6rem;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  width: 22px; height: 1.5px;
  background: currentColor;
  transition: transform .3s var(--ease), opacity .3s var(--ease);
}
.nav-toggle span + span { margin-top: 5px; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

.brand { margin-right: auto; }

/* Theme switch: a half-exposed disc that turns over when the lights go down. */
.theme-toggle {
  background: none;
  border: 0;
  padding: .6rem;
  margin-right: -.6rem;
  cursor: pointer;
  opacity: .8;
  transition: opacity .3s var(--ease);
}
.theme-toggle:hover { opacity: 1; }
.theme-toggle svg {
  display: block;
  width: 17px; height: 17px;
  transition: transform .8s var(--ease);
}
:root[data-theme="dark"] .theme-toggle svg { transform: rotate(180deg); }

@media (max-width: 760px) {
  .nav-toggle { display: block; order: 1; margin-right: -.6rem; }
  .theme-toggle { margin-right: 0; }

  .nav {
    position: fixed;
    inset: 4.5rem 0 auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--paper);
    color: var(--ink);
    padding: 1rem var(--gutter) 2.5rem;
    border-bottom: 1px solid var(--line);
    transform: translateY(-140%);
    transition: transform .4s var(--ease);
  }
  .nav[data-open="true"] { transform: translateY(0); }
  .nav a { width: 100%; padding-block: .9rem; border-bottom: 1px solid var(--line); font-size: var(--step-0); }
  .nav a::after { display: none; }
}

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
  position: relative;
  min-height: 92svh;
  display: grid;
  align-items: end;
  overflow: hidden;
  background: var(--night);
  color: var(--on-dark);
}

.hero__media { position: absolute; inset: 0; }

/* <picture> is the element in the flow, so it — not just the <img> — has to fill the box,
   otherwise height:100% on the image resolves against an auto-height parent. */
.hero__media picture,
.hero__media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.hero__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,.35) 0%, rgba(0,0,0,0) 35%, rgba(0,0,0,.55) 100%);
}

.hero__body {
  position: relative;
  padding-bottom: clamp(3rem, 7vw, 7rem);
  padding-top: 8rem;
}

.hero__title {
  font-size: var(--step-4);
  max-width: 16ch;
}

.hero__scroll {
  position: absolute;
  bottom: 1.6rem;
  right: var(--gutter);
  font-size: var(--step--1);
  letter-spacing: .18em;
  text-transform: uppercase;
  opacity: .8;
  animation: nudge 2.6s var(--ease) infinite;
}
@keyframes nudge {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(6px); }
}

/* ==========================================================================
   Intro / prose
   ========================================================================== */

.lede {
  font-family: var(--font-display);
  font-size: var(--step-2);
  line-height: 1.32;
  letter-spacing: -.015em;
  max-width: 26ch;
}

.prose { max-width: var(--measure); font-size: var(--step-0); }
.prose h2 { font-size: var(--step-2); margin: 2.4em 0 .6em; }
.prose h3 { font-size: var(--step-1); margin: 2em 0 .5em; }
.prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.1em; }
.prose li { margin-bottom: .4em; }
.prose blockquote {
  margin: 2em 0;
  padding-left: 1.4em;
  border-left: 2px solid var(--ink);
  font-family: var(--font-display);
  font-size: var(--step-1);
  line-height: 1.4;
}
.prose img { margin: 2.2em 0; width: 100%; }
.prose figure { margin: 2.2em 0; }
.prose figure img { margin: 0; }
.prose figcaption { font-size: var(--step--1); color: var(--ink-mute); margin-top: .7em; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.6em 0; }

/* ==========================================================================
   Gallery cards
   ========================================================================== */

.cards {
  display: grid;
  gap: clamp(1.5rem, 3vw, 3rem) clamp(1rem, 2vw, 2rem);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
}
.cards--two { grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); }

.card { text-decoration: none; display: block; }

.card__media {
  position: relative;
  overflow: hidden;
  background: var(--paper-sunk);
  aspect-ratio: 4 / 5;
}
.card--wide .card__media { aspect-ratio: 3 / 2; }

.card__media picture,
.card__media img {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 1.1s var(--ease);
}
.card:hover .card__media img { transform: scale(1.04); }

.card__title { font-family: var(--font-display); font-size: var(--step-1); margin: 1rem 0 .15rem; }
/* Sentence case, not uppercase: card meta carries a free-text subtitle as often as a
   photo count, and a shouted sentence reads badly. */
.card__meta {
  font-size: var(--step--1);
  color: var(--ink-mute);
}

/* ==========================================================================
   Photo grid (masonry via CSS columns) + reveal
   ========================================================================== */

.photo-grid { columns: 3; column-gap: clamp(.6rem, 1.4vw, 1.4rem); }
@media (max-width: 1100px) { .photo-grid { columns: 2; } }
@media (max-width: 620px)  { .photo-grid { columns: 1; } }

.photo-grid__item {
  break-inside: avoid;
  margin-bottom: clamp(.6rem, 1.4vw, 1.4rem);
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: var(--paper-sunk);
  cursor: zoom-in;
  position: relative;
  overflow: hidden;
}
.photo-grid__item picture { display: block; }
.photo-grid__item img { width: 100%; height: auto; transition: transform .9s var(--ease); }
.photo-grid__item:hover img { transform: scale(1.03); }

.reveal { opacity: 0; transform: translateY(18px); }
.reveal.is-visible {
  opacity: 1;
  transform: none;
  transition: opacity .9s var(--ease), transform .9s var(--ease);
}

/* ==========================================================================
   Lightbox
   ========================================================================== */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--night);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity .32s var(--ease), visibility .32s;
}
.lightbox[data-open="true"] { opacity: 1; visibility: visible; }

/* The stage's own track must be definite (minmax(0, 1fr), not the implicit auto row) or the
   image's max-height: 100% has nothing to resolve against, and a tall photo on a large screen
   grows past the stage and covers the caption bar. */
.lightbox__stage {
  position: relative;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  overflow: hidden;
  padding: clamp(2.5rem, 5vw, 4rem) clamp(1rem, 7vw, 6rem);
  min-height: 0;
}
.lightbox__stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
}

.lightbox__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: rgba(253,251,248,.75);
  font-size: var(--step--1);
  letter-spacing: .1em;
  padding: 0 clamp(1rem, 4vw, 2.5rem) clamp(1rem, 3vw, 2rem);
}

.lightbox__btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(253,251,248,.1);
  border: 0;
  color: var(--on-dark);
  width: 3rem; height: 3rem;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 1.4rem;
  transition: background .25s var(--ease);
}
.lightbox__btn:hover { background: rgba(253,251,248,.22); }
.lightbox__btn[data-dir="prev"] { left: clamp(.5rem, 2vw, 1.5rem); }
.lightbox__btn[data-dir="next"] { right: clamp(.5rem, 2vw, 1.5rem); }

.lightbox__close {
  position: absolute;
  top: clamp(.8rem, 2vw, 1.5rem);
  right: clamp(.8rem, 2vw, 1.5rem);
  background: none; border: 0;
  color: var(--on-dark);
  font-size: 1.6rem;
  line-height: 1;
  padding: .6rem;
  cursor: pointer;
  z-index: 1;
}

body.is-locked { overflow: hidden; }

/* ==========================================================================
   Forms
   ========================================================================== */

.field { margin-bottom: 1.5rem; }
.field label {
  display: block;
  font-size: var(--step--1);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: .5rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: .65rem 0;
  transition: border-color .25s var(--ease);
}
.field input:focus,
.field textarea:focus,
.field select:focus { outline: none; border-bottom-color: var(--ink); }
.field textarea { resize: vertical; min-height: 9rem; }

/* Honeypot: hidden from people, reachable by naive bots. */
.hp { position: absolute; left: -9999px; opacity: 0; height: 0; overflow: hidden; }

.btn {
  display: inline-block;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--on-ink);
  padding: .85rem 2.2rem;
  font-size: var(--step--1);
  letter-spacing: .16em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background .3s var(--ease), color .3s var(--ease);
}
.btn:hover { background: transparent; color: var(--ink); }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--ghost:hover { background: var(--ink); color: var(--on-ink); }

.link-more {
  display: inline-block;
  font-size: var(--step--1);
  letter-spacing: .16em;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  padding-bottom: .25rem;
}

.note {
  padding: 1rem 1.2rem;
  border-left: 2px solid var(--ink);
  background: var(--paper-sunk);
  font-size: var(--step--1);
  margin-bottom: 1.8rem;
}
.note--error { border-left-color: var(--danger); }

.validation-summary, .field-error { color: var(--danger); font-size: var(--step--1); }
.field-error { margin-top: .4rem; display: block; }

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: clamp(2.5rem, 5vw, 4rem);
  font-size: var(--step--1);
  color: var(--ink-soft);
}
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2.5rem;
  align-items: baseline;
  justify-content: space-between;
}
.site-footer a { text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.socials { display: flex; gap: 1.4rem; letter-spacing: .12em; text-transform: uppercase; }

/* ==========================================================================
   Page header (non-hero pages)
   ========================================================================== */

.page-head { padding-block: clamp(3rem, 7vw, 6rem) clamp(2rem, 4vw, 3.5rem); }
.page-head h1 { font-size: var(--step-3); max-width: 20ch; }
.page-head p { margin-top: 1.2rem; color: var(--ink-soft); max-width: 52ch; }

.photo-placeholder {
  width: 100%;
  height: 100%;
  min-height: 12rem;
  background: var(--paper-sunk);
}

.empty-state {
  padding: clamp(3rem, 8vw, 6rem) 0;
  text-align: center;
  color: var(--ink-mute);
}

/* ==========================================================================
   Journal + about
   ========================================================================== */

.post-head { padding-block: clamp(3rem, 7vw, 6rem) 2rem; }
.post-head h1 { font-size: var(--step-3); }
.post-meta {
  font-size: var(--step--1);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 1.2rem;
}
.post-cover { margin-bottom: clamp(2rem, 5vw, 4rem); }

.about-grid {
  display: grid;
  gap: clamp(2rem, 5vw, 4.5rem);
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  align-items: start;
}
@media (max-width: 860px) { .about-grid { grid-template-columns: 1fr; } }

.contact-grid {
  display: grid;
  gap: clamp(2rem, 5vw, 4.5rem);
  grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
  align-items: start;
}
@media (max-width: 860px) { .contact-grid { grid-template-columns: 1fr; } }

.detail-list { list-style: none; padding: 0; margin: 0; }
.detail-list li { padding-block: .8rem; border-bottom: 1px solid var(--line); }
.detail-list li:first-child { border-top: 1px solid var(--line); }

/* ==========================================================================
   Motion preferences
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}
