/* ── Tokens ── */
:root {
  /* Color */
  --color-bg: #101010;
  --color-text: #fff;
  --color-accent: #FFA303;
  --color-text-muted: rgb(156, 156, 156);

  /* Typography */
  --font-family: 'Rams', sans-serif;

  --font-size-lg: clamp(1.4rem, 0.3rem + 2vw, 2.5rem);
  --line-height-lg: 1;
  --letter-spacing-lg: -0.02em;

  --font-size-md: clamp(1.25rem, 0.4rem + 1.4vw, 1.8rem);
  --line-height-md: 1.1;
  --letter-spacing-md: -0.01em;

  --font-size-sm: clamp(1rem, 0.3rem + 1vw, 1.25rem);
  --line-height-sm: 1.25;
  --letter-spacing-sm: 0em;

  --font-weight: 400;

  /* Spacing */
  --space-xs: 0.1em;
  --space-sm: 0.75em;
  --space-md: 1.2em;
  --space-lg: 4em;
  --space-section: 20vh;
  --space-page: clamp(1rem, 1.5vw + 0.65rem, 2.5rem);

  /* Border radius */
  --radius-sm: 2px;
  --radius-md: 4px;

  /* Animation */
  --transition-color: color 0.15s ease;
}

/* ── Font ── */
@font-face {
  font-family: 'Rams';
  src: url('../fonts/Rams-569.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ── Cursor ── */
@media (pointer: fine) {
  * {
    cursor: none;
  }

  #cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    background: var(--color-accent);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    will-change: transform, opacity;
    z-index: 9999;
  }

  #img-viewer-backdrop,
  #img-viewer,
  #img-viewer * {
    cursor: auto;
  }

  #img-viewer-stage {
    cursor: grab;
  }

  #img-viewer-stage:active {
    cursor: grabbing;
  }
}

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

/* ── Base ── */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--color-bg);
}

/* ── Resize smoothing ── */
@media (prefers-reduced-motion: no-preference) {
  html {
    transition: font-size 0.2s ease;
  }

  body {
    transition: padding 0.2s ease, font-size 0.2s ease;
  }
}

html,
body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  padding: var(--space-page);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight);
  line-height: var(--line-height-lg);
  letter-spacing: var(--letter-spacing-lg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}


/* ── Container ── */
.container {
  max-width: 600px;
  min-width: 33.33vw;
  padding-bottom: 10vh;
}

/* ── Utilities ── */
.orange {
  color: var(--color-accent);
}

.tight {
  margin: unset !important;
}

.text-lg {
  font-size: var(--font-size-lg);
  line-height: var(--line-height-lg);
  letter-spacing: var(--letter-spacing-lg);
}

.text-md {
  font-size: var(--font-size-md);
  line-height: var(--line-height-md);
  letter-spacing: var(--letter-spacing-md);
}

.text-sm {
  font-size: var(--font-size-sm);
  line-height: var(--line-height-sm);
  letter-spacing: var(--letter-spacing-sm);
}

.spacer-lg {
  height: var(--space-lg);
}

.heading {
  font-size: var(--font-size-md);
  line-height: var(--line-height-md);
  letter-spacing: var(--letter-spacing-md);
  color: var(--color-accent);
}

/* ── Selection ── */
::selection {
  background: var(--color-accent);
  color: var(--color-bg);
}


.bio p+p {
  margin-top: var(--space-sm);
}

.line-mask {
  display: block;
  overflow: hidden;
  margin-bottom: -0.15em;
}

.line-inner {
  display: block;
  padding-bottom: 0.15em;
  will-change: transform;
}


/* ── Works / Apps / Contact / Case Studies ── */
.works,
.apps,
.contact,
.case-study {
  display: none;
}

.works .line-mask+.line-mask,
.apps .line-mask+.line-mask,
.contact .line-mask+.line-mask {
  margin-top: var(--space-xs);
}

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

@media (max-width: 600px) {
  body {
    padding-bottom: 8rem;
  }
}

.muted {
  color: var(--color-text-muted);
}

.works-item .muted {
  text-align: right;
}

.works-item a {
  color: var(--color-text);
  text-decoration: none;
  transition: var(--transition-color);
}

.works-item a:hover {
  color: var(--color-text-muted);
}

