/* ---------- Токени ---------- */
:root {
  --color-bg: #F3F3F1;
  --color-surface: #FFFFFF;
  --color-text: #141414;
  --color-muted: #5C5C5C;
  --color-line: #E0E0DC;
  --color-line-strong: #D6D6D2;

  --font-sans: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --gutter: 24px;
  --gap: 8px;
  --tap: 44px;
}

/* ---------- База ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

body:has(.viewer[open]) { overflow: hidden; }

ul { margin: 0; padding: 0; list-style: none; }
p { margin: 0; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }

a { color: var(--color-text); text-decoration: none; }
a:hover { color: var(--color-muted); }

:focus-visible { outline: 2px solid var(--color-text); outline-offset: 2px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- Шапка ---------- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 4px 24px;
  padding: 20px var(--gutter);
}

.brand {
  min-height: var(--tap);
  padding: 0;
  border: 0;
  background: none;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand__sub { font-weight: 400; color: var(--color-muted); }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 22px;
  font-size: 14px;
}

.filters { display: flex; flex-wrap: wrap; gap: 0 22px; }

.filter,
.site-nav__link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0;
  border: 0;
  background: none;
  font-size: 14px;
}

.filter[aria-pressed="true"] {
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 6px;
}

/* ---------- Сітка робіт ---------- */
.works {
  flex-grow: 1;
  padding: 0 var(--gutter) 48px;
}

.works__grid {
  columns: 3 300px;
  column-gap: var(--gap);
}

.works__item {
  break-inside: avoid;
  margin-bottom: var(--gap);
}

.work {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  overflow: hidden;
}

.work__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.2s ease;
}

.work:hover .work__image { opacity: 0.92; }

/* ---------- Підвал ---------- */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 24px;
  padding: 18px var(--gutter) 24px;
  border-top: 1px solid var(--color-line);
  font-size: 13px;
  color: var(--color-muted);
}

.site-footer__links { display: flex; flex-wrap: wrap; gap: 0 20px; }

.site-footer__links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
}

/* ---------- Перегляд роботи ---------- */
.viewer {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--color-bg);
  color: var(--color-text);
}

.viewer[open] { display: flex; flex-direction: column; }

.viewer__bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px var(--gutter);
  font-size: 14px;
}

.viewer__counter { color: var(--color-muted); }

.viewer__controls { display: flex; gap: 8px; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: 1px solid var(--color-line-strong);
  background: var(--color-surface);
}

.icon-button--dark {
  border-color: var(--color-text);
  background: var(--color-text);
  color: var(--color-surface);
}

.icon-button svg,
.compare__handle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.viewer__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  padding: 0 var(--gutter) var(--gutter);
}

.viewer__stage {
  flex: 999 1 520px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.viewer__hint { font-size: 12px; color: var(--color-muted); }

.viewer__aside {
  flex: 1 1 240px;
  min-width: 0;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
  color: var(--color-muted);
}

.viewer__aside .eyebrow { color: var(--color-text); }

.viewer__credit { line-height: 1.5; }

/* ---------- Порівняння до/після ---------- */
.compare {
  --pos: 50%;
  --ratio: 1;
  --max-height: min(76vh, 900px);

  position: relative;
  width: min(100%, calc(var(--max-height) * var(--ratio)));
  aspect-ratio: var(--ratio);
  margin: 0;
  overflow: hidden;
  user-select: none;
}

.compare__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.compare__image--before { clip-path: inset(0 calc(100% - var(--pos)) 0 0); }

.compare__label {
  position: absolute;
  top: 12px;
  padding: 3px 8px;
  background: rgb(255 255 255 / 0.85);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.compare__label--before { left: 12px; }
.compare__label--after { right: 12px; }

.compare__divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  width: 2px;
  margin-left: -1px;
  background: var(--color-surface);
  pointer-events: none;
}

.compare__handle {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-surface);
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.18);
  transform: translate(-50%, -50%);
}

/* Невидимий повзунок на все фото: тягнути можна будь-де, працює і з клавіатури. */
.compare__range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
  touch-action: pan-y;
}

.compare:has(.compare__range:focus-visible) {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

/* ---------- Деталь 100% ---------- */
.detail {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--color-line);
}

.detail__image {
  position: absolute;
  top: -90%;
  left: -100%;
  width: 300%;
  max-width: none;
  height: 300%;
  object-fit: cover;
}

/* ---------- Мобільні ---------- */
@media (max-width: 640px) {
  :root { --gutter: 16px; }

  .site-header { padding-block: 12px; }

  .viewer { overflow-y: auto; }
  .viewer__body { flex: none; }
  .viewer__bar { padding-block: 10px; }
  .compare { --max-height: 70vh; }
  .viewer__aside { max-width: none; }
  .detail { max-width: 240px; }
}

@media (prefers-reduced-motion: reduce) {
  .work__image { transition: none; }
}
