/* =========================================================
   Wiktor Bystrek - Fotografia
   Minimal gallery-first stylesheet. Theming via CSS custom
   properties on :root / [data-theme]. No preprocessor, no
   build step.
   ========================================================= */

/* Smooth cross-page fades where supported; no-op elsewhere. */
@view-transition {
  navigation: auto;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, h4, p, ul, li, figure { margin: 0; padding: 0; }
ul { list-style: none; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Theme tokens ---------- */
:root {
  --bg: #faf9f7;
  --bg-elevated: #ffffff;
  --text: #141312;
  --text-muted: #63615c;
  --border: #e4e1db;
  --accent: #141312;
  --placeholder: #ece9e3;
  --overlay: rgba(10, 10, 10, 0.92);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;

  --gap: clamp(0.5rem, 1.2vw, 1.25rem);
  --container: 1440px;
  --transition: 220ms ease;
}

/*
  Only source of truth for dark mode: the explicit data-theme attribute,
  set synchronously by the inline bootstrap script in <head> before first
  paint (it already resolves prefers-color-scheme itself). No separate
  @media(prefers-color-scheme) block here on purpose - a second source of
  truth at equal CSS specificity made the toggle fragile depending on
  stylesheet edit order.
*/
:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-elevated: #141414;
  --text: #f2f1ee;
  --text-muted: #a3a099;
  --border: #262624;
  --accent: #f2f1ee;
  --placeholder: #1c1c1a;
  --overlay: rgba(0, 0, 0, 0.96);
}

html {
  color-scheme: light dark;
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--transition), color var(--transition);
}

/* ---------- Utility ---------- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.75rem 1.25rem;
  border-radius: 4px;
  z-index: 200;
  transition: top var(--transition);
}
.skip-link:focus { top: 1rem; }

/* ---------- Typography ---------- */
h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: -0.01em;
}

h2 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
}

h3 {
  font-size: clamp(1.15rem, 2vw, 1.5rem);
}

/* ---------- Global FX (cursor, grain, scroll progress) ---------- */
.grain {
  position: fixed;
  inset: 0;
  z-index: 250;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
}
[data-theme="dark"] .grain { opacity: 0.05; }

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  z-index: 300;
  pointer-events: none;
}
.scroll-progress__bar {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
}

.cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 30px;
  height: 30px;
  border: 1px solid var(--text);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  mix-blend-mode: difference;
  transition: width 220ms ease, height 220ms ease, opacity 220ms ease, background-color 220ms ease;
}
.cursor.is-active { opacity: 1; }
.cursor.is-hover {
  width: 54px;
  height: 54px;
  background: var(--text);
}
html.has-custom-cursor,
html.has-custom-cursor * {
  cursor: none;
}

@media (pointer: coarse), (hover: none) {
  .cursor, .scroll-progress { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cursor { display: none; }
  .grain { display: none; }
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  transition: transform 320ms ease, box-shadow 320ms ease;
}

.site-header.is-hidden {
  transform: translateY(-100%);
}

.site-header.is-scrolled {
  box-shadow: 0 12px 30px -20px rgba(0, 0, 0, 0.35);
}

.site-header__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 1rem clamp(1rem, 3vw, 2.5rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.main-nav { display: flex; align-items: center; }

.nav-list {
  display: flex;
  gap: clamp(1rem, 2.5vw, 2rem);
  font-size: 0.95rem;
}

.nav-list a {
  display: inline-block;
  color: var(--text-muted);
  transition: color var(--transition), transform 260ms cubic-bezier(.16, .8, .24, 1);
}
.nav-list a:hover,
.nav-list a:focus-visible { color: var(--text); }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 0.5rem;
}
.nav-toggle__bar {
  width: 20px;
  height: 2px;
  background: var(--text);
  transition: transform var(--transition), opacity var(--transition);
}

/* ---------- Language switch ---------- */
.lang-switch {
  display: grid;
  place-items: center;
  height: 2.25rem;
  padding: 0 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: color var(--transition), border-color var(--transition), background-color var(--transition), transform 260ms cubic-bezier(.16, .8, .24, 1);
}
.lang-switch:hover,
.lang-switch:focus-visible {
  color: var(--text);
  border-color: var(--text-muted);
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  transition: background-color var(--transition), transform 260ms cubic-bezier(.16, .8, .24, 1);
}
.theme-toggle:hover { background: var(--placeholder); }

.theme-toggle .icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}
/* icon visibility is controlled by Vue's v-show (assets/js/app.js) */

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 92vh;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.hero__media {
  position: absolute;
  inset: 0;
  background: var(--placeholder);
}
.hero__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: translateY(var(--parallax, 0)) scale(1.08);
  will-change: transform;
}
@media (prefers-reduced-motion: reduce) {
  .hero__media img { transform: none; }
}
.hero__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.55), rgba(0,0,0,0) 45%);
}

