/* Section flow: clean architectural transitions and 1080 one-screen fitting.
   Loaded last, ensuring crisp boundaries, zero gradient smudges, and seamless chapter flow. */

/* ---------- 1. Exact navigation anchors (no scroll-snap: it fought smooth anchor jumps) ---------- */
:where(section[id], div[id]) {
  scroll-margin-top: var(--header-height, 64px) !important;
}

/* ---------- 1b. Reveals belong to ONE manager ----------
   The scroll-driven (`animation-timeline: view()`) layer used to run in parallel with the
   IntersectionObserver manager in motion.js: two animations per block, and the scroll-driven
   one replayed on every pass, so scrolling back up made the page perform again.
   Per the interaction contract a reveal happens ONCE, on arrival, and then gets out of the way,
   so the observer is now the only reveal engine (see src/motion.js + src/motion.css).
   Only the sheet shadow — which is a scroll POSITION value, not an entrance — stays here. */
@supports (animation-timeline: view()) {
  #raboty {
    animation: flow-sheet both linear;
    animation-timeline: view();
    animation-range: entry 0% entry 45%;
  }
}
@keyframes flow-sheet {
  from { box-shadow: 0 -28px 72px rgba(0, 0, 0, .26); }
  to   { box-shadow: 0 -12px 36px rgba(0, 0, 0, .08); }
}
@media (prefers-reduced-motion: reduce) {
  main > section.wrap, main > section.wrap > *, #raboty { animation: none !important; }
}

/* ---------- 2. Clean transition from dark 3D exhibit into paper sheet ---------- */
/* No dirty gradient overlays: the 3D block ends cleanly without dead padding. */
.cine {
  padding-bottom: 0 !important;
}
.cine::after {
  display: none !important;
}

/* The first light block (#raboty) rolls up cleanly over the dark 3D stage
   like an architectural drawing sheet, with a subtle elevation shadow. */
#raboty {
  position: relative;
  z-index: 2;
  background: var(--paper);
  box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.08);
}

/* Clean hairline architectural dividing rule between subsequent light blocks */
main > section.wrap:not(#raboty) {
  border-top: 1px solid var(--line);
}

/* ---------- 3. One screen per block on 1080-tall display, never cropped ---------- */
main > section:not(.cine):not(.hero) {
  min-height: calc(100svh - var(--header-height, 64px));
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;
  padding-block: clamp(28px, 4.6svh, 68px);
}

.section-head {
  margin-bottom: clamp(16px, 2.6svh, 34px);
}
.section-head > p {
  padding-top: clamp(0px, 2svh, 24px);
}

.work summary {
  padding-block: clamp(12px, 2.2svh, 24px);
}
.work-body {
  padding-bottom: clamp(12px, 2svh, 22px);
}
.cta {
  padding-top: clamp(20px, 3.6svh, 44px);
}

/* ---------- Portfolio: material cards instead of a thin ledger ----------
   No client photos yet (pending approval), so each card carries an honest material swatch:
   the cladding type, not a fake render of the building. */
