/* =========================
   Theme variables
========================= */
:root {
  --bg: #0b0f14;
  --card: #121823;
  --accent: #5eead4;
  --accent2: #60a5fa;
  --text: #e6edf3;
  --muted: #a1a9b3;
  --link: #5eead4;
  --link-visited: #93c5fd;
  --link-hover: #22d3ee;
  --link-active: #34d399;
}

/* =========================
   Base
========================= */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    Ubuntu,
    "Helvetica Neue",
    Arial,
    sans-serif;
  line-height: 1.6;
}

/* Containers */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 24px;
}

.site-header .container {
  padding-top: 24px;
}

/* Text utils */
.link {
  color: var(--accent);
}

.sub {
  color: var(--muted);
  margin: 14px 0 18px;
}

/* Card / Grid / Buttons */
.card {
  background: var(--card);
  padding: 20px;
  border-radius: 16px;
  border: 1px solid #1e2633;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.btn {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #0b0f14;
  text-decoration: none;
  font-weight: 700;
}

.btn.secondary {
  background: #1f2937;
  color: var(--text);
  border: 1px solid #2b3647;
}

.btn.tertiary {
  background: transparent;
  color: var(--accent2);
  border: 1px solid var(--accent2);
}

.btn.tertiary:hover {
  background: var(--accent2);
  color: #0b0f14;
}

/* Footer */
.site-footer {
  border-top: 1px solid #1e2633;
  margin-top: 12px;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: var(--muted);
}

.footer-made {
  color: var(--muted);
  font-style: italic;
}

/* =========================
   Header / Navigation
========================= */
.header-inner.header-grid {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "brand nav actions";
  align-items: center;
  gap: 16px;
}

.header-inner.header-grid.nav-collapsed .nav {
  display: none;
}

.header-inner.header-grid.nav-collapsed .hamburger {
  display: inline-flex;
}

.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.logo {
  height: 48px;
  width: auto;
}

.header-grid .nav {
  grid-area: nav;
  justify-self: center;
}

.header-actions,
.header-right {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: end;
  margin-left: auto;
  position: relative;
}

/* Hamburger */
.hamburger {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid #2b3647;
  border-radius: 10px;
  background: #1f2937;
  cursor: pointer;
  position: relative;
  transition:
    box-shadow 0.2s,
    background-color 0.2s,
    border-color 0.2s,
    transform 0.15s;
  will-change: transform;
}

.hamburger:hover {
  background: #222d3f;
  border-color: #33465f;
  box-shadow: 0 4px 12px rgb(0 0 0 / 25%);
}

.hamburger span {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transform-origin: center;
  transition:
    transform 0.22s,
    opacity 0.18s,
    top 0.22s,
    background-color 0.22s;
}

.hamburger span:nth-child(1) {
  top: 12px;
}

.hamburger span:nth-child(2) {
  top: 19px;
}

.hamburger span:nth-child(3) {
  top: 26px;
}

.hamburger[aria-expanded="true"] {
  background: #1b2433;
  border-color: #3a4c66;
}

.hamburger[aria-expanded="true"] span:nth-child(1) {
  top: 19px;
  transform: rotate(45deg);
}

.hamburger[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0.5);
}

.hamburger[aria-expanded="true"] span:nth-child(3) {
  top: 19px;
  transform: rotate(-45deg);
}

.hamburger:active {
  transform: translateY(1px);
}

.hamburger:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

.nav-force .hamburger {
  display: inline-flex;
}

/* Nav links */
.nav ul {
  display: flex;
  gap: 16px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav a {
  color: var(--text);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 12px;
  transition: all 0.2s ease;
}

.header-grid .nav a:hover {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #0b0f14;
  box-shadow: 0 4px 12px rgb(0 0 0 / 40%);
  transform: translateY(-1px);
}

.header-grid .nav a.is-current,
.header-grid .nav a[aria-current="page"] {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #0b0f14;
  font-weight: 700;
  box-shadow: 0 6px 18px rgb(0 0 0 / 45%);
}

.header-grid .nav a.is-current:hover,
.header-grid .nav a[aria-current="page"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgb(0 0 0 / 50%);
}

.header-grid .nav a:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

/* Mobile nav */
.nav.nav-mobile a {
  border-radius: 10px;
  transition: all 0.2s ease;
}

.nav.nav-mobile a:hover {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #0b0f14;
}

.nav.nav-mobile a.is-current,
.nav.nav-mobile a[aria-current="page"] {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #0b0f14;
  font-weight: 700;
}

.nav.nav-mobile a:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

/* Language dropdown */
.dropdown {
  flex: 0 0 auto;
  position: relative;
}

.dropbtn {
  background: #1f2937;
  color: #e6edf3;
  padding: 8px 14px;
  font-weight: 600;
  border: 1px solid #2b3647;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 40px;
}

.dropbtn .fi {
  font-size: 20px;
  line-height: 1;
}

.fi {
  border-radius: 3px;
}

.dropdown .dropdown-content {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  background: #121823;
  border-radius: 8px;
  box-shadow: 0 6px 12px rgb(0 0 0 / 40%);
  z-index: 2000;
  width: max-content;
  max-height: 70vh;
  overflow-y: auto;
  white-space: nowrap;
}

.dropdown .dropdown-content a {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 14px;
  line-height: 1.3;
  color: #e6edf3;
  text-decoration: none;
}

.dropdown .dropdown-content a:hover {
  background: #1e2633;
  color: var(--text);
}

.dropdown .dropdown-content a.active {
  background: #1e2633;
  color: var(--accent);
  font-weight: 700;
  border-radius: 8px;
}

.dropdown .show {
  display: block;
}

/* =========================
   Hero / CTA
========================= */
.hero .tagline {
  color: var(--accent);
  margin-top: 8px;
}

.hero h1 {
  margin-top: 0;
}

.cta-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
}