.hero__content {
  position: relative;
  z-index: 1;
  padding: clamp(1.5rem, 5vw, 4rem);
  color: #f5f4f1;
}

.hero__title {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 8vw, 5.5rem);
  font-weight: 400;
  line-height: 1;
}

.hero__title .char {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.5em);
}
.hero__title.is-built .char {
  animation: charReveal 900ms cubic-bezier(.16, .8, .24, 1) both;
  animation-delay: calc(var(--i, 0) * 28ms + 150ms);
}
@keyframes charReveal {
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .hero__title .char { opacity: 1; transform: none; animation: none; }
}

.hero__subtitle {
  margin-top: 0.5rem;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(1.1rem, 2.2vw, 1.4rem);
  color: rgba(245, 244, 241, 0.8);
  letter-spacing: 0.02em;
  opacity: 0;
  animation: fadeUp 800ms cubic-bezier(.16, .8, .24, 1) 900ms both;
}

.hero__stats {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(1.5rem, 4vw, 3rem);
  margin-top: clamp(1.5rem, 4vw, 2.5rem);
  opacity: 0;
  animation: fadeUp 800ms cubic-bezier(.16, .8, .24, 1) 1150ms both;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat__num {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 500;
  color: #f5f4f1;
  font-variant-numeric: tabular-nums;
}

.stat__label {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(245, 244, 241, 0.65);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .hero__subtitle, .hero__stats { animation: none; opacity: 1; }
}

.hero__scroll {
  position: absolute;
  bottom: clamp(1rem, 3vw, 2rem);
  right: clamp(1rem, 3vw, 2rem);
  z-index: 1;
  width: 1px;
  height: 48px;
  background: rgba(245, 244, 241, 0.5);
}
.hero__scroll span {
  position: absolute;
  top: 0; left: -3px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #f5f4f1;
  animation: scrollDot 1.8s ease-in-out infinite;
}
@keyframes scrollDot {
  0% { top: 0; opacity: 1; }
  100% { top: 40px; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .hero__scroll span { animation: none; top: 20px; }
}

/* ---------- Projects / Gallery ---------- */
.projects {
  max-width: var(--container);
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 6rem) clamp(1rem, 3vw, 2.5rem);
}

.section-head {
  margin-bottom: clamp(2rem, 5vw, 3.5rem);
}

/* ---------- Projects hub (homepage cards) ---------- */
.projects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(1.5rem, 4vw, 2.5rem);
}

@media (min-width: 640px) {
  .projects-grid { grid-template-columns: repeat(3, 1fr); }
}

.project-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform 260ms cubic-bezier(.16, .8, .24, 1);
  will-change: transform;
}

.project-card__media {
  aspect-ratio: 1 / 1;
  background: var(--placeholder);
  overflow: hidden;
}

.project-card__media picture,
.project-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 400ms ease;
}

.project-card:hover .project-card__media img,
.project-card:focus-visible .project-card__media img {
  transform: scale(1.035);
}

