/* ---------- variables ---------- */
:root {
  --bg: #f7f4ef;
  --paper: #ffffff;
  --ink: #1c1a17;
  --ink-soft: #77726a;
  --line: #ddd7cc;
  --accent: #9a3b2e;
  --accent-deep: #4a1310;
  --font-display: 'Playfair Display', serif;
  --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  font-size: clamp(15px, 0.5vw + 13.5px, 18px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- about page background ---------- */
/* one shared background value (--about-bg), reused as-is on both the body and
   the header — not two separately authored images. Because the attachment is
   "fixed", the browser positions/sizes the image relative to the viewport
   itself rather than each element's own box, so both layers land on exactly
   the same pixels automatically: no page content ever shows through the
   sticky header, and scrolling never breaks the continuity between them. */
:root {
  --about-bg:
    linear-gradient(rgba(247, 244, 239, 0.52), rgba(247, 244, 239, 0.52)),
    url('../assets/portfolioinfobackground.jpg') center top / cover no-repeat fixed;
}
body.page-about {
  background: var(--about-bg);
}
body.page-about .site-header {
  background: var(--about-bg);
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 56px);
}

/* ---------- home link (splash page only) ---------- */
.home-link {
  position: fixed;
  top: 22px;
  left: 22px;
  z-index: 100;
  padding: 8px 16px;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: var(--bg);
  transition: background .2s ease, color .2s ease;
}
.home-link:hover {
  background: var(--ink);
  color: var(--bg);
}

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 18px;
  padding-bottom: 18px;
}
.brand {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 1vw + 0.8rem, 1.4rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 16px;
  border: 1px solid var(--ink);
  border-radius: 3px;
  transition: background .2s ease, color .2s ease;
}
.brand:hover {
  background: var(--ink);
  color: var(--bg);
}
nav.main-nav {
  display: flex;
  align-items: center;
  gap: clamp(20px, 3vw, 44px);
  font-size: 0.92rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
nav.main-nav a {
  position: relative;
  padding: 4px 0;
}
nav.main-nav a::after {
  content: '';
  position: absolute;
  left: 0; right: 100%;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transition: right .25s ease;
}
nav.main-nav a:hover::after,
nav.main-nav a.active::after { right: 0; }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}
.nav-toggle span {
  width: 22px; height: 1.4px;
  background: var(--ink);
}

@media (max-width: 700px) {
  nav.main-nav {
    position: fixed;
    inset: 65px 0 0 0;
    background: var(--bg);
    flex-direction: column;
    justify-content: center;
    gap: 32px;
    font-size: 1.1rem;
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
  }
  nav.main-nav.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }
  .nav-toggle { display: flex; }
}

/* ---------- hero (intro splash) ---------- */
.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(40px, 8vh, 80px) 0;
  background-image: url('../assets/background-watercolor.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.hero-eyebrow {
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 18px;
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.6rem, 5vw + 1rem, 5.2rem);
  line-height: 1.05;
  margin: 0 0 24px;
  max-width: 16ch;
}
.hero p.lede {
  max-width: 46ch;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

/* staggered intro reveal */
.hero .hero-eyebrow.fade-in { transition-delay: .1s; }
.hero h1.fade-in { transition-delay: .22s; }
.hero p.lede.fade-in { transition-delay: .38s; }
.hero .intro-actions.fade-in { transition-delay: .54s; }

.intro-actions {
  margin-top: 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}
.intro-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 40px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: background .35s ease, color .35s ease;
}
.intro-btn:hover,
.intro-btn:focus-visible {
  background: var(--ink);
  color: var(--bg);
}
.intro-btn:focus-visible { outline: 1.5px dashed var(--accent); outline-offset: 3px; }

