/* ============================================================
   morgunov.tech design system — v1 — components.css
   Reusable chrome + atoms shared across morgunov.tech services:
   top bar, language switch, theme switcher, buttons, section heads,
   lists, prose, footer, scroll chrome, focus ring, page shell.
   Depends on tokens.css + base.css. Page-specific layout (hero, stats,
   career, ventures, cards, /uses, /collaborate, contact) lives in each
   site's own stylesheet, loaded after this file.
   ============================================================ */

/* ============================================================
   morgunov.tech — V4 page styles (Braun / Dieter Rams aesthetic)
   Page-specific layout + components. No build step.
   Depends on the shared design-system layer, loaded first:
     /ds/v1/fonts.css   — @font-face (IBM Plex Sans + Mono)
     /ds/v1/tokens.css  — colour + type tokens, 4 themes
     /ds/v1/base.css    — reset, body, base typography, sr-only, skip-link
   ============================================================ */

.v4-root {
  background: var(--v4-bg);
  color: var(--v4-fg);
  padding: 36px 56px 56px;
  max-width: 1280px;
  margin: 0 auto;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* --- Top bar --- */

.v4-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0 14px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--v4-fg);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.v4-bar-mid {
  display: flex;
  gap: 6px 22px;
  justify-content: center;
  color: var(--v4-muted);
  /* Wrap to a second row when 7 links don't fit (around 768–960 px).
     Without wrap, flex squishes labels and breaks them inside words
     («ОБО / МНЕ»). */
  flex-wrap: wrap;
}

.v4-bar-mid a {
  color: inherit;
  text-decoration: none;
  padding: 8px 4px;
  /* Keep multi-word labels («Обо мне», «Своё дело») on one line —
     they should break between links, not inside a label. */
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.v4-bar-mid a:hover,
.v4-bar-mid a:focus-visible {
  color: var(--v4-fg);
  text-decoration: underline;
  text-decoration-color: var(--v4-orange);
  text-underline-offset: 4px;
}

.v4-bar-right {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  align-items: center;
  color: var(--v4-fg);
}

.v4-lang {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.v4-lang-link {
  color: var(--v4-muted);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 8px 6px;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.v4-lang-link:hover,
.v4-lang-link:focus-visible {
  color: var(--v4-fg);
}

.v4-lang-link.is-active {
  color: var(--v4-fg);
  border-bottom-color: var(--v4-orange);
}

.v4-lang-sep {
  color: var(--v4-dim);
}

/* --- Theme dropdown --- */

.v4-theme {
  position: relative;
}

.v4-icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--v4-fg);
  cursor: pointer;
  padding: 0;
  font: inherit;
  transition: color 0.15s ease;
}

.v4-icon-btn:hover,
.v4-icon-btn:focus-visible {
  color: var(--v4-orange-text);
}

.v4-icon-btn svg {
  width: 14px;
  height: 14px;
}

/* Theme icons: only one visible at a time, driven by [data-theme] on <html>.
   Sun is the fallback if no data-theme is set yet (e.g. JS disabled). */
.v4-icon-btn .v4-icon-moon,
.v4-icon-btn .v4-icon-contrast {
  display: none;
}

[data-theme="dark"] .v4-icon-btn .v4-icon-sun {
  display: none;
}

[data-theme="dark"] .v4-icon-btn .v4-icon-moon {
  display: block;
}

[data-theme="high-contrast"] .v4-icon-btn .v4-icon-sun {
  display: none;
}

[data-theme="high-contrast"] .v4-icon-btn .v4-icon-contrast {
  display: block;
}

.v4-theme-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  display: none;
  flex-direction: column;
  background: var(--v4-paper);
  border: 1px solid var(--v4-line);
  padding: 6px;
  min-width: 170px;
  z-index: 50;
}

.v4-theme.is-open .v4-theme-menu {
  display: flex;
}

.v4-theme-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--v4-fg);
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.v4-theme-btn:hover,
.v4-theme-btn:focus-visible {
  background: var(--v4-bg);
  color: var(--v4-orange-text);
}

.v4-theme-btn[aria-pressed="true"] {
  color: var(--v4-orange-text);
  border-color: var(--v4-orange);
}

.v4-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  min-height: 40px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--v4-fg);
  background: transparent;
  color: var(--v4-fg);
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.v4-btn:hover,
.v4-btn:focus-visible {
  background: var(--v4-fg);
  color: var(--v4-bg);
}

.v4-btn-primary {
  background: var(--v4-orange);
  color: var(--v4-on-accent);
  border-color: var(--v4-orange);
}

.v4-btn-primary:hover,
.v4-btn-primary:focus-visible {
  filter: brightness(0.9);
  background: var(--v4-orange);
  color: var(--v4-on-accent);
  border-color: var(--v4-orange);
}

/* --- Sections --- */

.v4-section {
  margin-bottom: 36px;
  scroll-margin-top: 40px;
}

/* Defer rendering of below-fold sections until they're scrolled near.
   First section (#about) renders immediately so the page feels snappy. */
.v4-section + .v4-section {
  content-visibility: auto;
  contain-intrinsic-size: 0 800px;
}

.v4-section-head {
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--v4-fg);
}

.v4-section-num {
  display: block;
  font-family: var(--v4-mono);
  font-size: 11px;
  color: var(--v4-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
  margin-bottom: 6px;
}

.v4-h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.015em;
}