.cta-row a {
  text-align: center;
  flex: 0 0 auto;
}

.cta-row span {
  display: none;
}

.cta-row[aria-label="Post navigation"],
.cta-row[aria-label="Pagination"] {
  justify-content: space-between;
}

/* =========================
   Services / Skills
========================= */
.services-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
}

.services-content .service-block + .service-block {
  margin-top: 16px;
}

.service-block h2 {
  margin-top: 0;
}

.service-block .bullets {
  margin: 10px 0 0;
}

.service-block .bullets li + li {
  margin-top: 6px;
}

.service-cta-final {
  margin-top: 16px;
  text-align: center;
}

.services-toc {
  position: sticky;
  top: 96px;
  align-self: start;
}

.services-toc h3 {
  margin-top: 0;
}

.services-toc ul {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.services-toc li + li {
  margin-top: 6px;
}

.services-toc a {
  color: var(--muted);
  text-decoration: none;
}

.services-toc a:hover {
  color: var(--accent);
}

.service-block .btn {
  margin-top: 8px;
  background: transparent;
  color: var(--accent2);
  border: 1px solid var(--accent2);
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 600;
}

.service-block .btn:hover {
  background: var(--accent2);
  color: #0b0f14;
}

.toc-spy a.active {
  color: var(--accent);
  font-weight: 700;
}

.spy-section {
  scroll-margin-top: 96px;
}

/* =========================
   Contacts
========================= */
.contacts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-placeholder {
  border: 1px dashed #2b3647;
  border-radius: 12px;
  padding: 14px;
  background: #0f141e;
}

.form-placeholder-inner {
  padding: 12px 10px;
  border-radius: 8px;
  background: #0b0f14;
  color: var(--muted);
}

.contact-meta {
  list-style: none;
  padding: 0;
  margin: 12px 0 16px;
}

.contact-meta li {
  color: var(--muted);
}

.contact-channels {
  display: grid;
  gap: 8px;
  margin: 8px 0 16px;
}

.contact-item {
  display: grid;
  grid-template-columns: 28px 140px 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #1e2633;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  background: #101621;
}

.contact-item:hover {
  background: #151d2a;
  border-color: #2b3647;
}

.ci-ico {
  font-size: 18px;
  line-height: 1;
}

.ci-label {
  color: var(--muted);
}

.ci-value {
  justify-self: end;
  color: var(--text);
}

.contact-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* =========================
   Mobile TOC (Overview)
========================= */
.toc-mobile {
  display: none;
  position: relative;
}

.toc-toggle {
  background: #1f2937;
  color: var(--text);
  border: 1px solid #2b3647;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.toc-drawer {
  margin-top: 8px;
  background: var(--card);
  border: 1px solid #1e2633;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
}

.toc-drawer ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-drawer li + li {
  margin-top: 6px;
}

.toc-drawer a {
  color: var(--muted);
  text-decoration: none;
}

.toc-drawer a:hover {
  color: var(--accent);
}

/* =========================
   Facts / helpers
========================= */
.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 12px;
  margin: 12px 0 0;
}

.facts dt {
  font-weight: 700;
  color: var(--text);
}

.facts dd {
  margin: 0;
  color: var(--muted);
}

.facts-list {
  margin: 0;
  padding-left: 18px;
}

.facts-list li {
  margin: 2px 0;
}

.section + .section {
  margin-top: 16px;
}

/* =========================
   Link styling by page types
========================= */
.projects-page .services-content a:not(.btn),
.projects-page .section a:not(.btn),
.blog-page .services-content .card a:not(.btn),
.blog-page article.card a:not(.btn),
.taxonomy-page .services-content .card a:not(.btn),
.home-page .card a:not(.btn),
.home-page .section a:not(.btn) {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 0.08em;
}

