:root {
  --color-bg: #080b0b;
  --color-bg-soft: #101514;
  --color-surface: rgba(8, 11, 11, 0.68);
  --color-surface-muted: rgba(16, 21, 20, 0.32);
  --color-text: #efe6cf;
  --color-text-soft: rgba(216, 210, 189, 0.78);
  --color-text-muted: rgba(216, 210, 189, 0.55);
  --color-primary: #d96b70;
  --color-primary-dark: #c4575d;
  --color-primary-soft: rgba(217, 107, 112, 0.12);
  --color-border: rgba(216, 210, 189, 0.18);
  --color-border-strong: rgba(216, 210, 189, 0.32);
  --color-sidebar: rgba(16, 21, 20, 0.42);
  --color-sidebar-mobile: rgba(16, 21, 20, 0.76);
  --color-overlay-main: rgba(8, 11, 11, 0.96);
  --color-overlay-mid: rgba(8, 11, 11, 0.62);
  --color-overlay-end: rgba(8, 11, 11, 0.9);
  --color-radial: rgba(217, 107, 112, 0.35);
  --shadow-card: 0 22px 70px rgba(0, 0, 0, 0.48);
  --shadow-float: 0 16px 40px rgba(0, 0, 0, 0.28);
  --font-mono: "Courier New", monospace;
  --radius: 14px;
  --sidebar-width: 195px;
  --frame-corner-size: 42px;
  --frame-corner-offset: 1.2rem;
  --frame-content-safe: calc(var(--frame-corner-offset) + var(--frame-corner-size) + 0.75rem);
}

html[data-theme="light"] {
  --color-bg: #50505085;
  --color-bg-soft: #fff8ece5;
  --color-surface: rgba(255, 248, 236, 0.88);
  --color-surface-muted: rgba(243, 227, 205, 0.66);
  --color-text: #2d241f;
  --color-text-soft: rgba(61, 47, 40, 0.82);
  --color-text-muted: rgba(61, 47, 40, 0.6);
  --color-primary: #df2d36;
  --color-primary-dark: #a44d52;
  --color-primary-soft: rgba(217, 107, 112, 0.16);
  --color-border: rgba(88, 66, 54, 0.16);
  --color-border-strong: rgba(88, 66, 54, 0.28);
  --color-sidebar: rgba(255, 248, 236, 0.94);
  --color-sidebar-mobile: rgba(255, 248, 236, 0.94);
  --color-overlay-main: rgba(246, 239, 227, 0.92);
  --color-overlay-mid: rgba(246, 239, 227, 0.72);
  --color-overlay-end: rgba(255, 248, 236, 0.88);
  --color-radial: rgba(217, 107, 112, 0.16);
  --shadow-card: 0 20px 52px rgba(112, 84, 64, 0.16);
  --shadow-float: 0 18px 34px rgba(112, 84, 64, 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

section[id] {
  scroll-margin-top: 1.25rem;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-mono);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.is-loading {
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: var(--color-bg);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(90deg, var(--color-overlay-main), var(--color-overlay-mid), var(--color-overlay-end)),
    radial-gradient(circle at 72% 42%, var(--color-radial), transparent 0 10%, transparent 20%),
    url("../img/bg/hero-bg.png");
  background-size: cover;
  background-position: center;
  filter: grayscale(0.55) contrast(1.08) brightness(0.8);
}

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

a {
  color: inherit;
  text-decoration: none;
}

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

a:focus-visible,
button:focus-visible {
  outline: 2px solid rgba(217, 107, 112, 0.75);
  outline-offset: 4px;
  border-radius: 8px;
}

button {
  font: inherit;
}

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    linear-gradient(135deg, var(--color-overlay-main), var(--color-overlay-end)),
    var(--color-bg);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.page-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.page-loader__label {
  color: var(--color-text);
  font-size: clamp(1.15rem, 2.5vw, 1.8rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;
}

.site-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.5rem 1.25rem;
  overflow: auto;
  border-right: 1px solid var(--color-border);
  background: var(--color-sidebar);
  backdrop-filter: blur(10px);
}

.sidebar__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
}

.brand {
  display: inline-flex;
  align-items: center;
}

.brand__logo {
  width: min(220px, 100%);
  height: auto;
  opacity: 0.94;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: auto;
  padding-bottom: 0.25rem;
}

.nav a {
  color: var(--color-text);
  font-size: 0.95rem;
  transition: color 0.2s ease, transform 0.2s ease;
}

.nav a:hover {
  color: var(--color-primary);
  transform: translateX(6px);
}

.nav-toggle {
  display: none;
}

.main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 2vw, 1.5rem);
  padding: clamp(1.25rem, 3vw, 2rem);
}