.works .works-item span:first-child {
  transition: var(--transition-color);
}

.works .works-item:hover span:first-child {
  color: var(--color-text-muted);
}

.works .works-item .muted::after {
  content: attr(data-default);
}


/* ── Case Studies ── */

/* Slide background color variants */
.carousel-slide.slide-bg-teal  { background: #0C3A41; }
.carousel-slide.slide-bg-light { background: #e7e7e7; }
.carousel-slide.slide-bg-rust  { background: #70270C; }

.case-section {
  padding-bottom: var(--space-section);
  min-height: 80vh;
}

.case-section:last-child {
  min-height: unset;
}

.case-section p+p {
  margin-top: var(--space-sm);
}

.case-section .case-carousel-wrap+p {
  margin-top: var(--space-sm);
}


.case-carousel-wrap {
  width: calc(100vw - 2 * var(--space-page));
}

.case-carousel {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  gap: var(--space-page);
  margin-top: var(--space-md);
}

.case-carousel::-webkit-scrollbar {
  display: none;
}

.carousel-item {
  flex: 0 0 calc(100% - 32px);
  max-width: 450px;
  scroll-snap-align: start;
  flex-shrink: 0;
}

@media (min-width: 601px) {
  .carousel-item {
    flex: 0 0 calc((100% - 2 * var(--space-page)) / 3.2);
    max-width: none;
  }
}

.carousel-slide {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  background: #222222;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5%;
  overflow: hidden;
  position: relative;
  cursor: none;
}

.carousel-slide img,
.carousel-slide video {
  width: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

.carousel-slide img.fill {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
  box-shadow: none;
  position: absolute;
  inset: 0;
}

.carousel-caption {
  margin-top: var(--space-page);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-sm);
  letter-spacing: var(--letter-spacing-sm);
}

/* ── Case Meta ── */
.case-meta {
  margin-top: var(--space-md);
  display: grid;
  gap: var(--space-md);
}

.case-meta-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

/* ── Case Image Placeholder ── */
.case-img {
  margin-top: var(--space-lg);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  aspect-ratio: 16 / 9;
}

.case-img+p {
  margin-top: var(--space-sm);
}

/* ── Case Caption ── */
.case-caption {
  color: var(--color-text-muted);
}

/* ── Image Viewer ── */
#img-viewer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 499;
}

#img-viewer {
  display: none;
  position: fixed;
  background: #101010;
  border-radius: var(--radius-md);
  z-index: 500;
  overflow: hidden;
}

#img-viewer-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  overflow: hidden;
}

#img-viewer-stage:active {
  cursor: grabbing;
}

#img-viewer.is-video #img-viewer-stage,
#img-viewer.is-video #img-viewer-stage:active {
  cursor: default;
}

#img-viewer-img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  border-radius: var(--radius-sm);
}

#img-viewer-video {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

#img-viewer-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  border-radius: var(--radius-md);
  color: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: color 0.15s ease, background 0.15s ease;
}

#img-viewer-close:hover {
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
}

.carousel-expand {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  border-radius: var(--radius-md);
  color: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  transition: color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  pointer-events: none;
}

.carousel-slide:hover .carousel-expand {
  opacity: 1;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
}

@media (max-width: 600px) {
  .carousel-expand {
    display: none;
  }
}

/* ── Nav ── */
.nav {
  position: fixed;
  bottom: var(--space-page);
  left: var(--space-page);
  padding-top: var(--space-md);
  z-index: 2;
}

.nav .line-mask {
  display: block;
  overflow: hidden;
}

.nav .line-mask+.line-mask {
  margin-top: var(--space-xs);
}

.nav a {
  display: block;
  text-decoration: none;
  color: var(--color-text);
  transition: var(--transition-color);
}

.nav a:hover {
  color: var(--color-text-muted);
}

.nav a.active {
  color: var(--color-accent);
}

.nav .back-mask {
  display: none;
}

.nav .back-mask.visible {
  display: block;
}

.works-item[data-to] {
  cursor: default;
}

.works-item.unavailable {
  cursor: none;
  color: var(--color-text-muted);
}

@media (max-width: 600px) {
  .nav {
    bottom: var(--space-page);
    left: var(--space-page);
  }
}