/* ============================================
   FONTS
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap');

/* ============================================
   CSS VARIABLES
   ============================================ */

:root {
  /* Colours */
  --color-bg: #ffffff;
  --color-text: #111111;
  --color-text-muted: #828282;
  --color-accent: rgb(227, 105, 86);
  --color-border: #e2e8f0;
  --color-card-bg: #efeded;
  --color-bento-bg: #000000;
  --color-text-on-dark: rgb(244, 238, 230);

  /* Typography */
  --text-sm: 0.875rem;
  --text-base: 1.025rem;
  --text-xl: 1.25rem;
  --text-2xl: 2.5rem;
  --text-3xl: 4rem;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Layout */
  --gutter-width: 14rem;
  --gutter-gap: 2rem;
  --prose-width: 48rem;
  --sidenote-width: var(--gutter-width);
  --sidenote-offset: var(--gutter-gap);
  --content-overhang: var(--space-xl);
  --content-overhang-wide: var(--space-xl);
  --radius: 9px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0f0f0f;
    --color-text: rgb(244, 238, 230);
    --color-text-muted: rgb(149, 143, 135);
    --color-accent: rgb(227, 105, 86);
    --color-border: #1e293b;
    --color-card-bg: #1f1f1f;
  }
}

/* ============================================
   RESET & BASE
   ============================================ */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  background-color: var(--color-bg);
}

body {
  margin: 0;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: var(--text-base);
  line-height: 1.625;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-2xl);
  line-height: 1.2;
}

h1 { font-size: var(--text-3xl); padding-bottom: var(--space-md);}
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }

p {
  margin: var(--space-md) 0;
}

a {
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  transition: color 0.3s;
}

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

strong {
  font-weight: 700;
}

ul, ol {
  margin: var(--space-md) 0;
  padding-left: var(--space-lg);
}

li {
  margin: var(--space-sm) 0;
}

li::marker {
  color: var(--color-accent);
}

img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

