/* ============ Tokens ============ */
:root {
  /* palette taken from the reference: white/grey base, black type, warm oak & bronze from the interiors */
  --bg: #F6F2EB;        /* milky linen */
  --paper: #FDFBF7;     /* warm milk */
  --ink: #231E19;       /* espresso */
  --muted: #6B6258;     /* warm grey, >5:1 on linen */
  --line: #E2DBD0;
  --sand: #EADFCE;      /* soft travertine */
  --stone: #D5C6B1;
  --oak: #B3855A;       /* honey oak */
  --bronze: #6B4A2F;    /* walnut */
  --sage: #858E71;      /* olive, from the plants in the interiors */
  --sage-soft: #DCDDCC;
  --olive-deep: #4B5140;  /* deep olive section */
  --clay: #A95A3F;        /* terracotta */
  --clay-soft: #EACFB6;

  /* dark section */
  --night: #231E19;
  --night-line: #3D342B;
  --night-text: #F0E9DF;
  --night-muted: #AA9F91;
  --glow: rgba(169, 90, 63, 0.22);
  --deep: #1E1915;      /* hero dimming = top of the About section */

  --serif: "Cormorant Garamond", "Times New Roman", Georgia, serif;
  --sans: "Jost", "Helvetica Neue", Arial, sans-serif;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  /* type scale (≈ +60% vs. first version) */
  --fs-body: clamp(18px, 0.75vw + 15px, 27px);
  --fs-lead: clamp(20px, 1vw + 15px, 30px);
  --fs-small: clamp(16px, 0.5vw + 13px, 22px);
  --fs-label: clamp(13px, 0.4vw + 11px, 19px);

  --rail: 0px;
  --gutter: clamp(20px, 4vw, 72px);
  --max: 1760px;
}

@media (min-width: 1100px) {
  :root { --rail: 56px; --gutter: calc(var(--rail) + clamp(20px, 2.4vw, 56px)); }
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1500px 1000px at 85% -12%, var(--paper), transparent 66%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, p, dl, dd, ul { margin: 0; padding: 0; }
ul { list-style: none; }
svg { display: block; }

:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; }
::selection { background: var(--sand); color: var(--ink); }

