/* =========================================================
   DESIGN TOKENS
   ========================================================= */
:root {
  /* Color — light mode (default) */
  --color-bg: #F4F2EE;
  --color-bg-alt: #FFFFFF;
  --color-surface-secondary: #E8E5DF;
  --color-surface-secondary-hover: #DDD9D2;
  --color-text: #111111;
  --color-text-muted: #8A8A85;
  --color-text-subtle: #B6B6B0;
  --color-rule: #E2E0DA;
  --color-dark-bg: #0A0A0A;
  --color-dark-text: #FAFAF7;
  --color-dark-text-muted: #8A8A85;

  /* Typography */
  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;

  --fs-label: 0.75rem;       /* 12px - small uppercase labels */
  --fs-meta: 0.875rem;       /* 14px - metadata, header nav */
  --fs-body: 1.0625rem;      /* 17px - project descriptions */
  --fs-h2-section: clamp(1.5rem, 2vw, 1.875rem);   /* project name */
  --fs-h1-hero: clamp(2.25rem, 4.5vw, 4.5rem);     /* hero text */
  --fs-h1-contact: clamp(2.25rem, 4vw, 4rem);      /* contact headline */
  --fs-about: clamp(1.875rem, 3vw, 3rem);          /* about prose */

  --lh-tight: 1.15;
  --lh-snug: 1.3;
  --lh-normal: 1.55;
  --lh-relaxed: 1.7;

  --ls-tight: -0.02em;
  --ls-normal: 0;
  --ls-wide: 0.08em;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;
  --space-10: 8rem;

  --gutter: clamp(1.5rem, 4vw, 4rem);

  /* Layout */
  --header-h: 72px;
  --section-min-h: 100vh;
  --section-padding-y: clamp(4rem, 8vw, 7rem);

  /* Border radius — modernized scale */
  --radius-sm: 8px;    /* small UI: hover states, scrollbar */
  --radius-md: 12px;   /* buttons, small surfaces */
  --radius-lg: 16px;   /* images, portraits, cards */
  --radius-xl: 24px;   /* large prominent containers */
}

/* Dark mode — auto-detect from OS preference */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1A1916;
    --color-bg-alt: #232220;
    --color-surface-secondary: #232220;
    --color-surface-secondary-hover: #2D2C28;
    --color-text: #F0EFEA;
    --color-text-muted: #999996;
    --color-text-subtle: #5E5D58;
    --color-rule: #2D2C28;
    --color-dark-bg: #0A0A0A;
    --color-dark-text: #F0EFEA;
    --color-dark-text-muted: #8A8A85;
  }
}

/* Manual override — user toggle via data-theme attribute takes precedence */
[data-theme="light"] {
  --color-bg: #F4F2EE;
  --color-bg-alt: #FFFFFF;
  --color-surface-secondary: #E8E5DF;
  --color-surface-secondary-hover: #DDD9D2;
  --color-text: #111111;
  --color-text-muted: #8A8A85;
  --color-text-subtle: #B6B6B0;
  --color-rule: #E2E0DA;
  --color-dark-bg: #0A0A0A;
  --color-dark-text: #FAFAF7;
  --color-dark-text-muted: #8A8A85;
}

[data-theme="dark"] {
  --color-bg: #1A1916;
  --color-bg-alt: #232220;
  --color-surface-secondary: #232220;
  --color-surface-secondary-hover: #2D2C28;
  --color-text: #F0EFEA;
  --color-text-muted: #999996;
  --color-text-subtle: #5E5D58;
  --color-rule: #2D2C28;
  --color-dark-bg: #0A0A0A;
  --color-dark-text: #F0EFEA;
  --color-dark-text-muted: #8A8A85;
}

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

html {
  scroll-behavior: smooth;
  scroll-snap-type: y mandatory;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* When user is in/past About, snap is disabled (toggled by JS) */
html.snap-off {
  scroll-snap-type: none;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  letter-spacing: var(--ls-normal);
  background-color: var(--color-bg);
  color: var(--color-text);
}

h1, h2, h3, h4, h5, h6, p, dl, dt, dd, figure {
  margin: 0;
}

dl, dd, dt {
  padding: 0;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.6;
}

/* =========================================================
   HEADER
   ========================================================= */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  background-color: var(--color-bg);
  z-index: 100;
}

.logo {
  font-size: var(--fs-meta);
  font-weight: 500;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  justify-self: start;
}

.primary-nav {
  display: flex;
  gap: var(--space-5);
  justify-self: center;
}

