:root[data-theme="light"] {
  --bg: #ffffff;
  --fg: #121212;
  --thumb-1: #d9d9d9;
  --thumb-2: #cecdcd;
  --thumb-3: #c3c3c3;
  --thumb-4: #b8b8b8;
  --thumb-5: #b0b0b0;
  --thumb-6: #ababab;
  --screen-2: #e6e6e6;
  --screen-3: #d2d2d2;
  --screen-4: #bdbdbd;
  --divider: rgba(18, 18, 18, 0.12);
  --fg-muted: #666666;
}

:root[data-theme="dark"] {
  --bg: #121212;
  --fg: #f5f5f5;
  --thumb-1: #3a3a3a;
  --thumb-2: #444444;
  --thumb-3: #4e4e4e;
  --thumb-4: #585858;
  --thumb-5: #626262;
  --thumb-6: #6c6c6c;
  --screen-2: #333333;
  --screen-3: #3d3d3d;
  --screen-4: #474747;
  --divider: rgba(245, 245, 245, 0.12);
  --fg-muted: #a5a5a5;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background-color: var(--bg);
  overscroll-behavior-y: none;
}

body {
  color: var(--fg);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  transition: color .3s ease;
}

a { color: inherit; }

/* ---------- Header / Footer ---------- */

.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 65px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background-color: var(--bg);
  z-index: 1000;
  transition: transform .3s ease;
}

.site-header.hidden {
  display: none;
}

.logo {
  display: flex;
  align-items: center;
  color: var(--fg);
  text-decoration: none;
}

.logo.active {
  cursor: default;
  pointer-events: none;
}

.header-link {
  text-decoration: none;
  font-size: 14px;
  padding: 8px;
}

.header-link.active {
  text-decoration: underline;
  cursor: default;
  pointer-events: none;
}

.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 20px;
  height: 14px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  width: 100%;
  height: 1px;
  background: var(--fg);
  transition: transform .2s ease, opacity .2s ease;
}

.menu-toggle.open span:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}

.menu-toggle.open span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.open span:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

.mobile-menu {
  display: none;
  position: fixed;
  top: 65px;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 900;
  flex-direction: column;
  justify-content: space-between;
}

.mobile-menu-links {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.mobile-menu-link {
  font-size: 14px;
  text-decoration: none;
  color: var(--fg);
}

.mobile-menu-link.active {
  cursor: default;
  pointer-events: none;
}

.mobile-menu-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 65px;
  padding: 0 20px;
}

.site-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 65px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background-color: var(--bg);
  z-index: 1000;
}

.site-footer.hidden { display: none; }

.footer-left {
  display: flex;
  justify-content: space-between;
  width: 296px;
}

.view-links {
  display: flex;
  gap: 80px;
}

.footer-link {
  background: none;
  border: none;
  font: inherit;
  color: var(--fg);
  font-size: 14px;
  padding: 8px;
  cursor: pointer;
}

.footer-link.active {
  text-decoration: underline;
}

.view-link.active {
  cursor: default;
}

/* ---------- Pages ---------- */

.page { display: none; }
.page.active { display: block; }

/* ---------- Home ---------- */

#page-home.active {
  position: relative;
  min-height: 100vh;
  padding: 65px 0;
  display: flex;
  align-items: center;
}

.home-layout { display: none; width: 100%; }

#page-home[data-mode="line"] .layout-line { display: block; }
#page-home[data-mode="grid"] .layout-grid { display: grid; }
#page-home[data-mode="random"] .layout-random { display: flex; }

/* line view */

.layout-line {
  overflow-x: auto;
  scrollbar-width: none;
}
.layout-line::-webkit-scrollbar { display: none; }

.line-track {
  display: flex;
  align-items: center;
  gap: 16px;
  width: max-content;
  padding: 0 80px;
}

.thumb-line {
  flex: 0 0 400px;
  width: 400px;
  height: 326px;
  border-radius: 4px;
  cursor: pointer;
  transition: flex-basis .4s ease, width .4s ease, height .4s ease;
}

.thumb-line:hover {
  flex-basis: 500px;
  width: 500px;
  height: 408px;
}

/* grid (bento) view */

.layout-grid {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 24px;
  padding: 0 32px;
  height: calc(100vh - 130px);
}

.grid-cell {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  cursor: pointer;
}

.grid-fill {
  position: absolute;
  inset: 0;
  transition: transform .4s ease;
}

.grid-cell:hover .grid-fill {
  transform: scale(1.15);
}

.grid-bottom-left {
  display: flex;
  gap: 24px;
}
.grid-bottom-left .grid-cell { flex: 1; }

.grid-bottom-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* random view */

