/* ==========================================================================
   GEOTHM — main.css
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design Tokens
   -------------------------------------------------------------------------- */

:root {
  /* Typography */
  --font-serif:  'Georgia', 'Times New Roman', serif;
  --font-sans:   system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Courier New', monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  2rem;
  --text-4xl:  2.75rem;
  --text-5xl:  3.5rem;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Layout */
  --content-max:       1280px;
  --prose-max:         68ch;
  --stage-panel-width: 42%;
  --header-height:     56px;

  /* Light mode colors */
  --color-bg:           #faf9f7;
  --color-surface:      #ffffff;
  --color-surface-alt:  #f4f3f0;
  --color-border:       #e0ddd6;
  --color-text:         #18170f;
  --color-text-muted:   #6b6860;
  --color-text-subtle:  #a09e98;
  --color-accent:       #1a1a1a;
  --color-accent-hover: #000000;
  --color-link:         #2563eb;
  --color-code-bg:      #f0eeea;
  --color-code-border:  #dddad3;

  /* Carousel */
  --carousel-overlay-start: rgba(0,0,0,0.80);
  --carousel-overlay-mid:   rgba(0,0,0,0.25);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10), 0 2px 4px rgba(0,0,0,0.06);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 500ms ease;

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

[data-theme="dark"] {
  --color-bg:           #0e0d0b;
  --color-surface:      #1a1917;
  --color-surface-alt:  #222120;
  --color-border:       #2e2d2a;
  --color-text:         #e8e5de;
  --color-text-muted:   #9b9890;
  --color-text-subtle:  #6b6860;
  --color-accent:       #e8e5de;
  --color-accent-hover: #ffffff;
  --color-link:         #60a5fa;
  --color-code-bg:      #1e1d1b;
  --color-code-border:  #2e2d2a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.30);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.40);
}

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


/* --------------------------------------------------------------------------
   2. Reset + Base
   -------------------------------------------------------------------------- */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

img, svg, video {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

ul, ol {
  list-style: none;
}


/* --------------------------------------------------------------------------
   3. Site Header
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.site-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text);
  text-decoration: none;
}

.site-logo__mark {
  font-size: var(--text-xl);
  opacity: 0.7;
  line-height: 1;
}

.site-logo__name {
  font-size: var(--text-lg);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.site-nav__link {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color var(--transition-fast);
}

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

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: var(--text-base);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.theme-toggle:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}


/* --------------------------------------------------------------------------
   4. Homepage Carousel
   -------------------------------------------------------------------------- */

.carousel {
  position: relative;
  width: 100%;
  height: calc(100svh - var(--header-height));
  overflow: hidden;
  background: var(--color-accent);
  outline: none;
}

.carousel:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: -2px;
}

.carousel__track {
  width: 100%;
  height: 100%;
  position: relative;
}

.carousel__slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--transition-slow);
  pointer-events: none;
}

.carousel__slide.is-active {
  opacity: 1;
  pointer-events: auto;
}

.carousel__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.carousel__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    var(--carousel-overlay-start) 0%,
    var(--carousel-overlay-mid) 55%,
    transparent 100%
  );
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--space-16) var(--space-12);
}

.carousel__category {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.7);
  margin-bottom: var(--space-3);
}

.carousel__title {
  font-size: var(--text-4xl);
  font-family: var(--font-serif);
  font-weight: normal;
  line-height: 1.15;
  margin-bottom: var(--space-4);
  max-width: 640px;
}

.carousel__title a {
  color: white;
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.carousel__title a:hover {
  opacity: 0.85;
}

.carousel__desc {
  font-size: var(--text-base);
  color: rgba(255,255,255,0.75);
  max-width: 480px;
  line-height: 1.6;
}

.carousel__btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: white;
  font-size: var(--text-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.2);
  transition: background var(--transition-fast);
  z-index: 10;
}

.carousel__btn:hover {
  background: rgba(255,255,255,0.25);
}

.carousel__btn--prev { left: var(--space-6); }
.carousel__btn--next { right: var(--space-6); }

.carousel__dots {
  position: absolute;
  bottom: var(--space-8);
  right: var(--space-12);
  display: flex;
  gap: var(--space-2);
}

.carousel__dot {
  width: 24px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.35);
  transition: background var(--transition-base), width var(--transition-base);
}

.carousel__dot.is-active {
  background: rgba(255,255,255,0.9);
  width: 36px;
}


/* --------------------------------------------------------------------------
   5. Home: Recent Works Section
   -------------------------------------------------------------------------- */

