/* Barebones layout — Helvetica, cream background, thin black rules */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Helvetica, Arial, sans-serif;
  background: #f5f0e6;
  color: #111;
  line-height: 1.5;
}

/* Custom cursor: inverts pixels under the dot (difference blend) */
#custom-cursor {
  display: none;
  position: fixed;
  width: calc(14px * 1.75);
  height: calc(14px * 1.75);
  margin: calc(-14px * 1.75 / 2) 0 0 calc(-14px * 1.75 / 2);
  border-radius: 50%;
  background: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
  z-index: 2147483646;
  transform-origin: center center;
  will-change: transform;
}

html.has-custom-cursor #custom-cursor {
  display: block;
}

html.has-custom-cursor,
html.has-custom-cursor body,
html.has-custom-cursor button,
html.has-custom-cursor a,
html.has-custom-cursor [role="button"] {
  cursor: none !important;
}

#custom-cursor.is-clicking {
  animation: custom-cursor-click 0.42s cubic-bezier(0.34, 1.45, 0.64, 1) forwards;
}

@keyframes custom-cursor-click {
  0% {
    transform: scale(1);
  }
  28% {
    transform: scale(0.48);
  }
  55% {
    transform: scale(1.22);
  }
  100% {
    transform: scale(1);
  }
}

@media (pointer: coarse) {
  html.has-custom-cursor,
  html.has-custom-cursor body,
  html.has-custom-cursor button,
  html.has-custom-cursor a {
    cursor: auto !important;
  }

  html.has-custom-cursor #custom-cursor {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.has-custom-cursor,
  html.has-custom-cursor body,
  html.has-custom-cursor button,
  html.has-custom-cursor a {
    cursor: auto !important;
  }

  #custom-cursor {
    display: none !important;
  }

  #custom-cursor.is-clicking {
    animation: none;
  }
}

a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-thickness: 2px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: #f5f0e6;
  border-bottom: 1px solid #000;
}

.brand {
  font-weight: 700;
  text-decoration: none;
}

.brand:hover {
  text-decoration: underline;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
}

.site-nav a {
  text-decoration: none;
  font-size: 0.9375rem;
}

.site-nav a:hover {
  text-decoration: underline;
}

.site-nav a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Full-width, top-left content like Projects (not a centered narrow column) */
main {
  max-width: none;
  margin: 0;
  padding: 1.25rem 1.25rem 2rem;
}

