/* ---------------------------------------------------------------------------
   Ognyan Dimitrov — photo gallery
   Visual language follows the old Adobe Portfolio site: a 1200px two-column
   cover grid, monochrome images that regain their colour on hover, and a thin
   frame around every photograph.

   Everything that was in the Adobe theme (see reference/) lives here as a
   custom property, so the look can be re-tuned in one place.

   Two themes share the same layout: dark is the default, light is opt-in via
   the switch in the header (html[data-theme="light"]).
--------------------------------------------------------------------------- */

:root {
  color-scheme: dark;

  /* dark — the default */
  --bg: #0d0d0d;
  --fg: #ececec;
  --muted: #7d7d7d;
  --line: #2a2a2a;
  --line-hover: #f2f2f2;
  --header-bg: rgba(13, 13, 13, 0.92);

  --site-max: 1200px;
  --gutter: 32px;
  --grid-gap-y: 48px;
  --grid-gap-x: 32px;

  --frame: 1px solid var(--line);

  --photo-gap: 28px;
  --saturate-ms: 420ms;
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --header-h: 72px;
}

/* Light theme — the original Adobe look, unchanged. */
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #ffffff;
  --fg: #141414;
  --muted: #8b8b8b;
  --line: #e6e4e1;
  --line-hover: #141414;
  --header-bg: rgba(255, 255, 255, 0.92);
}

@media (max-width: 700px) {
  :root {
    --gutter: 20px;
    --grid-gap-y: 32px;
    --grid-gap-x: 16px;
    --photo-gap: 16px;
    --header-h: 60px;
  }
}

/* ------------------------------------------------------------------ base -- */

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease, border-color 0.2s ease;
}

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

/* ---------------------------------------------------------------- header -- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.site-header.is-scrolled {
  border-bottom-color: var(--line);
}

.nav-container {
  width: 100%;
  max-width: var(--site-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.gallery-title a,
.page-title a {
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.gallery-title a:hover,
.page-title a:hover {
  color: var(--fg);
}

.gallery-title a.active {
  color: var(--fg);
}

/* ----------------------------------------------------------- theme switch -- */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.theme-toggle:hover {
  color: var(--fg);
  border-color: var(--fg);
}

.theme-toggle:active {
  transform: scale(0.94);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* In dark mode the switch offers light, and vice versa. */
.theme-toggle .icon-sun,
:root[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

.theme-toggle .icon-moon,
:root[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}

/* ------------------------------------------------------------------ main -- */

.site-wrap {
  max-width: var(--site-max);
  margin: 0 auto;
  padding: 0 var(--gutter) 96px;
}

/* ------------------------------------------------------- cover grid (index) */

.project-covers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--grid-gap-y) var(--grid-gap-x);
  padding: 8px 0 0;
}

.project-cover {
  display: block;
  min-width: 0;
}

.cover-image {
  overflow: hidden;
}

.cover__img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: var(--frame);
  filter: grayscale(1);
  transition: filter var(--saturate-ms) var(--ease), border-color 0.2s ease;
}

.project-cover:hover .cover__img,
.project-cover:focus-visible .cover__img {
  filter: grayscale(0);
  border-color: var(--line-hover);
}

.details {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-top: 12px;
}

.details .title {
  font-size: 15px;
  letter-spacing: 0.01em;
}

.details .date {
  flex: none;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.project-cover:hover .details .title {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

@media (max-width: 560px) {
  .project-covers {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ------------------------------------------------------- album (page) view */

.page-header {
  padding: 64px 0 44px;
  text-align: center;
}

.page-header .title {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.125rem);
  font-weight: 500;
  letter-spacing: -0.01em;
}

.page-header .date {
  margin: 10px 0 0;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.page-header .description {
  max-width: 60ch;
  margin: 16px auto 0;
  color: var(--muted);
}

.project-module + .project-module {
  margin-top: var(--photo-gap);
}

.project-module img {
  display: block;
  width: 100%;
  border: var(--frame);
  filter: grayscale(1);
  transition: filter var(--saturate-ms) var(--ease), border-color 0.2s ease;
}

.project-module:hover img {
  filter: grayscale(0);
  border-color: var(--line-hover);
}

/* ------------------------------------------------------- other projects -- */

.other-projects {
  margin-top: 96px;
  padding-top: 40px;
  border-top: 1px solid var(--line);
}

.other-projects h2 {
  margin: 0 0 28px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.other-projects-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 28px 20px;
}

.other-projects-grid .cover__img {
  aspect-ratio: 4 / 3;
}

.other-projects-grid .details {
  padding-top: 9px;
}

.other-projects-grid .details .title {
  font-size: 13px;
}

.other-projects-grid .details .date {
  display: none;
}

@media (max-width: 900px) {
  .other-projects-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------------------------------------------------------- back to top -- */

.back-to-top {
  margin-top: 72px;
  text-align: center;
}

.back-to-top a {
  display: inline-block;
  padding: 10px 0;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.back-to-top a:hover {
  color: var(--fg);
}

/* ---------------------------------------------------------------- contact -- */

.contact {
  max-width: 640px;
  margin: 0 auto;
  padding: 96px 0 0;
}

.contact h1 {
  margin: 0 0 24px;
  font-size: clamp(1.5rem, 3vw, 2.125rem);
  font-weight: 500;
}

.contact p {
  color: var(--muted);
  margin: 0 0 32px;
}

.contact ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.contact li a {
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
}

.contact li a:hover {
  border-bottom-color: var(--fg);
}

/* Touch devices never fire :hover, so the mono-to-colour reveal would leave every
   photograph permanently grey. Show them in colour instead. */
@media (hover: none), (pointer: coarse) {
  .cover__img,
  .project-module img {
    filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .cover__img,
  .project-module img,
  .site-header,
  .theme-toggle,
  a {
    transition: none;
  }
}

/* -------------------------------------------------------------- lightbox -- */
/* Every album photo links to its original upload; this overlay shows it. */

html.lightbox-open {
  overflow: hidden;
}

.project-module a {
  display: block;
  cursor: zoom-in;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.96);
}

.lightbox:focus {
  outline: none;
}

.lightbox[hidden] {
  display: none;
}

.lightbox__figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 0;
  padding: 0 56px;
}

.lightbox__img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 96px);
  max-height: calc(100dvh - 96px);
  width: auto;
  height: auto;
}

.lightbox__caption {
  color: #a8a8a8;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lightbox__close,
.lightbox__nav {
  position: fixed;
  z-index: 101;
  border: 0;
  padding: 8px 14px;
  background: transparent;
  color: #f2f2f2;
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.2s ease;
}

.lightbox__close:hover,
.lightbox__nav:hover {
  opacity: 1;
}

.lightbox__close:focus-visible,
.lightbox__nav:focus-visible {
  outline-color: #f2f2f2;
  opacity: 1;
}

.lightbox__close {
  top: 18px;
  right: 20px;
  font-size: 34px;
}

.lightbox__nav {
  top: 50%;
  transform: translateY(-50%);
  font-size: 42px;
}

.lightbox__nav--prev {
  left: 14px;
}

.lightbox__nav--next {
  right: 14px;
}

@media (max-width: 700px) {
  .lightbox__figure {
    padding: 0 8px;
  }
  .lightbox__nav {
    font-size: 32px;
  }
  .lightbox__img {
    max-height: calc(100vh - 84px);
    max-height: calc(100dvh - 84px);
  }
}
