:root {
  color-scheme: dark;
  --ink: #090a0c;
  --paper: #f1efeb;
  --field: #e8e7e2;
  --wine: #7b1026;
  --signal: #b21f3d;
  --signal-small-dark: #e53a5d;
  --muted: #8e9196;
  --rule-light: rgba(241, 239, 235, 0.22);
  --rule-dark: rgba(9, 10, 12, 0.22);
  --container: 1360px;
  --gutter: clamp(20px, 4vw, 68px);
}

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

html {
  background: var(--ink);
  scrollbar-color: var(--signal) var(--ink);
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

a {
  color: inherit;
}

a:focus-visible,
summary:focus-visible,
.project-rail:focus-visible {
  outline: 3px solid #ff456c;
  outline-offset: 5px;
}

.skip-link {
  position: fixed;
  z-index: 300;
  top: 12px;
  left: 12px;
  padding: 12px 16px;
  background: var(--paper);
  color: var(--ink);
  font: 600 12px/1 "IBM Plex Mono", monospace;
  text-decoration: none;
  text-transform: uppercase;
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: none;
}

.site-header {
  position: sticky;
  z-index: 100;
  top: 0;
  border-bottom: 1px solid var(--rule-light);
  background: rgba(9, 10, 12, 0.98);
}

.site-header__inner {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr);
  align-items: stretch;
  width: min(100%, var(--container));
  min-height: 72px;
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.brand,
.telegram-link,
.site-nav a,
.mobile-nav,
.eyebrow,
.portfolio-hero__count,
.project-card__category,
.project-card__position,
.project-card__preview figcaption,
.project-card__url,
.rail-status,
.rail-hint,
.site-footer {
  font-family: "IBM Plex Mono", monospace;
  text-transform: uppercase;
}

.brand,
.telegram-link,
.site-nav a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  text-decoration: none;
}

.brand {
  align-self: center;
  width: max-content;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
}

.site-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(126px, 1fr));
  border-inline: 1px solid var(--rule-light);
}

.site-nav a {
  position: relative;
  gap: 10px;
  justify-content: center;
  padding: 0 18px;
  border-right: 1px solid var(--rule-light);
  color: rgba(241, 239, 235, 0.66);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.site-nav a:last-child {
  border-right: 0;
}

.site-nav a::before {
  content: attr(data-index);
  color: var(--signal-small-dark);
  font-size: 11px;
}

.site-nav a:hover {
  background: rgba(241, 239, 235, 0.05);
  color: var(--paper);
}

.site-nav a[aria-current="page"] {
  background: var(--wine);
  color: var(--paper);
}

.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: 9px;
  left: 14px;
  height: 2px;
  background: var(--paper);
}

.telegram-link {
  align-self: center;
  justify-self: end;
  gap: 10px;
  padding: 0 16px;
  border: 1px solid rgba(241, 239, 235, 0.38);
  background: var(--signal);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.telegram-link:hover {
  background: #ca2648;
}

.mobile-nav {
  display: none;
}

.eyebrow {
  margin: 0;
  color: var(--signal-small-dark);
  font: 600 11px/1.2 "IBM Plex Mono", monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.portfolio-hero {
  position: relative;
  min-height: 470px;
  overflow: hidden;
  isolation: isolate;
  border-bottom: 1px solid var(--rule-light);
  background-color: var(--ink);
  background-image: url("/assets/textures/ink-surface.webp");
  background-repeat: repeat;
  background-size: 627px 627px;
}

.portfolio-hero::before {
  content: "05";
  position: absolute;
  z-index: -1;
  top: 24px;
  right: max(var(--gutter), calc((100vw - var(--container)) / 2 + var(--gutter)));
  color: transparent;
  font: 700 clamp(220px, 27vw, 420px) / 0.8 Oswald, sans-serif;
  letter-spacing: -0.08em;
  -webkit-text-stroke: 1px rgba(241, 239, 235, 0.11);
}

.portfolio-hero__plane {
  position: absolute;
  z-index: -1;
  right: -6vw;
  bottom: -62px;
  width: min(66vw, 1040px);
  height: 210px;
  clip-path: polygon(10% 42%, 78% 0, 100% 22%, 96% 100%, 0 100%);
  background-color: var(--wine);
  background-image: url("/assets/textures/wine-surface.webp");
  background-repeat: repeat;
  background-size: 627px 627px;
}

.portfolio-hero__inner {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  gap: clamp(54px, 9vw, 150px);
  align-items: end;
  width: min(100%, var(--container));
  min-height: 470px;
  margin: 0 auto;
  padding: 74px var(--gutter) 76px;
}

.portfolio-hero__title-block {
  transform: translateY(clamp(-184px, calc(40vw - 576px), 0px));
}

.portfolio-hero h1 {
  max-width: 940px;
  margin: 18px 0 0;
  font: 700 clamp(82px, 10vw, 148px) / 0.82 Oswald, sans-serif;
  letter-spacing: -0.055em;
  text-transform: uppercase;
}

.portfolio-hero__brief {
  position: relative;
  max-width: 410px;
  padding-top: 22px;
  border-top: 1px solid rgba(241, 239, 235, 0.55);
}

.portfolio-hero__count {
  display: block;
  margin-bottom: 22px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
}

.portfolio-hero__brief p {
  max-width: 39ch;
  margin: 0 0 20px;
  font-size: clamp(16px, 1.3vw, 19px);
  line-height: 1.45;
}

.portfolio-hero__brief a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 18px;
  font: 600 11px/1 "IBM Plex Mono", monospace;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.portfolio-hero__brief a:hover {
  text-decoration: underline;
  text-underline-offset: 7px;
}

.portfolio-stage {
  position: relative;
  padding: 58px 0 78px;
  overflow: hidden;
  background: var(--ink);
}

.portfolio-stage::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 14px;
  background: linear-gradient(90deg, var(--wine) 0 34%, var(--paper) 34% 36%, var(--wine) 36% 100%);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 100%, 48% 46%, 0 100%);
}

