/* Sergei Aleshin — personal site
   Lacoste palette + Apple-like rhythm */

:root {
  --green: #004d40;
  --green-deep: #00332b;
  --green-soft: #0a6b5c;
  --red: #c8102e;
  --red-soft: #e11d3a;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", Helvetica, Arial, sans-serif;

  --header-h: 3.25rem;
  --tab-h: 4.25rem;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --max: 68rem;
  --pad: clamp(1.25rem, 4vw, 2.5rem);
}

/* Light */
html,
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7f6;
  --bg-elevated: #ffffff;
  --bg-muted: #e8eeec;
  --text: #0a1f1c;
  --text-secondary: #3d524e;
  --text-tertiary: #6b7f7a;
  --border: rgba(0, 77, 64, 0.12);
  --accent: var(--green);
  --accent-hover: var(--green-soft);
  --cta-bg: var(--green);
  --cta-text: #ffffff;
  --cta-secondary-bg: transparent;
  --cta-secondary-border: rgba(0, 77, 64, 0.35);
  --hero-grad: radial-gradient(
      120% 80% at 85% 10%,
      rgba(0, 77, 64, 0.14) 0%,
      transparent 55%
    ),
    radial-gradient(
      90% 60% at 10% 90%,
      rgba(200, 16, 46, 0.06) 0%,
      transparent 50%
    ),
    linear-gradient(165deg, #f8faf9 0%, #eef3f1 45%, #e4ebe8 100%);
  --portrait-bg: linear-gradient(145deg, #dce8e4 0%, #b8cdc6 100%);
  --shadow-soft: 0 24px 48px rgba(0, 40, 34, 0.08);
  --header-bg: rgba(245, 247, 246, 0.82);
  --tab-bg: rgba(255, 255, 255, 0.92);
  --theme-color: #004d40;
}

/* Dark */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #061412;
  --bg-elevated: #0c1f1b;
  --bg-muted: #122824;
  --text: #f2f7f5;
  --text-secondary: #b4c5c0;
  --text-tertiary: #7a918b;
  --border: rgba(242, 247, 245, 0.1);
  --accent: #5cb8a8;
  --accent-hover: #7dcec0;
  --cta-bg: #f2f7f5;
  --cta-text: #061412;
  --cta-secondary-bg: transparent;
  --cta-secondary-border: rgba(242, 247, 245, 0.28);
  --hero-grad: radial-gradient(
      110% 70% at 90% 0%,
      rgba(10, 107, 92, 0.35) 0%,
      transparent 55%
    ),
    radial-gradient(
      80% 50% at 0% 100%,
      rgba(200, 16, 46, 0.12) 0%,
      transparent 45%
    ),
    linear-gradient(165deg, #061412 0%, #0a1c18 50%, #0e2420 100%);
  --portrait-bg: linear-gradient(145deg, #14332d 0%, #0a201c 100%);
  --shadow-soft: 0 24px 48px rgba(0, 0, 0, 0.35);
  --header-bg: rgba(6, 20, 18, 0.85);
  --tab-bg: rgba(12, 31, 27, 0.94);
  --theme-color: #061412;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.01em;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (min-width: 900px) {
  body {
    padding-bottom: 0;
  }
}

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

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color 0.2s var(--ease);
}

a:hover {
  color: var(--accent-hover);
}

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--cta-bg);
  color: var(--cta-text);
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  height: 100%;
  padding: 0 var(--pad);
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 0.3rem;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
  /* Same readable surface as a browser tab favicon */
  background: #f4f4f4;
  padding: 0.12rem;
  box-sizing: content-box;
}

.brand-name {
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.03em;
}

.desktop-nav {
  display: none;
  align-items: center;
  gap: 0.15rem;
  margin-left: auto;
}

.desktop-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  padding: 0.4rem 0.65rem;
  border-radius: 0.5rem;
}

.desktop-nav a:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.desktop-nav a.is-active {
  color: var(--text);
}

.desktop-nav a.is-active::after {
  content: "";
  display: block;
  width: 0.35rem;
  height: 0.35rem;
  margin: 0.2rem auto 0;
  border-radius: 50%;
  background: var(--red);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

@media (min-width: 900px) {
  .header-controls {
    margin-left: 0;
  }

  .desktop-nav {
    display: flex;
  }
}

.lang-switch {
  display: inline-flex;
  padding: 0.15rem;
  border-radius: 999px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
}

.lang-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
}

.lang-btn[aria-pressed="true"] {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.theme-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-muted);
  color: var(--text-secondary);
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.theme-toggle:hover {
  color: var(--text);
}

html[data-theme="light"] .theme-icon-sun,
html[data-theme="dark"] .theme-icon-moon {
  display: none;
}

/* Sections */
.section {
  scroll-margin-top: calc(var(--header-h) + 0.5rem);
  padding: clamp(3.5rem, 8vw, 6.5rem) 0;
}

.section-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--pad);
}

.section-header {
  max-width: 38rem;
  margin-bottom: clamp(2rem, 5vw, 3rem);
}