.wrap {
  width: 100%;
  max-width: calc(var(--max) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.eyebrow,
.section-num,
.service__tag {
  font-family: var(--sans);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.h2 {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(2.6rem, 5.6vw, 6rem);
  line-height: 1.04;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

em { font-style: italic; color: var(--bronze); }

/* ============ Header ============ */
.header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  transition: background-color 300ms ease, box-shadow 300ms ease;
}
.header.is-scrolled {
  background: rgba(246, 242, 235, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 var(--line);
}
.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: clamp(72px, 6vw, 104px);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-size: clamp(19px, 0.8vw + 15px, 28px);
  letter-spacing: 0.02em;
  min-height: 44px;
}
.logo__mark { width: 1.4em; height: 1.4em; }
.logo__mark path {
  stroke: var(--ink);
  stroke-width: 1.2;
  fill: none;
  transition: transform 400ms var(--ease-out);
  transform-origin: center;
}
.logo__dot { color: var(--oak); }

.nav { display: flex; align-items: center; gap: clamp(16px, 3vw, 56px); }
.nav a {
  position: relative;
  font-size: var(--fs-small);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.nav a:not(.nav__cta)::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 8px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 300ms var(--ease-out);
}
.nav__cta {
  padding: 0.55em 1.3em;
  border: 1px solid var(--ink);
  transition: background-color 200ms ease, color 200ms ease, transform 160ms var(--ease-out);
}
.nav__cta:active { transform: scale(0.97); }

@media (hover: hover) and (pointer: fine) {
  .logo:hover .logo__mark path { transform: rotate(90deg); }
  .nav a:not(.nav__cta):hover::after { transform: scaleX(1); transform-origin: left; }
  .nav__cta:hover { background: var(--ink); color: var(--bg); }
}

@media (max-width: 720px) {
  .nav a:not(.nav__cta) { display: none; }
}

/* ============ Side rails ============ */
.rail { display: none; }

@media (min-width: 1100px) {
  .rail {
    display: flex;
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 15;
    width: var(--rail);
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    color: var(--ink);
    transition: color 400ms ease;
  }
  .rail.rail--on-dark { color: var(--night-text); }
  .rail--left { left: 0; }
  .rail--right { right: 0; justify-content: space-between; padding-block: 140px 48px; }

  /* ruler with ticks that slide with scroll */
  .rail__ruler {
    position: absolute;
    inset: 0;
    overflow: hidden;
    --ruler-mask: linear-gradient(transparent 6%, #000 22%, #000 43%,
      transparent 46%, transparent 54%, #000 57%, #000 78%, transparent 94%);
    -webkit-mask-image: var(--ruler-mask);
            mask-image: var(--ruler-mask);
  }
  .rail__ticks {
    position: absolute;
    left: 0; right: 0;
    top: -80px;
    height: calc(100% + 160px);
    opacity: 0.45;
    background:
      linear-gradient(90deg, currentColor 0 1px, transparent 1px) right / 1px 100% no-repeat,
      repeating-linear-gradient(to bottom, currentColor 0 1px, transparent 1px 80px) right / 34px 100% no-repeat,
      repeating-linear-gradient(to bottom, currentColor 0 1px, transparent 1px 16px) right / 12px 100% no-repeat;
    will-change: transform;
  }

  .rail__index {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: var(--rail);
    display: grid;
    place-items: center;
    padding-block: 18px;
  }
  /* short tick to the right of the number, never crossing it */
  .rail__index::before {
    content: "";
    position: absolute;
    right: 0;
    top: 50%;
    width: 10px;
    height: 1px;
    background: currentColor;
    opacity: 0.6;
  }
  .rail__num {
    font-family: var(--serif);
    font-size: 24px;
    line-height: 1;
    position: relative;
    transition: opacity 250ms ease, filter 250ms ease, transform 250ms var(--ease-out);
  }
  .rail__num.is-changing { opacity: 0; filter: blur(3px); transform: translateY(6px); }

  .rail__caption {
    writing-mode: vertical-rl;
    font-size: 13px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    opacity: 0.7;
    white-space: nowrap;
  }
  .rail__progress {
    position: relative;
    width: 1px;
    height: 22vh;
  }
  .rail__progress::before {
    content: "";
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0.25;
  }
  .rail__progress span {
    position: absolute;
    inset: 0;
    background: currentColor;
    transform-origin: top;
    transform: scaleY(0);
  }
  .rail__mark { width: 30px; height: 30px; will-change: transform; }
  .rail__mark rect { fill: none; stroke: currentColor; stroke-width: 1; }
  .rail__mark circle { fill: currentColor; }
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: clamp(54px, 3vw + 40px, 76px);
  padding-inline: 1.8em;
  font-size: var(--fs-small);
  letter-spacing: 0.04em;
  border: 1px solid var(--ink);
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease, transform 160ms var(--ease-out);
}
.btn--solid { background: var(--ink); color: var(--bg); }
.btn:active { transform: scale(0.97); }

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  font-size: var(--fs-small);
  letter-spacing: 0.04em;
}
.link-arrow span { transition: transform 300ms var(--ease-out); }

@media (hover: hover) and (pointer: fine) {
  .btn--solid:hover { background: var(--bronze); border-color: var(--bronze); }
  .link-arrow:hover span { transform: translateX(6px); }
}

/* ============ Hero ============ */
.hero {
  min-height: 100svh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  align-items: center;
  gap: clamp(24px, 4vw, 96px);
  padding-block: clamp(110px, 10vw, 160px) 60px;
}
.hero__text { position: relative; z-index: 2; }

.hero__title {
  margin-top: 0.8em;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(3.2rem, 8vw, 10.5rem);
  line-height: 0.96;
  letter-spacing: -0.02em;
}
.hero__lead {
  margin-top: 1.3em;
  max-width: 30ch;
  color: var(--muted);
  font-size: var(--fs-lead);
}
.hero__actions {
  margin-top: clamp(32px, 3.5vw, 64px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 40px;
}

.hero__art { margin: 0; }
.art { width: 100%; height: auto; max-height: 82svh; overflow: visible; }

.art .guides line,
.art .guides circle {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
  stroke-dasharray: 0.006 0.008;
}
.art .shape--sand   { fill: var(--sand); }
.art .shape--oak    { fill: var(--oak); }
.art .shape--bronze { fill: var(--bronze); }
.art .shape--sage   { fill: var(--sage-soft); }
.art .grain { fill: none; stroke: var(--bronze); stroke-width: 1; opacity: 0.28; }
.art .line  { fill: none; stroke: var(--ink); stroke-width: 1.3; }
.art .line--thin { stroke-width: 1; }
.art .dim line { stroke: var(--muted); stroke-width: 1; }
.art text {
  font-family: var(--sans);
  font-size: 15px;
  letter-spacing: 0.14em;
  fill: var(--muted);
}



/* hero draw-in (runs once on load) */
.anim .art .line,
.anim .art .dim line { stroke-dasharray: 1; stroke-dashoffset: 1; }
.anim .art .shape { opacity: 0; }
.anim .art text,
.anim .art .guides { opacity: 0; }

.anim .art.is-drawn .guides { opacity: 1; transition: opacity 1200ms ease 100ms; }
.anim .art.is-drawn .line,
.anim .art.is-drawn .dim line {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1600ms var(--ease-in-out) 300ms;
}
/* Появление фигур — обычный переход прозрачности со своей задержкой у каждой.
   Ни keyframes, ни clip-path, ни fill-mode: в разных браузерах именно они
   оставляли фигуры невидимыми. Здесь худшее, что может случиться, —
   фигуры появятся сразу, без плавности. */
.anim .art .shape { transition: opacity 900ms var(--ease-out) var(--d, 0ms); }
.anim .art.is-drawn .shape { opacity: 1; }
.anim .art .shape--sand   { --d: 500ms; }
.anim .art .shape--oak    { --d: 700ms; }
.anim .art .shape--bronze { --d: 900ms; }
.anim .art .shape--sage   { --d: 1050ms; }
.anim .art.is-drawn text { opacity: 1; transition: opacity 800ms ease 1300ms; }

/* ============ Reveal on scroll ============ */
.anim .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 900ms var(--ease-out), transform 900ms var(--ease-out);
  transition-delay: var(--d, 0ms);
}
.anim .reveal.is-in { opacity: 1; transform: none; }

/* ============ About ============ */
.about {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  align-items: end;
  gap: clamp(40px, 6vw, 140px);
  padding-block: clamp(80px, 11vw, 200px);
  border-top: 1px solid var(--line);
}
.about .h2 { margin-top: 0.6em; }
.about__text {
  margin-top: 1.4em;
  max-width: 46ch;
  color: var(--muted);
  font-size: var(--fs-lead);
}

.facts { display: grid; }
.fact {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding-block: clamp(18px, 1.6vw, 30px);
  border-top: 1px solid var(--line);
}
.fact:last-child { border-bottom: 1px solid var(--line); }
.fact dt {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(3rem, 5.4vw, 5.6rem);
  line-height: 1;
}
.fact dd { font-size: var(--fs-small); color: var(--muted); text-align: right; }

/* ============ Section heads ============ */
.section-head {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  padding-top: clamp(28px, 2.4vw, 44px);
  border-top: 1px solid var(--line);
  margin-bottom: clamp(40px, 5vw, 96px);
}

/* ============ Work tiles ============ */
.work { padding-bottom: clamp(80px, 11vw, 200px); }

.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(16px, 2vw, 40px);
}

.tile__art {
  aspect-ratio: 4 / 5;
  max-width: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.tile__art svg { width: 78%; height: auto; transition: transform 900ms var(--ease-out); }
.tile__art--light { background: var(--paper); }
.tile__art--sand  { background: var(--sand); }
.tile__art--ink   { background: var(--ink); }

@media (hover: hover) and (pointer: fine) {
  .tile:hover .tile__art svg { transform: scale(1.04); }
}

.tile__title {
  margin-top: 0.7em;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.2rem, 2.8vw, 3.4rem);
  line-height: 1.15;
}
.tile__text { margin-top: 0.4em; color: var(--muted); max-width: 30ch; }

/* plan */
.p-wall { fill: none; stroke: var(--ink); stroke-width: 3; }
.p-leaf { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.p-door { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.p-fill { fill: var(--sage-soft); }
.p-dot  { fill: var(--oak); }
.p-dim  { fill: none; stroke: var(--muted); stroke-width: 1; }

/* cube */
.c-top    { fill: var(--paper); }
.c-left   { fill: var(--oak); }
.c-right  { fill: var(--bronze); }
.c-ray    { stroke: var(--paper); stroke-width: 1; opacity: 0.9; }
.c-shadow { fill: var(--bronze); opacity: 0.14; }

/* drawing */
.d-line   { fill: none; stroke: var(--bg); stroke-width: 1.3; }
.d-accent { fill: var(--oak); }
.d-dim    { fill: none; stroke: var(--night-muted); stroke-width: 1; }

/* ============ Services ============ */
.services { padding-bottom: clamp(80px, 11vw, 200px); }

.services__grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: clamp(16px, 2vw, 40px);
}

.service-art {
  position: relative;
  background: var(--sage-soft);
  display: grid;
  place-items: center;
  padding: clamp(28px, 3vw, 56px);
  overflow: hidden;
}
.service-art svg { width: 100%; max-width: 480px; height: auto; margin-bottom: 1.5em; }
.service-art__caption {
  position: absolute;
  left: clamp(28px, 3vw, 56px);
  bottom: clamp(20px, 2.4vw, 40px);
  font-size: var(--fs-label);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--bronze);
}
.sa-guide  { fill: none; stroke: var(--sage); opacity: 0.6; stroke-width: 1; stroke-dasharray: 4 5; }
.sa-square { fill: none; stroke: var(--ink); stroke-width: 1.4; }
.sa-square:first-of-type { fill: rgba(251, 248, 243, 0.6); }
.sa-arc    { fill: none; stroke: var(--bronze); stroke-width: 1.2; stroke-dasharray: 5 6; }
.sa-leg    { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.sa-pivot  { fill: var(--ink); }
.sa-tip    { fill: var(--oak); }
.sa-tick   { fill: none; stroke: var(--ink); stroke-width: 1; }

/* compass slowly swings when the tile is in view */
.anim .service-art.is-in .sa-leg,
.anim .service-art.is-in .sa-tip {
  transform-origin: 236px 50px;
  animation: swing 6s var(--ease-in-out) infinite alternate;
}
@keyframes swing {
  from { transform: rotate(-4deg); }
  to   { transform: rotate(3deg); }
}

.service {
  padding: clamp(32px, 3.4vw, 64px);
  background: var(--paper);
  border: 1px solid transparent;
  transition: border-color 300ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .service:hover { border-color: var(--line); }
}
.service__icon {
  width: clamp(56px, 4.4vw, 80px);
  height: auto;
  fill: none; stroke: var(--ink); stroke-width: 1.1;
  margin-bottom: clamp(32px, 3vw, 56px);
}
.service:nth-child(2) .service__icon rect { fill: var(--oak); stroke: var(--ink); }
.service:nth-child(3) .service__icon rect:first-child { fill: var(--paper); }
.service:nth-child(3) .service__icon rect:last-child { fill: var(--sage-soft); }
.service__title {
  margin-top: 0.35em;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.2rem, 2.8vw, 3.4rem);
  line-height: 1.1;
}
.service__text { margin-top: 0.8em; color: var(--muted); }

/* ============ Contact ============ */
.contact {
  position: relative;
  background:
    radial-gradient(70% 90% at 88% 110%, var(--glow), transparent 70%),
    var(--night);
  color: var(--night-text);
  overflow: hidden;
}
.contact__inner {
  position: relative;
  padding-block: clamp(96px, 12vw, 220px);
}
.contact .section-num { color: var(--night-muted); }
.contact em { color: var(--oak); }

.contact__shape {
  position: absolute;
  right: var(--gutter);
  bottom: 0;
  width: min(40vw, 620px);
  height: auto;
  pointer-events: none;
}
.contact__shape path { fill: none; stroke: var(--night-line); stroke-width: 1.2; }
.contact__shape circle { fill: var(--oak); opacity: 0.45; }

.contact__title {
  position: relative;
  margin-top: 0.5em;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(3rem, 9vw, 9.5rem);
  line-height: 1;
  letter-spacing: -0.015em;
}

.contact__list {
  position: relative;
  margin-top: clamp(48px, 6vw, 110px);
  max-width: 1000px;
  border-top: 1px solid var(--night-line);
}
.contact__list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px 16px;
  flex-wrap: wrap;
  padding-block: clamp(14px, 1.4vw, 28px);
  border-bottom: 1px solid var(--night-line);
}
.contact__list span {
  font-size: var(--fs-label);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--night-muted);
}
.contact__list a {
  font-size: clamp(20px, 1.6vw + 12px, 38px);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-position: 100% 90%;
  background-repeat: no-repeat;
  transition: background-size 400ms var(--ease-out), color 200ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .contact__list a:hover { background-size: 100% 1px; background-position: 0 90%; color: var(--sand); }
}