.v4-h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--v4-muted);
  margin: 18px 0 8px;
  font-weight: 500;
}

.v4-h3:first-child {
  margin-top: 0;
}

.v4-body {
  display: block;
}

.v4-body-aside {
  display: none;
}

/* --- Lists --- */

.v4-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.v4-list li {
  padding-left: 18px;
  position: relative;
  line-height: 1.5;
  margin-bottom: 0;
}

.v4-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 8px;
  height: 1px;
  background: var(--v4-fg);
}

.v4-list a {
  color: var(--v4-fg);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--v4-line);
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.v4-list a:hover,
.v4-list a:focus-visible {
  color: var(--v4-orange-text);
  text-decoration-color: var(--v4-orange-text);
}

.v4-list--spaced {
  margin-top: 12px;
}

/* --- Prose --- */

.v4-prose p {
  margin: 0 0 12px;
  line-height: 1.55;
}

.v4-prose p:last-child {
  margin-bottom: 0;
}

.v4-prose strong {
  font-weight: 600;
}

.v4-prose a {
  color: var(--v4-fg);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--v4-line);
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.v4-prose a:hover,
.v4-prose a:focus-visible {
  color: var(--v4-orange-text);
  text-decoration-color: var(--v4-orange-text);
}

/* Inline code in prose — small mono pill with paper bg + soft border.
   Used heavily on /about for build hashes, file paths, colour tokens,
   English-loanwords («git log», «#FF6600», «SEMYON5076»). */
.v4-prose code,
.v4-list code {
  font-family: var(--v4-mono);
  font-size: 0.92em;
  padding: 1px 5px;
  background: var(--v4-bg);
  border: 1px solid var(--v4-line-soft);
  border-radius: 0;
  letter-spacing: 0;
  text-transform: none;
}

/* When a .v4-prose follows a .v4-list, keep a comfortable air-gap.
   .v4-list itself has no bottom margin; without this rule the closing
   paragraph would butt right up against the last list item. */
.v4-list + .v4-prose {
  margin-top: 18px;
}

.v4-terms {
  font-style: italic;
  color: var(--v4-muted);
  font-size: 13px;
  margin: 12px 0 0;
}

/* Live indicator dot (current role in #02 + active product in #05).
   Pulses to suggest «вот это сейчас работает». Reduced-motion users get
   a static dot via the global animation-duration: 0.001ms override. */
.v4-live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--v4-orange);
  flex-shrink: 0;
  animation: v4-pulse 2.4s ease-in-out infinite;
}

@keyframes v4-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* --- Footer --- */

.v4-foot {
  margin-top: 40px;
  padding-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--v4-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  flex-wrap: wrap;
  gap: 12px;
  font-weight: 500;
}

.v4-foot-privacy {
  text-align: right;
}

.v4-foot a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--v4-line);
  text-underline-offset: 2px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.v4-foot a:hover,
.v4-foot a:focus-visible {
  color: var(--v4-orange-text);
  text-decoration-color: var(--v4-orange-text);
}

.v4-foot code {
  font-family: var(--v4-mono);
  font-size: inherit;
  letter-spacing: 0;
  text-transform: none;
}

/* --- Scroll-to-top button --- */

.v4-scroll-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--v4-fg);
  background: var(--v4-paper);
  color: var(--v4-fg);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, color 0.15s ease, border-color 0.15s ease;
  z-index: 9;
  font-family: var(--v4-mono);
  font-size: 16px;
  padding: 0;
}

.v4-scroll-top.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.v4-scroll-top:hover,
.v4-scroll-top:focus-visible {
  color: var(--v4-orange-text);
}

/* --- Mobile scroll progress bar ---
   On ≤960px the right-column section nav is hidden, so a thin top-anchored
   bar takes over as a "where am I in the document" cue. Width is set in JS
   from window.scrollY / (scrollHeight - clientHeight). Above .v4-scroll-top
   (z:9) and .v4-section-nav (z:9), below .skip-link (z:100). */

.v4-scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--v4-orange);
  z-index: 11;
  pointer-events: none;
}

@media (min-width: 961px) {
  .v4-scroll-progress {
    display: none;
  }
}

/* --- Sticky section nav (right column, scroll-spy) --- */

/* Hidden by default until the user has scrolled past 300px. We use
   visibility (not the `inert` attribute) so JS doesn't need to toggle
   anything beyond a single class — and so old WebKit doesn't choke on
   inert-driven layer suppression. visibility transitions instantly on
   show so the fade-in plays, and after the fade-out so links stop
   accepting clicks/focus. */
.v4-section-nav {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 9;
  font-family: var(--v4-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.v4-section-nav.is-visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease, visibility 0s linear 0s;
}

.v4-section-nav a {
  color: var(--v4-dim);
  text-decoration: none;
  padding: 2px 6px;
  transition: color 0.15s ease;
}

.v4-section-nav a:hover,
.v4-section-nav a:focus-visible {
  color: var(--v4-fg);
}

.v4-section-nav a.is-active {
  color: var(--v4-fg);
}

@media (max-width: 960px) {
  .v4-section-nav {
    display: none;
  }
}

/* --- Focus ring --- */

.v4-page :focus-visible {
  outline: 2px solid var(--v4-orange);
  outline-offset: 2px;
}