blockquote {
  margin: var(--space-lg) 0;
  padding: var(--space-md) 1.25rem;
  background: var(--color-card-bg);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 6px 6px 0;
  font-size: 0.925rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

blockquote p {
  margin: 0;
}

blockquote p + p {
  margin-top: 0.75rem;
}

/* ============================================
   SITE HEADER
   ============================================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: color-mix(in srgb, var(--color-bg) 80%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--color-text-muted) 20%, transparent);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  max-width: var(--prose-width);
  margin: 0 auto;
  padding-bottom: 1.25rem;
  width: 100%;
  box-sizing: border-box;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.profile-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s;
  font-size: var(--text-base);
}

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

.header-profile-image {
  height: 2rem;
  width: auto;
  border-radius: 50%;
  margin-left: -0.5rem;
}

.site-name {
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
}

.site-name:hover {
  color: var(--color-accent);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transform: translateY(0.05em);
}

.nav-link {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: 500;
  text-decoration: none;
  margin-left: 1rem;
}

.nav-link.active {
  color: var(--color-text);
}

.nav-link:hover {
  color: var(--color-text-muted);
}

@media (hover: hover) {
  .nav-link {
    transition: color 0.3s;
  }

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

.nav-link::after {
  content: "↗";
  margin-left: 0.3em;
}

@media (hover: hover) {
  .nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding-left: 0;
    padding-right: 1.3em;
    transition: color 0.3s, padding 0.3s;
  }

  .nav-link::before {
    content: "→";
    margin-right: 0.3em;
    opacity: 0;
    transition: opacity 0.3s;
  }

  .nav-link::after {
    position: absolute;
    right: 0;
    margin-left: 0;
    opacity: 1;
    transition: opacity 0.3s;
  }

  .nav-link:hover {
    padding-left: 1.3em;
    padding-right: 0;
  }

  .nav-link:hover::before {
    opacity: 1;
    animation: arrow-beckon 0.8s ease-in-out 0.3s infinite;
  }

  .nav-link:hover::after {
    opacity: 0;
  }
}

.nav-icon {
  display: flex;
  align-items: center;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
  max-width: var(--prose-width);
  margin: 0 auto;
  padding: 0 var(--space-lg) 0;
}

@media (min-width: 80rem) {
  .main-content {
    overflow: visible;
  }
}

/* ============================================
   HERO SECTION
   ============================================ */

.hero {
  padding-top: var(--space-lg);
  padding-bottom: var(--space-md);
}

.hero-summary {
  margin-bottom: var(--space-md);
}

.hero-summary p:first-child {
  font-weight: 500;
}

.hero-summary p {
  margin: 0 0 var(--space-md);
}

.hero-summary p:last-child {
  margin-bottom: 0;
}

.section-title {
  font-weight: 500;
}

.section-title::after {
  content: "⤵";
  display: inline-block;
  margin-left: 0.4rem;
  vertical-align: -0.4rem;
}

/* ============================================
   PROJECTS BENTO (Home page)
   ============================================ */

.projects-bento {
  display: grid;
  gap: 2px;
  padding: 2px;
  grid-template-columns: 1fr;
  background: var(--color-bento-bg);
  width: 100%;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.projects-bento--fixed {
  grid-auto-rows: 1fr;
}

.projects-bento--fixed .project-card {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.projects-bento--fixed .project-image {
  flex: 1;
  min-height: 0;
  aspect-ratio: auto;
}

@media (min-width: 40rem) {
  .projects-bento {
    margin-top: var(--space-xl);
    margin-bottom: var(--space-xl);
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================
   PROJECT CARDS
   ============================================ */

.project-card {
  display: block;
  text-decoration: none;
  background: var(--color-bento-bg);
  overflow: hidden;
  transition: background-color 0.3s;
}

.project-card:hover {
  background: color-mix(in srgb, var(--color-card-bg) 8%, black);
  color: var(--color-text);
}

@media (prefers-color-scheme: dark) {
  .project-card:hover {
    background: color-mix(in srgb, var(--color-card-bg) 60%, black);
  }
}

.project-image {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 0;
  transition: filter 0.3s;
}

.projects-bento:has(.project-card:hover) .project-image {
  filter: saturate(0.75) brightness(0.60);
}

.projects-bento:has(.project-card:hover) .project-info {
  opacity: 0.5;
}

.projects-bento .project-card:hover .project-image {
  filter: saturate(1);
}

.projects-bento .project-card:hover .project-info {
  opacity: 1;
}

.project-info {
  padding: 2rem var(--space-lg);
  /* margin-top: -1rem; */
  color: var(--color-text-on-dark);
  transition: opacity 0.3s;
}

@media (min-width: 40rem) {
  .project-info {
    padding: 2rem;
    margin-left: 0.25rem;
  }
}

.project-title {
  margin: 0 0 var(--space-sm);
  display: inline-flex;
  align-items: center;
}

.project-title::before {
  content: "→";
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-width 0.3s, opacity 0.3s, margin-right 0.3s;
  margin-right: 0;
}

.project-title::after {
  content: "→";
  max-width: 1.5em;
  overflow: hidden;
  opacity: 1;
  transition: max-width 0.3s, opacity 0.3s, margin-left 0.3s;
  margin-left: 0.3em;
}

@media (hover: hover) {
  .project-card:hover .project-title::before {
    max-width: 1.5em;
    opacity: 1;
    margin-right: 0.3em;
    animation: arrow-beckon 0.8s ease-in-out 0.3s infinite;
  }

  .project-card:hover .project-title::after {
    max-width: 0;
    opacity: 0;
    margin-left: 0;
  }
}

.project-summary {
  display: block;
  margin: 0 0 var(--space-sm);
  line-height: 1.3;
}

/* ============================================
   PRODUCT LIST
   ============================================ */

.product-grid {
  display: inline;
}

.product-item {
  font-size: var(--text-base);
}

.product-item:not(:last-child)::after {
  content: " • ";
}

/* ============================================
   SONNOX PRODUCTS
   ============================================ */

.sonnox-products {
  padding-top: var(--space-sm);
  color: var(--color-text-muted);
}

.sonnox-products .product-item,
.sonnox-products .product-item a {
  color: var(--color-text-muted);
}

.sonnox-products .product-item a:hover {
  color: var(--color-accent);
}

.sonnox-products .section-title::after {
  display: none;
}

/* ============================================
   HOW I WORK
   ============================================ */

.how-i-work {
  padding: var(--space-xl) 0;
}

.how-i-work-content p {
  margin: 0 0 var(--space-md);
}

.how-i-work-content li {
  margin-bottom: var(--space-md);
}

.how-i-work-content li strong {
  font-weight: 500;
}

.how-i-work-content li >:last-child {
  color: var(--color-text);
}

/* ============================================
   PROJECT PAGE
   ============================================ */

.project-page {
  max-width: var(--prose-width);
}

@media (min-width: 80rem) {
  .project-page {
    overflow: visible;
  }
}

.project-page-title {
  font-size: var(--text-3xl);
  margin: var(--space-xl) 0 var(--space-md);
  font-weight: 700;
}

.project-page-summary {
  margin: 0 0 var(--space-lg);
}

.project-intro {
  margin-top: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.project-intro p {
  margin: 0 0 var(--space-md);
}

.project-intro p:last-child {
  margin-bottom: 0;
}

.project-meta {
  margin-bottom: var(--space-lg);
}

.project-role,
.project-contribution {
  margin-bottom: var(--space-lg);
}

.project-role h2,
.project-contribution h2 {
  font-size: var(--text-base);
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-sm);
}

.project-role p,
.project-contribution p {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.6;
}

/* ============================================
   PAGE TOC
   ============================================ */

/* Page TOC for project pages */
.page-toc {
  background: var(--color-card-bg);
  border-radius: var(--radius);
  padding: var(--space-xl) var(--space-md);
  margin: var(--space-2xl) calc(-1 * var(--space-lg) + var(--space-sm));
}

@media (min-width: 40rem) {
  .page-toc {
    padding: var(--space-xl) var(--content-overhang);
    margin: var(--space-2xl) calc(-1 * var(--content-overhang));
  }
}

.page-toc h2 {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-md);
}

.page-toc ul {
  display: flex;
  flex-direction: column;
  gap: var(--space-base);
  list-style: none;
  margin: 0;
  padding: 0;
}

.page-toc li {
  margin: 0;
  margin-top: 0.25rem;
}

.page-toc a {
  font-size: var(--text-base);
  color: var(--color-text);
  text-decoration: none;
  transition: color 0.3s;
}

.page-toc a:hover {
  color: var(--color-accent);
}

/* Hide nested TOC levels */
.page-toc ul ul {
  display: none;
}

/* ============================================
   PROJECT CONTENT
   ============================================ */

.project-content {
  margin-bottom: var(--space-2xl);
  position: relative;
}

.project-content h3 {
  margin-top: var(--space-xl);
}

.project-content img {
  margin: 1rem calc(-1 * var(--space-lg) + var(--space-sm));
  max-width: calc(100% + (var(--space-lg) - var(--space-sm)) * 2);
}

@media (min-width: 40rem) {
  .project-content img {
    margin: 1rem 0 1rem calc(-1 * var(--content-overhang));
    max-width: calc(100% + var(--content-overhang) * 2);
  }
}

.project-content p,
.project-content li {
  position: relative;
}

@media (min-width: 80rem) {
  .project-content blockquote {
    position: absolute;
    right: calc(-1 * (var(--sidenote-width) + var(--sidenote-offset)));
    width: var(--sidenote-width);
    margin: 0;
    padding: 0;
    background: transparent;
    border-left: none;
    border-radius: 0;
    font-size: var(--text-sm);
  }

  .project-content blockquote p {
    margin: 0;
  }
}

/* ============================================
   PROJECT LINKS
   ============================================ */

.project-links {
  padding-top: var(--space-xl);
  border-top: 1px solid var(--color-border);
}

.project-links h2 {
  font-size: var(--text-base);
  margin: 0 0 var(--space-md);
}

.project-links p {
  margin: var(--space-sm) 0;
}

/* ============================================
   BENTO GRID (Testimonials)
   ============================================ */

.bento-grid {
  display: grid;
  gap: var(--space-sm);
  grid-template-columns: 1fr;
  width: 100%;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-xl);
  padding: 0 var(--space-sm);
  box-sizing: border-box;
}

@media (min-width: 40rem) {
  .bento-grid {
    padding: 0 var(--space-sm);
  }

  /* Auto-detect item count and apply tailored layouts */

  /* 1 item: full width */
  .bento-grid:has(> :nth-child(1)):not(:has(> :nth-child(2))) {
    grid-template-columns: 1fr;
  }

  /* 2 items: 2 equal columns */
  .bento-grid:has(> :nth-child(2)):not(:has(> :nth-child(3))) {
    grid-template-columns: repeat(2, 1fr);
  }

  /* 3 items: 3 equal columns */
  .bento-grid:has(> :nth-child(3)):not(:has(> :nth-child(4))) {
    grid-template-columns: repeat(3, 1fr);
  }

  /* 4 items: 2×2 grid */
  .bento-grid:has(> :nth-child(4)):not(:has(> :nth-child(5))) {
    grid-template-columns: repeat(2, 1fr);
  }

  /* 5 items: 3 on top, 2 spanning bottom */
  .bento-grid:has(> :nth-child(5)):not(:has(> :nth-child(6))) {
    grid-template-columns: repeat(6, 1fr);
  }
  .bento-grid:has(> :nth-child(5)):not(:has(> :nth-child(6))) > :nth-child(1),
  .bento-grid:has(> :nth-child(5)):not(:has(> :nth-child(6))) > :nth-child(2),
  .bento-grid:has(> :nth-child(5)):not(:has(> :nth-child(6))) > :nth-child(3) {
    grid-column: span 2;
  }
  .bento-grid:has(> :nth-child(5)):not(:has(> :nth-child(6))) > :nth-child(4),
  .bento-grid:has(> :nth-child(5)):not(:has(> :nth-child(6))) > :nth-child(5) {
    grid-column: span 3;
  }

  /* 6+ items: auto-fit fallback */
  .bento-grid:has(> :nth-child(6)) {
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  }
}

/* ============================================
   TESTIMONIAL CARDS
   ============================================ */

.testimonial-card {
  background: var(--color-card-bg);
  border-radius: var(--radius);
  padding: var(--space-lg) var(--space-md);
  display: flex;
  flex-direction: column;
}

@media (min-width: 40rem) {
  .testimonial-card {
    padding: var(--space-lg);
  }
}

.testimonial-artists {
  font-size: var(--text-base);
  color: var(--color-accent);
  font-weight: 700;
}

.testimonial-name {
  color: var(--color-text-muted);
  font-weight: 600;
  margin: 0 0 var(--space-xs);
  transition: color 0.3s;
}

.testimonial-quote {
  margin: 0;
  flex: 1;
}

/* ============================================
   VIDEO CARD
   ============================================ */

.video-card {
  background: var(--color-card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  grid-column: span 2;
}

@media (max-width: 40rem) {
  .video-card {
    grid-column: span 1;
  }
}

.video-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
}

.video-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
}

/* ============================================
   IMAGE BENTO (Project pages)
   ============================================ */

.image-bento {
  display: grid;
  gap: 2px;
  padding: 2px;
  grid-template-columns: 1fr;
  background: var(--color-bento-bg);
  width: 100%;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-xl);
}

@media (min-width: 30rem) {
  .image-bento {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 40rem) {
  .image-bento {
    grid-template-columns: repeat(3, 1fr);
  }

  /* 2 items: 2 columns */
  .image-bento:has(> img:nth-of-type(2)):not(:has(> img:nth-of-type(3))) {
    grid-template-columns: repeat(2, 1fr);
  }

  /* 4 items: 2×2 grid */
  .image-bento:has(> img:nth-of-type(4)):not(:has(> img:nth-of-type(5))) {
    grid-template-columns: repeat(2, 1fr);
  }
}

.image-bento img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  border-radius: 0;
  margin: 0;
  max-width: 100%;
}

.image-bento--fixed {
  grid-auto-rows: 1fr;
}

.image-bento--fixed img {
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
}

.image-bento img.span-2 {
  grid-column: span 2;
}

.image-bento img.rows-2 {
  grid-row: span 2;
  aspect-ratio: 8 / 10;
}

.image-bento img.fit-cover {
  object-fit: cover;
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
  justify-self: stretch;
  align-self: stretch;
}

/* ============================================
   SIDENOTES
   ============================================ */

.sidenote-wrapper {
  position: relative;
}

.sidenote {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding: var(--space-sm) 0.75rem;
  background: var(--color-card-bg);
  border-radius: var(--radius);
  margin: var(--space-sm) 0;
  line-height: 1.4;
}

@media (min-width: 80rem) {
  .sidenote {
    position: absolute;
    left: 100%;
    margin-left: var(--gutter-gap);
    width: var(--sidenote-width);
    margin-top: 0;
    margin-bottom: 0;
    padding: 0;
    background: transparent;
    border-radius: 0;
    font-size: var(--text-sm);
    top: 0;
  }
}

/* ============================================
   SITE FOOTER
   ============================================ */

.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: 48rem;
  margin: var(--space-sm) auto 0;
  padding: var(--space-xl) var(--space-lg) var(--space-xl);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.site-footer span:last-child {
  display: none;
}

@media (min-width: 40rem) {
  .site-footer {
    justify-content: space-between;
  }

  .site-footer span:last-child {
    display: inline;
  }
}

.site-footer a {
  color: var(--color-text-muted);
  font-weight: 500;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--color-accent);
}

.site-footer a.footer-email {
  color: var(--color-text-muted);
}

.site-footer a.footer-email::before {
  content: "→";
  display: inline-block;
  margin-right: 0.2em;
}

@media (hover: hover) {
  .site-footer a.footer-email:hover {
    color: var(--color-text);
  }

  .site-footer a.footer-email:hover::before {
    animation: arrow-beckon 0.8s ease-in-out 0s infinite;
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes arrow-beckon {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-0.15em); }
}