/* ============ Footer ============ */
.footer { background: var(--night); color: var(--night-muted); font-size: var(--fs-small); }
.footer__inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding-block: clamp(24px, 2.4vw, 44px);
  border-top: 1px solid var(--night-line);
}

/* ============ About portrait ============ */
.about { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.5fr) minmax(0, 1fr); align-items: center; }
.about__portrait {
  position: relative;
  margin: 0;
  aspect-ratio: 4 / 5;
  max-width: 100%;
  overflow: hidden;
  background: var(--sage);
}
.about__portrait img,
.about__live {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
}
.about__live { opacity: 0; transition: opacity 800ms ease; }
.about__live.is-playing { opacity: 1; }
.about__portrait::after {
  content: "";
  position: absolute;
  inset: 55% 0 0 0;
  background: linear-gradient(transparent, rgba(35, 30, 25, 0.5));
  pointer-events: none;
}
.about__portrait figcaption {
  position: absolute;
  z-index: 1;
  left: 16px;
  bottom: 14px;
  font-size: var(--fs-label);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--night-text);
}

@media (max-width: 1500px) and (min-width: 961px) {
  .about { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr); }
  .about .facts { grid-column: 1 / -1; grid-template-columns: repeat(3, 1fr); column-gap: 32px; }
}