.section-header h2 {
  margin: 0 0 0.75rem;
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.section-lead {
  margin: 0;
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--text-secondary);
  line-height: 1.45;
  letter-spacing: -0.02em;
}

.section-header-prose {
  max-width: 46rem;
}

.section-lead-block {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.section-lead-block p {
  margin: 0;
  font-size: clamp(1.02rem, 1.8vw, 1.15rem);
  color: var(--text-secondary);
  line-height: 1.5;
  letter-spacing: -0.015em;
}

/* Hero */
.hero {
  position: relative;
  min-height: calc(100dvh - var(--header-h) - var(--tab-h));
  display: flex;
  align-items: center;
  padding: clamp(2rem, 6vw, 4rem) 0;
  overflow: hidden;
}

@media (min-width: 900px) {
  .hero {
    min-height: calc(100dvh - var(--header-h));
  }
}

.hero-atmosphere {
  position: absolute;
  inset: 0;
  background: var(--hero-grad);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--pad);
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(6.5rem, 0.8fr);
  gap: clamp(1rem, 3.5vw, 4rem);
  align-items: center;
}

.hero-copy {
  min-width: 0;
}

.hero-eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero-name {
  margin: 0 0 1rem;
  font-size: clamp(1.85rem, 6.2vw, 4.75rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.hero-tagline {
  margin: 0 0 1.75rem;
  max-width: 32rem;
  font-size: clamp(0.98rem, 2.1vw, 1.35rem);
  color: var(--text-secondary);
  line-height: 1.4;
  letter-spacing: -0.02em;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.65rem 1.35rem;
  border-radius: 980px;
  font-size: 0.9375rem;
  font-weight: 550;
  letter-spacing: -0.01em;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.2s var(--ease), color 0.2s var(--ease),
    border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--cta-bg);
  color: var(--cta-text);
}

.btn-primary:hover {
  color: var(--cta-text);
  filter: brightness(1.06);
}

.btn-secondary {
  background: var(--cta-secondary-bg);
  color: var(--text);
  border-color: var(--cta-secondary-border);
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--accent);
}

.hero-visual {
  display: flex;
  justify-content: flex-end;
  min-width: 0;
}

.portrait {
  width: 100%;
  max-width: 22rem;
  aspect-ratio: 1 / 1;
  border-radius: clamp(0.75rem, 2vw, 1.25rem);
  overflow: hidden;
  background: var(--portrait-bg);
  box-shadow: var(--shadow-soft);
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
}

/* About */
.about-body {
  max-width: 42rem;
  margin-bottom: clamp(2.5rem, 5vw, 3.5rem);
}

.about-body p {
  margin: 0 0 1rem;
  color: var(--text-secondary);
  font-size: 1.0625rem;
}

.about-body p:last-child {
  margin-bottom: 0;
}

