/* ============================================================
   TURN — warm modern craft-studio theme
   ============================================================ */

:root {
  --bg: #f4eee3;
  --bg-deep: #ece4d3;
  --ink: #221a12;
  --ink-soft: #5c5044;
  --muted: #998977;
  --accent: #a4682c;
  --line: rgba(34, 26, 18, 0.14);
  --card: #ffffff;
  --radius: 16px;
  --grid-columns: 4;
  --grid-gap: 14px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --head-h: 4.25rem;
}

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

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'FabrikatMono-Regular', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

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

/* === Grain overlay === */
.grain {
  position: fixed;
  inset: 0;
  z-index: 3000;
  pointer-events: none;
  opacity: 0.045;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* === Site header === */
.site-head {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  padding: 0 clamp(1.25rem, 3vw, 2.5rem);
  height: var(--head-h);
  transition: background 0.35s ease, border-color 0.35s ease, backdrop-filter 0.35s ease;
  border-bottom: 1px solid transparent;
}

.site-head.scrolled {
  background: rgba(244, 238, 227, 0.82);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom-color: var(--line);
}

.logo {
  font-family: 'FabrikatMono-Black', monospace;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
}

.logo-dot {
  color: var(--accent);
}

/* === Gallery navigation === */
nav.gallery-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem clamp(1.2rem, 2.5vw, 2.4rem);
}

nav.gallery-nav a {
  position: relative;
  font-family: 'FabrikatMono-Medium', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.45rem 0;
  cursor: pointer;
  transition: color 0.25s ease;
}

nav.gallery-nav a .nav-index {
  font-family: 'FabrikatMono-Light', monospace;
  font-size: 0.6em;
  color: var(--accent);
  margin-right: 0.45em;
  letter-spacing: 0.05em;
}

nav.gallery-nav a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.1rem;
  height: 1.5px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: right center;
  transition: transform 0.4s var(--ease-out);
}

nav.gallery-nav a:hover,
nav.gallery-nav a.active {
  color: var(--ink);
}

nav.gallery-nav a:hover::after,
nav.gallery-nav a.active::after {
  transform: scaleX(1);
  transform-origin: left center;
}

/* === Hero === */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.85;
}

.hero-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 62% 48% at 50% 46%, var(--bg) 0%, rgba(244, 238, 227, 0.55) 45%, rgba(244, 238, 227, 0) 75%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  text-align: center;
  padding: 0 1.25rem;
}

.hero-kicker {
  font-family: 'FabrikatMono-Medium', monospace;
  font-size: clamp(0.65rem, 1.4vw, 0.85rem);
  letter-spacing: 0.42em;
  text-indent: 0.42em; /* visually re-center tracked text */
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.2rem;
}

.hero-title {
  font-family: 'FabrikatMono-Black', monospace;
  font-size: clamp(5rem, 23vw, 22rem);
  line-height: 0.85;
  letter-spacing: -0.045em;
  text-transform: uppercase;
  color: var(--ink);
  overflow: hidden;
  padding: 0.04em 0.06em 0; /* keep tight glyph edges inside the clip */
  margin: 0 -0.06em;
}

.hero-title .ht-l {
  display: inline-block;
  will-change: transform;
}

.hero-sub {
  font-family: 'FabrikatMono-Light', monospace;
  font-size: clamp(0.85rem, 1.6vw, 1.05rem);
  line-height: 1.7;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  margin-top: 1.8rem;
}

.hero-scroll {
  position: absolute;
  bottom: 1.8rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  font-family: 'FabrikatMono-Light', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}

.hero-scroll-line {
  width: 1px;
  height: 3rem;
  background: var(--line);
  position: relative;
  overflow: hidden;
}

.hero-scroll-line::after {
  content: '';
  position: absolute;
  left: 0;
  top: -100%;
  width: 100%;
  height: 100%;
  background: var(--accent);
  animation: scroll-drip 2.2s var(--ease-out) infinite;
}

@keyframes scroll-drip {
  0%   { top: -100%; }
  55%  { top: 0; }
  100% { top: 100%; }
}

/* === Marquee === */
.marquee {
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--bg-deep);
}

.marquee-track {
  display: inline-flex;
  white-space: nowrap;
  padding: 0.95rem 0;
  font-family: 'FabrikatMono-Light', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-soft);
  will-change: transform;
}

.marquee-track span {
  margin-right: 2.75rem;
}

.marquee-dot {
  color: var(--accent);
}

.js .marquee-track {
  animation: marquee 30s linear infinite;
}

@keyframes marquee {
  to { transform: translateX(-50%); }
}

/* === Work / sections === */
.work {
  max-width: 1760px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 2.5rem);
  scroll-margin-top: var(--head-h);
}

.gallery-section {
  display: none;
  padding: clamp(3rem, 7vw, 5.5rem) 0 clamp(2rem, 5vw, 4rem);
}

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

.section-head {
  margin-bottom: clamp(1.8rem, 4vw, 3rem);
}

.section-index {
  font-family: 'FabrikatMono-Hairline', monospace;
  font-size: clamp(2.4rem, 5vw, 4rem);
  line-height: 1;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.section-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1.1rem;
}