/* ============ Work tiles as links ============ */
a.tile { display: block; color: inherit; }
.tile__go {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.6em;
  vertical-align: middle;
  opacity: 0.5;
  transition: transform 300ms var(--ease-out), opacity 200ms ease;
}
@media (hover: hover) and (pointer: fine) {
  a.tile:hover .tile__go { transform: translateX(8px); opacity: 1; }
}

/* ============ Portfolio ============ */
.portfolio { padding-bottom: clamp(80px, 11vw, 200px); }
.portfolio__head {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px 40px;
}
.portfolio__head .h2 { margin-top: 0.3em; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter {
  appearance: none;
  font: inherit;
  font-size: var(--fs-small);
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--stone);
  min-height: 48px;
  padding: 0.4em 1.1em;
  cursor: pointer;
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease, transform 160ms var(--ease-out);
}
.filter sup { font-size: 0.62em; color: var(--muted); margin-left: 2px; }
.filter:active { transform: scale(0.97); }
.filter.is-active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.filter.is-active sup { color: var(--stone); }
@media (hover: hover) and (pointer: fine) {
  .filter:not(.is-active):hover { border-color: var(--ink); }
}

.gallery {
  --cols: 3;
  --gap: clamp(10px, 1.2vw, 22px);
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-auto-rows: 4px;
  column-gap: var(--gap);
  transition: opacity 180ms ease;
}
.gallery.is-switching { opacity: 0; }
@media (max-width: 960px) { .gallery { --cols: 2; } }
@media (max-width: 520px) { .gallery { --cols: 1; } }

.g-item {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  margin: 0;
  background: transparent;
  cursor: zoom-in;
  animation: g-in 700ms var(--ease-out) both;
  animation-delay: var(--d, 0ms);
}
.g-frame {
  position: absolute;
  inset: 0 0 var(--gap) 0;
  overflow: hidden;
  background: var(--sand);
}
.g-frame img,
.g-frame video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  transition: transform 900ms var(--ease-out);
}
.g-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 0 rgba(251, 248, 243, 0.6);
  transition: box-shadow 300ms var(--ease-out);
  pointer-events: none;
}
.g-badge {
  position: absolute;
  z-index: 1;
  left: 12px;
  top: 12px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(35, 30, 25, 0.55);
}
.g-badge svg { width: 12px; height: 12px; fill: var(--night-text); margin-left: 2px; }
@media (hover: hover) and (pointer: fine) {
  .g-item:hover .g-frame img,
  .g-item:hover .g-frame video { transform: scale(1.035); }
  .g-item:hover .g-frame::after { box-shadow: inset 0 0 0 10px rgba(251, 248, 243, 0.6); }
}
.g-item:focus-visible { outline: none; }
.g-item:focus-visible .g-frame { outline: 2px solid var(--ink); outline-offset: 2px; }

@keyframes g-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

.gallery__more { display: flex; justify-content: center; margin-top: clamp(24px, 3vw, 48px); }
.gallery__more[hidden] { display: none; }
.gallery__more .btn { cursor: pointer; background: transparent; font-family: inherit; color: var(--ink); }
@media (hover: hover) and (pointer: fine) {
  .gallery__more .btn:hover { background: var(--ink); color: var(--bg); }
}

/* ============ Lightbox ============ */
.lightbox {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(24, 20, 17, 0.97);
  color: var(--night-text);
}
.lightbox[open] { animation: lb-fade 220ms ease both; }
.lightbox::backdrop { background: transparent; }
@keyframes lb-fade { from { opacity: 0; } to { opacity: 1; } }