.primary-nav a,
.contact-link {
  font-size: var(--fs-meta);
  font-weight: 500;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}

/* =========================================================
   HERO
   ========================================================= */
.hero {
  min-height: 100vh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  padding: var(--space-6) var(--gutter);
  display: grid;
  grid-template-rows: 1fr auto;
  position: relative;
}

.hero-content {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: var(--fs-h1-hero);
  font-weight: 400;
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-tight);
  max-width: 22ch;
}

.hero-footer {
  position: absolute;
  bottom: var(--space-6);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

.hero-footer > * {
  pointer-events: auto;
}

.scroll-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  color: var(--color-text-muted);
  transition: color 0.2s ease, transform 0.2s ease;
  animation: scroll-bounce 2.4s ease-in-out infinite;
}

.scroll-indicator:hover {
  color: var(--color-text);
  opacity: 1;
}

@keyframes scroll-bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .scroll-indicator {
    animation: none;
  }
}

/* =========================================================
   PROJECT SECTION
   ========================================================= */
.project {
  min-height: var(--section-min-h);
  scroll-snap-align: start;
  scroll-snap-stop: always;
  padding: var(--section-padding-y) var(--gutter);
  display: grid;
  grid-template-columns: minmax(280px, 30%) 1fr;
  gap: clamp(2rem, 6vw, 6rem);
  align-items: center;
  border-top: 1px solid var(--color-rule);
}

.project-content {
  max-width: 36ch;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.project-label {
  font-family: var(--font-display);
  font-size: var(--fs-h2-section);
  font-weight: 500;
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-tight);
}

.project-description {
  font-size: var(--fs-body);
  line-height: var(--lh-relaxed);
  color: var(--color-text);
}

.project-meta {
  display: flex;
  flex-direction: column;
  margin-top: var(--space-4);
}

.meta-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-top: 1px solid var(--color-rule);
  font-size: var(--fs-meta);
  line-height: var(--lh-snug);
}

.meta-row:last-child {
  border-bottom: 1px solid var(--color-rule);
}

.meta-row dt {
  color: var(--color-text-muted);
  font-weight: 400;
}

.meta-row dd {
  color: var(--color-text);
  font-weight: 400;
}

.meta-row dd a {
  display: inline-block;
  margin-right: var(--space-3);
}

.read-more {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding: 0.625rem 1.125rem;
  background-color: var(--color-surface-secondary);
  color: var(--color-text);
  font-size: var(--fs-meta);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: background-color 0.2s ease;
}

.read-more:hover {
  opacity: 1;
  background-color: var(--color-surface-secondary-hover);
}

.read-more .arrow {
  color: var(--color-text);
}

.coming-soon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding: 0.625rem 1.125rem;
  background-color: transparent;
  color: var(--color-text-muted);
  font-size: var(--fs-meta);
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-rule);
}

.arrow {
  display: inline-block;
  margin-left: 2px;
  color: var(--color-text-muted);
  font-weight: 400;
}

.project-visual {
  width: 100%;
  height: 100%;
  min-height: 320px;
  max-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.project-visual img {
  width: 100%;
  height: 100%;
  max-height: 70vh;
  object-fit: contain;
  object-position: center;
  background-color: transparent;
}

/* =========================================================
   PAST WORK (horizontal scroll, tier 2)
   ========================================================= */
.past-work {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  padding: var(--section-padding-y) 0 var(--space-9);
  border-top: 1px solid var(--color-rule);
}

.past-work-label {
  padding: 0 var(--gutter);
  margin-bottom: var(--space-7);
  font-size: var(--fs-meta);
  font-weight: 500;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.past-work-scroll {
  display: flex;
  gap: clamp(2rem, 3.5vw, 3.5rem);
  overflow-x: auto;
  padding: 0 var(--gutter) var(--space-4);
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--gutter);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--color-rule) transparent;
}

.past-work-scroll::-webkit-scrollbar {
  height: 6px;
}

.past-work-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.past-work-scroll::-webkit-scrollbar-thumb {
  background: var(--color-rule);
  border-radius: 3px;
}

.work-card {
  flex: 0 0 clamp(400px, 44vw, 620px);
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  text-decoration: none;
  color: inherit;
  transition: opacity 0.2s ease;
}

.work-card:hover {
  opacity: 0.7;
}

.work-card-visual {
  height: clamp(280px, 36vh, 440px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.work-card-visual img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.work-card-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 1.9vw, 1.75rem);
  font-weight: 500;
  letter-spacing: var(--ls-tight);
  color: var(--color-text);
}

