/* =============================================================
   GLOBAL STYLES
   Base resets, typography, layout, and shared components.
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;600&family=Barlow+Condensed:wght@700;900&display=swap');
@import './tokens.css';

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

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

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

ul, ol {
  list-style: none;
}

/* --- Layout utilities --- */
.container {
  width: 100%;
  max-width: var(--max-width-wide);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.container--narrow {
  max-width: var(--max-width-content);
}

/* --- Nav --- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background-color: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
}

.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-wordmark {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: opacity var(--transition-fast);
}

.nav-wordmark:hover {
  opacity: 0.5;
}

.nav-links {
  display: flex;
  gap: var(--space-6);
}

.nav-links a {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-weight: var(--weight-medium);
  transition: color var(--transition-fast);
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--color-text-primary);
}

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

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: var(--space-1);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  transition: color var(--transition-fast), opacity var(--transition-fast);
}

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

.theme-icon--moon { display: none; }
[data-theme="dark"] .theme-icon--sun  { display: none; }
[data-theme="dark"] .theme-icon--moon { display: block; }

/* --- Page sections --- */
.page-section {
  padding-block: var(--space-16);
}

.page-section--hero {
  padding-block: var(--space-20) var(--space-16);
}

.section-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

/* --- Hero display type --- */
.hero-display {
  font-family: var(--font-display);
  margin-bottom: var(--space-8);
}

.hero-display__line1 {
  display: flex;
  align-items: baseline;
  gap: 0.25em;
  line-height: 1;
}

.hero-display__small {
  font-size: clamp(1.1rem, 2.5vw, 1.75rem);
  font-weight: var(--weight-bold);
  color: var(--color-text-secondary);
  letter-spacing: 0.02em;
}

.hero-display__fill {
  display: block;
  font-size: clamp(3.5rem, 11vw, 8.5rem);
  font-weight: var(--weight-black);
  color: var(--color-purple);
  letter-spacing: -0.02em;
  line-height: 0.92;
}

.hero-display__outline {
  display: block;
  font-size: clamp(3.5rem, 11vw, 8.5rem);
  font-weight: var(--weight-black);
  color: transparent;
  -webkit-text-stroke: 2px var(--color-text-primary);
  letter-spacing: -0.02em;
  line-height: 0.92;
}

.hero-sub {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  max-width: 480px;
  line-height: var(--leading-relaxed);
}

/* --- Project cards --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-5);
}

.project-card {
  aspect-ratio: 4 / 5;
  display: flex;
  flex-direction: column;
  border: 3.5px solid var(--color-purple);
  border-radius: 6px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}

.project-card:hover .project-card__media img,
.project-card:hover .project-card__media video {
  transform: scale(1.04);
}

/* --- Media (top ~80%): the gif/photo does the talking --- */
.project-card__media {
  position: relative;
  flex: 4 1 0%;
  min-height: 0;
  overflow: hidden;
  border-bottom: 2.5px solid var(--color-purple);
  background: var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.project-card__media img,
.project-card__media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-base);
}

/* --- Body (bottom ~20%): name + description, left-justified --- */
.project-card__body {
  flex: 1 1 0%;
  min-height: 0;
  background: var(--color-bg);
  padding: var(--space-3) var(--space-5);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: var(--space-1);
  text-align: left;
}

.project-card__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-black);
  line-height: var(--leading-tight);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: transparent;
  -webkit-text-stroke: 1px var(--color-text-secondary);
}

.project-card__desc {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

/* --- Prose (case study pages) --- */
.prose {
  max-width: var(--max-width-content);
}

.prose h1 {
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
  line-height: var(--leading-tight);
  margin-bottom: var(--space-4);
}

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

.prose h3 {
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
}

.prose p {
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-4);
}

.prose ul {
  list-style: disc;
  padding-left: var(--space-6);
  color: var(--color-text-secondary);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: rgba(0,0,0,0.06);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
}

/* --- Case study cards (project detail pages) --- */
.case-card {
  border: 2.5px solid var(--color-purple);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  padding: var(--space-8);
  margin-bottom: var(--space-5);
}

.case-card h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-black);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-purple);
  margin-bottom: var(--space-4);
}

@media (max-width: 640px) {
  .case-card {
    padding: var(--space-6);
  }
}

/* --- Case study layout: cards left, media gallery right --- */
.case-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
  align-items: start;
}