.lightbox__stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(64px, 7vw, 96px) clamp(16px, 8vw, 120px);
  overflow: auto;
  overscroll-behavior: contain;
}
.lightbox__stage.is-tall { place-items: start center; }
.lightbox__media {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 2 * clamp(64px, 7vw, 96px));
  object-fit: contain;
  animation: lb-in 320ms var(--ease-out) both;
}
.lightbox__stage.is-tall .lightbox__media { max-height: none; width: min(100%, 1400px); }
@keyframes lb-in {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.lightbox__btn {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 1px solid rgba(240, 233, 223, 0.25);
  border-radius: 50%;
  background: rgba(24, 20, 17, 0.6);
  color: var(--night-text);
  cursor: pointer;
  transition: background-color 200ms ease, border-color 200ms ease, transform 160ms var(--ease-out);
}
.lightbox__btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.lightbox__btn:active { transform: scale(0.94); }
.lightbox__close { top: 16px; right: 16px; }
.lightbox__prev { left: 16px; top: calc(50% - 28px); }
.lightbox__next { right: 16px; top: calc(50% - 28px); }
@media (hover: hover) and (pointer: fine) {
  .lightbox__btn:hover { background: var(--clay); border-color: var(--clay); }
}
.lightbox__count {
  position: absolute;
  left: 50%;
  bottom: 22px;
  margin: 0;
  transform: translateX(-50%);
  font-size: var(--fs-label);
  letter-spacing: 0.2em;
  color: var(--night-muted);
}
@media (max-width: 640px) {
  .lightbox__prev, .lightbox__next { top: auto; bottom: 10px; width: 48px; height: 48px; }
  .lightbox__stage { padding: 64px 8px 72px; }
  .lightbox__media { max-height: calc(100dvh - 136px); }
}

@media (prefers-reduced-motion: reduce) {
  .g-item, .lightbox__media, .lightbox[open] { animation: none; }
  .g-frame img, .g-frame video { transition: none; }
}

/* ============ Portfolio: directions + types ============ */
.portfolio__head { flex-direction: column; align-items: flex-start; }

.p-sections {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 1.2vw, 20px);
  margin-bottom: clamp(20px, 2.4vw, 36px);
}
.p-section {
  appearance: none;
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  column-gap: 14px;
  padding: clamp(16px, 1.6vw, 26px) 0 clamp(14px, 1.4vw, 22px);
  border: 0;
  border-top: 1px solid var(--stone);
  background: transparent;
  color: var(--muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: color 200ms ease;
}
.p-section::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: -1px;
  height: 3px;
  background: var(--clay);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 400ms var(--ease-out);
}
.p-section.is-active { color: var(--ink); }
.p-section.is-active::before { transform: scaleX(1); }
.p-section__num {
  grid-row: 1 / 3;
  font-size: var(--fs-label);
  letter-spacing: 0.16em;
  color: var(--clay);
}
.p-section__title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.7rem, 2.6vw, 3rem);
  line-height: 1.1;
}
.p-section__count { font-size: var(--fs-label); letter-spacing: 0.08em; margin-top: 4px; }
@media (hover: hover) and (pointer: fine) {
  .p-section:not(.is-active):hover { color: var(--ink); }
}
@media (max-width: 720px) {
  .p-sections { grid-template-columns: 1fr; gap: 0; }
  .p-section { padding-block: 14px; }
}

.filters { margin-bottom: clamp(24px, 3vw, 48px); }
.filter:disabled { opacity: 0.4; cursor: default; }

.gallery__empty {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 12px;
  padding: clamp(48px, 7vw, 120px) 20px;
  border: 1px dashed var(--stone);
  animation: g-in 600ms var(--ease-out) both;
}
.gallery__empty[hidden] { display: none; }
.gallery__empty svg { width: 96px; height: 96px; margin-bottom: 8px; }
.gallery__empty path { fill: none; stroke: var(--ink); stroke-width: 1.2; }
.gallery__empty circle { fill: var(--clay); }
.gallery__empty-title { font-family: var(--serif); font-size: clamp(1.8rem, 2.6vw, 2.8rem); line-height: 1.1; }
.gallery__empty-text { max-width: 42ch; color: var(--muted); }

/* ============ Color rhythm ============ */
/* full-bleed section backgrounds without extra wrappers */
.bleed {
  background: var(--section-bg);
  box-shadow: 0 0 0 100vmax var(--section-bg);
  clip-path: inset(0 -100vmax);
}

.art .shape--bronze { fill: var(--clay); }