.portfolio-stage__head {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  align-items: end;
  width: min(100%, var(--container));
  margin: 0 auto 30px;
  padding-inline: var(--gutter);
}

.portfolio-stage__head h2 {
  margin: 7px 0 0;
  font: 700 clamp(38px, 4.4vw, 66px) / 0.94 Oswald, sans-serif;
  letter-spacing: -0.035em;
  text-transform: uppercase;
}

.rail-controls {
  display: flex;
  gap: 18px;
  align-items: center;
}

.rail-status {
  min-width: 72px;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.rail-actions {
  display: flex;
}

.rail-button {
  display: inline-flex;
  width: 50px;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(241, 239, 235, 0.4);
  font: 600 18px/1 "IBM Plex Mono", monospace;
  text-decoration: none;
}

.rail-button + .rail-button {
  border-left: 0;
}

.rail-button:hover {
  background: var(--paper);
  color: var(--ink);
}

.rail-button[aria-disabled="true"] {
  color: rgba(241, 239, 235, 0.28);
  pointer-events: none;
}

.rail-progress {
  width: min(calc(100% - (2 * var(--gutter))), var(--container));
  height: 2px;
  margin: 0 auto 22px;
  overflow: hidden;
  background: rgba(241, 239, 235, 0.16);
}

.rail-progress span {
  display: block;
  width: 20%;
  height: 100%;
  background: var(--signal);
}

.project-rail {
  display: grid;
  grid-auto-columns: min(84vw, 1320px);
  grid-auto-flow: column;
  gap: clamp(18px, 2vw, 32px);
  margin: 0;
  padding: 0 max(var(--gutter), calc((100vw - var(--container)) / 2 + var(--gutter))) 24px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scroll-padding-inline: max(var(--gutter), calc((100vw - var(--container)) / 2 + var(--gutter)));
  scroll-snap-type: x mandatory;
  scrollbar-color: var(--paper) rgba(241, 239, 235, 0.1);
}

.project-card {
  min-width: 0;
  list-style: none;
  scroll-margin-top: 84px;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.project-card > article {
  overflow: hidden;
  border: 1px solid rgba(241, 239, 235, 0.35);
  background: var(--ink);
  color: var(--paper);
}

.project-card__header {
  display: flex;
  min-height: 116px;
  justify-content: space-between;
  gap: 26px;
  align-items: center;
  padding: 22px clamp(22px, 2.3vw, 36px);
  border-bottom: 1px solid var(--rule-light);
}

.project-card__identity {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(18px, 2vw, 30px);
  align-items: center;
}

.project-card__index {
  color: #df2c50;
  font: 700 clamp(56px, 5.4vw, 84px) / 0.8 Oswald, sans-serif;
  letter-spacing: -0.05em;
}

.project-card__category,
.project-card__position {
  margin: 0;
  color: var(--signal-small-dark);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.project-card h2 {
  margin: 5px 0 0;
  font: 700 clamp(38px, 4.1vw, 64px) / 0.94 Oswald, sans-serif;
  letter-spacing: -0.035em;
  text-transform: uppercase;
}

.project-card__position {
  flex: none;
  color: rgba(241, 239, 235, 0.62);
}

.project-card__preview {
  position: relative;
  margin: 0;
  overflow: hidden;
  background: #111215;
}

.project-card__preview img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center top;
  background: #111215;
}

.project-card__preview figcaption {
  position: absolute;
  right: 0;
  bottom: 0;
  padding: 8px 11px;
  background: rgba(9, 10, 12, 0.88);
  color: rgba(241, 239, 235, 0.72);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.project-card__footer {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(330px, 1.2fr);
  gap: clamp(34px, 5vw, 84px);
  align-items: end;
  min-height: 118px;
  padding: 24px clamp(22px, 2.3vw, 36px);
  background: var(--paper);
  color: var(--ink);
}

.project-card__footer > p {
  max-width: 58ch;
  margin: 0;
  font-size: clamp(14px, 1.15vw, 17px);
  line-height: 1.45;
}

.project-card__link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 54px;
  padding: 8px 0;
  border-top: 1px solid currentColor;
  font: 600 11px/1.2 "IBM Plex Mono", monospace;
  letter-spacing: 0.05em;
  text-decoration: none;
  text-transform: uppercase;
}

.project-card__link:hover {
  color: var(--signal);
}

.project-card__url {
  overflow: hidden;
  font-size: 11px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.58;
}

.project-card[data-current] > article {
  border-color: rgba(241, 239, 235, 0.72);
}

.rail-hint {
  width: min(100%, var(--container));
  margin: 18px auto 0;
  padding-inline: var(--gutter);
  color: rgba(241, 239, 235, 0.52);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.portfolio-contact {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.52fr);
  gap: clamp(48px, 8vw, 138px);
  align-items: end;
  min-height: 570px;
  padding: clamp(74px, 9vw, 126px) max(var(--gutter), calc((100vw - var(--container)) / 2 + var(--gutter)));
  overflow: hidden;
  background-color: var(--field);
  background-image: url("/assets/textures/paper-scratches.webp");
  background-repeat: repeat;
  background-size: 627px 627px;
  color: var(--ink);
}

.portfolio-contact::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: min(52vw, 760px);
  height: 16px;
  background: var(--wine);
  clip-path: polygon(0 0, 100% 0, 92% 100%, 0 100%);
}

.portfolio-contact .eyebrow {
  color: var(--signal);
}

.portfolio-contact h2 {
  position: relative;
  margin: 15px 0 0;
  font: 700 clamp(70px, 10vw, 148px) / 0.83 Oswald, sans-serif;
  letter-spacing: -0.05em;
  text-transform: uppercase;
}

.portfolio-contact__link {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  min-height: 178px;
  align-content: space-between;
  padding: 24px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font: 600 11px/1.2 "IBM Plex Mono", monospace;
  letter-spacing: 0.07em;
  text-decoration: none;
  text-transform: uppercase;
}

.portfolio-contact__link strong {
  grid-column: 1 / -1;
  font: 600 clamp(36px, 4.3vw, 62px) / 0.9 Oswald, sans-serif;
  letter-spacing: -0.035em;
  text-transform: none;
}

.portfolio-contact__link:hover {
  background: var(--wine);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 26px max(var(--gutter), calc((100vw - var(--container)) / 2 + var(--gutter)));
  border-top: 1px solid var(--rule-light);
  background: var(--ink);
  color: rgba(241, 239, 235, 0.5);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 980px) {
  .site-header__inner {
    grid-template-columns: 1fr auto;
  }

  .site-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    border-top: 1px solid var(--rule-light);
  }

  .site-nav a {
    min-height: 48px;
  }

  .portfolio-hero {
    min-height: 470px;
  }

  .portfolio-hero__inner {
    grid-template-columns: 1fr;
    gap: 40px;
    min-height: 470px;
    padding-top: 62px;
    padding-bottom: 64px;
  }

  .portfolio-hero__title-block {
    transform: none;
  }

  .portfolio-hero h1 {
    font-size: clamp(80px, 15vw, 118px);
  }

  .portfolio-hero__brief {
    max-width: 560px;
  }

  .portfolio-hero__plane {
    width: 86vw;
  }

  .project-rail {
    grid-auto-columns: 88vw;
  }

  .project-card__footer {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .portfolio-contact {
    grid-template-columns: 1fr;
  }

  .portfolio-contact__link {
    max-width: 560px;
  }
}

@media (max-width: 767px) {
  .site-header__inner {
    min-height: 64px;
    padding-block: 8px;
  }

  .site-nav,
  .telegram-link {
    display: none;
  }

  .mobile-nav {
    position: relative;
    display: block;
    align-self: center;
    justify-self: end;
  }

  .mobile-nav summary {
    display: inline-flex;
    min-width: 76px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--rule-light);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    list-style: none;
    cursor: pointer;
  }

  .mobile-nav summary::-webkit-details-marker {
    display: none;
  }

  .mobile-nav summary::after {
    content: "+";
    margin-left: 9px;
    color: #ff456c;
  }

  .mobile-nav[open] summary::after {
    content: "−";
  }

  .mobile-nav nav {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    display: grid;
    width: min(290px, calc(100vw - 40px));
    border: 1px solid var(--rule-light);
    background: var(--ink);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.44);
  }

  .mobile-nav nav a {
    display: flex;
    min-height: 52px;
    align-items: center;
    padding: 0 18px;
    border-bottom: 1px solid var(--rule-light);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-decoration: none;
  }

  .mobile-nav nav a:last-child {
    border-bottom: 0;
    background: var(--signal);
  }

  .mobile-nav nav a[aria-current="page"]::before {
    content: "●";
    margin-right: 10px;
    color: #ff456c;
    font-size: 12px;
  }

  .portfolio-hero,
  .portfolio-hero__inner {
    min-height: 410px;
  }

  .portfolio-hero__inner {
    gap: 28px;
    padding-top: 50px;
    padding-bottom: 48px;
  }

  .portfolio-hero::before {
    top: 42px;
    right: 20px;
    font-size: 190px;
  }

  .portfolio-hero h1 {
    margin-top: 13px;
    font-size: clamp(54px, 16vw, 72px);
  }

  .portfolio-hero__brief {
    padding-top: 16px;
  }

  .portfolio-hero__count {
    margin-bottom: 12px;
  }

  .portfolio-hero__brief p {
    margin-bottom: 10px;
    font-size: 15px;
  }

  .portfolio-hero__brief a {
    display: none;
  }

  .portfolio-hero__plane {
    right: -38vw;
    bottom: -82px;
    width: 132vw;
    height: 180px;
  }

  .portfolio-stage {
    padding-top: 52px;
  }

  .portfolio-stage__head {
    margin-bottom: 22px;
  }

  .portfolio-stage__head h2 {
    font-size: clamp(34px, 11vw, 48px);
  }

  .rail-controls,
  .rail-progress,
  .rail-hint {
    display: none;
  }

  .project-rail {
    display: grid;
    grid-auto-flow: row;
    grid-auto-columns: auto;
    gap: 18px;
    padding: 0 var(--gutter);
    overflow: visible;
    scroll-snap-type: none;
  }

  .project-card__header {
    min-height: 92px;
    padding: 16px 18px;
  }

  .project-card__identity {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 12px;
  }

  .project-card__index {
    font-size: 43px;
  }

  .project-card__category,
  .project-card__position {
    font-size: 12px;
  }

  .project-card h2 {
    font-size: clamp(28px, 8.8vw, 40px);
    line-height: 0.96;
  }

  .project-card__preview img {
    width: 100%;
    height: clamp(218px, 68vw, 270px);
    aspect-ratio: 4 / 3;
    object-fit: cover;
  }

  .project-card__preview figcaption {
    display: none;
  }

  .project-card__footer {
    min-height: 0;
    gap: 18px;
    padding: 18px;
  }

  .project-card__footer > p {
    font-size: 14px;
  }

  .project-card__link {
    grid-template-columns: 1fr auto;
  }

  .project-card__url {
    display: none;
  }

  .portfolio-contact {
    min-height: 520px;
    padding-top: 74px;
    padding-bottom: 74px;
  }

  .portfolio-contact h2 {
    font-size: clamp(62px, 20vw, 94px);
  }

  .portfolio-contact__link {
    min-height: 144px;
  }

  .site-footer {
    flex-direction: column;
    font-size: 12px;
  }

  .eyebrow,
  .portfolio-hero__count,
  .project-card__preview figcaption,
  .project-card__link,
  .rail-hint,
  .portfolio-contact__link {
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  .portfolio-hero h1 {
    font-size: clamp(47px, 15.5vw, 59px);
  }

  .project-card__position {
    display: none;
  }

  .project-card__header,
  .project-card__footer {
    padding-inline: 15px;
  }
}

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