/* Custom Properties */
:root {
  /* Colors */
  --c-accent: #c60000;
  --c-black: #000000;
  --c-white: #ffffff;
  --c-gray-100: #f5f5f5;
  --c-gray-200: #e8e8e8;
  --c-gray-400: #b0b0b0;
  --c-gray-600: #666666;

  /* Grid */
  --grid: 8px;
  --sp-1: calc(var(--grid) * 1); /* 8px */
  --sp-2: calc(var(--grid) * 2); /* 16px */
  --sp-3: calc(var(--grid) * 3); /* 24px */
  --sp-4: calc(var(--grid) * 4); /* 32px */
  --sp-6: calc(var(--grid) * 6); /* 48px */
  --sp-8: calc(var(--grid) * 8); /* 64px */
  --sp-12: calc(var(--grid) * 12); /* 96px */

  /* Layout */
  --container: 1200px;
  --nav-h: var(--sp-6);
  --label-w: 200px;

  /* Font */
  --font: 'Piazzolla', Georgia, serif;

  /* Animation */
  --animation-in: 10px;
  --animation-out: 150px;
  --nav-animation-duration: 0.3s;

  /* Icon */
  --icon-size: 14px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + var(--sp-4));
}

body {
  background: var(--c-white);
  color: var(--c-black);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 300;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

main {
  overflow-x: clip;
}

/* Container */
.container {
  margin-inline: auto;
  max-width: var(--container);
  padding-inline: var(--sp-6);
}

/* Navigation */
#site-nav {
  align-items: center;
  background: var(--c-white);
  border-bottom: 1px solid var(--c-gray-200);
  display: flex;
  gap: var(--sp-3);
  height: var(--nav-h);
  inset: 0 0 auto 0;
  justify-content: space-between;
  overflow: hidden;
  padding-inline: var(--sp-6);
  position: fixed;
  z-index: 100;

  ul {
    align-items: stretch;
    display: flex;
    flex: 1;
    gap: var(--sp-2);
    list-style: none;

    li {
      display: contents;
    }
  }

  ul a {
    align-self: stretch;
    color: var(--c-gray-600);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.14em;
    padding: var(--sp-1) var(--sp-1);
    text-decoration: none;
    text-transform: uppercase;
    transition: color 0.15s;
    white-space: nowrap;

    &:hover {
      color: var(--c-black);
    }

    &[aria-current='true'] {
      color: var(--c-accent);
    }

    &:focus-visible {
      outline: 2px solid var(--c-accent);
      outline-offset: -2px;
    }
  }

  #menu-btn {
    display: none;
  }

  #print-btn {
    background: transparent;
    border: 1px solid var(--c-black);
    color: var(--c-black);
    cursor: pointer;
    flex-shrink: 0;
    font-family: var(--font);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.12em;
    padding: var(--sp-1) var(--sp-3);
    position: relative;
    text-transform: uppercase;
    transition:
      background 0.15s,
      color 0.15s;
    z-index: 1;

    &:hover {
      background: var(--c-black);
      color: var(--c-white);
    }

    &:focus-visible {
      outline: 2px solid var(--c-accent);
      outline-offset: -1px;
    }
  }
}

/* Hero */
.hero {
  padding-block: calc(var(--nav-h) + var(--sp-8)) var(--sp-8);
}

.hero .container {
  align-items: end;
  display: grid;
  gap: var(--sp-8);
  grid-template-columns: 2fr 1fr;

  .hero-identity {
    h1 {
      font-size: clamp(3rem, 5.5vw, 4.5rem);
      font-weight: 300;
      letter-spacing: -0.025em;
      line-height: 1;
      margin-bottom: var(--sp-3);
    }

    &::after {
      background: var(--c-accent);
      content: '';
      display: block;
      height: 4px;
      width: 48px;
    }
  }

  .hero-subtitle {
    color: var(--c-gray-600);
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.15em;
    margin-bottom: var(--sp-4);
    text-transform: uppercase;
  }

  .hero-bar {
    background: var(--c-accent);
    height: 4px;
    width: 48px;
  }
}