.home-recent {
  padding: var(--space-16) var(--space-8);
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
}

.section-heading {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-8);
}

.home-recent .works-grid {
  margin-bottom: var(--space-10);
}


/* --------------------------------------------------------------------------
   6. Works Grid + Cards
   -------------------------------------------------------------------------- */

.works-header {
  padding: var(--space-16) var(--space-8) var(--space-8);
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-8);
}

.works-header h1 {
  font-size: var(--text-4xl);
  font-family: var(--font-serif);
  font-weight: normal;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-3);
}

.works-header p {
  color: var(--color-text-muted);
  font-size: var(--text-lg);
}

.works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-6);
}

.work-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.work-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.work-card__link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.work-card__image-wrap {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--color-surface-alt);
}

.work-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.work-card:hover .work-card__image {
  transform: scale(1.04);
}

.work-card__body {
  padding: var(--space-5) var(--space-6);
}

.work-card__tag {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
  display: block;
  margin-bottom: var(--space-2);
}

.work-card__title {
  font-size: var(--text-lg);
  font-family: var(--font-serif);
  font-weight: normal;
  line-height: 1.35;
  margin-bottom: var(--space-2);
  color: var(--color-text);
}


/* --------------------------------------------------------------------------
   7. Category Nav + Pagination
   -------------------------------------------------------------------------- */

.category-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 0 var(--space-8) var(--space-8);
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
}

.category-nav__item {
  padding: var(--space-2) var(--space-4);
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: all var(--transition-fast);
  cursor: default;
}

a.category-nav__item {
  cursor: pointer;
}

a.category-nav__item:hover {
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

.category-nav__item.is-active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-bg);
}

[data-theme="dark"] .category-nav__item.is-active {
  background: var(--color-text);
  border-color: var(--color-text);
  color: var(--color-bg);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding-top: var(--space-12);
}

.pagination__btn {
  padding: var(--space-2) var(--space-6);
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  text-decoration: none;
  transition: all var(--transition-fast);
}

a.pagination__btn:hover {
  border-color: var(--color-text-muted);
  background: var(--color-surface-alt);
}

.pagination__btn.is-disabled {
  color: var(--color-text-subtle);
  border-color: var(--color-border);
  pointer-events: none;
}

.pagination__info {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  min-width: 4ch;
  text-align: center;
}

.works-grid-wrapper {
  padding: 0 var(--space-8) var(--space-16);
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
}


/* --------------------------------------------------------------------------
   8. Two-Column Work Layout
   -------------------------------------------------------------------------- */

.work-layout {
  display: flex;
  min-height: calc(100dvh - var(--header-height));
  align-items: flex-start;
}

/* LEFT: sticky stage viewer */
.work-stages {
  width: var(--stage-panel-width);
  flex-shrink: 0;
  position: sticky;
  top: var(--header-height);
  height: calc(100dvh - var(--header-height));
  display: flex;
  flex-direction: column;
  background: var(--color-surface-alt);
  border-right: 1px solid var(--color-border);
  overflow: hidden;
}

.stage-images {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  overflow: hidden;
  background: #0e0d0b;
}

.stage-image {
  position: absolute;
  inset: var(--space-8);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-slow);
  pointer-events: none;
}

.stage-image.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.stage-image img,
.stage-image svg {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: var(--radius-md);
}

/* Progress bar */
.stage-progress {
  padding: var(--space-4) var(--space-8) var(--space-6);
  border-top: 1px solid var(--color-border);
}

.stage-progress__track {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}

/* Progress steps are now buttons */
.stage-progress__step {
  height: 4px;
  flex: 1;
  background: var(--color-border);
  border-radius: 2px;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background var(--transition-base), transform var(--transition-fast);
  /* Extend click target above/below */
  position: relative;
}

.stage-progress__step::before {
  content: '';
  position: absolute;
  inset: -6px 0;
}

.stage-progress__step:hover {
  background: var(--color-text-muted);
  transform: scaleY(1.5);
}

.stage-progress__step.is-active {
  background: var(--color-text);
}

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

.stage-progress__label {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  letter-spacing: 0.04em;
}

/* Manual stage navigation buttons */
.stage-nav {
  display: flex;
  gap: var(--space-1);
}

