/* ============================================
   alexvoigt.com — Base Styles
   ============================================ */

@font-face {
  font-family: 'Gutenberg';
  src: url('/assets/fonts/gutenberg-a.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

/* --- Custom Properties --- */
:root {
  /* Colors — dark base, warm accents */
  --bg-primary: #222226;
  --bg-secondary: #12121a;
  --text-primary: #e8e6e3;
  --text-secondary: #a8a8a8;
  --accent: #9863df;
  --accent-hover: #b07def;

  /* Typography */
  --font-body: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --font-size-base: 1rem;
  --font-size-4xl: 4rem;

  /* Transitions */
  --transition-base: 250ms ease;
}

/* --- Reset --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  min-height: 100vh;
  min-height: 100dvh;
}

/* --- Hero (full viewport) --- */
.hero {
  position: relative;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  overflow: hidden;
  isolation: isolate;
}

.hero__canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.hero__canvas canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
}

.hero__content {
  position: relative;
  z-index: 1;
  padding-left: 8%;
}

.hero__name {
  font-family: 'Gutenberg', Georgia, serif;
  font-size: clamp(2.5rem, 6vw, var(--font-size-4xl));
  font-weight: 400;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -0.02em;
  cursor: default;
}

.hero__name--fluid-active {
  color: transparent;
  -webkit-user-select: text;
  user-select: text;
}

.fluid-text-canvas {
  position: absolute;
  z-index: 1;
  pointer-events: auto;
}

.hero__content {
  mix-blend-mode: difference;
}

.hero__links {
  position: fixed;
  bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 1.25rem;
  z-index: 2;
}

.hero__icon {
  font-size: 1.5rem;
  text-decoration: none;
  opacity: 0.65;
  transition: opacity var(--transition-base), transform var(--transition-base);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

.hero__icon:hover {
  opacity: 1;
  transform: scale(1.15);
}

/* --- Page fade-in --- */
.page-enter {
  animation: fadeIn 0.4s ease backwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
}

/* ============================================
   Navigation
   ============================================ */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.nav__inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem max(2rem, env(safe-area-inset-left, 2rem)) 1rem max(2rem, env(safe-area-inset-right, 2rem));
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav__logo {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.nav__links {
  display: flex;
  gap: 1.75rem;
}

.nav__link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color var(--transition-base);
}

.nav__link:hover,
.nav__link.active {
  color: var(--text-primary);
}

.nav__toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.nav__toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background-color: var(--text-primary);
  border-radius: 1px;
  transition: transform var(--transition-base), opacity var(--transition-base);
}

.nav__toggle--active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__toggle--active span:nth-child(2) { opacity: 0; }
.nav__toggle--active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================
   Layout helpers
   ============================================ */
.main {
  min-height: calc(100vh - 160px);
  min-height: calc(100dvh - 160px);
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 2rem;
}

.section {
  padding: 4rem 0;
}

.section__header {
  margin-bottom: 2.5rem;
}

.section__title {
  font-size: clamp(2rem, 4vw, var(--font-size-4xl));
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.section__subtitle {
  margin-top: 0.5rem;
  color: var(--text-secondary);
  font-size: 1.05rem;
}

/* ============================================
   Grid / Cards (existing pattern)
   ============================================ */
.grid {
  display: grid;
  gap: 1.5rem;
}

.grid--2 {
  grid-template-columns: repeat(2, 1fr);
}

.card {
  display: block;
  padding: 1.5rem;
  background-color: var(--bg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color var(--transition-base), transform var(--transition-base);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.card__title {
  font-size: 1.15rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.card__description {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}

.card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  font-size: 0.8rem;
  padding: 0.2em 0.6em;
  background: rgba(152, 99, 223, 0.12);
  color: var(--accent);
  border-radius: 4px;
}

/* ============================================
   Post list (writing)
   ============================================ */
.post-list {
  display: flex;
  flex-direction: column;
}

.post-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-decoration: none;
  color: var(--text-primary);
  transition: color var(--transition-base);
}

.post-item:hover {
  color: var(--accent-hover);
}

.post-item__title {
  font-size: 1.05rem;
}

.post-item__date {
  color: var(--text-secondary);
  font-size: 0.9rem;
  white-space: nowrap;
  margin-left: 1rem;
}

/* ============================================
   Footer
   ============================================ */
.footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 2rem 0;
}

.footer__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer__copy {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.footer__links {
  display: flex;
  gap: 1.25rem;
}

.footer__link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color var(--transition-base);
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.5rem 0;
}

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

/* ============================================
   Gallery grid
   ============================================ */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.gallery-card {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  aspect-ratio: 16 / 9;
  background-color: var(--bg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: border-color var(--transition-base), transform var(--transition-base);
}

.gallery-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.gallery-card__thumb {
  position: absolute;
  inset: 0;
}

.gallery-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-card__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.25rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 60%);
}

.gallery-card__title {
  font-size: 1.1rem;
  font-weight: 500;
}

.gallery-card__description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* Source badge (hover-only) */
.gallery-card[data-source]::after {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.3rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity var(--transition-base);
  pointer-events: none;
}

.gallery-card[data-source="synthetic"]::after {
  content: "\2728";
}

.gallery-card[data-source="sourced"]::after {
  content: "\1F4F7";
}

.gallery-card--model {
  background: none;
  border: none;
  border-radius: 0;
  aspect-ratio: 4 / 3;
  width: min(100%, 300px);
}

.gallery-card--model:hover {
  border-color: transparent;
  transform: scale(1.05);
}

.gallery-card--model .gallery-card__thumb img {
  object-fit: contain;
}

.gallery-card[data-source]:hover::after {
  opacity: 1;
}

/* ============================================
   Gallery hero (full-viewport with Vanta.js)
   ============================================ */
.gallery-hero {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.gallery-hero__back {
  position: fixed;
  top: calc(1.25rem + env(safe-area-inset-top, 0px));
  left: calc(1.25rem + env(safe-area-inset-left, 0px));
  z-index: 10;
  padding: 0.5rem 1rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text-primary);
  text-decoration: none;
  background: rgba(34, 34, 38, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  transition: background var(--transition-base);
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.gallery-hero__back:hover {
  background: rgba(34, 34, 38, 0.95);
}

.gallery-hero__title {
  font-size: clamp(2rem, 4vw, var(--font-size-4xl));
  font-weight: 400;
  color: #fff;
  margin-bottom: 2rem;
  letter-spacing: -0.02em;
}

.gallery-hero__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem;
  justify-content: center;
  max-width: 640px;
  width: 100%;
}

.gallery-hero__grid:has(.gallery-card--model) {
  max-width: 1200px;
}

.gallery-hero__grid .gallery-card {
  width: min(100%, 300px);
}

.hero:has(.gallery-hero) {
  height: auto;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: visible;
}

/* ============================================
   Viewer (full-screen scene page)
   ============================================ */
.viewer {
  position: fixed;
  inset: 0;
  background-color: #000;
  overflow: hidden;
}

.viewer canvas {
  display: block;
}

.viewer__back {
  position: absolute;
  top: 1.25rem;
  left: 1.25rem;
  z-index: 10;
  padding: 0.5rem 1rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text-primary);
  text-decoration: none;
  background: rgba(34, 34, 38, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  transition: background var(--transition-base);
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.viewer__back:hover {
  background: rgba(34, 34, 38, 0.95);
}

/* Loading indicator */
.viewer__loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  text-align: center;
  transition: opacity 0.3s ease;
}

.viewer__loading--hidden {
  opacity: 0;
  pointer-events: none;
}

.viewer__loading-bar {
  width: 200px;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.viewer__loading-fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hint text */
.viewer__hint {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}

.viewer__hint--visible {
  opacity: 1;
}

.viewer__hint--hidden {
  opacity: 0;
}

/* ============================================
   About page
   ============================================ */
.about__content {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 3rem;
  margin-bottom: 3rem;
}

.about__bio p {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 1rem;
}

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

.about__sidebar h3 {
  font-size: 1.05rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.about__sidebar h3:not(:first-child) {
  margin-top: 1.5rem;
}

.about__sidebar ul {
  list-style: none;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.8;
}

.contact {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.contact h2 {
  font-size: 1.4rem;
  font-weight: 400;
}

.contact__links {
  display: flex;
  gap: 1.5rem;
  margin-top: 1.25rem;
}

.contact__link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color var(--transition-base);
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.5rem 0;
}

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

/* ============================================
   Info page (hero-style)
   ============================================ */
.info__content {
  max-width: 480px;
  text-align: center;
}

.info__content > p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.7;
}

.info__heading {
  font-size: 1.4rem;
  font-weight: 400;
  color: #fff;
  margin-top: 2.5rem;
  margin-bottom: 0.5rem;
}

.info__subtext {
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.info-legend {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.info-legend__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-primary);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  transition: background var(--transition-base), color var(--transition-base);
}

.info-legend__item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--accent-hover);
}

.info-legend__emoji {
  font-size: 1.4rem;
  width: 2rem;
  text-align: center;
  flex-shrink: 0;
}

.info-legend__label {
  font-size: 1.05rem;
}

/* ============================================
   SPA Overlay (homepage content loading)
   ============================================ */

/* Overlay container (covers viewport, hidden by default) */
.spa-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  visibility: hidden;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  transition: visibility 0s 0.4s;
}