.project-card__body {
  padding-top: 1rem;
}

.project-card__title {
  font-size: 1.15rem;
}

.project-card__native {
  color: var(--text-muted);
  font-weight: 400;
}

.project-card__meta {
  margin-top: 0.3rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.project-card__desc {
  margin-top: 0.6rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.project-card__link {
  display: inline-block;
  margin-top: 0.85rem;
  font-size: 0.88rem;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition), transform 260ms cubic-bezier(.16, .8, .24, 1);
}

.project-card:hover .project-card__link,
.project-card:focus-visible .project-card__link {
  border-color: var(--text);
}

/* ---------- Project subpage ---------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
  transition: color var(--transition), transform 260ms cubic-bezier(.16, .8, .24, 1);
}
.back-link:hover,
.back-link:focus-visible { color: var(--text); }

.project-page__head {
  max-width: 68ch;
  margin-bottom: clamp(2rem, 5vw, 3.5rem);
}

.project-page__head p + p { margin-top: 1rem; }

.project-page__title {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.project-page__meta {
  margin-top: 0.4rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.project-page__desc {
  margin-top: 1.5rem;
  color: var(--text-muted);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}

@media (min-width: 640px) {
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
  .gallery-grid { grid-template-columns: repeat(4, 1fr); }
}

.gallery-item-wrap { aspect-ratio: 1 / 1; }

.gallery-item {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--placeholder);
  overflow: hidden;
  position: relative;
  transition: transform 260ms cubic-bezier(.16, .8, .24, 1);
  will-change: transform;
}

.gallery-item picture,
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 400ms ease;
}

.gallery-item:hover img,
.gallery-item:focus-visible img {
  transform: scale(1.035);
}

/* ---------- About ---------- */
.about {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.about__inner {
  max-width: 68ch;
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 6rem) clamp(1rem, 3vw, 2.5rem);
}

.about__inner p + p { margin-top: 1rem; }

.about__exhibitions {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.about__exhibitions h3 {
  font-size: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
}

.about__exhibitions li {
  color: var(--text-muted);
}

.exh-title { color: var(--text); font-weight: 500; }

.exh-link {
  display: inline-block;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: border-color var(--transition), transform 260ms cubic-bezier(.16, .8, .24, 1);
}
.exh-link:hover,
.exh-link:focus-visible { border-color: var(--text); }

/* ---------- Side projects ---------- */
.side-projects {
  max-width: var(--container);
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 6rem) clamp(1rem, 3vw, 2.5rem);
}

.side-project-card {
  margin-top: clamp(1.5rem, 4vw, 2.5rem);
  max-width: 60ch;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: clamp(1.25rem, 3vw, 2rem);
}

.side-project-card h3 {
  font-size: 1.2rem;
}

.side-project-card p {
  margin-top: 0.6rem;
  color: var(--text-muted);
}

.side-project-card__link {
  display: inline-block;
  margin-top: 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-bottom: 1px solid var(--text);
  transition: transform 260ms cubic-bezier(.16, .8, .24, 1);
}

/* ---------- Contact ---------- */
.contact__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 6rem) clamp(1rem, 3vw, 2.5rem);
}

.contact__inner p + p { margin-top: 0.5rem; }

.contact__inner a {
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  border-bottom: 1px solid var(--border);
  transition: border-color var(--transition), color var(--transition);
}
.contact__inner a:hover,
.contact__inner a:focus-visible {
  color: var(--text-muted);
  border-color: var(--text-muted);
}

/* ---------- Footer ---------- */
.site-footer {
  padding: 2rem clamp(1rem, 3vw, 2.5rem) 3rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---------- Lightbox ----------
   Mounted/unmounted by Vue's <Transition name="lightbox">, which applies
   the enter/leave classes below - see assets/js/app.js. */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay);
}