/* Home — main column centered in the viewport; copy stays left-aligned */
main.main--home {
  min-height: calc(100vh - 4.75rem);
  min-height: calc(100dvh - 4.75rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

main.main--home #section-home {
  max-width: 38rem;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
}

/* Narrow reading column — writing post only */
main.main--article {
  max-width: 38rem;
  margin-left: auto;
  margin-right: auto;
  padding: 2rem 1.25rem 4rem;
}

/* Project detail — full width, huge carousel, wider centered copy */
main.main--project-article {
  max-width: none;
  margin: 0;
  padding: 1rem 1.25rem 2.5rem;
}

/* Same centered column as title, rule, and body (76rem) */
main.main--project-article .writing-article-back {
  max-width: 76rem;
  margin: 0 auto 1rem;
  text-align: left;
}

main.main--project-article .project-article-gallery {
  width: 100%;
  max-width: 76rem;
  margin-left: auto;
  margin-right: auto;
  margin-top: 0.25rem;
  margin-bottom: 1.75rem;
  padding: 0;
}

/* Wider peek of prev/next slide (~10% each side + gap) */
main.main--project-article .project-carousel-slide {
  flex-basis: 80%;
  display: flex;
  align-items: center;
  justify-content: center;
}

main.main--project-article .project-carousel-slide--solo {
  flex-basis: 100%;
}

main.main--project-article .project-carousel-slide img {
  display: block;
  max-width: 100%;
  max-height: min(88vh, 1400px);
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid #000;
  background: #fff;
}

/* Title + meta centered; body left-aligned for readable paragraphs */
main.main--project-article .writing-article-header {
  max-width: 76rem;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

main.main--project-article .writing-article-body {
  max-width: 76rem;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
}

main.main--project-article .project-article.section h1 {
  text-align: center;
}

main.main--project-article .writing-article-meta {
  text-align: center;
}

main.main--project-article .writing-article-body p {
  text-align: left;
}

/* Art — multi-column masonry: same width per column, packed top-to-bottom (no row dead space) */
.art-grid {
  column-count: 3;
  column-gap: 1rem;
  margin-top: 1.5rem;
}

.art-grid img {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: 1rem;
  break-inside: avoid;
  page-break-inside: avoid;
  -webkit-column-break-inside: avoid;
  background: #fff;
}

@media (max-width: 48rem) {
  .art-grid {
    column-count: 2;
  }
}

@media (max-width: 28rem) {
  .art-grid {
    column-count: 1;
  }
}

.section {
  display: none;
}

.section.is-active {
  display: block;
}

/* View transition: content fades in and eases down from above (title first via stagger) */
@keyframes section-enter {
  from {
    opacity: 0;
    transform: translateY(-14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section.is-active > * {
  opacity: 0;
  animation: section-enter 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.section.is-active > *:nth-child(1) {
  animation-delay: 0.03s;
}
.section.is-active > *:nth-child(2) {
  animation-delay: 0.08s;
}
.section.is-active > *:nth-child(3) {
  animation-delay: 0.13s;
}
.section.is-active > *:nth-child(4) {
  animation-delay: 0.18s;
}
.section.is-active > *:nth-child(5) {
  animation-delay: 0.23s;
}
.section.is-active > *:nth-child(6) {
  animation-delay: 0.28s;
}
.section.is-active > *:nth-child(7) {
  animation-delay: 0.33s;
}
.section.is-active > *:nth-child(8) {
  animation-delay: 0.38s;
}
.section.is-active > *:nth-child(9) {
  animation-delay: 0.43s;
}
.section.is-active > *:nth-child(10) {
  animation-delay: 0.48s;
}
.section.is-active > *:nth-child(11) {
  animation-delay: 0.53s;
}
.section.is-active > *:nth-child(12) {
  animation-delay: 0.58s;
}

@media (prefers-reduced-motion: reduce) {
  .section.is-active > * {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* Page titles: upper left, full width of main (same intent as Projects) */
.section > h1,
#section-home .home-intro {
  text-align: left;
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

.section h1 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  font-weight: 700;
}

#section-home .home-intro {
  margin: 0 0 1rem;
}

.writing-article.section h1,
.project-article.section h1 {
  text-align: left;
  font-size: 1.75rem;
  line-height: 1.25;
}

.project-article-gallery {
  margin: 0 0 1.5rem;
}

.project-article-gallery[hidden] {
  display: none !important;
}

.project-carousel-shell {
  width: 100%;
}

/* Arrows sit on the image strip (overlay), not at screen edges */
.project-carousel-viewport-wrap {
  position: relative;
  width: 100%;
}

.project-carousel-btn--overlay {
  position: absolute;
  top: 50%;
  z-index: 2;
  transform: translateY(-50%);
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0.25rem 0.45rem;
  /* Invert underlying image (same idea as #custom-cursor) so arrows stay visible on any slide */
  color: #fff;
  background: transparent;
  border: none;
  mix-blend-mode: difference;
}

#project-carousel-prev.project-carousel-btn--overlay {
  left: 0.35rem;
}

#project-carousel-next.project-carousel-btn--overlay {
  right: 0.35rem;
}

.project-carousel-counter-row {
  margin: 0.6rem 0 0;
  text-align: center;
  font-size: 0.8125rem;
}

.project-carousel-counter-row[hidden] {
  display: none !important;
}

.project-carousel-btn--overlay[hidden] {
  display: none !important;
}

/* Horizontal carousel — main slide ~88% width so next/prev peek (Photos-style) */
.project-carousel-viewport {
  overflow: hidden;
  width: 100%;
}

.project-carousel-track {
  display: flex;
  gap: 0.65rem;
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.project-carousel-slide {
  flex: 0 0 88%;
  min-width: 0;
}

.project-carousel-slide--solo {
  flex-basis: 100%;
}

.project-carousel-slide img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #000;
  background: #fff;
}

.project-carousel-btn {
  font: inherit;
  padding: 0.35rem 0.75rem;
  background: transparent;
  border: 1px solid #000;
  cursor: pointer;
}

.project-carousel-btn.project-carousel-btn--overlay {
  border: none;
  padding: 0.25rem 0.45rem;
  mix-blend-mode: difference;
}

.project-carousel-btn--overlay:hover:not(:disabled) {
  background: transparent;
  text-decoration: none;
  opacity: 0.92;
}

.project-carousel-btn:hover:not(:disabled) {
  text-decoration: underline;
}

.project-carousel-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.project-carousel-counter {
  font-size: 0.8125rem;
  min-width: 3.5rem;
  text-align: center;
}

.project-article .writing-article-meta:empty {
  display: none;
}

.section p {
  margin: 0 0 1rem;
}

.section-lead {
  margin: 0 0 0.5rem;
  font-size: 0.9375rem;
}

.section code {
  font-size: 0.875em;
}

.home-intro {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

/* Projects — landscape image ratio (≈16:10), title + line below; scales with column width */
.project-grid {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 52rem) {
  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 32rem) {
  .project-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

a.project-card {
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}

/* Light sweep from top — enters with strong ease-out (log-like deceleration); leaves slower and softer */
a.project-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.58);
  transform: scaleY(0);
  transform-origin: top center;
  transition: transform 0.95s cubic-bezier(0.5, 0.02, 0.55, 0.98);
}

a.project-card:hover::before {
  transform: scaleY(1);
  transition: transform 0.62s cubic-bezier(0.18, 0.82, 0.22, 1);
}

.project-card {
  margin: 0;
  padding: 0;
  border: 1px solid #000;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  transition: outline-offset 0.05s ease;
}

.project-card:focus {
  outline: 1px solid #000;
  outline-offset: 2px;
}

.project-card:focus:not(:focus-visible) {
  outline: none;
}

.project-card:focus-visible {
  outline: 1px solid #000;
  outline-offset: 2px;
}

.project-card-img-wrap {
  position: relative;
  z-index: 0;
  width: 100%;
  aspect-ratio: 16 / 10;
  flex-shrink: 0;
  border-bottom: 1px solid #000;
  overflow: hidden;
  background: #fff;
}

.project-card-img-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.project-card-inner {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  padding: 0.65rem 0.65rem 0.75rem;
  min-height: 4.25rem;
}

.project-card h2 {
  margin: 0 0 0.25rem;
  font-size: 0.875rem;
  font-weight: 700;
}

.project-card p {
  margin: 0;
  font-size: 0.8125rem;
}

/* Writing — index list */
.writings-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  border-top: 1px solid #000;
}

.writings-list li {
  margin: 0;
  padding: 0;
  border-bottom: 1px solid #000;
}

.writings-list a {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding: 0.75rem 0;
  text-decoration: none;
  color: inherit;
}

.writings-list a::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.52);
  transform: scaleY(0);
  transform-origin: top center;
  transition: transform 0.95s cubic-bezier(0.5, 0.02, 0.55, 0.98);
}

.writings-list a:hover::before {
  transform: scaleY(1);
  transition: transform 0.62s cubic-bezier(0.18, 0.82, 0.22, 1);
}

.writings-list a:hover .title {
  text-decoration: underline;
}

.writings-list a .title,
.writings-list a time {
  position: relative;
  z-index: 1;
  transition: color 0.5s cubic-bezier(0.18, 0.82, 0.22, 1);
}

.writings-list a:hover .title,
.writings-list a:hover time {
  color: #3f3f3f;
}

.writings-list .title {
  font-weight: 700;
}

.writings-list time {
  font-size: 0.875rem;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  a.project-card::before,
  .writings-list a::before {
    transition: opacity 0.22s ease;
    transform: none;
    opacity: 0;
    background: rgba(255, 255, 255, 0.42);
  }

  a.project-card:hover::before,
  .writings-list a:hover::before {
    opacity: 1;
  }

  .writings-list a .title,
  .writings-list a time {
    transition: color 0.15s ease;
  }
}

/* Writing — single post (distinct from index list) */
.writing-article-back {
  margin: 0 0 1.5rem;
  font-size: 0.9375rem;
}

.writing-article-back a {
  text-decoration: none;
}

.writing-article-back a:hover {
  text-decoration: underline;
}

.writing-article-header {
  margin: 0 0 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #000;
}

.writing-article-meta {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
}

.writing-article-body {
  font-size: 1.0625rem;
  line-height: 1.65;
}

.writing-article-body p {
  margin: 0 0 1.15rem;
}

.writing-article-body .writing-article-subheading {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 1.65rem 0 0.65rem;
}

.writing-article-body .writing-article-subheading:first-child {
  margin-top: 0;
}

.writing-article-body p:last-child {
  margin-bottom: 0;
}

/* Contact */
.contact-block {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid #000;
}

.contact-block p {
  margin: 0 0 0.5rem;
}

.contact-block p:last-child {
  margin-bottom: 0;
}

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