:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f4ef;
  --bg-top: #ffffff;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: rgba(255, 255, 255, 0.94);
  --ink: #111111;
  --ink-soft: rgba(17, 17, 17, 0.62);
  --line: rgba(17, 17, 17, 0.14);
  --line-strong: rgba(17, 17, 17, 0.82);
  --grid: rgba(17, 17, 17, 0.045);
  --shadow: 0 22px 60px rgba(17, 17, 17, 0.06);
  --preview-bg: #111111;
  --preview-overlay: rgba(17, 17, 17, 0.08);
  --radius-lg: 30px;
  --radius-md: 18px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090909;
  --bg-top: #161616;
  --surface: rgba(20, 20, 20, 0.8);
  --surface-strong: rgba(24, 24, 24, 0.92);
  --ink: #f3f1ea;
  --ink-soft: rgba(243, 241, 234, 0.64);
  --line: rgba(243, 241, 234, 0.12);
  --line-strong: rgba(243, 241, 234, 0.82);
  --grid: rgba(243, 241, 234, 0.04);
  --shadow: 0 28px 72px rgba(0, 0, 0, 0.28);
  --preview-bg: #0f0f0f;
  --preview-overlay: rgba(243, 241, 234, 0.05);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(127, 127, 127, 0.08), transparent 28%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.34;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.32), transparent 72%);
}

a {
  color: inherit;
}

.theme-toggle {
  position: fixed;
  top: 22px;
  right: 20px;
  z-index: 20;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.theme-toggle-icon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.theme-toggle-icon svg {
  width: 18px;
  height: 18px;
}

.theme-toggle-icon-moon {
  opacity: 0;
  transform: scale(0.72);
}

:root[data-theme="dark"] .theme-toggle-icon-sun {
  opacity: 0;
  transform: scale(0.72);
}

:root[data-theme="dark"] .theme-toggle-icon-moon {
  opacity: 1;
  transform: scale(1);
}

.archive-page {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.archive-section + .archive-section {
  margin-top: 36px;
}

.section-header {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.section-header::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
  margin-left: 14px;
}

.section-label {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 34px;
  font-style: italic;
  line-height: 1;
}

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

.section-grid-single {
  grid-template-columns: minmax(0, 1fr);
}

.project-card {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    background-color 180ms ease;
}

.project-card-portfolio {
  min-height: auto;
}

.project-card:hover {
  transform: translateY(-4px);
  border-color: var(--line-strong);
  box-shadow: 0 28px 72px rgba(17, 17, 17, 0.12);
}

:root[data-theme="dark"] .project-card:hover {
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.34);
}

.project-card:hover .card-preview img {
  transform: scale(1.02);
}

.card-preview {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--preview-bg);
  border-bottom: 1px solid var(--line);
}

.card-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, var(--preview-overlay) 100%);
  pointer-events: none;
}

.card-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  transition: transform 280ms ease;
}

.project-card-portfolio .card-preview {
  aspect-ratio: 16 / 7;
}

.card-content {
  padding: 20px;
  display: flex;
  align-items: flex-start;
}

.project-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: start;
}

.project-icon {
  width: 65px;
  height: 65px;
  border-radius: 2px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  overflow: hidden;
  flex-shrink: 0;
}

.project-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

:root[data-theme="dark"] .project-icon img:not(.project-icon-image-raster) {
  filter: invert(1);
}

.project-copy h2 {
  margin: 0;
  font-size: clamp(22px, 2.5vw, 29px);
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.project-copy p {
  margin: 10px 0 0;
  width: 100%;
  font-size: 15px;
  line-height: 1.6;
  text-wrap: pretty;
  color: var(--ink-soft);
}

@media (max-width: 920px) {
  .section-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .theme-toggle {
    top: 14px;
    right: 12px;
    width: 38px;
    height: 38px;
  }

  .archive-page {
    width: calc(100% - 24px);
    padding-top: 18px;
  }

  .archive-section + .archive-section {
    margin-top: 28px;
  }

  .section-label {
    font-size: 30px;
  }

  .section-grid {
    gap: 18px;
  }

  .project-card {
    min-height: auto;
    border-radius: 24px;
    grid-template-rows: auto 103px;
  }

  .card-preview,
  .project-card-portfolio .card-preview {
    aspect-ratio: 16 / 7;
  }

  .card-content {
    padding: 16px;
    min-height: 103px;
  }

  .project-head {
    gap: 14px;
  }

  .project-icon {
    width: 65px;
    height: 65px;
    border-radius: 2px;
  }

  .project-copy h2 {
    font-size: 16px;
    line-height: 1.2;
  }

  .project-copy p {
    font-size: 12px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

}

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