.projects-page .services-content a:not(.btn):visited,
.projects-page .section a:not(.btn):visited,
.blog-page .services-content .card a:not(.btn):visited,
.blog-page article.card a:not(.btn):visited,
.taxonomy-page .services-content .card a:not(.btn):visited,
.home-page .card a:not(.btn):visited,
.home-page .section a:not(.btn):visited {
  color: var(--link-visited);
}

.projects-page .services-content a:not(.btn):hover,
.projects-page .section a:not(.btn):hover,
.blog-page .services-content .card a:not(.btn):hover,
.blog-page article.card a:not(.btn):hover,
.taxonomy-page .services-content .card a:not(.btn):hover,
.home-page .card a:not(.btn):hover,
.home-page .section a:not(.btn):hover {
  color: var(--link-hover);
}

.projects-page .services-content a:not(.btn):active,
.projects-page .section a:not(.btn):active,
.blog-page .services-content .card a:not(.btn):active,
.blog-page article.card a:not(.btn):active,
.taxonomy-page .services-content .card a:not(.btn):active,
.home-page .card a:not(.btn):active,
.home-page .section a:not(.btn):active {
  color: var(--link-active);
}

/* не подсвечиваем таксономии внутри меты */
.blog-page article.card .sub a[href*="/tags/"],
.blog-page article.card .sub a[href*="/categories/"],
.taxonomy-page .card .sub a[href*="/tags/"],
.taxonomy-page .card .sub a[href*="/categories/"] {
  color: var(--text);
  text-decoration: none;
}

.blog-page article.card .sub a[href*="/tags/"]:hover,
.blog-page article.card .sub a[href*="/categories/"]:hover,
.taxonomy-page .card .sub a[href*="/tags/"]:hover,
.taxonomy-page .card .sub a[href*="/categories/"]:hover {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* Accessibility focus */
.blog-page .services-content .card a:not(.btn):focus-visible,
.blog-page article.card a:not(.btn):focus-visible,
.taxonomy-page .services-content .card a:not(.btn):focus-visible,
.home-page .card a:not(.btn):focus-visible,
.home-page .section a:not(.btn):focus-visible {
  outline: 2px solid currentcolor;
  outline-offset: 2px;
  border-radius: 2px;
}

/* =========================
   Responsive
========================= */

/* ≤ 860px */
@media (width <= 53.75em) {
  .hamburger {
    display: inline-block;
  }

  .header-inner.header-grid {
    grid-template-columns: auto 1fr auto;
  }

  .header-actions {
    position: relative;
  }

  .nav.nav-mobile {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    display: none;
    z-index: 900;
    background: var(--card);
    border: 1px solid #1e2633;
    border-radius: 12px;
    width: max-content;
    max-width: min(92vw, 26.25em);
    box-shadow: 0 0.375em 0.75em rgb(0 0 0 / 40%);
    overflow: hidden;
  }

  .nav.nav-mobile.open {
    display: block;
  }

  .nav.nav-mobile ul {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: 0.375em;
    list-style: none;
  }

  .nav.nav-mobile a {
    display: block;
    padding: 8px 12px;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    border-radius: 8px;
  }

  .nav.nav-mobile a:hover {
    background: #1e2633;
  }

  .contacts-grid {
    grid-template-columns: 1fr;
  }
}

/* ≤ 660px */
@media (width <= 41.25em) {
  .toc-mobile {
    display: inline-block;
    position: relative;
  }

  .toc-mobile .toc-drawer {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 1200;
    width: max-content;
    min-width: 260px;
    max-width: calc(100vw - 32px);
    white-space: nowrap;
    max-height: 50vh;
    overflow-y: auto;
    display: none;
  }

  .toc-mobile[open] .toc-drawer {
    display: block;
  }

  .services-toc {
    display: none;
  }

  .services-layout {
    grid-template-columns: 1fr;
  }
}

/* ≤ 500px */
@media (width <= 500px) {
  .dropbtn .code {
    display: none;
  }

  .dropdown .dropdown-content {
    left: auto;
    right: 0;
    text-align: left;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .hamburger,
  .hamburger span,
  .nav a {
    transition: none !important;
  }
}

/* ==== Auto-hide header ==== */
.site-header {
  position: sticky; /* сохраняет место в потоке — контент не «прыгает» */
  top: 0;
  z-index: 2000;
  backdrop-filter: saturate(140%) blur(8px);
  background: color-mix(in oklab, #0b0f14 80%, transparent);
  transition:
    transform 0.22s ease,
    box-shadow 0.18s ease,
    background-color 0.18s ease;
  will-change: transform;
}

.site-header.header-hidden {
  transform: translateY(-110%);
  box-shadow: none;
}

.site-header.header-shown {
  transform: translateY(0);
  box-shadow: 0 6px 24px rgb(0 0 0 / 28%);
}

/* при самом верху — без тени */
.site-header.at-top {
  box-shadow: none;
}

/* уважение к reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .site-header {
    transition: none !important;
  }
}