#portfolio {
  padding-block: clamp(22px, 3.2svh, 54px);
}
#portfolio .projects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 1.4vw, 20px);
  border: 0;
}
#portfolio .project {
  position: relative;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  grid-template-areas: "swatch tags" "swatch main" "swatch meta" "swatch more";
  gap: 10px clamp(18px, 2vw, 28px);
  align-content: start;
  padding: clamp(20px, 2.2svh, 28px);
  background: var(--paper-soft, #fff);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  /* Hover state lives in src/interactions.css: one recipe for every card-like surface. */
}
/* Ghost numeral in the corner: the index becomes texture, not a table column. */
#portfolio .project-index {
  position: absolute;
  top: 10px; right: 16px;
  padding: 0;
  font-size: clamp(56px, 4.6vw, 84px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.06em;
  color: #eceee8;
  pointer-events: none;
  user-select: none;
}
#portfolio .project-swatch {
  grid-area: swatch;
  position: relative;
  display: block;
  width: 84px;
  min-height: 100%;
  border-radius: 2px;
  overflow: hidden;
  background: #b9bcb5;
}
#portfolio .project-swatch::after {
  content: '';
  position: absolute; inset: 0;
  transition: transform 600ms var(--ease-out-quint);
}
/* СФТК + НВФ: graphite fibre-cement courses with open joints over warm plaster. */
#portfolio .project[data-material="nvf"] .project-swatch::after {
  background:
    repeating-linear-gradient(0deg, transparent 0 62px, rgba(0,0,0,.55) 62px 66px),
    repeating-linear-gradient(90deg, transparent 0 40px, rgba(0,0,0,.4) 40px 43px),
    linear-gradient(135deg, #4b545a, #363d42 55%, #4d565c);
}
/* Гибкая керамика: thin clay-toned tiles, slight brick bond. */
#portfolio .project[data-material="ceramic"] .project-swatch::after {
  background:
    repeating-linear-gradient(0deg, transparent 0 22px, rgba(255,255,255,.55) 22px 24px),
    repeating-linear-gradient(90deg, transparent 0 30px, rgba(255,255,255,.45) 30px 32px),
    linear-gradient(160deg, #b98a6a, #a06f52 60%, #c39a7c);
}
/* СФТК: fine mineral plaster, light, almost flat. */
#portfolio .project[data-material="plaster"] .project-swatch::after {
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.35), transparent 45%),
    radial-gradient(circle at 70% 80%, rgba(0,0,0,.08), transparent 50%),
    linear-gradient(180deg, #dcd9d0, #cfcbc0);
}
/* СФБ + натуральный камень: large stone slabs with subtle veining. */
#portfolio .project[data-material="stone"] .project-swatch::after {
  background:
    repeating-linear-gradient(0deg, transparent 0 48px, rgba(0,0,0,.35) 48px 50px),
    linear-gradient(115deg, transparent 40%, rgba(255,255,255,.18) 42%, transparent 45%),
    linear-gradient(60deg, transparent 60%, rgba(255,255,255,.12) 62%, transparent 66%),
    linear-gradient(150deg, #8d8c86, #6f6f6a 50%, #9b9a93);
}
#portfolio .project-tags {
  grid-area: tags;
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 6px;
}
#portfolio .project-tags li {
  font-size: 11.5px;
  line-height: 1;
  letter-spacing: .02em;
  text-transform: uppercase;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--paper);
}
#portfolio .project-main { grid-area: main; }
#portfolio .project h3 {
  font-size: clamp(22px, 1.75vw, 30px);
  max-width: 18ch;
}
#portfolio .project-scope {
  margin-top: 6px;
  font-size: 14.5px;
  max-width: 34ch;
}
#portfolio .project-meta {
  grid-area: meta;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
#portfolio .project-meta dt { font-size: 11.5px; margin-bottom: 3px; }
#portfolio .project-meta dd { font-size: 15px; overflow-wrap: anywhere; }
/* Wide cards: six facts in two rows. The long values (Заказчик, Местоположение) sit in the
   wider middle column, the short ones (Девелопер/Класс, Этажность/Сроки) flank them. */
@media (min-width: 1100px) {
  #portfolio .project-meta { grid-template-columns: minmax(0, .8fr) minmax(0, 1.5fr) minmax(0, .8fr); gap: 8px 16px; }
}
#portfolio .project-more {
  grid-area: more;
  justify-content: flex-start;
  text-align: left;
  padding-top: 0;
  font-size: 12.5px;
}
#portfolio .project-more span {
  border: 0;
  padding: 5px 10px;
  border-radius: 999px;
  background: #f3ecd6;
  color: #6b5a1e;
}
#portfolio .projects-note {
  margin-top: clamp(10px, 1.4svh, 18px);
  font-size: 12.5px;
}
#portfolio .partners {
  margin-top: clamp(12px, 2svh, 32px);
  padding-top: clamp(10px, 1.4svh, 20px);
}
#portfolio .partners-item {
  font-size: clamp(15px, 1.1vw, 19px);
  min-height: 34px;
}
@media (max-width: 900px) {
  #portfolio .projects { grid-template-columns: 1fr; }
  #portfolio .project { grid-template-columns: 64px minmax(0, 1fr); gap: 8px 16px; padding: 18px; }
  #portfolio .project-swatch { width: 64px; }
  #portfolio .project-index { font-size: 48px; top: 8px; right: 12px; }
  #portfolio .project h3 { font-size: 21px; max-width: none; }
  #portfolio .project-meta { grid-template-columns: 1fr; gap: 8px; }
}
@media (max-width: 480px) {
  /* Phone: the material becomes a header strip instead of a side column. */
  #portfolio .project { grid-template-columns: 1fr; grid-template-areas: "swatch" "tags" "main" "meta" "more"; }
  #portfolio .project-swatch { width: 100%; min-height: 0; height: 56px; }
  #portfolio .project-index { top: 66px; }
}