.skills-title {
  margin: 0 0 1.25rem;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.skills-grid {
  margin: 0;
  display: grid;
  gap: 1.25rem 2rem;
  grid-template-columns: 1fr;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

@media (min-width: 640px) {
  .skills-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.skill-group {
  margin: 0;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.skill-group dt {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.skill-group dd {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  letter-spacing: -0.015em;
}

/* Experience timeline */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(2.5rem, 5vw, 3.5rem);
}

.timeline-item {
  display: grid;
  gap: 1rem 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

@media (min-width: 800px) {
  .timeline-item {
    grid-template-columns: minmax(12rem, 0.38fr) 1fr;
  }
}

.timeline-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.timeline-period {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
}

.timeline-role {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.timeline-company {
  font-size: 1rem;
  color: var(--accent);
  font-weight: 550;
}

.timeline-content p {
  margin: 0 0 1rem;
  color: var(--text-secondary);
}

.timeline-content ul {
  margin: 0 0 1rem;
  padding-left: 1.15rem;
  color: var(--text-secondary);
}

.timeline-content li {
  margin-bottom: 0.45rem;
}

.timeline-content li::marker {
  color: var(--red);
}

.timeline-stack {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

/* Portfolio */
.portfolio-project {
  margin-bottom: clamp(2.75rem, 6vw, 4rem);
}

.portfolio-project:last-child {
  margin-bottom: 0;
}

.portfolio-project-header {
  max-width: 40rem;
  margin-bottom: 1.35rem;
}

.portfolio-project-header h3 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 650;
  letter-spacing: -0.03em;
}

.portfolio-project-header p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 1.05rem;
  letter-spacing: -0.015em;
}

.device-rail {
  display: flex;
  gap: 1.25rem;
  overflow-x: auto;
  padding: 0.35rem 0 1rem;
  margin: 0 calc(var(--pad) * -1);
  padding-left: var(--pad);
  padding-right: var(--pad);
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.device-rail:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 4px;
}

.phone-device,
.tablet-device {
  margin: 0;
  flex: 0 0 auto;
  scroll-snap-align: start;
}

.phone-device {
  width: min(72vw, 15.5rem);
}

.tablet-device {
  width: min(88vw, 28rem);
}

.phone-frame,
.tablet-frame {
  position: relative;
  background: #0b0b0c;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.phone-frame {
  border-radius: 1.65rem;
  padding: 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.tablet-frame {
  border-radius: 1rem;
  padding: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.phone-frame img,
.tablet-frame img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 1.2rem;
  background: #111;
}

.tablet-frame img {
  border-radius: 0.55rem;
}

.phone-device figcaption,
.tablet-device figcaption {
  margin-top: 0.7rem;
  font-size: 0.875rem;
  font-weight: 550;
  letter-spacing: -0.01em;
  color: var(--text-tertiary);
  text-align: center;
}

.device-zoom {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  font: inherit;
  color: inherit;
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  -webkit-appearance: none;
}

.device-zoom:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

body.lightbox-open {
  overflow: hidden;
}

.lightbox[hidden] {
  display: none !important;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) 1rem
    max(1rem, env(safe-area-inset-bottom));
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(6, 20, 18, 0.78);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor: zoom-out;
}

.lightbox-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 72rem);
  max-height: calc(100dvh - 2rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  pointer-events: none;
}

.lightbox-image {
  max-width: 100%;
  max-height: calc(100dvh - 5.5rem);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 0.75rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  background: #0b0b0c;
}

.lightbox-caption {
  margin: 0;
  color: #f2f7f5;
  font-size: 0.9375rem;
  font-weight: 550;
  letter-spacing: -0.01em;
  text-align: center;
  pointer-events: none;
}

.lightbox-close {
  position: absolute;
  top: -0.25rem;
  right: 0;
  z-index: 2;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1px solid rgba(242, 247, 245, 0.22);
  background: rgba(12, 31, 27, 0.88);
  color: #f2f7f5;
  display: grid;
  place-items: center;
  cursor: pointer;
  pointer-events: auto;
  padding: 0;
}

.lightbox-close:hover {
  background: rgba(12, 31, 27, 1);
}

.lightbox-close:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

@media (min-width: 900px) {
  .lightbox-close {
    top: 0;
    right: -0.25rem;
  }
}

/* Pricing — interaction containers, not card chrome */
.pricing-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--border);
}

.pricing-item {
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--border);
}

@media (min-width: 800px) {
  .pricing-list {
    grid-template-columns: repeat(3, 1fr);
    gap: 0 2rem;
    border-top: 0;
  }

  .pricing-item {
    padding: 0;
    border-bottom: 0;
    border-top: 1px solid var(--border);
    padding-top: 1.75rem;
  }
}

.pricing-item h3 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.pricing-rate {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.pricing-meta {
  margin: 0 0 0.85rem;
  font-size: 0.8125rem;
  font-weight: 550;
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
}

.pricing-item p:last-child {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9875rem;
}

.pricing-note {
  margin: 2rem 0 0;
  color: var(--text-tertiary);
  font-size: 0.9375rem;
}

/* Contacts */
.contact-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 36rem;
  border-top: 1px solid var(--border);
}

.contact-list li {
  display: grid;
  gap: 0.25rem;
  padding: 1.15rem 0;
  border-bottom: 1px solid var(--border);
}

@media (min-width: 560px) {
  .contact-list li {
    grid-template-columns: 9.5rem 1fr;
    align-items: baseline;
    gap: 1.25rem;
  }
}

.contact-label {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.contact-list a {
  font-size: 1.0625rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  text-decoration: none;
  color: var(--text);
  word-break: break-word;
}

.contact-list a:hover {
  color: var(--accent);
}

/* Footer */
.site-footer {
  padding: 2.5rem var(--pad) 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.875rem;
}

.site-footer p {
  margin: 0;
}

.footer-brand {
  color: var(--text-secondary);
  font-weight: 550;
}

.footer-sep {
  margin: 0 0.4rem;
}

@media (max-width: 899px) {
  .site-footer {
    padding-bottom: 1.5rem;
  }
}

/* Mobile tab bar */
.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  padding: 0.35rem 0.15rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
  background: var(--tab-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  color: var(--text-tertiary);
  text-decoration: none;
  font-size: 0.625rem;
  font-weight: 550;
  letter-spacing: -0.01em;
  min-width: 0;
  padding: 0.2rem;
  border-radius: 0.5rem;
  -webkit-tap-highlight-color: transparent;
}

.tab-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.tab-item svg {
  flex-shrink: 0;
}

.tab-icon-usd {
  display: none;
}

html[lang="en"] .tab-icon-rub {
  display: none;
}

html[lang="en"] .tab-icon-usd {
  display: block;
}

.tab-item.is-active {
  color: var(--accent);
}

.tab-item.is-active svg {
  stroke: var(--accent);
}

.tab-item.is-active::after {
  content: "";
  width: 0.25rem;
  height: 0.25rem;
  border-radius: 50%;
  background: var(--red);
  margin-top: -0.05rem;
}

@media (min-width: 900px) {
  .tab-bar {
    display: none;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