.hero,
.section {
  position: relative;
  z-index: 1;
}

.frame-panel,
.project-card,
.info-card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(10px);
}

.frame-panel::before,
.frame-panel::after {
  content: "";
  position: absolute;
  width: var(--frame-corner-size);
  height: var(--frame-corner-size);
  z-index: 0;
  pointer-events: none;
}

.frame-panel::before {
  top: var(--frame-corner-offset);
  left: var(--frame-corner-offset);
  border-top: 1px solid var(--color-border-strong);
  border-left: 1px solid var(--color-border-strong);
}

.frame-panel::after {
  right: var(--frame-corner-offset);
  bottom: var(--frame-corner-offset);
  border-right: 1px solid var(--color-border-strong);
  border-bottom: 1px solid var(--color-border-strong);
}

.frame-panel > * {
  position: relative;
  z-index: 1;
}

.hero {
  min-height: calc(100vh - 4rem);
  display: grid;
  align-items: center;
  gap: 1rem;
}

.hero__panel {
  width: min(760px, 100%);
  padding: clamp(2rem, 5vw, 4rem);
}

.eyebrow {
  margin-bottom: 1rem;
  color: var(--color-primary);
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  color: var(--color-text);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -0.04em;
}

h1 {
  max-width: 780px;
  font-size: clamp(2.25rem, 6vw, 4.5rem);
}

h2 {
  font-size: clamp(1.45rem, 3vw, 2rem);
}

h3 {
  font-size: clamp(1.2rem, 2vw, 1.5rem);
}

.hero__text,
.info-card p,
.project-card p,
.contact-band p {
  max-width: 680px;
  margin-top: 1rem;
  color: var(--color-text-soft);
}

.hero__actions,
.project-card__actions,
.contact-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.4rem;
}