.work-card-description {
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  color: var(--color-text-muted);
}

/* =========================================================
   ABOUT
   ========================================================= */
.about {
  padding: var(--section-padding-y) var(--gutter);
  display: grid;
  grid-template-columns: minmax(280px, 30%) 1fr;
  gap: clamp(2rem, 6vw, 6rem);
  align-items: start;
  border-top: 1px solid var(--color-rule);
}

.about-portrait {
  width: 100%;
}

.about-portrait img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  filter: grayscale(100%);
}

.about-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.about-content p {
  font-size: var(--fs-about);
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-tight);
  color: var(--color-text);
}

/* =========================================================
   CONTACT FOOTER
   ========================================================= */
.contact {
  background-color: var(--color-dark-bg);
  color: var(--color-dark-text);
  padding: var(--section-padding-y) var(--gutter) var(--space-7);
  display: grid;
  grid-template-rows: auto auto auto;
  gap: var(--space-7);
}

.contact h2 {
  font-family: var(--font-display);
  font-size: var(--fs-h1-contact);
  font-weight: 400;
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-tight);
  max-width: 22ch;
}

.contact-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-6);
  max-width: 900px;
}

.contact-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.contact-label {
  font-size: var(--fs-body);
  font-weight: 500;
}

.contact-value {
  font-size: var(--fs-meta);
  color: var(--color-dark-text-muted);
}

.contact-copyright {
  font-size: var(--fs-meta);
  font-weight: 500;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--color-dark-text-muted);
  text-align: right;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 900px) {
  .site-header {
    grid-template-columns: auto auto;
    grid-template-rows: auto;
  }

  .logo {
    grid-column: 1;
  }

  .primary-nav {
    display: none;
  }

  .header-actions {
    display: none;
  }

  .site-header {
    grid-template-columns: 1fr auto;
  }

  .hero {
    padding-top: calc(var(--header-h) + var(--space-6));
    padding-bottom: calc(var(--header-h) + var(--space-6));
  }

  .hero h1 {
    max-width: none;
  }

  .project,
  .about {
    grid-template-columns: 1fr;
    min-height: auto;
    gap: var(--space-7);
  }

  .past-work {
    min-height: auto;
    justify-content: flex-start;
  }

  html,
  html.snap-off {
    scroll-snap-type: none;
  }

  .project-content {
    max-width: none;
  }

  .project-visual {
    order: -1;
    min-height: 240px;
    max-height: 50vh;
  }

  .about-portrait {
    max-width: none;
  }

  .about-portrait img {
    aspect-ratio: 1 / 1;
    object-fit: cover;
    object-position: center 20%;
  }

  .meta-row {
    grid-template-columns: 80px 1fr;
  }

  .work-card {
    flex: 0 0 75vw;
  }

  .work-card-visual {
    height: auto;
    aspect-ratio: 4 / 3;
  }

  .contact {
    min-height: auto;
    gap: var(--space-7);
  }

  .contact-links {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  :root {
    --gutter: 1.25rem;
  }
}

/* =========================================================
   PAGINATION DOTS
   ========================================================= */
.pagination {
  position: fixed;
  right: var(--gutter);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 18px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
}

.pagination.visible {
  opacity: 1;
  pointer-events: auto;
}

.pagination-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-rule);
  display: block;
  transition: background-color 200ms ease, transform 200ms ease;
  position: relative;
  text-decoration: none;
}

/* Invisible larger hit area for better click target */
.pagination-dot::before {
  content: '';
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
}

.pagination-dot:hover {
  background-color: var(--color-text);
  transform: scale(1.3);
}

.pagination-dot.active {
  background-color: var(--color-text);
  transform: scale(1.4);
}

.pagination-dot:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 4px;
}

/* Hide on small viewports — rely on native swipe */
@media (max-width: 900px) {
  .pagination {
    display: none;
  }
}

/* On desktop, reserve a column on the right for pagination dots
   so content has equal gutter spacing on both sides of the dots.
   Hero is excluded because pagination dots are hidden there — the
   centered h1 should sit on the true viewport center. */
@media (min-width: 901px) {
  .project,
  .about,
  .contact,
  .past-work-label,
  .past-work-scroll {
    padding-right: calc(2 * var(--gutter) + 8px);
  }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-snap-type: none;
    scroll-behavior: auto;
  }
  .pagination,
  .pagination-dot {
    transition: none;
  }
}

/* =========================================================
   MOBILE MENU
   ========================================================= */

/* Hamburger button — hidden on desktop */
.mobile-menu-button {
  display: none;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  width: 44px;
  height: 44px;
  position: relative;
  justify-self: end;
}