/* About: soft warm bridge from the dark hero video down to the linen section */
.about.bleed {
  position: relative;
  isolation: isolate;
  color: var(--night-text);
  border-top: 0;
  background: none;
  box-shadow: none;
  clip-path: none;
}
.about.bleed::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  background: linear-gradient(180deg,
    var(--deep) 0%,  /* continues the hero video */
    #3B342D 26%,
    #574C41 62%,     /* warm taupe */
    #8C8073 84%,
    var(--bg) 100%); /* meets the next section */
}
.about.bleed .section-num { color: #CFC4B6; }
.about.bleed .about__text { color: #D6CCBF; }
.about.bleed .fact { border-color: rgba(240, 233, 223, 0.22); }
.about.bleed .fact dt { color: var(--sand); }
.about.bleed .fact dd { color: #D6CCBF; }

/* Work: each tile its own material */
.work { padding-top: clamp(80px, 11vw, 200px); }
.portfolio { position: relative; }
.work .section-head { border-top: 0; padding-top: 0; }
.tile__art--sage { background: var(--sage-soft); }
.tile__art--clay { background: var(--clay-soft); }
.tile__art--sage .p-fill { fill: var(--paper); }
.tile__art--sage .p-dot  { fill: var(--clay); }

/* Services: travertine band that flows in from linen and out into the dark contacts */
.services.bleed {
  position: relative;
  isolation: isolate;
  background: none;
  box-shadow: none;
  clip-path: none;
  padding-top: clamp(96px, 11vw, 200px);
  padding-bottom: clamp(160px, 13vw, 240px);
}
.services.bleed::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  background:
    linear-gradient(0deg, var(--night) 0, rgba(35, 30, 25, 0) 150px),  /* flows into contacts */
    linear-gradient(180deg, var(--bg) 0, var(--sand) 340px);           /* flows out of linen */
}
.services .section-head { border-top: 0; padding-top: 0; }
.services .service__text { color: var(--muted); }
.service-art { background: var(--olive-deep); }
.service-art__caption { color: var(--sand); }
.service-art .sa-guide  { stroke: var(--sage-soft); opacity: 0.35; }
.service-art .sa-square { stroke: var(--night-text); }
.service-art .sa-square:first-of-type { fill: rgba(240, 233, 223, 0.08); }
.service-art .sa-arc    { stroke: var(--clay-soft); }
.service-art .sa-leg    { stroke: var(--night-text); }
.service-art .sa-pivot  { fill: var(--sand); }
.service-art .sa-tip    { fill: var(--clay); }
.service-art .sa-tick   { stroke: var(--sage-soft); }
.service:nth-child(2) .service__icon rect { fill: var(--clay); }

/* Services: all three cards share one hover reaction */
.services__grid > .reveal.is-in {
  transition: transform 450ms var(--ease-out), box-shadow 450ms var(--ease-out), border-color 300ms ease;
  transition-delay: 0ms;
}
.service-art svg { transition: transform 700ms var(--ease-out); }
.service__icon { transition: transform 450ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .services__grid > .reveal.is-in:hover {
    transform: translateY(-8px);
    box-shadow: 0 22px 40px -24px rgba(35, 30, 25, 0.45);
  }
  .service-art:hover svg { transform: scale(1.05) rotate(-2deg); }
  .service:hover .service__icon { transform: translateY(-4px); }
}

/* Accents */
@media (hover: hover) and (pointer: fine) {
  .btn--solid:hover { background: var(--clay); border-color: var(--clay); }
  .service:hover { border-color: var(--stone); }
}
.contact em { color: var(--clay-soft); }
.contact__shape circle { fill: var(--clay); opacity: 0.6; }
.logo__dot { color: var(--clay); }

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  .services__grid { grid-template-columns: 1fr 1fr; }
  .service-art { grid-column: 1 / -1; aspect-ratio: 16 / 7; }
  .service-art svg { width: auto; height: 100%; max-height: 360px; }
}

@media (max-width: 960px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-block: 110px 40px;
  }
  .hero__art { order: -1; max-width: 520px; width: 80%; margin-inline: auto; }
  .art { max-height: none; }
  .hero__title { font-size: clamp(3.2rem, 12vw, 7rem); }

  .about { grid-template-columns: 1fr; align-items: start; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tiles .tile:last-child { grid-column: 1 / -1; }
  .tiles .tile:last-child .tile__art { aspect-ratio: 16 / 9; }
  .tiles .tile:last-child .tile__art svg { width: auto; height: 82%; }
  .contact__shape circle { display: none; }
}

@media (max-width: 640px) {
  .hero__art { width: 100%; }
  .hero__title { font-size: clamp(2.9rem, 13.5vw, 4.4rem); }
  .tiles, .services__grid { grid-template-columns: 1fr; }
  .service-art { aspect-ratio: 1 / 1; }
  .tiles .tile:last-child .tile__art { aspect-ratio: 4 / 5; }
  .tiles .tile:last-child .tile__art svg { width: 78%; height: auto; }
  .contact__shape { width: 80vw; opacity: 0.6; }
}

/* ============ Reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .anim .reveal { transform: none; transition: opacity 400ms ease; }
  .anim .art.is-drawn .line,
  .anim .art.is-drawn .dim line { transition: none; }
  .anim .art.is-drawn .shape { animation: none; transition: opacity 400ms ease; }
  .art [data-depth] { transition: none; transform: none !important; }
  .tile__art svg { transition: none; }
  .anim .service-art.is-in .sa-leg,
  .anim .service-art.is-in .sa-tip { animation: none; }
  .rail__num { transition: opacity 250ms ease; }
}

/* ============ Hero video background + dark header ============ */
.hero {
  position: relative;
  isolation: isolate;
  color: var(--night-text);
}
.hero__bg {
  position: absolute;
  z-index: 0;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  overflow: hidden;
  background: var(--night);
}
.hero__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hero__bg::after {
  /* dimming: stronger on the left where the text sits */
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(30, 25, 21, 0.84) 0%, rgba(30, 25, 21, 0.62) 45%, rgba(30, 25, 21, 0.38) 100%),
    linear-gradient(180deg,
      rgba(30, 25, 21, 0.4) 0%,
      rgba(30, 25, 21, 0) 22%,
      rgba(30, 25, 21, 0) 48%,
      rgba(30, 25, 21, 0.55) 74%,
      rgba(30, 25, 21, 0.9) 92%,
      var(--deep) 100%);
}

