/* ==========================================================================
   Портфолио — базовая типографика, каркас страницы и адаптивная сетка.
   Работает с 320 px до 1440 px и шире. Стили галерей — project-gallery.css.
   ========================================================================== */

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

:root {
  --text: #2c2c2b;
  --muted: #66635f;
  --bg: #ffffff;
  --surface: #f9f8f7;
  --border: #e6e5e3;
  --accent: #2783de;
  --hero-surface: #f8f0e3;
  --hero-border: #d7cbb8;

  --container: 1120px;
  --gutter: clamp(16px, 1.1rem + 1.6vw, 48px);
  --stack: clamp(14px, 0.9rem + 1vw, 24px);
  --radius: 10px;

  /* Высота фиксированной шапки. content.js подставляет измеренное значение,
     это — запасное значение до скриптов и при узких экранах. */
  --header-height: 64px;
  --scroll-offset: calc(var(--header-height) + clamp(8px, 1vw, 20px));
}

html {
  /* Плавная fluid-база: весь текст на странице масштабируется через rem. */
  font-size: clamp(15px, 14.2px + 0.3vw, 17px);
  scroll-behavior: smooth;
  scroll-padding-top: var(--scroll-offset);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  background: var(--bg);
  color: var(--text);
  overflow-wrap: break-word;
}

h1, h2, h3, h4 { text-wrap: balance; }
p, li { text-wrap: pretty; }

a { color: inherit; }

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

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; }

::selection { background: #eaff3f; color: #111; }

/* --- Каркас --------------------------------------------------------------- */

.container {
  width: min(100% - var(--gutter) * 2, var(--container));
  margin-inline: auto;
}

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

.divider { width: 100%; height: 1px; background: var(--border); }

.skip-link {
  position: fixed;
  top: 0; left: var(--gutter);
  z-index: 200;
  padding: 10px 18px;
  background: var(--text);
  color: #fff;
  font-size: 0.9rem;
  border-radius: 0 0 var(--radius) var(--radius);
  text-decoration: none;
  transform: translateY(-130%);
  transition: transform 0.18s ease;
}
.skip-link:focus-visible { transform: translateY(0); }

.noscript-notice {
  margin: calc(var(--header-height) + 24px) var(--gutter) 0;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  text-align: center;
}

/* --- Шапка ---------------------------------------------------------------- */

.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px clamp(12px, 3vw, 40px);
  min-height: 4rem;
  padding-block: 8px;
  width: min(100% - var(--gutter) * 2, var(--container));
  margin-inline: auto;
}

.nav-logo {
  font-size: clamp(1rem, 0.9rem + 0.45vw, 1.2rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.3;
  text-decoration: none;
  min-width: 0;
}
.nav-logo:hover { color: var(--accent); }

.nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: clamp(12px, 2.6vw, 32px);
  list-style: none;
}