.layout-random {
  align-items: center;
  justify-content: center;
  padding: 0 80px;
  height: 480px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.layout-random.is-overflowing {
  justify-content: flex-start;
}
.layout-random::-webkit-scrollbar { display: none; }

.thumb-random {
  position: relative;
  flex-shrink: 0;
  width: 202px;
  margin-left: -36px;
  transform: rotate(var(--r)) translateY(var(--ty));
  z-index: var(--z, 1);
  cursor: pointer;
}

.thumb-random:first-child { margin-left: 0; }

.thumb-random:hover {
  z-index: 10;
}

.thumb-random-inner {
  width: 202px;
  height: 326px;
  border-radius: 4px;
  transition: transform .4s ease;
}

.thumb-random:hover .thumb-random-inner {
  transform: scale(1.28);
}

/* ---------- Project page v2 (sidebar + accordion) ---------- */

.page-project.active { display: block; }

.project-v2 {
  display: flex;
  min-height: 100vh;
}

.project-sidebar {
  width: 360px;
  flex: none;
  padding: 0 32px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sidebar-header,
.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  width: 100%;
}

.accordion-list {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding-top: 80px;
  flex: 1 0 auto;
}

.project-title {
  font-size: 20px;
  font-weight: 500;
  margin: 80px 0 0;
}

.project-title + .accordion-list {
  padding-top: 32px;
}

.project-dots,
.more-info-toggle.accordion-item-header,
.project-modal {
  display: none;
}

.accordion-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  font: inherit;
  color: var(--fg);
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.accordion-item-title {
  font-size: 14px;
  text-transform: uppercase;
}

.accordion-item-toggle {
  font-size: 14px;
}

.accordion-item-body {
  display: none;
  font-size: 14px;
  line-height: 1.5;
  margin: 8px 0 0 0;
  max-width: 296px;
}

.accordion-item.open .accordion-item-body {
  display: block;
}

.accordion-item-body p {
  margin: 0 0 12px;
}

.accordion-item-body ul {
  margin: 0 0 12px;
  padding-left: 16px;
}

.accordion-item-body li {
  margin-bottom: 6px;
}

.accordion-item-body p:last-child,
.accordion-item-body ul:last-child,
.accordion-item-body li:last-child {
  margin-bottom: 0;
}

.accordion-stats {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.stat-value {
  display: block;
}

.stat-label {
  display: block;
}

.project-image {
  flex: 1;
  min-height: 100vh;
}

#page-project .project-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  align-self: flex-start;
  overflow-y: auto;
}

.project-close-desktop {
  position: fixed;
  top: 22px;
  right: 32px;
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  z-index: 1000;
}

.project-close-desktop span {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--fg);
}

.project-close-desktop span:nth-child(1) {
  transform: rotate(45deg);
}

.project-close-desktop span:nth-child(2) {
  transform: rotate(-45deg);
}

.project-screen {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.project-screen video {
  width: 80%;
  height: 80%;
  object-fit: contain;
}

.project-screen img {
  width: 80%;
  height: 80%;
  object-fit: contain;
}

.proj-image {
  flex: 1 1 50%;
  align-self: stretch;
}

.proj-copy {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 40px;
  padding: 80px 40px;
}

.proj-lorem {
  max-width: 392px;
  line-height: 1.5;
  margin: 0;
}

.proj-lorem p,
.proj-lorem ul {
  margin: 0 0 8px 0;
  padding-left: 20px;
}

.proj-lorem p {
  padding-left: 0;
}

.proj-lorem p:last-child,
.proj-lorem ul:last-child {
  margin-bottom: 0;
}

.proj-lorem p.label {
  margin-bottom: 0;
}

/* ---------- About ---------- */

.page-about.active { display: block; }

.about-title {
  font-size: 20px;
  font-weight: 500;
  text-transform: uppercase;
  margin: 0;
}

.about-bio {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 80px;
  flex: 1 0 auto;
  width: 100%;
}

.about-timeline-col {
  width: 360px;
  flex: none;
  padding: 192px 32px 0;
  min-height: 100vh;
  box-sizing: border-box;
}

.about-timeline {
  height: calc(100vh - 192px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-right: 16px;
  padding-bottom: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--thumb-1) transparent;
}

.about-timeline::-webkit-scrollbar {
  width: 8px;
}

.about-timeline::-webkit-scrollbar-track {
  background: transparent;
}

.about-timeline::-webkit-scrollbar-thumb {
  background-color: var(--thumb-1);
  border-radius: 4px;
}

.timeline-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-year {
  font-size: 14px;
  white-space: nowrap;
}

.timeline-rule {
  flex: 1;
  height: 1px;
  background: var(--divider);
}

.timeline-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.timeline-item {
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg-muted);
}

#img-about {
  background: var(--thumb-1) url('covers/about.jpg') center/cover no-repeat;
}

/* ---------- Mobile ---------- */