/* Process rows in #poryadok: clean architectural rhythm */
.process article {
  padding-block: clamp(14px, 2.2svh, 24px);
}
.process p {
  font-size: 15px;
}

/* Desktop up to a full-screen 1080 display: tune type & rhythm so four real objects
   plus the partner row still make ONE screen. */
@media (min-width: 900px) and (max-height: 1100px) {
  #portfolio {
    padding-block: clamp(16px, 2.2svh, 36px);
  }
  #portfolio .section-head {
    margin-bottom: clamp(10px, 1.6svh, 20px);
  }
  #portfolio .section-head > p {
    padding-top: 0;
    font-size: 14.5px;
  }
  #portfolio .projects { gap: 12px; }
  #portfolio .project {
    padding: 16px 18px;
    gap: 8px 20px;
  }
  #portfolio .project h3 {
    font-size: clamp(19px, 1.4vw, 24px);
  }
  /* The one-line scope repeats the tags and lives in full in the dialog: on a 1080 screen the
     card carries title + material + six facts, nothing else. */
  #portfolio .project-scope { display: none; }
  #portfolio .project-meta { padding-top: 8px; gap: 6px 16px; }
  #portfolio .project-meta dt { margin-bottom: 2px; }
  #portfolio .project-meta dd {
    font-size: 13.5px;
  }
  #portfolio .project-index { font-size: 56px; }
  #portfolio .projects-note {
    margin-top: 6px;
    font-size: 11.5px;
  }
  #portfolio .partners {
    margin-top: clamp(8px, 1.4svh, 18px);
    padding-top: 8px;
  }
  #portfolio .partners-item {
    min-height: 30px;
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .section-fade, .section-fade-in, .sr, .sr-in {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

@media (min-width: 900px) and (max-height: 800px) {
  #portfolio .project {
    padding: 12px 16px;
  }
  #portfolio .project-scope { display: none; }
  #portfolio .partners-item {
    min-height: 26px;
    font-size: 14px;
  }
  #portfolio .projects-note {
    font-size: 11px;
  }
}

@media (min-width: 900px) and (max-height: 820px) {
  .section-head > p {
    padding-top: 0;
    font-size: 14.5px;
  }
  h2 {
    font-size: clamp(28px, 3vw, 40px);
  }
  .process h3 {
    font-size: 20px;
  }
  .process p {
    font-size: 14.5px;
  }
  .work summary {
    font-size: clamp(18px, 1.8vw, 23px);
  }
}

/* 1080 viewport fit: partner lockups keep their visual weight without pushing the section below the fold. */
@media (min-width: 900px) and (max-height: 1100px) {
  #portfolio .partners-list { gap: 12px 18px; }
  #portfolio .partners-item.partners-logo {
    min-height: 68px;
    padding: 9px 12px 8px;
    grid-template-rows: minmax(26px, 1fr) auto;
  }
  #portfolio .partner-mark { max-height: 30px; font-size: 20px; }
  #portfolio .partner-mark--five { height: 30px; }
  #portfolio .partner-mark--eurospar { width: 112px; height: 24px; }
  #portfolio .partner-name { font-size: 10px; }
  #portfolio .partners { margin-top: 8px; padding-top: 8px; }
}
@media (min-width: 900px) and (max-height: 820px) {
  /* More presence for partners; the project cards carry less vertical weight. */
  #portfolio .partners-item.partners-logo { min-height: 82px; padding: 11px 14px 10px; }
  #portfolio .partner-mark { max-height: 34px; font-size: 21px; }
  #portfolio .partner-mark--five { height: 34px; }
  #portfolio .partner-mark--eurospar { width: 126px; height: 26px; }
  #portfolio .partner-name { font-size: 10px; }
  #portfolio .project { padding: 9px 12px; gap: 5px 16px; }
  #portfolio .project-swatch { width: 68px; min-height: 84px; }
  #portfolio .project h3 { font-size: 18px; }
  #portfolio .project-meta { padding-top: 5px; }
  #portfolio .project-meta dd { font-size: 12.5px; }
  #portfolio .projects-note { margin-top: 4px; }
  #portfolio .partners { margin-top: 6px; padding-top: 6px; }
}

/* Closed specialization rows fit the desktop chapter; expanded descriptions keep natural flow. */
@media (min-width: 1000px) and (max-height: 1100px) {
  #raboty { padding-block: clamp(24px, 3svh, 36px); }
  #raboty .work summary {
    font-size: clamp(20px, 1.65vw, 25px);
    padding-block: 16px;
  }
}