.hamburger-line {
  display: block;
  position: absolute;
  left: 8px;
  width: 28px;
  height: 1.5px;
  background-color: var(--color-text);
  transition: transform 0.25s ease, opacity 0.15s ease, top 0.25s ease;
}

.hamburger-line:nth-child(1) { top: 16px; }
.hamburger-line:nth-child(2) { top: 22px; }
.hamburger-line:nth-child(3) { top: 28px; }

/* Hamburger transforms to X when menu is open */
.mobile-menu-button[aria-expanded="true"] .hamburger-line:nth-child(1) {
  top: 22px;
  transform: rotate(45deg);
}
.mobile-menu-button[aria-expanded="true"] .hamburger-line:nth-child(2) {
  opacity: 0;
}
.mobile-menu-button[aria-expanded="true"] .hamburger-line:nth-child(3) {
  top: 22px;
  transform: rotate(-45deg);
}

/* Mobile menu overlay — fills viewport below header */
.mobile-menu {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-bg);
  z-index: 95;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
}

.mobile-menu.open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-menu-nav {
  display: flex;
  flex-direction: column;
  padding: var(--space-7) var(--gutter);
  gap: var(--space-2);
}

.mobile-menu-nav a {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 500;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--color-text);
  text-decoration: none;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-rule);
}

.mobile-menu-nav a:last-child {
  border-bottom: none;
}

/* Show hamburger and hide desktop nav items on mobile */
@media (max-width: 900px) {
  .mobile-menu-button {
    display: block;
  }
}

/* Hide mobile menu on desktop */
@media (min-width: 901px) {
  .mobile-menu {
    display: none;
  }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .hamburger-line,
  .mobile-menu {
    transition: none;
  }
}

/* =========================================================
   THEME TOGGLE
   ========================================================= */

/* Smooth theme transition */
html, body {
  transition: background-color 250ms ease, color 250ms ease;
}

.theme-toggle {
  background: transparent;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s ease;
}

.theme-toggle:hover {
  background-color: var(--color-surface-secondary);
}

.theme-toggle svg {
  display: block;
  width: 18px;
  height: 18px;
}

/* Default (light mode): show moon icon (click to switch to dark) */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

/* OS dark mode (no manual override): show sun icon */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  html:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* Manual dark override: show sun icon */
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Manual light override: show moon icon */
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* Header actions wrapper (theme toggle + contact link) */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  justify-self: end;
}

/* Hide header actions wrapper (theme toggle + contact link) on mobile —
   theme toggle goes into the hamburger menu, contact is in there too */
@media (max-width: 900px) {
  .header-actions {
    display: none;
  }
}

/* Theme toggle inside mobile menu — uses a switch instead of icons */
.mobile-menu-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) 0;
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 500;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--color-text);
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.mobile-menu-theme-toggle:hover {
  background-color: transparent;
}

/* Toggle switch UI — Material 3 inspired */
.toggle-switch {
  position: relative;
  width: 52px;
  height: 32px;
  background-color: transparent;
  border: 2px solid var(--color-text-subtle);
  border-radius: 16px;
  transition: background-color 220ms cubic-bezier(0.2, 0, 0, 1), border-color 220ms cubic-bezier(0.2, 0, 0, 1);
  flex-shrink: 0;
  box-sizing: border-box;
}

.toggle-switch-thumb {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 16px;
  height: 16px;
  background-color: var(--color-text-subtle);
  border-radius: 50%;
  transition: width 220ms cubic-bezier(0.2, 0, 0, 1),
              height 220ms cubic-bezier(0.2, 0, 0, 1),
              top 220ms cubic-bezier(0.2, 0, 0, 1),
              left 220ms cubic-bezier(0.2, 0, 0, 1),
              background-color 220ms ease;
}

/* When dark mode is active (manual override) — toggle ON state */
[data-theme="dark"] .toggle-switch {
  background-color: var(--color-text);
  border-color: var(--color-text);
}

[data-theme="dark"] .toggle-switch-thumb {
  width: 24px;
  height: 24px;
  top: 2px;
  left: 22px;
  background-color: var(--color-bg);
}

/* When OS is dark and no manual override — toggle ON state */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .toggle-switch {
    background-color: var(--color-text);
    border-color: var(--color-text);
  }
  html:not([data-theme="light"]) .toggle-switch-thumb {
    width: 24px;
    height: 24px;
    top: 2px;
    left: 22px;
    background-color: var(--color-bg);
  }
}