.section-title {
  font-family: 'FabrikatMono-Black', monospace;
  font-size: clamp(2.2rem, 6vw, 4.4rem);
  line-height: 1;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

.section-count {
  font-family: 'FabrikatMono-Light', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.gallery-description {
  font-family: 'FabrikatMono-Light', monospace;
  font-size: 0.95rem;
  line-height: 1.7;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  max-width: 56ch;
  margin-top: 1.2rem;
}

/* === Gallery grid === */
.gallery-grid {
  columns: var(--grid-columns);
  column-gap: var(--grid-gap);
}

.gallery-section.gallery-various-projects .gallery-grid {
  columns: 3;
}

.gallery-grid figure {
  margin: 0 0 var(--grid-gap);
  break-inside: avoid;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--bg-deep);
  box-shadow: 0 1px 2px rgba(34, 26, 18, 0.06);
  transition: box-shadow 0.45s ease;
}

.gallery-grid figure:hover {
  box-shadow: 0 18px 40px -16px rgba(34, 26, 18, 0.35);
}

.gallery-grid figure img {
  width: 100%;
  height: auto;
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.7s var(--ease-out);
  will-change: transform;
}

.gallery-grid figure img.loaded {
  opacity: 1;
}

.gallery-grid figure:hover img.loaded {
  transform: scale(1.045);
}

.gallery-grid figcaption {
  position: absolute;
  left: 0.8rem;
  bottom: 0.8rem;
  font-family: 'FabrikatMono-Medium', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--bg);
  background: rgba(34, 26, 18, 0.72);
  padding: 0.35rem 0.6rem;
  border-radius: 100px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.45s var(--ease-out);
  pointer-events: none;
}

.gallery-grid figure:hover figcaption {
  opacity: 1;
  transform: translateY(0);
}

/* Scroll-in reveal (gated on .js so content is never hidden without it) */
.js .gallery-grid figure {
  opacity: 0;
  transform: translateY(28px);
}

.js .gallery-grid figure.in-view {
  opacity: 1;
  transform: none;
  transition:
    opacity 0.65s ease var(--d, 0ms),
    transform 0.9s var(--ease-out) var(--d, 0ms),
    box-shadow 0.45s ease;
}

.js .section-head {
  opacity: 0;
  transform: translateY(22px);
}

.js .section-head.in-view {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s ease, transform 0.9s var(--ease-out);
}

/* === Responsive columns === */
@media (max-width: 1400px) {
  .gallery-grid,
  .gallery-section.gallery-various-projects .gallery-grid { columns: 3; }
}

@media (max-width: 980px) {
  .gallery-grid,
  .gallery-section.gallery-various-projects .gallery-grid { columns: 2; }
}

@media (max-width: 640px) {
  .site-head {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.1rem;
    height: auto;
    padding-top: 0.8rem;
    padding-bottom: 0.8rem;
  }
  .hero-sub br { display: none; }
}

@media (max-width: 520px) {
  .gallery-grid,
  .gallery-section.gallery-various-projects .gallery-grid { columns: 1; }
  :root { --grid-gap: 12px; }
}

/* === Lightbox === */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(20, 14, 9, 0.93);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox.open {
  opacity: 1;
  visibility: visible;
}

.lightbox-img-wrap {
  position: relative;
  max-width: 90vw;
  max-height: 86vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img-wrap img {
  max-width: 90vw;
  max-height: 86vh;
  width: auto;
  object-fit: contain;
  position: absolute;
  opacity: 0;
  border-radius: 8px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7);
  transition: opacity 0.18s ease;
}

.lightbox-img-wrap img.lb-active {
  position: relative;
  opacity: 1;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  z-index: 1010;
  width: 2.9rem;
  height: 2.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(244, 238, 227, 0.3);
  border-radius: 50%;
  color: #f4eee3;
  font-family: 'FabrikatMono-Light', monospace;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease, transform 0.25s var(--ease-out);
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background: #f4eee3;
  color: #221a12;
  border-color: #f4eee3;
  transform: scale(1.06);
}

.lightbox-close {
  top: 1.2rem;
  right: 1.2rem;
  font-size: 1.4rem;
}

.lightbox-prev,
.lightbox-next {
  top: 50%;
  margin-top: -1.45rem;
}

.lightbox-prev { left: 1.2rem; }
.lightbox-next { right: 1.2rem; }

@media (max-width: 640px) {
  .lightbox-prev { left: 0.6rem; }
  .lightbox-next { right: 0.6rem; }
  .lightbox-prev, .lightbox-next { width: 2.4rem; height: 2.4rem; }
}

.lightbox-counter {
  position: absolute;
  bottom: 1.1rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'FabrikatMono-Thin', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: rgba(244, 238, 227, 0.55);
  z-index: 1010;
}

body.lb-open {
  overflow: hidden;
}

/* === Footer === */
.site-foot {
  border-top: 1px solid var(--line);
  margin-top: clamp(2rem, 6vw, 4rem);
  padding: clamp(4rem, 10vw, 7rem) clamp(1.25rem, 3vw, 2.5rem) 2.2rem;
  text-align: center;
}

.foot-big {
  font-family: 'FabrikatMono-Black', monospace;
  font-size: clamp(1.9rem, 6.5vw, 4.2rem);
  letter-spacing: -0.03em;
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: 2.6rem;
}

.foot-meta {
  font-family: 'FabrikatMono-Light', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.foot-note {
  color: var(--accent);
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .marquee-track { animation: none; }
  .hero-scroll-line::after { animation: none; top: 0; }
  .js .gallery-grid figure,
  .js .section-head {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .gallery-grid figure img,
  .gallery-grid figure,
  nav.gallery-nav a::after {
    transition-duration: 0.01ms;
  }
}