/* Contact List */
.contact-list {
  align-items: baseline;
  display: grid;
  gap: var(--sp-1) var(--sp-2);
  grid-template-columns: auto 1fr;

  dt {
    align-items: center;
    align-self: stretch;
    color: var(--c-gray-400);
    display: flex;
    font-size: 10px;
    font-weight: 500;
    justify-content: flex-end;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  dd {
    color: var(--c-gray-600);
    font-size: 0.875rem;
  }

  a {
    color: var(--c-black);
  }
  .url {
    display: none;
  }
}

:is(.contact-list, .footer-contacts) a {
  border-bottom: 1px solid var(--c-gray-200);
  text-decoration: none;
  transition:
    border-color 0.15s,
    color 0.15s;

  &:hover {
    border-color: var(--c-accent);
    color: var(--c-accent);
  }
}

/* Local Time Clock */
.time-colon {
  animation: blink-colon 2s step-start infinite;
}

/* Sections — two-column grid (label | body) */
.section {
  border-top: 1px solid var(--c-gray-200);
  display: grid;
  gap: var(--sp-6);
  grid-template-columns: var(--label-w) 1fr;
  padding-block: var(--sp-8);
}

.section-label {
  color: var(--c-gray-400);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  padding-top: var(--sp-1);
  text-transform: uppercase;

  &::before {
    background: var(--c-accent);
    content: '';
    display: block;
    height: 2px;
    margin-bottom: var(--sp-2);
    width: 20px;
  }
}

/* Sections — list styles: custom bullet via ::before, break-inside: avoid */
.section-body ul {
  list-style: none;
  padding: 0;

  li {
    break-inside: avoid;
    font-size: 0.875rem;
    margin-bottom: var(--sp-2);
    padding-left: var(--sp-3);
    position: relative;

    &::before {
      background: var(--c-accent);
      content: '';
      height: 1px;
      left: 0;
      position: absolute;
      top: 0.87em;
      width: var(--sp-2);
    }
  }
}

/* Scroll Reveal — CSS scroll-driven animations (view() timeline), falls back via @supports */
@media screen {
  @supports (animation-timeline: view()) {
    :is(.section-body, .hero, .entry) {
      animation: reveal-on-scroll-right linear both;
      animation-range: entry var(--animation-in) entry var(--animation-out);
      animation-timeline: view();
    }

    :is(.section-label) {
      animation: reveal-on-scroll-left linear both;
      animation-range: entry var(--animation-in) entry var(--animation-out);
      animation-timeline: view();
    }
  }
}

/* Prose */
.prose p + p {
  margin-top: var(--sp-3);
}

/* Experience Entries */
.entry {
  padding-block: var(--sp-6) var(--sp-6);

  &:first-of-type {
    padding-top: 0;
  }

  &:last-of-type {
    padding-bottom: 0;
  }

  + .entry {
    border-top: 1px solid var(--c-gray-100);
  }

  .entry-header {
    align-items: baseline;
    display: flex;
    gap: var(--sp-3);
    justify-content: space-between;
    margin-bottom: var(--sp-1);
  }

  .entry-role {
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.3;
  }

  .entry-date {
    color: var(--c-gray-400);
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.04em;
    white-space: nowrap;
  }

  .entry-company {
    color: var(--c-accent);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.1em;
    margin-bottom: var(--sp-3);
    min-height: 1.7;
    text-transform: uppercase;

    p > & {
      letter-spacing: unset;
      margin-bottom: unset;
    }
  }

  p {
    margin-bottom: var(--sp-2);
  }

  p:last-child {
    margin-bottom: 0;
  }

  .entry-stack {
    color: var(--c-gray-600);
    font-size: 12px;
    font-style: italic;
  }
}

/* Skills Grid */
.skill-grid {
  column-count: 2;
  column-gap: var(--sp-4);
}

/* Languages Table */
table {
  border-collapse: collapse;
  width: 100%;

  th,
  td {
    border-bottom: 1px solid var(--c-gray-200);
    font-size: 0.875rem;
    padding: var(--sp-2) var(--sp-3);
    text-align: left;
  }

  thead th {
    color: var(--c-gray-400);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
  }

  tbody th {
    font-weight: 400;
  }

  th:first-child,
  td:first-child {
    padding-left: 0;
  }
}

/* Utilities */
.icon {
  fill: currentcolor;
  flex-shrink: 0;
  height: var(--icon-size);
  vertical-align: middle;
  width: var(--icon-size);
}

.sr-only {
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.build-info {
  display: none;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--c-gray-200);
  padding-block: var(--sp-8);

  @media screen and (max-width: 620px) {
    padding-block: var(--sp-6);
  }
}

.footer-contacts {
  --icon-size: 1rem;

  align-items: center;
  color: var(--c-gray-600);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.75rem;
  justify-content: center;
  margin: 0;
  padding: calc(var(--sp-1) / 2);

  @media screen and (max-width: 620px) {
    gap: 0 var(--sp-2);
  }

  span:not(:first-child)::before {
    content: '\00B7';
    display: inline-block;
    text-align: center;
    width: var(--sp-3);

    @media screen and (max-width: 620px) {
      content: none;
    }
  }

  a {
    color: currentColor;
  }
}

/* Responsive — tablet ≤ 900px */
@media screen and (max-width: 900px) {
  :root {
    --label-w: 140px;
  }

  #site-nav {
    padding: 0 var(--sp-1);

    ul {
      gap: 0;
    }
  }
}