.stage-nav__btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.stage-nav__btn:hover:not(:disabled) {
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

.stage-nav__btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* RIGHT: scrollable post content */
.work-content {
  flex: 1;
  min-width: 0;
  padding: var(--space-16) var(--space-12);
}

/* Shortcode sentinel: invisible, zero height */
.stage-sentinel {
  height: 0;
  overflow: hidden;
  visibility: hidden;
  margin: 0;
  padding: 0;
}


/* --------------------------------------------------------------------------
   9. Work Post Header + Meta
   -------------------------------------------------------------------------- */

.work-header {
  margin-bottom: var(--space-12);
  padding-bottom: var(--space-8);
  border-bottom: 1px solid var(--color-border);
}

.work-meta__category {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
  margin-bottom: var(--space-3);
}

.work-title {
  font-size: var(--text-4xl);
  font-family: var(--font-serif);
  font-weight: normal;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: var(--space-4);
  color: var(--color-text);
}


.work-description {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  line-height: 1.6;
  max-width: var(--prose-max);
}

.work-footer {
  margin-top: var(--space-16);
  padding-top: var(--space-8);
  border-top: 1px solid var(--color-border);
}


/* --------------------------------------------------------------------------
   10. Prose (blog post body)
   -------------------------------------------------------------------------- */

.prose {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  line-height: 1.8;
  color: var(--color-text);
  max-width: var(--prose-max);
}

.prose h2 {
  font-family: var(--font-sans);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: var(--space-12);
  margin-bottom: var(--space-4);
  color: var(--color-text);
}

.prose h3 {
  font-family: var(--font-sans);
  font-size: var(--text-xl);
  font-weight: 600;
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
  color: var(--color-text);
}

.prose p {
  margin-bottom: var(--space-5);
}

.prose ul,
.prose ol {
  list-style: revert;
  padding-left: var(--space-6);
  margin-bottom: var(--space-5);
}

.prose li {
  margin-bottom: var(--space-2);
}

.prose a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

.prose strong {
  font-weight: 700;
  color: var(--color-text);
}

.prose em {
  font-style: italic;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-code-bg);
  border: 1px solid var(--color-code-border);
  border-radius: var(--radius-sm);
  padding: 0.15em 0.4em;
  color: var(--color-text);
}

.prose pre {
  background: var(--color-code-bg);
  border: 1px solid var(--color-code-border);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  overflow-x: auto;
  margin-bottom: var(--space-6);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

.prose blockquote {
  border-left: 3px solid var(--color-border);
  padding-left: var(--space-5);
  color: var(--color-text-muted);
  font-style: italic;
  margin-bottom: var(--space-5);
}

.prose hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-10) 0;
}

/* Syntax highlighting classes from Chroma (dracula) */
.prose .highlight {
  margin-bottom: var(--space-6);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.prose .highlight pre {
  margin: 0;
  border-radius: 0;
  border: none;
  background: #282a36;
}


/* --------------------------------------------------------------------------
   11. Buttons
   -------------------------------------------------------------------------- */

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  background: var(--color-accent);
  color: var(--color-bg);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  border-color: var(--color-text-muted);
  color: var(--color-text);
}


/* --------------------------------------------------------------------------
   12. Site Footer
   -------------------------------------------------------------------------- */

.site-footer {
  padding: var(--space-8);
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.site-footer__copy {
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}


/* --------------------------------------------------------------------------
   13. Responsive Breakpoints
   -------------------------------------------------------------------------- */

/* Tablet: stack two-column layout */
@media (max-width: 960px) {
  .work-layout {
    flex-direction: column;
  }

  .work-stages {
    position: relative;
    top: 0;
    width: 100%;
    height: 65vw;
    min-height: 320px;
    max-height: 520px;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .work-content {
    padding: var(--space-10) var(--space-6);
  }
}

/* Mobile */
@media (max-width: 640px) {
  .carousel {
    height: calc(100svh - var(--header-height));
  }

  .carousel__overlay {
    padding: var(--space-8) var(--space-6);
  }

  .carousel__title {
    font-size: var(--text-2xl);
  }

  .carousel__btn {
    display: none;
  }

  .carousel__dots {
    right: var(--space-6);
    bottom: var(--space-6);
  }

  .site-header {
    padding: 0 var(--space-4);
  }

  .works-header {
    padding: var(--space-10) var(--space-4) var(--space-6);
  }

  .works-header h1 {
    font-size: var(--text-3xl);
  }

  .category-nav {
    padding: 0 var(--space-4) var(--space-6);
  }

  .works-grid-wrapper {
    padding: 0 var(--space-4) var(--space-10);
  }

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

  .home-recent {
    padding: var(--space-10) var(--space-4);
  }

  .work-title {
    font-size: var(--text-3xl);
  }

  .work-content {
    padding: var(--space-8) var(--space-4);
  }
}