.hero .eyebrow { color: rgba(240, 233, 223, 0.72); }
.hero em { color: var(--clay-soft); }
.hero__lead { color: #D8CEC1; }
.hero .btn--solid { background: var(--night-text); border-color: var(--night-text); color: var(--ink); }
.hero .link-arrow { color: var(--night-text); }
@media (hover: hover) and (pointer: fine) {
  .hero .btn--solid:hover { background: var(--clay); border-color: var(--clay); color: var(--night-text); }
}

/* composition reads as light line-work over the video */
.hero .art .guides line,
.hero .art .guides circle { stroke: rgba(240, 233, 223, 0.28); }
.hero .art .line { stroke: var(--night-text); }
.hero .art .dim line { stroke: rgba(240, 233, 223, 0.6); }
.hero .art text { fill: rgba(240, 233, 223, 0.7); }
.hero .art .shape--sand { fill: rgba(234, 223, 206, 0.85); }
.hero .art .shape--sage { fill: rgba(214, 215, 197, 0.75); }

.header,
.header.is-scrolled {
  background: rgba(28, 24, 20, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--night-text);
}
.header { box-shadow: 0 1px 0 rgba(240, 233, 223, 0.08); }
.header.is-scrolled { background: rgba(28, 24, 20, 0.94); box-shadow: 0 1px 0 rgba(240, 233, 223, 0.1); }
.header .logo__mark path { stroke: var(--night-text); }
.header .logo__dot { color: var(--clay-soft); }
.header .nav__cta { border-color: rgba(240, 233, 223, 0.7); }
@media (hover: hover) and (pointer: fine) {
  .header .nav__cta:hover { background: var(--night-text); border-color: var(--night-text); color: var(--ink); }
}

/* ============ Architectural detailing ============ */

/* section number turns into a drawing caption with a leader line */
.section-num {
  display: flex;
  align-items: center;
  gap: 16px;
}
.section-num::after {
  content: "";
  flex: 1;
  height: 1px;
  background: currentColor;
  opacity: 0.28;
}
.portfolio__head .section-num { width: 100%; }

/* scale bar under the headings */
.scale-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 1.2em;
}
.scale-bar__ticks {
  position: relative;
  width: clamp(120px, 12vw, 190px);
  height: 12px;
  background:
    linear-gradient(90deg, currentColor 0 1px, transparent 1px) 0 100% / 100% 1px no-repeat,
    repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 25%) 0 100% / 100% 7px no-repeat,
    repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 12.5%) 0 100% / 100% 4px no-repeat;
  color: var(--ink);
  opacity: 0.4;
}
.scale-bar__label {
  font-size: var(--fs-label);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* crop marks on the light cards and tiles */
.tile__art,
.service,
.g-frame,
.about__portrait {
  --crop: 10px;
  position: relative;
}
.tile__art::before,
.service::before,
.about__portrait::before {
  content: "";
  position: absolute;
  inset: 8px;
  pointer-events: none;
  background:
    linear-gradient(currentColor, currentColor) 0 0 / 1px var(--crop) no-repeat,
    linear-gradient(currentColor, currentColor) 0 0 / var(--crop) 1px no-repeat,
    linear-gradient(currentColor, currentColor) 100% 0 / 1px var(--crop) no-repeat,
    linear-gradient(currentColor, currentColor) 100% 0 / var(--crop) 1px no-repeat,
    linear-gradient(currentColor, currentColor) 0 100% / 1px var(--crop) no-repeat,
    linear-gradient(currentColor, currentColor) 0 100% / var(--crop) 1px no-repeat,
    linear-gradient(currentColor, currentColor) 100% 100% / 1px var(--crop) no-repeat,
    linear-gradient(currentColor, currentColor) 100% 100% / var(--crop) 1px no-repeat;
  opacity: 0.35;
  z-index: 1;
}
.tile__art--ink::before { color: var(--night-text); opacity: 0.3; }
.tile__art--sage::before,
.tile__art--clay::before { color: var(--ink); opacity: 0.22; }
.service::before { color: var(--stone); opacity: 0.8; }
.about__portrait::before { color: var(--night-text); opacity: 0.45; }

/* drawing label on the tiles */
.tile__label {
  position: absolute;
  z-index: 2;
  top: 20px;
  right: 20px;
  font-size: var(--fs-label);
  letter-spacing: 0.18em;
  color: var(--ink);
  opacity: 0.65;
}
.tile { position: relative; }
.tiles .tile:last-child .tile__label { color: var(--night-text); }

/* gallery: sheet number, shown on hover */
.g-num {
  position: absolute;
  z-index: 2;
  right: 12px;
  bottom: calc(var(--gap) + 12px);
  font-size: var(--fs-label);
  letter-spacing: 0.16em;
  color: var(--night-text);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 300ms ease, transform 300ms var(--ease-out);
  text-shadow: 0 1px 10px rgba(24, 20, 17, 0.6);
}
@media (hover: hover) and (pointer: fine) {
  .g-item:hover .g-num { opacity: 1; transform: none; }
}

/* title block (stamp) in the contacts */
.stamp {
  position: relative;
  margin-top: clamp(48px, 5vw, 88px);
  margin-left: auto;
  width: min(100%, 460px);
  border: 1px solid var(--night-line);
  background: rgba(30, 25, 21, 0.93);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  font-size: var(--fs-label);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.stamp__row {
  display: grid;
  grid-template-columns: 8em 1fr;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--night-line);
}
.stamp__row:last-child { border-bottom: 0; }
.stamp__row span { color: var(--night-muted); }
.stamp__row b { font-weight: 400; color: var(--night-text); }

.footer__sheet { letter-spacing: 0.2em; }

/* hero: the composition gets a proper drawing frame */
.hero__art { position: relative; z-index: 1; }
.hero .art .guides line,
.hero .art .guides circle { stroke-dasharray: 0.004 0.01; }

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

/* Слежение за курсором считается покадрово в script.js.
   CSS-переходов у этих transform нет специально: они накладывались
   на покадровый расчёт и движение выглядело вязким и запаздывающим. */
.hero__art .art,
.art [data-depth] { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .hero__art .art { transform: none !important; }
}

/* ============ Floating architectural shapes ============ */
.work, .portfolio, .services { position: relative; }

.floaters {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.floater {
  position: absolute;
  will-change: transform;
}
.floater__art {
  width: 100%;
  height: auto;
  animation: floaty var(--dur, 18s) var(--ease-in-out) var(--delay, 0s) infinite alternate;
}
.fl-line { fill: none; stroke: var(--ink); stroke-width: 1; opacity: 0.22; }
.fl-dash { fill: none; stroke: var(--ink); stroke-width: 1; stroke-dasharray: 4 6; opacity: 0.18; }
.fl-dot  { fill: var(--clay); opacity: 0.45; }

@keyframes floaty {
  from { transform: translate3d(0, -10px, 0) rotate(-1.5deg); }
  to   { transform: translate3d(8px, 12px, 0) rotate(1.5deg); }
}

/* placement, always in the empty areas next to the headings */
.work .f-arch    { top: 2%;  right: 1%;  width: clamp(180px, 20vw, 300px); }
.work .f-circle  { top: 14%; right: 24%; width: clamp(90px, 9vw, 150px); }
.work .f-steps   { top: 7%;  right: 38%; width: clamp(120px, 13vw, 210px); opacity: 0.8; }

.portfolio .f-grid { top: 1%;  right: 2%;  width: clamp(150px, 17vw, 260px); }
.portfolio .f-axo  { top: 12%; right: 24%; width: clamp(100px, 11vw, 170px); }

.services .f-arc { top: 3%;  right: 3%;  width: clamp(140px, 15vw, 240px); }
.services .f-tri { top: 16%; right: 26%; width: clamp(90px, 10vw, 150px); }

@media (max-width: 1100px) {
  .work .f-steps, .portfolio .f-axo, .services .f-tri { display: none; }
  .work .f-arch, .portfolio .f-grid, .services .f-arc { opacity: 0.7; }
}
@media (max-width: 760px) {
  .floaters { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .floater__art { animation: none; }
  .floater { transform: none !important; }
}

/* ============ Performance: phones, old laptops, slow links ============ */
/* hero poster shows instantly; the video fades in on top only if it loads */
.hero__poster,
.hero__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hero__video { opacity: 0; transition: opacity 600ms ease; }
.hero__bg.is-playing .hero__video { opacity: 1; }

/* the browser can skip painting gallery items that are far off screen */
.g-item {
  content-visibility: auto;
  contain-intrinsic-size: auto 420px;
}

/* blur is expensive on weak GPUs: drop it on small screens */
@media (max-width: 900px) {
  .header,
  .header.is-scrolled {
    background: rgba(30, 25, 21, 0.96);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .stamp { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(30, 25, 21, 0.96); }
  .g-badge { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(35, 30, 25, 0.68); }
  .about__portrait::before,
  .tile__art::before,
  .service::before { display: none; }   /* fewer layers to composite */
}

/* coarse pointers never hover: skip the hover-only machinery entirely */
@media (hover: none) {
  .g-num { display: none; }
  .floater__art { animation: none; }
}

/* ============ Accessibility helper ============ */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ============ Process ============ */
.process { padding-bottom: clamp(80px, 11vw, 200px); position: relative; }
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(16px, 2vw, 40px);
}
.step {
  padding-top: clamp(20px, 2vw, 32px);
  border-top: 1px solid var(--line);
}
.step__num {
  font-size: var(--fs-label);
  letter-spacing: 0.2em;
  color: var(--clay);
}
.step__title {
  margin-top: 0.5em;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.8rem, 2.2vw, 2.6rem);
  line-height: 1.15;
}
.step__text { margin-top: 0.6em; color: var(--muted); font-size: var(--fs-small); }
.step__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-top: 0.6em;
  font-size: var(--fs-small);
  border-bottom: 1px solid var(--stone);
}
.step__link span { transition: transform 300ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .step__link:hover { border-color: var(--ink); }
  .step__link:hover span { transform: translateX(5px); }
}
@media (max-width: 960px) { .steps { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .steps { grid-template-columns: 1fr; } }

/* ============ Пока открыт просмотр работы ============ */
/* останавливаем всё, что рисуется в фоне: иначе браузер параллельно
   считает анимации и декодирует видео под затемнением */
.lb-open .floater__art,
.lb-open .service-art .sa-leg,
.lb-open .service-art .sa-tip { animation-play-state: paused; }
.lb-open .hero__bg,
.lb-open .rail { visibility: hidden; }

/* контакт без ссылки (например, WhatsApp, пока нет номера телефона) */
.contact__plain {
  font-weight: 400;
  font-size: clamp(20px, 1.6vw + 12px, 38px);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--night-text);
}

/* ============ Экран загрузки ============ */
.loader { display: none; }

.js.loading .loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(22px, 3vw, 34px);
  background: var(--deep);
  color: var(--night-text);
}
.js.loading body { overflow: hidden; }