/* Responsive — mobile ≤ 640px */
@media screen and (max-width: 640px) {
  :root {
    --menu-close-position: calc((100% + var(--nav-h)) * -1);
    --hamburger-width: calc(var(--nav-h) / 2);
    --line-position: calc(var(--hamburger-width) / 3);
  }

  #site-nav {
    justify-content: space-between;
    overflow: visible;
    padding: 0 var(--sp-1) 0 0;

    /* Mobile Navigation */
    #menu-btn {
      align-items: center;
      appearance: none;
      background: transparent;
      border: none;
      cursor: pointer;
      display: flex;
      height: var(--nav-h);
      justify-content: center;
      position: relative;
      width: var(--nav-h);
      z-index: 1;
    }

    .hamburger {
      appearance: unset;
      position: relative;

      &,
      &::before,
      &::after {
        background: var(--c-black);
        border-radius: 1px;
        display: block;
        height: 2px;
        overflow: visible;
        width: var(--hamburger-width);
      }

      &::before,
      &::after {
        content: '';
        left: 0;
        position: absolute;
      }

      &::before {
        top: calc(var(--line-position) * -1);
      }

      &::after {
        top: var(--line-position);
      }

      :is(#menu-btn[open]) & {
        animation: hamburger-middle var(--nav-animation-duration) forwards;

        &::before {
          animation: hamburger-top var(--nav-animation-duration) forwards;
        }

        &::after {
          animation: hamburger-bottom var(--nav-animation-duration) forwards;
        }
      }

      :is(#menu-btn[closing]) & {
        animation: hamburger-middle-close var(--nav-animation-duration) forwards;

        &::before {
          animation: hamburger-top-close var(--nav-animation-duration) forwards;
        }

        &::after {
          animation: hamburger-bottom-close var(--nav-animation-duration) forwards;
        }
      }
    }

    #menu-btn + ul {
      background: var(--c-white);
      border-bottom: 1px solid var(--c-gray-200);
      display: flex;
      flex-direction: column;
      gap: 0;
      inset: var(--nav-h) 0 auto 0;
      opacity: 0;
      padding-block: var(--sp-2);
      position: fixed;
      transform: translateX(var(--menu-close-position));
      transition:
        transform var(--nav-animation-duration),
        opacity var(--nav-animation-duration);

      li,
      a {
        display: block;
      }

      a {
        padding: var(--sp-2) var(--sp-4);
      }
    }

    #menu-btn[open] + ul {
      opacity: 1;
      transform: translateX(0);
    }

    #menu-btn[closing] + ul {
      opacity: 0;
      transform: translateX(var(--menu-close-position));
    }
  }

  .container {
    padding-inline: var(--sp-3);
  }

  main {
    padding-bottom: 0;
  }

  .hero {
    height: 100dvh;
    justify-content: space-between;
    padding-block: calc(var(--sp-6) + var(--nav-h)) var(--sp-6);
    position: relative;

    .container {
      gap: var(--sp-6);
      grid-template-columns: 1fr;
    }

    .hero-decor {
      animation: hide-decor linear both;
      animation-range: entry var(--animation-in) entry var(--animation-out);
      animation-timeline: view();
      bottom: 0;
      display: flex;
      justify-content: center;
      left: 0;
      position: absolute;
      width: 100%;

      &::before {
        animation: hero-decor-animation 1.5s ease-out both infinite;
        bottom: -100%;
        color: var(--c-accent);
        content: '\00AB';
        display: inline-block;
        font-size: 2rem;
        height: 2rem;
        line-height: 0.7;
        position: relative;
        text-align: center;
        width: 2rem;
      }
    }
  }

  .section {
    gap: var(--sp-3);
    grid-template-columns: 1fr;
    padding-block: var(--sp-6);

    &:last-of-type {
      margin-bottom: 0;
    }
  }

  .section-label {
    padding-top: 0;
  }

  .entry-header {
    flex-wrap: wrap;
    gap: var(--sp-1);
  }

  .skill-grid {
    column-count: 1;

    li:last-child {
      margin-bottom: 0;
    }
  }
}