.button,
.contact-link,
.text-link {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  color: var(--color-primary-dark);
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.button,
.contact-link {
  justify-content: center;
  padding: 0.62rem 0.95rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.contact-copy {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  min-width: min(100%, 18rem);
  padding: 0.62rem 0.95rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.contact-copy__text {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: left;
}

.contact-copy__icon {
  width: 0.95rem;
  height: 0.95rem;
  flex: 0 0 auto;
}

.contact-copy__icon--success {
  display: none;
}

.button--icon {
  padding: 0;
  width: 3.15rem;
  height: 3.15rem;
  border-radius: 14px;
  overflow: hidden;
}

.button__icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.button__icon--inline {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.button {
  gap: 0.55rem;
}

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

.button--primary {
  background: var(--color-primary);
  color: var(--color-bg-soft);
  border: 1px solid var(--color-primary-dark);
}

.button--primary:hover {
  background: var(--color-primary-dark);
  color: var(--color-bg-soft);
}

.button--ghost {
  background: transparent;
  color: var(--color-primary-dark);
  border: 1px solid var(--color-border-strong);
}

.button:hover,
.contact-link:hover,
.contact-copy:hover {
  transform: translateY(-1px);
}

.button--ghost:hover {
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
}

.text-link {
  padding-bottom: 0.2rem;
  color: var(--color-primary-dark);
  border-bottom: 1px solid transparent;
}

.text-link::after {
  content: "_";
  margin-left: 0.18em;
  animation: cursor-blink 1.05s steps(1, end) infinite;
}

.text-link:hover,
.contact-link:hover,
.contact-copy:hover {
  color: var(--color-primary);
}

.text-link:hover {
  border-color: var(--color-primary);
}

.cv-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.78rem 1.15rem;
  border: 1px solid var(--color-primary-dark);
  border-radius: 999px;
  background:
    linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.22);
  color: var(--color-bg-soft);
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    filter 0.2s ease;
}

.cv-download__icon {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.cv-download:hover {
  color: var(--color-bg-soft);
  transform: translateY(-2px);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.28);
  filter: saturate(1.08);
}

@keyframes cursor-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.hero__meta {
  align-self: end;
  justify-self: end;
  color: var(--color-text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.section {
  padding: clamp(2rem, 5vw, 3.5rem) 0;
}

.section-header {
  margin-bottom: 1.4rem;
}

.section-header--inline {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
}

.intro__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.cv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.cv-layout {
  display: grid;
  gap: 1rem;
}

.info-card {
  min-height: 100%;
  padding: 1.25rem;
  border-radius: var(--radius);
}

.projects-list,
.projects-preview {
  display: grid;
  gap: 1.25rem;
}

.project-card {
  display: grid;
  grid-template-columns: minmax(240px, 0.42fr) minmax(0, 1fr);
  overflow: hidden;
  border-radius: var(--radius);
}

.project-card__media {
  min-height: 260px;
  border-right: 1px solid var(--color-border);
  background: var(--color-surface-muted);
}

.project-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.12) contrast(1.02) brightness(0.94);
}

.project-card__body {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: clamp(1.25rem, 2.5vw, 1.8rem);
}

.project-card__kicker {
  margin-top: 0;
  color: var(--color-primary);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.project-card h2,
.project-card h3 {
  margin-top: 0.5rem;
  color: var(--color-text);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.2rem;
  list-style: none;
}

.tag-list li {
  padding: 0.25rem 0.55rem;
  background: var(--color-surface-muted);
  color: var(--color-text-soft);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 0.82rem;
}

.contact-band .frame-panel {
  padding: clamp(2rem, 5vw, 4rem);
  border-radius: var(--radius);
}

.cv-profile {
  display: grid;
  grid-template-columns: minmax(220px, 0.34fr) minmax(0, 1fr);
  overflow: hidden;
  border-radius: var(--radius);
}

.cv-profile__media {
  min-height: 100%;
  border-right: 1px solid var(--color-border);
  background: var(--color-surface-muted);
}

.cv-profile__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  filter: contrast(1.02) brightness(0.96);
}

.cv-profile__body {
  padding: clamp(1.25rem, 2.5vw, 1.8rem);
}

.cv-copy {
  max-width: 68ch;
}

.cv-card .eyebrow {
  margin-bottom: 0.85rem;
}

.cv-card {
  padding: 1rem;
}

.cv-stack {
  margin-top: 1.3rem;
}

.cv-list strong {
  color: var(--color-text);
  font-size: 0.98rem;
  font-weight: 500;
}

.cv-list {
  display: grid;
  gap: 0.7rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cv-list li {
  display: grid;
  gap: 0.1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--color-border);
}

.cv-list li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.cv-list span {
  color: var(--color-text-soft);
  line-height: 1.4;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.site-footer__links {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.site-footer__links a {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  overflow: hidden;
  transition: transform 0.22s ease, opacity 0.22s ease, background-color 0.22s ease;
}

.site-footer__links a:hover {
  transform: translateY(-2px) scale(1.06);
  opacity: 0.92;
  background-color: var(--color-primary-soft);
}

.site-footer__links img {
  width: 44px;
  height: auto;
  opacity: 0.92;
  border-radius: inherit;
}

.site-footer__meta {
  color: var(--color-text-muted);
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-align: right;
  text-transform: lowercase;
}

.contact-link {
  color: var(--color-primary-dark);
}

.contact-link:hover,
.contact-copy:hover {
  background: var(--color-primary-soft);
}

.contact-email-group {
  display: inline-flex;
  width: fit-content;
}

.contact-copy.is-copied {
  border-color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.contact-copy.is-copied .contact-copy__icon--copy {
  display: none;
}

.contact-copy.is-copied .contact-copy__icon--success {
  display: block;
}

.theme-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 80;
  display: inline-grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  padding: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-float);
  backdrop-filter: blur(14px);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.theme-toggle:hover {
  transform: translateY(-2px) scale(1.03);
  background: #fff;
  border-color: var(--color-primary);
}

.theme-toggle__icon {
  position: absolute;
  width: 3.12rem;
  height: 3.12rem;
  object-fit: contain;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.theme-toggle__icon--moon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.theme-toggle__icon--sun {
  opacity: 0;
  transform: scale(0.8) rotate(-12deg);
}

html[data-theme="light"] .theme-toggle__icon--sun {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

html[data-theme="light"] .theme-toggle__icon--moon {
  opacity: 0;
  transform: scale(0.8) rotate(12deg);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 960px) {
  .intro__grid {
    grid-template-columns: 1fr;
  }

  .cv-grid {
    grid-template-columns: 1fr;
  }

  .cv-profile {
    grid-template-columns: 1fr;
  }

  .cv-profile__media {
    min-height: 340px;
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }

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

  .project-card__media {
    min-height: 220px;
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }
}

@media (max-width: 850px) {
  :root {
    --sidebar-rail: 56px;
    --sidebar-open: 260px;
    --frame-corner-size: 26px;
    --frame-corner-offset: 0.85rem;
    --frame-content-safe: calc(var(--frame-corner-offset) + var(--frame-corner-size) + 0.65rem);
  }

  .site-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: var(--sidebar-rail);
    height: 100vh;
    gap: 0;
    overflow: hidden;
    padding: 0;
    border-right: 1px solid var(--color-border);
    background: var(--color-sidebar-mobile);
    transition: width 0.25s ease;
  }

  .sidebar__top {
    min-height: 0;
    justify-content: center;
    padding: 0.75rem 0.5rem 0.5rem;
    border-bottom: 1px solid var(--color-border);
  }

  .brand {
    display: none;
  }

  .brand__logo {
    width: 150px;
  }

  .nav-toggle {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    cursor: pointer;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-surface-muted);
  }

  .nav-toggle__bar {
    display: block;
    width: 18px;
    height: 1px;
    margin: 2px 0;
    background: var(--color-text-soft);
  }

  .nav {
    gap: 0.55rem;
    margin-top: 0;
    padding: 0 0.9rem 1rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
  }

  .nav a {
    font-size: 0.82rem;
  }

  .sidebar--open {
    width: var(--sidebar-open);
    overflow: auto;
  }

  .sidebar--open .sidebar__top {
    justify-content: space-between;
    padding: 0.85rem 1rem 0.75rem;
  }

  .sidebar--open .brand {
    display: flex;
  }

  .sidebar--open .nav {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
  }

  .main {
    padding: 1.2rem 1.2rem 1.8rem calc(1.2rem + var(--sidebar-rail));
  }

  .theme-toggle {
    top: 0.9rem;
    right: 0.9rem;
    width: 3.5rem;
    height: 3.5rem;
  }

  .theme-toggle__icon {
    width: 2.81rem;
    height: 2.81rem;
  }

  .hero {
    min-height: calc(100vh - 2.4rem);
  }

  .hero__panel,
  .contact-band .frame-panel {
    padding: max(1.25rem, var(--frame-content-safe)) 1rem;
  }

  h1 {
    font-size: clamp(2rem, 11vw, 3rem);
  }

  .hero__meta {
    display: none;
  }

  .section-header--inline,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-footer__meta {
    text-align: left;
  }
}