@media (max-width: 640px) {

  .project-close-desktop {
    display: none;
  }

  .site-header, .site-footer {
    padding: 16px 20px;
  }

  .site-header.hidden {
    display: flex;
    background: transparent;
  }

  .site-header.modal-open {
    display: none;
  }

  .site-header.hidden::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--bg);
    opacity: 0;
    transition: opacity .3s ease;
  }

  .site-header.hidden.scrolled::before,
  .site-header.hidden:has(+ .mobile-menu.open)::before {
    opacity: 1;
  }

  .site-header.header-hidden {
    transform: translateY(-100%);
  }

  .header-nav {
    display: none;
  }

  .menu-toggle {
    display: flex;
  }

  .mobile-menu.open {
    display: flex;
  }

  .footer-left {
    display: none;
  }

  #page-project .sidebar-footer,
  #page-about .sidebar-footer {
    display: none;
  }

  .view-links {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    width: 100%;
  }

  .view-links .view-link:nth-child(1) { justify-self: start; }
  .view-links .view-link:nth-child(2) { justify-self: center; }
  .view-links .view-link:nth-child(3) { justify-self: end; }

  .header-link {
    font-size: 12px;
  }

  .footer-link {
    font-size: 12px;
    padding: 6px;
  }

  /* home */

  .line-track {
    padding: 0 20px;
    gap: 12px;
  }

  .thumb-line {
    flex: 0 0 calc(100vw - 64px);
    width: calc(100vw - 64px);
    height: calc((100vw - 64px) * 0.815);
  }

  .thumb-line:hover {
    flex-basis: calc(100vw - 64px);
    width: calc(100vw - 64px);
    height: calc((100vw - 64px) * 0.815);
  }

  #page-home[data-mode="grid"] .layout-grid {
    display: flex;
    flex-direction: column;
    height: auto;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    padding: 0 20px;
    gap: 12px;
    scrollbar-width: none;
  }
  .layout-grid::-webkit-scrollbar { display: none; }

  .grid-bottom-left,
  .grid-bottom-right {
    gap: 12px;
  }

  .grid-bottom-left {
    flex-direction: column;
  }

  .layout-grid .grid-cell {
    height: 160px !important;
    flex: none !important;
  }

  .layout-grid > .grid-cell {
    height: calc((100vh - 130px) * 0.4) !important;
  }

  .grid-bottom-right {
    flex-direction: row;
  }

  .grid-bottom-right .grid-cell {
    flex: 1 !important;
    height: 160px !important;
  }

  .layout-random {
    padding: 0 20px;
    height: 320px;
  }

  .thumb-random {
    width: 130px;
    margin-left: -24px;
  }

  .thumb-random-inner {
    width: 130px;
    height: 210px;
  }

  /* project page v2 */

  .project-v2 {
    flex-direction: column;
  }

  #page-project .project-v2 {
    height: 100vh;
    height: 100dvh;
    padding-bottom: 65px;
  }

  .project-sidebar {
    width: 100%;
    min-height: auto;
    padding: 0 20px;
  }

  #page-project .project-sidebar {
    position: static;
    height: auto;
  }

  #page-project .sidebar-header,
  #page-about .sidebar-header {
    display: none;
  }

  .project-title {
    font-size: 20px;
    margin: 24px 0 8px;
  }

  .project-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 24px;
    z-index: 10;
  }

  .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
  }

  .dot.active {
    background: #4d4d4d;
  }

  .more-info-toggle.accordion-item-header {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 65px;
    background: var(--bg);
    padding: 16px 20px;
    z-index: 900;
  }

  .more-info-toggle .accordion-item-title {
    padding-bottom: 10px;
  }

  .more-info-toggle .accordion-item-toggle {
    padding-bottom: 10px;
  }

  #accordionList {
    display: none;
  }

  .project-modal.open {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 950;
    overflow-y: auto;
  }

  .project-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
  }

  .modal-close {
    position: relative;
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
  }

  .modal-close span {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--fg);
  }

  .modal-close span:nth-child(1) {
    transform: rotate(45deg);
  }

  .modal-close span:nth-child(2) {
    transform: rotate(-45deg);
  }

  .project-modal .project-title {
    margin: 24px 20px 32px;
  }

  .project-modal.open #accordionListModal {
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding: 0 20px 40px;
  }

  .accordion-list {
    padding-top: 40px;
  }

  .accordion-item-body {
    max-width: 100%;
  }

  .project-image {
    width: 100%;
    min-height: 50vh;
    order: -1;
    position: relative;
  }

  #page-project .project-image {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
  }

  .project-screens {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .project-screens::-webkit-scrollbar {
    display: none;
  }

  .project-screen {
    position: static;
    flex: 0 0 100%;
    height: 100%;
    scroll-snap-align: start;
  }

  .proj-copy {
    padding: 24px 20px;
    gap: 16px;
  }

  .proj-lorem {
    max-width: 100%;
  }

  /* about */

  .about-bio {
    padding-top: 40px;
  }

  .about-timeline-col {
    width: 100%;
    min-height: auto;
    padding: 24px 20px 0;
  }

  .about-timeline {
    height: auto;
    overflow-y: visible;
    padding-bottom: 52px;
  }
}