.spa-overlay--active {
  visibility: visible;
  pointer-events: auto;
  transition: visibility 0s;
}

/* Content panel */
.spa-overlay__panel {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.spa-overlay--active .spa-overlay__panel {
  opacity: 1;
  transition: opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Scrollable content area — absolute positioning for reliable iOS scroll */
.spa-overlay__scroll {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: scroll;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  padding-top: 1rem;
  opacity: 1;
  transition: opacity 0.2s ease;
}

/* Cross-fade for content switching */
.spa-overlay__scroll--fading {
  opacity: 0;
}

.spa-overlay .gallery-hero {
  min-height: 0;
  margin: auto 0;
}

/* Body state: lock scroll, fade hero elements */
body.spa--content-visible {
  overflow: hidden;
}

.hero__content,
.hero__links {
  transition: opacity 0.4s ease, transform 0.4s ease;
}

body.spa--content-visible .hero__content {
  opacity: 0;
  transform: scale(0.95);
}

body.spa--content-visible .hero__links {
  opacity: 0;
  pointer-events: none;
}

/* Touch devices: disable fluid text canvas */
@media (hover: none) and (pointer: coarse) {
  .fluid-text-canvas {
    display: none !important;
  }
  .hero__name--fluid-active {
    color: #fff !important;
  }
  .spa-overlay__scroll {
    touch-action: pan-y;
  }
  .gallery-card[data-source]::after {
    opacity: 0.7;
  }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  :root {
    --font-size-4xl: 2.5rem;
  }

  /* Disable fluid text on mobile — prevent ghost rendering */
  .fluid-text-canvas {
    display: none !important;
  }
  .hero__name--fluid-active {
    color: #fff !important;
  }

  .nav__toggle {
    display: flex;
  }

  .nav__links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    padding: 1rem max(2rem, env(safe-area-inset-right, 2rem)) 1.5rem max(2rem, env(safe-area-inset-left, 2rem));
    background-color: var(--bg-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .nav__links--open {
    display: flex;
    z-index: 100;
  }

  .nav__links .nav__link {
    padding: 0.75rem 0;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

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

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

  .about__content {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .contact__links {
    flex-direction: column;
    gap: 0.75rem;
  }

  .footer__inner {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }

  .container {
    padding: 0 1.25rem;
  }

  .viewer__hint {
    bottom: 1.25rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 1rem;
  }

  .post-item {
    flex-direction: column;
    gap: 0.25rem;
  }

  .post-item__date {
    margin-left: 0;
  }

  .gallery-hero__grid {
    gap: 1.25rem;
  }
}

/* ============================================
   Landscape (short viewport)
   ============================================ */
@media (orientation: landscape) and (max-height: 500px) {
  .hero__links {
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    gap: 1rem;
  }
  .hero__icon {
    font-size: 1.25rem;
  }
  .hero__name {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
  }
  .gallery-hero {
    padding: 1rem;
  }
}

@media (orientation: landscape) and (max-height: 700px) and (min-width: 768px) {
  .hero__links {
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }
}

/* ============================================
   Accessibility
   ============================================ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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