/* Single, larger slot for the main gif/photo (right column).
   Default (no media yet, or an iframe embed with no intrinsic size) keeps a
   fixed placeholder shape; once an actual img/video is present, the box
   drops the fixed ratio and sizes itself to the media's natural aspect
   ratio instead of cropping it. */
.case-media-main {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 2.5px solid var(--color-purple);
  border-radius: var(--radius-md);
  background: var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.case-media-main:has(img),
.case-media-main:has(video) {
  aspect-ratio: auto;
  display: block;
  padding: 0;
  background: none;
}

.case-media-main img,
.case-media-main video {
  display: block;
  width: 100%;
  height: auto;
}

.case-media-main iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Extra gifs/photos beyond the main one: full-width, 2 columns, wraps into as many rows as needed */
.case-media {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  align-items: start;
  gap: var(--space-3);
  margin-top: var(--space-8);
}

.case-media__item {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 2.5px solid var(--color-purple);
  border-radius: var(--radius-md);
  background: var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

/* Once a real photo is in, size the box to its natural aspect ratio instead of cropping it into a square */
.case-media__item:has(img),
.case-media__item:has(video) {
  aspect-ratio: auto;
  display: block;
  padding: 0;
  background: none;
}

.case-media__item img,
.case-media__item video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.case-media__item:has(img) img,
.case-media__item:has(video) video {
  position: static;
  width: 100%;
  height: auto;
}

@media (max-width: 900px) {
  .case-layout {
    grid-template-columns: 1fr;
  }
}

/* --- Book viewer: click through storybook-style pages --- */
.book-viewer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
}

.book-viewer__stage {
  position: relative;
  width: min(560px, 100%);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 2.5px solid var(--color-purple);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  flex-shrink: 1;
}

.book-viewer__stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.book-viewer__arrow {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--color-purple);
  background: var(--color-bg);
  color: var(--color-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.book-viewer__arrow:hover {
  opacity: 0.7;
}

.book-viewer__arrow svg {
  width: 18px;
  height: 18px;
}

.book-viewer__caption {
  text-align: center;
  margin-top: var(--space-5);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

@media (max-width: 480px) {
  .book-viewer {
    gap: var(--space-2);
  }

  .book-viewer__arrow {
    width: 36px;
    height: 36px;
  }
}

/* --- Inline link style --- */
.link-accent {
  color: var(--color-purple);
  font-weight: var(--weight-medium);
  transition: opacity var(--transition-fast);
}

.link-accent:hover {
  opacity: 0.75;
}

/* --- Button --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity var(--transition-fast);
  text-decoration: none;
}

.btn:hover { opacity: 0.85; }

.btn--primary {
  background: var(--color-text-primary);
  color: var(--color-text-inverse);
}

.btn--outline {
  background: transparent;
  color: var(--color-text-primary);
  border-color: var(--color-border);
}

.btn--outline:hover {
  background: rgba(0,0,0,0.04);
  opacity: 1;
}

/* --- More button: outline-style text, hard rectangular shadow --- */
.btn-more {
  display: inline-block;
  padding: var(--space-3) var(--space-10);
  background: transparent;
  border: 2px solid var(--color-text-primary);
  border-radius: 0;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-black);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--color-text-primary);
  cursor: pointer;
  box-shadow: 6px 6px 0 var(--color-text-primary);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-more:hover {
  transform: translate(3px, 3px);
  box-shadow: 3px 3px 0 var(--color-text-primary);
}

.btn-more:active {
  transform: translate(6px, 6px);
  box-shadow: 0 0 0 var(--color-text-primary);
}

/* --- Divider --- */
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin-block: var(--space-2);
}

/* --- Theme transitions --- */
body           { transition: background-color var(--transition-base), color var(--transition-base); }
.site-nav      { transition: background-color var(--transition-base), border-color var(--transition-base); }
.project-card  { transition: background-color var(--transition-base), border-color var(--transition-base); }

/* --- Responsive --- */
@media (max-width: 640px) {
  .container {
    padding-inline: var(--space-4);
  }

  .page-section {
    padding-block: var(--space-10);
  }

  .page-section--hero {
    padding-block: var(--space-12) var(--space-10);
  }

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

  .hero-display__outline {
    -webkit-text-stroke-width: 1.5px;
  }
}
