:root {
  color-scheme: light;
  --paper: #faf9f6;
  --ink: #252520;
  --muted: #676760;
  --line: #deded7;
  --surface: #eeede7;
  --link-hover: #000;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
:root[data-theme="dark"] {
  --link-hover: #fff;
}
@supports (color: color-mix(in srgb, black, white)) {
  :root { --link-hover: color-mix(in srgb, var(--ink) 20%, #000); }
  :root[data-theme="dark"] { --link-hover: color-mix(in srgb, var(--ink) 20%, #fff); }
}
* { box-sizing: border-box; }
body { max-width: 1600px; margin: 0 auto; padding: 0 40px; }
a { color: inherit; text-decoration: none; }
a:focus-visible { outline: 2px solid var(--ink); outline-offset: 6px; }
a:is(:hover, :focus-visible) { color: var(--link-hover); text-decoration: none; }
p, h1, h2, figure { margin: 0; }
.skip-link { position: absolute; top: -100px; left: 20px; padding: 12px; background: var(--paper); z-index: 2; }
.skip-link:focus { top: 12px; }
.site-header { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 40px; padding: 38px 0 48px; }
.profile { min-width: 0; }
.profile-identity { display: flex; align-items: center; min-height: 44px; min-width: 0; }
.identity { min-width: 0; font-size: 25px; font-weight: 400; line-height: 1.3; letter-spacing: -.6px; }
.identity a { display: inline-flex; align-items: center; gap: 14px; max-width: 100%; }
.identity a > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.brand-logo { display: block; width: 44px; height: 44px; object-fit: contain; flex-shrink: 0; }
.brand-placeholder { background: var(--ink); }
.profile-description { margin-top: 16px; color: var(--muted); font-size: 15px; line-height: 1.65; white-space: pre-line; }
.contacts { display: flex; flex-wrap: nowrap; align-items: center; gap: 24px; font-size: 14px; line-height: 1.5; font-style: normal; min-width: 0; }
.contacts a { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; white-space: nowrap; }
.contact-icon { flex-shrink: 0; color: var(--muted); }
.contacts a:is(:hover, :focus-visible) .contact-icon { color: var(--link-hover); }
.header-aside { display: flex; align-items: center; justify-content: flex-end; gap: 60px; min-width: 0; }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 44px; min-height: 44px; padding: 0; color: var(--muted); border: 0; border-radius: 4px; background: transparent; cursor: pointer; }
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { color: var(--ink); }
.theme-track { display: block; position: relative; width: 44px; height: 26px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.theme-thumb { position: absolute; top: 2px; left: 2px; display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: var(--paper); }
.theme-toggle[aria-checked="true"] .theme-thumb { transform: translateX(18px); }
.theme-icon--moon { display: none; }
:root[data-theme="dark"] .theme-icon--sun { display: none; }
:root[data-theme="dark"] .theme-icon--moon { display: block; }
.theme-toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
h1 { font-weight: 400; font-size: clamp(36px, 4vw, 62px); line-height: 1.08; letter-spacing: -.045em; overflow-wrap: break-word; }
.project-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 50px 24px; scroll-margin-top: 25px; }
.category-filters { display: flex; flex-wrap: wrap; gap: 10px 24px; margin: 0 0 30px; }
.category-filters[hidden], .project-card[hidden], .filter-empty[hidden] { display: none; }
.category-filters button { padding: 8px 0; color: var(--muted); font: inherit; font-size: 14px; border: 0; border-bottom: 1px solid transparent; background: transparent; cursor: pointer; }
.category-filters button[aria-pressed="true"] { color: var(--ink); border-bottom-color: currentColor; }
.category-filters button:hover { color: var(--ink); }
.category-filters button:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.filter-empty { padding: 40px 0 70px; color: var(--muted); font-size: 16px; }
.project-card a { display: block; position: relative; }
.project-card a:hover { text-decoration: none; }
.cover { aspect-ratio: 4 / 3; position: relative; overflow: hidden; background: var(--surface); }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: var(--cover-fit, cover); object-position: var(--cover-x, 50%) var(--cover-y, 50%); }
.project-card .cover, .cover-preview { border-radius: var(--cover-radius, 0px); }
.project-card .cover { touch-action: pan-y pinch-zoom; }
.project-card .cover img { pointer-events: none; user-select: none; -webkit-user-drag: none; }
.preview-indicators { position: absolute; inset: auto 0 0; display: flex; gap: 4px; padding: 24px 12px 12px; background: linear-gradient(transparent, #0005); opacity: 0; pointer-events: none; }
.preview-indicators > span { flex: 1; height: 3px; background: #ffffff70; }
.preview-indicators > .is-current { background: white; }
.project-card a:hover .preview-indicators, .project-card a:focus-visible .preview-indicators { opacity: 1; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (hover: none) { .preview-indicators { opacity: 1; } }
.card-caption { position: absolute; inset: auto 0 0; z-index: 2; padding: 48px 16px 20px; color: #fff; background: linear-gradient(transparent, #000b); line-height: 1.4; pointer-events: none; }
.card-caption h2 { min-width: 0; font-size: 15px; font-weight: 400; letter-spacing: -.02em; overflow-wrap: anywhere; }
/* Скрываем стрелку и на страницах, оставшихся в кеше браузера. */
.card-caption > span { display: none; }
@media (hover: hover) and (pointer: fine) {
  .project-card a:hover .card-caption { opacity: 0; }
}
@media (prefers-reduced-motion: no-preference) {
  .card-caption { transition: opacity 160ms ease; }
}
.arrow-icon { display: inline-block; vertical-align: -.15em; flex-shrink: 0; }
.project-pagination a:is(:hover, :focus-visible) .next-label { color: var(--link-hover); }
.site-footer { border-top: 1px solid var(--line); margin-top: 65px; padding: 22px 0 28px; display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 12px; }
.project-intro { padding: 0 0 55px; }
.back-link { font-size: 14px; color: var(--muted); }
.project-heading { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; margin-top: 48px; }
.client { font-size: 14px; color: var(--muted); margin-bottom: 16px; }
.description { max-width: 590px; font-size: 18px; line-height: 1.65; align-self: end; white-space: pre-line; }
.gallery { display: grid; gap: 20px; width: 100%; min-width: 0; }
.gallery-row { display: grid; grid-template-columns: var(--gallery-columns, 1fr); gap: var(--row-gap, 20px); align-items: start; width: 100%; min-width: 0; }
.gallery figure { min-width: 0; min-height: 0; margin: 0; aspect-ratio: var(--frame-ratio); border-radius: var(--cover-radius, 0px); overflow: hidden; }
.gallery .gallery-image { display: block; width: 100%; height: 100%; }
.gallery img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center; }
.project-pagination { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 25px; font-size: 16px; }
.project-pagination a:last-child { text-align: right; }
.next-label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 10px; }
@media (min-width: 1800px) { .site-header { padding-top: 45px; } }
@media (max-width: 1000px) {
  .project-heading { gap: 32px; }
  .description { font-size: 16px; }
}
@media (max-width: 900px) {
  .site-header { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .header-aside { justify-content: space-between; }
}
@media (max-width: 700px) {
  body { padding: 0 20px; }
  .site-header { padding: 28px 0 20px; gap: 12px; }
  .identity { font-size: 24px; }
  .profile-description { margin-top: 12px; font-size: 14px; }
  .contacts { display: flex; flex-wrap: nowrap; justify-content: flex-start; align-items: center; gap: clamp(8px, 2.5vw, 16px); max-width: 100%; padding-top: 0; }
  .contacts a { gap: 6px; min-height: 44px; white-space: nowrap; }
  .contacts .contact-icon { width: 18px; height: 18px; }
  .header-aside { width: 100%; }
  .project-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .category-filters { gap: 8px 18px; margin-bottom: 24px; }
  .category-filters button { font-size: 13px; }
  .card-caption { padding: 40px 14px 20px; }
  .card-caption h2 { font-size: 14px; }
  .site-footer { font-size: 11px; }
  .project-intro { padding: 0 0 30px; }
  .project-heading { grid-template-columns: minmax(0, 1fr); gap: 25px; margin-top: 32px; }
  .gallery { gap: 16px; }
  .gallery:not(.gallery--automatic) .gallery-row { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .gallery:not(.gallery--automatic) figure { aspect-ratio: var(--source-ratio); }
  .project-pagination { font-size: 14px; margin-top: 32px; }
}
@media (max-width: 360px) {
  .contacts { gap: 8px; font-size: 13px; }
}

.gallery-image { display: block; cursor: zoom-in; }
.gallery-image:focus-visible { outline: 3px solid var(--ink); outline-offset: -4px; }
html.viewer-open { overflow: hidden; }
.image-viewer { position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; height: 100dvh; max-height: none; margin: 0; padding: 20px; border: 0; background: var(--paper); color: var(--ink); }
.image-viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 12px; }
.image-viewer::backdrop { background: rgba(0, 0, 0, .85); }
.viewer-toolbar, .viewer-navigation { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.viewer-counter { color: var(--muted); font-size: 14px; }
.image-viewer button { display: grid; place-items: center; width: 44px; height: 44px; padding: 10px; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); color: var(--ink); cursor: pointer; }
.image-viewer button:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.image-viewer svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.viewer-stage { min-height: 0; min-width: 0; display: flex; align-items: center; justify-content: center; position: relative; }
.viewer-stage img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-error { position: absolute; padding: 20px; background: var(--paper); max-width: 400px; line-height: 1.5; }
.viewer-error[hidden], .viewer-navigation[hidden] { display: none; }
.viewer-navigation { justify-content: center; }
@media (max-width: 700px) { .image-viewer { padding: 12px; padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: max(12px, env(safe-area-inset-bottom)); } }

/* Вид главной страницы задаётся в локальной админке. */
.project-grid[data-layout="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.project-grid[data-layout="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* Разная ширина и общая высота фреймов: каждый ряд заполняет всю сетку. */
/* Поля карточек дают зазор 20 px, не добавляя его между 24 служебными колонками. */
.project-grid[data-layout="mixed"] { grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 20px 0; align-items: stretch; width: calc(100% + 20px); margin-inline: -10px; }
.project-grid[data-layout="mixed"] .project-card { grid-column: span var(--project-span, 8); min-width: 0; margin-inline: 10px; }
.project-grid[data-layout="mixed"] .project-card a { height: 100%; }
.project-grid[data-layout="mixed"] .cover { aspect-ratio: auto; height: clamp(180px, 20vw, 280px); }
.project-grid[data-layout="list"] { grid-template-columns: minmax(0, 1fr); gap: 0; }
.project-grid[data-layout="list"] .project-card { padding: 24px 0; border-bottom: 1px solid var(--line); }
.project-grid[data-layout="list"] .cover { aspect-ratio: auto; height: clamp(160px, 18vw, 240px); }
@media (max-width: 1100px) {
  .project-grid[data-layout="3"], .project-grid[data-layout="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-grid[data-layout="mixed"] .project-card { grid-column: span var(--project-span-tablet, 12); }
}
@media (max-width: 700px) {
  .project-grid[data-layout="3"], .project-grid[data-layout="4"] { grid-template-columns: minmax(0, 1fr); }
  .project-grid[data-layout="mixed"] { grid-template-columns: minmax(0, 1fr); width: 100%; margin-inline: 0; }
  .project-grid[data-layout="mixed"] .project-card { grid-column: 1 / -1; margin-inline: 0; }
  .project-grid[data-layout="mixed"] .cover { height: min(300px, calc((100vw - 40px) * .75)); }
  .project-grid[data-layout="list"] .project-card { padding: 18px 0; }
}

/* Каждый эффект включается отдельно; без JS контент остаётся видимым. */
.preview-previous { pointer-events: none; }
.preview-indicators { z-index: 3; }
@media (prefers-reduced-motion: no-preference) {
  html.motion-ready[data-animations~="theme"],
  .motion-ready[data-animations~="theme"] body,
  .motion-ready[data-animations~="theme"] .identity a,
  .motion-ready[data-animations~="theme"] .project-card a,
  .motion-ready[data-animations~="theme"] .contacts a,
  .motion-ready[data-animations~="theme"] .project-pagination a,
  .motion-ready[data-animations~="theme"] .site-footer,
  .motion-ready[data-animations~="theme"] .contact-icon,
  .motion-ready[data-animations~="theme"] .profile-description,
  .motion-ready[data-animations~="theme"] .client,
  .motion-ready[data-animations~="theme"] .back-link,
  .motion-ready[data-animations~="theme"] .next-label,
  .motion-ready[data-animations~="theme"] .viewer-counter,
  .motion-ready[data-animations~="theme"] .cover,
  .motion-ready[data-animations~="theme"] .category-filters button,
  .motion-ready[data-animations~="theme"] .theme-track,
  .motion-ready[data-animations~="theme"] .theme-thumb,
  .motion-ready[data-animations~="theme"] .image-viewer,
  .motion-ready[data-animations~="theme"] .image-viewer button,
  .motion-ready[data-animations~="theme"] .project-grid[data-layout="list"] .project-card {
    transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease;
  }
  .motion-ready[data-animations~="theme"] .theme-thumb { transition: transform 180ms ease, background-color 180ms ease; }
}
@media (prefers-reduced-motion: no-preference) and (hover: hover) and (pointer: fine) {
  [data-animations~="hover"] .project-card .cover img { transition: transform 240ms cubic-bezier(.2,.65,.3,1); }
  [data-animations~="hover"] .project-card a:hover .cover img,
  [data-animations~="hover"] .project-card a:focus-visible .cover img { transform: scale(1.015); }
}