/* ---------- section heading ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 0 36px;
  border-top: 1px solid var(--line);
  margin-top: 0;
}
.section-head h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.6rem, 2vw + 1rem, 2.2rem);
  margin: 24px 0 0;
}
.section-head .count {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin: 24px 0 0;
}

/* ---------- gallery ---------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: start;
  gap: clamp(18px, 2.5vw, 34px);
  padding-bottom: 100px;
}
@media (max-width: 900px) {
  .gallery { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .gallery { grid-template-columns: 1fr; }
}

.piece {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.piece-frame {
  display: block;
  position: relative;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
}
.piece-frame.no-photo {
  aspect-ratio: 4 / 5;
}
.piece-photo {
  display: block;
  width: 100%;
  height: auto;
  transition: transform .5s ease;
}
.piece:hover .piece-photo { transform: scale(1.04); }

.piece-doodle {
  position: absolute;
  inset: 0;
  width: 46%;
  height: 46%;
  margin: auto;
  color: var(--ink-soft);
  opacity: .8;
}
.piece-frame:not(.no-photo) .piece-doodle { display: none; }
.piece-frame.no-photo .piece-photo { display: none; }

.piece-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 18px;
  background: linear-gradient(0deg, rgba(28,26,23,0.55) 0%, rgba(28,26,23,0) 45%);
  opacity: 0;
  transition: opacity .3s ease;
}
.piece:hover .piece-overlay,
.piece:focus-visible .piece-overlay { opacity: 1; }
.piece-overlay span {
  color: #fff;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.piece-caption {
  display: flex;
  gap: 10px;
  padding: 14px 2px 0;
  align-items: baseline;
}
.piece-num {
  font-family: var(--font-display);
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.piece-title {
  font-size: 0.98rem;
}

.piece:focus-visible .piece-frame {
  outline: 1.5px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 3vw, 36px);
  padding: clamp(16px, 5vw, 48px);
  background: rgba(18, 16, 14, 0.96);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
  z-index: 1000;
}
.lightbox.is-open { opacity: 1; pointer-events: auto; }

.lightbox-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 620px;
  width: 100%;
}
.lightbox-frame {
  max-width: min(560px, 90vw);
  position: relative;
  background: #fff;
  overflow: hidden;
}
.lightbox-frame.no-photo {
  width: min(460px, 90vw);
}
.lightbox-frame img.piece-photo {
  width: auto;
  height: auto;
  max-width: min(560px, 90vw);
  max-height: 62vh;
}
.lightbox-frame .piece-doodle { color: #b7b0a4; }

.lightbox-info { text-align: center; }
.lightbox-num {
  color: #b7b0a4;
  font-family: var(--font-display);
  font-size: 0.95rem;
}
.lightbox-title {
  font-family: var(--font-display);
  font-weight: 500;
  color: #fff;
  font-size: clamp(1.5rem, 2vw + 1.1rem, 2.1rem);
  margin: 8px 0 6px;
}
.lightbox-count {
  color: #8a8378;
  font-size: 0.85rem;
  margin: 0;
}

.lightbox-close,
.lightbox-nav {
  border: 1px solid rgba(255,255,255,0.3);
  background: transparent;
  color: #fff;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s ease, border-color .2s ease;
}
.lightbox-close:hover,
.lightbox-nav:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.6); }
.lightbox-close:focus-visible,
.lightbox-nav:focus-visible { outline: 1.5px dashed #fff; outline-offset: 2px; }

.lightbox-close {
  position: absolute;
  top: clamp(14px, 3vw, 30px);
  right: clamp(14px, 3vw, 30px);
}

@media (max-width: 640px) {
  .lightbox { flex-direction: column; padding-top: 76px; flex-wrap: wrap; }
  .lightbox-nav { position: static; }
  .lightbox-stage { order: -1; }
}

/* ---------- info page ---------- */
.info-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: clamp(30px, 6vw, 80px);
  padding: 20px 0 100px;
  align-items: start;
}
@media (max-width: 760px) {
  .info-grid { grid-template-columns: 1fr; }
}
.info-grid h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.8rem, 2.4vw + 1rem, 2.6rem);
  margin: 0 0 22px;
}
.info-grid p {
  max-width: 56ch;
  color: var(--accent-deep);
  margin-bottom: 18px;
}
.contact-block {
  border-top: none;
  padding-top: 28px;
}
.contact-block dt {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-deep);
  margin-top: 18px;
}
.contact-block dt:first-child { margin-top: 0; }
.contact-block dd {
  margin: 4px 0 0;
  font-size: 1.05rem;
}
.contact-block dd a {
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease, color .2s ease;
}
.contact-block dd a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 30px 0.5in 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.site-footer .socials {
  display: flex;
  gap: 18px;
}
.site-footer .socials a { transition: color .2s ease; }
.site-footer .socials a:hover { color: var(--accent); }

/* ---------- fade-in ---------- */
.fade-in {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .7s ease, transform .7s ease;
}
.fade-in.is-visible { opacity: 1; transform: none; }

/* ---------- page transition (brush-stroke sweep, erasing from bottom-right) ---------- */
.page-transition {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  -webkit-mask-image: url('../assets/background-watercolor.png');
  mask-image: url('../assets/background-watercolor.png');
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: 100% 100%;
  mask-position: 100% 100%;
  -webkit-mask-size: 0;
  mask-size: 0;
  filter: blur(6px);
  /* reveal (arrival) speed — kept short so the "blank page" hold doesn't grow */
  transition: mask-size .9s ease, -webkit-mask-size .9s ease, filter .9s ease, opacity .35s ease;
}
.page-transition.is-active {
  opacity: 1;
  pointer-events: auto;
  filter: blur(0);
  -webkit-mask-size: 220vmax;
  mask-size: 220vmax;
  /* leave (stroke sweep) speed — the slow, dramatic direction */
  transition: mask-size 2.2s ease, -webkit-mask-size 2.2s ease, filter 2.2s ease, opacity .35s ease;
}

main,
.site-header,
.site-footer {
  transition: opacity .6s ease, filter .6s ease, transform .6s ease;
}
body.is-transitioning > main,
body.is-transitioning > .site-header,
body.is-transitioning > .site-footer {
  opacity: 0;
  filter: blur(12px);
  transform: scale(1.04);
  transition: opacity 1.8s ease, filter 1.8s ease, transform 1.8s ease;
}

/* arriving page: snap instantly into the "fully erased" state (no flash of
   raw content), then js removes .pt-entering on the next frame so the
   already-defined transitions above animate it back to normal — continuing
   the wipe rather than holding on a blank watercolor screen */
html.pt-entering .page-transition {
  transition: none !important;
  opacity: 1 !important;
  pointer-events: auto;
  filter: blur(0);
  -webkit-mask-size: 220vmax !important;
  mask-size: 220vmax !important;
}
html.pt-entering main,
html.pt-entering .site-header,
html.pt-entering .site-footer {
  transition: none !important;
  opacity: 0;
  filter: blur(12px);
  transform: scale(1.04);
}

@media (prefers-reduced-motion: reduce) {
  .fade-in, .piece-photo, .lightbox, .lightbox-nav, .lightbox-close, .page-transition,
  main, .site-header, .site-footer {
    transition: none;
    animation: none;
    filter: none;
  }
}