.loader__mark { width: clamp(64px, 8vw, 96px); height: auto; }
.loader__ring {
  fill: none;
  stroke: rgba(240, 233, 223, 0.22);
  stroke-width: 1;
  stroke-dasharray: 3 7;
}
.loader__needle {
  fill: none;
  stroke: var(--night-text);
  stroke-width: 1.6;
  stroke-linecap: round;
  transform-origin: 32px 32px;             /* центр круга в координатах рисунка */
  animation: needle 1.6s cubic-bezier(0.62, 0, 0.38, 1) infinite;
}
.loader__pivot { fill: var(--clay); }

@keyframes needle {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.loader__word {
  font-size: var(--fs-label);
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: rgba(240, 233, 223, 0.72);
}
.loader__word span { color: var(--clay); }

.loader__bar {
  position: relative;
  width: min(220px, 46vw);
  height: 1px;
  background: rgba(240, 233, 223, 0.18);
  overflow: hidden;
}
.loader__bar i {
  position: absolute;
  inset: 0;
  background: var(--night-text);
  transform: scaleX(0);
  transform-origin: left;
  animation: loader-fill 1.4s ease-out forwards;
}
@keyframes loader-fill {
  from { transform: scaleX(0); }
  to   { transform: scaleX(0.9); }
}

/* уход: экран поднимается вверх и открывает первый экран */
.js.loading .loader.is-done {
  transform: translateY(-100%);
  transition: transform 800ms cubic-bezier(0.77, 0, 0.175, 1);
}
.js.loading .loader.is-done .loader__mark,
.js.loading .loader.is-done .loader__word,
.js.loading .loader.is-done .loader__bar {
  opacity: 0;
  transition: opacity 250ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .loader__needle { animation: none; }
  .loader__bar i { animation: none; transform: scaleX(0.9); }
  .js.loading .loader.is-done { transform: none; opacity: 0; transition: opacity 300ms ease; }
}

/* ============ Переключатель языка ============ */
.lang {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: clamp(4px, 1vw, 16px);
}
.lang__btn {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: var(--fs-label);
  letter-spacing: 0.14em;
  color: rgba(240, 233, 223, 0.5);
  padding: 0.5em 0.55em;
  min-height: 44px;
  cursor: pointer;
  transition: color 200ms ease;
}
.lang__btn.is-active { color: var(--night-text); }
.lang__btn.is-active::after {
  content: "";
  display: block;
  height: 1px;
  margin-top: 3px;
  background: var(--clay);
}
@media (hover: hover) and (pointer: fine) {
  .lang__btn:not(.is-active):hover { color: rgba(240, 233, 223, 0.85); }
}
@media (max-width: 460px) {
  .lang { margin-left: 2px; }
  .lang__btn { padding: 0.5em 0.35em; letter-spacing: 0.08em; }
}