.nav-link {
  display: inline-block;
  padding-block: 4px;
  font-size: clamp(0.88rem, 0.84rem + 0.2vw, 1rem);
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-link:hover { color: var(--text); }
.nav-link--external { text-decoration: underline; text-underline-offset: 3px; }
.nav-link--plain { color: var(--muted); }

/* --- Первый экран --------------------------------------------------------- */

.hero-band {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: var(--hero-surface);
  padding-block: calc(var(--header-height) + clamp(40px, 7vw, 88px)) clamp(48px, 7vw, 88px);
}

.hero-band::before {
  content: "";
  position: absolute;
  inset: var(--header-height) 0 0;
  z-index: -1;
  background: url("assets/hero-waves.png") center / cover no-repeat;
  opacity: 0.25;
  pointer-events: none;
}

.hero { max-width: 46rem; }

.hero-tag {
  font-size: clamp(0.78rem, 0.72rem + 0.2vw, 0.9rem);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: clamp(14px, 1rem + 0.6vw, 22px);
}

.hero-title {
  font-size: clamp(1.9rem, 1.1rem + 3.7vw, 3.3rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  /* Перенос строки приходит из содержимого (heroTitle). */
  white-space: pre-line;
}

.hero-text {
  margin-top: clamp(16px, 1rem + 1vw, 26px);
  max-width: 34rem;
  font-size: clamp(1rem, 0.93rem + 0.4vw, 1.22rem);
  line-height: 1.7;
  color: var(--muted);
}

.hero-cta {
  display: inline-block;
  margin-top: clamp(24px, 1.4rem + 1.6vw, 42px);
  padding: 0.8em 1.7em;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius);
  font-size: clamp(0.9rem, 0.86rem + 0.25vw, 1rem);
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.2s;
}
.hero-cta:hover { opacity: 0.85; transform: translateY(-2px); }

/* --- Навигатор направлений ------------------------------------------------ */

.works { padding-block: clamp(48px, 5vw + 24px, 96px); }

.section-label {
  font-size: clamp(0.75rem, 0.7rem + 0.2vw, 0.86rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: clamp(20px, 1.4rem + 1vw, 40px);
}

.directions {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(12px, 1.4vw, 18px);
  list-style: none;
}

.direction-item { grid-column: span 2; min-width: 0; }

/* Осознанный ряд 3 + 2: если в последнем ряду две карточки, они занимают по 3 колонки. */
.directions[data-remainder="2"] .direction-item:nth-last-child(-n + 2) { grid-column: span 3; }
/* Одна карточка в последнем ряду — по центру. */
.directions[data-remainder="1"] .direction-item:last-child { grid-column: 3 / span 2; }

.direction-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  min-width: 0;
  /* Одинаковая высота карточек во всех рядах: ряды 3 + 2 выглядят структурно. */
  height: 100%;
  min-height: clamp(148px, 11vw + 60px, 208px);
  padding: clamp(16px, 1.6vw, 28px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  transition: transform 0.2s, background-color 0.2s, border-color 0.2s;
}
.direction-card:hover {
  transform: translateY(-3px);
  background: var(--hero-surface);
  border-color: var(--hero-border);
}
.direction-card:focus-visible { outline-offset: 4px; }

.direction-index {
  font-size: clamp(0.72rem, 0.68rem + 0.2vw, 0.82rem);
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--accent);
}

.direction-label {
  font-size: clamp(1.25rem, 1rem + 1.35vw, 1.95rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-align: center;
  overflow-wrap: anywhere;
}

.direction-kind {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.direction-note {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.direction-mark { width: 0.9em; height: 0.9em; flex: none; }
.direction-card-plain { cursor: default; }
.direction-note--plain { color: var(--accent); }

/* --- Секции и проекты ----------------------------------------------------- */

.case-list { margin-top: clamp(48px, 4vw + 24px, 88px); }
.case-list:empty { margin-top: 0; }

.section-group { min-width: 0; }
.section-group + .section-group { margin-top: clamp(48px, 4vw + 20px, 88px); }

.portfolio-section-heading {
  margin-top: clamp(24px, 2vw + 12px, 48px);
  padding-block: clamp(14px, 1.4vw, 28px);
  border-top: 2px solid var(--text);
  font-size: clamp(1.75rem, 1.25rem + 2.3vw, 3rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}
.section-group > .portfolio-section-heading:first-child { margin-top: 0; }

.case {
  min-width: 0;
  border-top: 1px solid var(--border);
  padding-top: clamp(18px, 1.6vw, 30px);
  margin-top: clamp(36px, 3vw + 20px, 64px);
}
.section-group > .case:first-of-type { margin-top: clamp(20px, 1.6vw, 32px); }

.case-title {
  font-size: clamp(1.25rem, 1.05rem + 0.9vw, 1.7rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.case-meta {
  margin-top: 0.6rem;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--muted);
  text-align: left;
}

/* Описания занимают всю ширину контейнера и набираются по ширине. */
.case-description { margin-top: clamp(20px, 1.6vw + 8px, 34px); }

.case-description p,
.about-text p {
  max-width: none;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  hyphenate-limit-chars: 8 4 3;
  font-size: clamp(0.95rem, 0.92rem + 0.15vw, 1.05rem);
  line-height: 1.75;
}
.case-description p + p,
.about-text p + p { margin-top: var(--stack); }

.case-back {
  display: inline-block;
  margin-top: clamp(16px, 1.4vw, 26px);
  font-size: 0.88rem;
  color: var(--muted);
  text-decoration: none;
}
.case-back:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* --- Обо мне -------------------------------------------------------------- */

.about {
  padding-block: clamp(48px, 5vw + 20px, 96px);
  min-height: calc(100svh - var(--header-height));
}

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: clamp(28px, 4vw, 80px);
  align-items: start;
}

.about-title {
  font-size: clamp(1.5rem, 1.15rem + 1.6vw, 2.2rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: clamp(16px, 1.2rem + 0.6vw, 26px);
}

.about-text { max-width: none; }

.skills-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: clamp(20px, 1.6rem + 0.6vw, 34px);
  list-style: none;
}

.skill-tag {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.86rem;
}

.about-aside {
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 1.6rem + 0.6vw, 34px);
  min-width: 0;
}

.about-portrait { margin: 0; }
.about-portrait img {
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.about-stats {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(20px, 2vw, 40px);
}

.stat { min-width: 0; }

.stat-number {
  font-size: clamp(2rem, 1.6rem + 1.8vw, 3rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
}

.stat-label {
  margin-top: 6px;
  font-size: 0.88rem;
  color: var(--muted);
  text-align: left;
}

/* --- Контакты ------------------------------------------------------------- */

.contact {
  background: var(--surface);
  border-radius: 16px;
  width: min(100% - var(--gutter) * 2, var(--container));
  margin-inline: auto;
  margin-bottom: clamp(48px, 5vw, 96px);
  padding: clamp(28px, 3vw + 16px, 80px);
}

/* Секция контактов уже задаёт ширину и внутренние отступы. */
.contact > .container { width: 100%; max-width: none; padding-inline: 0; margin-inline: 0; }

.contact-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(28px, 4vw, 80px);
  align-items: center;
}

.contact-intro { min-width: 0; }

.contact-title {
  font-size: clamp(1.6rem, 1.2rem + 2vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 14px;
}

.contact-text {
  max-width: 34rem;
  color: var(--muted);
  line-height: 1.75;
  text-align: left;
}

.contact-links { display: grid; gap: 14px; list-style: none; min-width: 0; }

.contact-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  text-decoration: none;
  transition: border-color 0.2s, transform 0.2s;
}
.contact-link:hover { border-color: var(--accent); transform: translateX(4px); }

.contact-link-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--surface);
  font-size: 16px;
}

.contact-link-label { display: block; font-weight: 500; font-size: 0.95rem; }
.contact-link-value { display: block; font-size: 0.84rem; color: var(--muted); overflow-wrap: anywhere; }

/* --- Подвал --------------------------------------------------------------- */

.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.86rem; }

.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding-block: clamp(20px, 1.6rem + 0.6vw, 34px);
  width: min(100% - var(--gutter) * 2, var(--container));
  margin-inline: auto;
}

/* --- Адаптив -------------------------------------------------------------- */

@media (max-width: 900px) {
  .about-grid { grid-template-columns: minmax(0, 1fr); }
  .about-portrait img { max-width: 320px; }
}

@media (max-width: 860px) {
  .directions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .direction-item,
  .directions[data-remainder="2"] .direction-item:nth-last-child(-n + 2),
  .directions[data-remainder="1"] .direction-item:last-child { grid-column: span 2; }
  /* В двух колоноках последняя одинокая карточка растягивается на весь ряд. */
  .directions[data-pairs="1"] .direction-item:last-child { grid-column: 1 / -1; }
  .contact-inner { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 620px) {
  :root { --header-height: 84px; }
  .directions { grid-template-columns: minmax(0, 1fr); }
  .direction-item,
  .directions[data-remainder="2"] .direction-item:nth-last-child(-n + 2),
  .directions[data-remainder="1"] .direction-item:last-child,
  .directions[data-pairs="1"] .direction-item:last-child { grid-column: 1 / -1; }
  .direction-card { min-height: clamp(132px, 34vw, 168px); }
  .about { min-height: 0; }
  .site-footer-inner { justify-content: center; text-align: center; }
}

@media (max-width: 380px) {
  :root { --header-height: 104px; }
  .nav-links { justify-content: space-between; width: 100%; }
}

/* --- Уменьшенное движение -------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .direction-card, .contact-link, .skill-tag { border: 1px solid CanvasText; }
  :focus-visible { outline: 3px solid Highlight; }
}