.lightbox-enter-active,
.lightbox-leave-active {
  transition: opacity 260ms ease;
}
.lightbox-enter-active .lightbox__stage,
.lightbox-leave-active .lightbox__stage {
  transition: transform 320ms cubic-bezier(.16, .8, .24, 1);
}
.lightbox-enter-from,
.lightbox-leave-to {
  opacity: 0;
}
.lightbox-enter-from .lightbox__stage,
.lightbox-leave-to .lightbox__stage {
  transform: scale(0.96);
}
@media (prefers-reduced-motion: reduce) {
  .lightbox-enter-active,
  .lightbox-leave-active,
  .lightbox-enter-active .lightbox__stage,
  .lightbox-leave-active .lightbox__stage {
    transition: none;
  }
}

.lightbox__stage {
  max-width: min(92vw, 1400px);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.lightbox__img {
  max-width: 100%;
  max-height: 82vh;
  width: auto;
  height: auto;
  object-fit: contain;
  background: var(--placeholder);
}

.lightbox__caption {
  color: #d9d7d2;
  font-size: 0.85rem;
  text-align: center;
}

.lightbox__close {
  position: absolute;
  top: clamp(0.75rem, 2vw, 1.5rem);
  right: clamp(0.75rem, 2vw, 1.5rem);
  font-size: 2rem;
  line-height: 1;
  color: #f5f4f1;
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  transition: background-color var(--transition);
}
.lightbox__close:hover { background: rgba(255,255,255,0.1); }

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2.5rem;
  color: #f5f4f1;
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  transition: background-color var(--transition);
}
.lightbox__nav:hover { background: rgba(255,255,255,0.1); }
.lightbox__nav--prev { left: clamp(0.5rem, 2vw, 1.5rem); }
.lightbox__nav--next { right: clamp(0.5rem, 2vw, 1.5rem); }

@media (max-width: 640px) {
  .lightbox__nav { width: 2.5rem; height: 2.5rem; font-size: 2rem; }
}

/* ---------- Scroll reveals ---------- */
:is(
  .section-head,
  .project-card-wrap,
  .about__inner > h2,
  .about__inner > p,
  .about__exhibitions,
  .side-project-card,
  .contact__inner > *,
  .project-page__head,
  .back-link
) {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 700ms cubic-bezier(.16, .8, .24, 1), transform 700ms cubic-bezier(.16, .8, .24, 1);
}

:is(
  .section-head,
  .project-card-wrap,
  .about__inner > h2,
  .about__inner > p,
  .about__exhibitions,
  .side-project-card,
  .contact__inner > *,
  .project-page__head,
  .back-link
).is-visible {
  opacity: 1;
  transform: none;
}

.gallery-item-wrap {
  opacity: 0;
  clip-path: inset(0 0 100% 0);
  transition: opacity 500ms ease, clip-path 700ms cubic-bezier(.16, .8, .24, 1);
}
.gallery-item-wrap.is-visible {
  opacity: 1;
  clip-path: inset(0 0 0% 0);
}

@media (prefers-reduced-motion: reduce) {
  :is(
    .section-head,
    .project-card-wrap,
    .about__inner > h2,
    .about__inner > p,
    .about__exhibitions,
    .side-project-card,
    .contact__inner > *,
    .project-page__head,
    .back-link,
    .gallery-item-wrap
  ) {
    opacity: 1;
    transform: none;
    clip-path: none;
    transition: none;
  }

  .project-card,
  .gallery-item,
  .nav-list a,
  .lang-switch,
  .theme-toggle,
  .project-card__link,
  .side-project-card__link,
  .exh-link,
  .back-link {
    transition: none !important;
  }
}

/* ---------- Mobile nav ---------- */
@media (max-width: 640px) {
  .nav-toggle { display: flex; }

  .nav-list {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: var(--bg);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    font-size: 1.5rem;
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: transform var(--transition), opacity var(--transition), visibility var(--transition);
  }

  .nav-list.is-open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  .nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }
  .nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(2) {
    opacity: 0;
  }
  .nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }
}