@keyframes blink-colon {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

@keyframes reveal-on-scroll-right {
  from {
    opacity: 0;
    transform: translateX(50px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes reveal-on-scroll-left {
  from {
    opacity: 0;
    transform: translateX(-50px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes hero-decor-animation {
  0% {
    transform: rotate(-90deg) translateX(2rem);
  }

  50% {
    transform: rotate(-90deg) translateX(1.5rem);
  }

  100% {
    transform: rotate(-90deg) translateX(2rem);
  }
}

@keyframes hide-decor {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

@keyframes hamburger-top {
  0% {
    transform: translateY(0) rotate(0deg);
  }

  50% {
    transform: translateY(8px) rotate(0deg);
  }

  100% {
    transform: rotate(45deg) translateY(5.5px) translateX(6px);
  }
}

@keyframes hamburger-top-close {
  0% {
    transform: rotate(45deg) translateY(5.5px) translateX(6px);
  }

  50% {
    transform: translateY(8px) rotate(0deg);
  }

  100% {
    transform: translateY(0) rotate(0deg);
  }
}

@keyframes hamburger-bottom {
  0% {
    transform: translateY(0) rotate(0deg);
  }

  50% {
    transform: translateY(-8px) rotate(0deg);
  }

  100% {
    transform: rotate(-45deg) translateY(-5.5px) translateX(6px);
  }
}

@keyframes hamburger-bottom-close {
  0% {
    transform: rotate(-45deg) translateY(-5.5px) translateX(6px);
  }

  50% {
    transform: translateY(-8px) rotate(0deg);
  }

  100% {
    transform: translateY(0) rotate(0deg);
  }
}

@keyframes hamburger-middle {
  0% {
    background: var(--c-black);
  }

  50% {
    background: transparent;
  }

  100% {
    background: transparent;
  }
}

@keyframes hamburger-middle-close {
  0% {
    background: transparent;
  }

  50% {
    background: transparent;
  }

  100% {
    background: var(--c-black);
  }
}
