/* ══════════════════════════════════════
   Westerby Labs — Style System
   Warm Industrial: Instrument Serif + Public Sans
   ══════════════════════════════════════ */

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

/* ── Tokens ── */
:root {
  --bg: #F4EFE8;
  --surface: #E8E1D7;
  --surface-strong: #D8D0C4;
  --text: #262522;
  --text-soft: #5D5A55;
  --accent: #7C8790;
  --accent-deep: #5F6B74;
  --line: rgba(38, 37, 34, 0.12);

  --font-serif: 'Instrument Serif', Georgia, serif;
  --font-sans: 'Public Sans', system-ui, sans-serif;

  --step-xs: 12px;
  --step-sm: 14px;
  --step-md: 16px;
  --step-base: 18px;
  --step-lg: 24px;
  --step-xl: clamp(28px, 4vw, 36px);
  --step-2xl: clamp(36px, 5.5vw, 56px);
  --step-3xl: clamp(56px, 8vw, 96px);

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 48px;
  --space-2xl: 80px;
  --space-3xl: 120px;

  --radius-sm: 8px;
  --radius-md: 12px;

  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);

  --max-w: 1200px;
}

/* ── Base ── */
body {
  font-family: var(--font-sans);
  font-size: var(--step-base);
  line-height: 1.65;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(90deg, rgba(38, 37, 34, 0.04) 0 1px, transparent 1px 60px),
    repeating-linear-gradient(0deg, rgba(38, 37, 34, 0.04) 0 1px, transparent 1px 60px);
  background-size: 60px 60px;
  background-position: center top;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: var(--text);
  text-decoration: none;
  transition: color 180ms var(--ease-expo);
}

a:hover {
  color: var(--accent-deep);
}

a:focus-visible {
  outline: 2px solid var(--accent-deep);
  outline-offset: 2px;
  border-radius: 2px;
}

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

/* ── Typography ── */
h1, h2, h3 {
  font-family: var(--font-serif);
  line-height: 1.05;
  font-weight: 400;
}

h1 { font-size: var(--step-3xl); }
h2 { font-size: var(--step-2xl); }
h3 { font-size: var(--step-xl); }

p {
  max-width: 60ch;
}

/* ── Layout ── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 clamp(24px, 4vw, 48px);
}

/* ══════════════════════════════════════
   Header
   ══════════════════════════════════════ */
.site-header {
  padding: clamp(24px, 4vw, 40px) 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

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

.logo a {
  display: inline-flex;
  align-items: center;
}

.logo-wordmark {
  width: clamp(160px, 22vw, 220px);
  height: auto;
  color: var(--text);
  transition: color 180ms var(--ease-expo);
}

.logo a:hover .logo-wordmark {
  color: var(--accent-deep);
}

/* ── Hero socials ── */
.hero-socials {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 48px;
}

.hero-socials a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-family: var(--font-sans);
  font-size: var(--step-sm);
  font-weight: 500;
  color: var(--text-soft);
  transition: background 180ms var(--ease-expo), color 180ms var(--ease-expo);
}

.hero-socials a:hover {
  background: var(--surface-strong);
  color: var(--text);
}

.hero-socials svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}

/* ══════════════════════════════════════
   Hero
   ══════════════════════════════════════ */
.hero {
  padding: clamp(24px, 3vw, 48px) 0 clamp(24px, 3vw, 40px);
  text-align: center;
}

.hero h1 {
  font-style: italic;
  line-height: 0.96;
  letter-spacing: -0.02em;
}

.hero-rule {
  width: clamp(40px, 6vw, 64px);
  height: 1px;
  background: var(--line);
  margin: var(--space-lg) auto 0;
}

/* ══════════════════════════════════════
   Section chrome
   ══════════════════════════════════════ */
.section {
  padding: var(--space-2xl) 0;
  border-top: 1px solid var(--line);
}

.section-label {
  font-family: var(--font-sans);
  font-size: var(--step-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-sm);
}

.section-title {
  font-family: var(--font-serif);
  font-size: var(--step-2xl);
  line-height: 1.05;
  margin-bottom: var(--space-xl);
}

/* ══════════════════════════════════════
   Projects
   ══════════════════════════════════════ */
.projects {
  border-top: 1px solid var(--line);
  padding: var(--space-lg) 0 var(--space-xl);
}

.projects .container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ══════════════════════════════════════
   Card Stack
   ══════════════════════════════════════ */
.card-stack {
  position: relative;
  width: 360px;
  height: 480px;
  touch-action: none;
  cursor: grab;
  outline: none;
}

.card-stack:focus-visible {
  outline: none;
}

.card-stack:active {
  cursor: grabbing;
}

.card {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 500ms var(--ease-expo), opacity 500ms var(--ease-expo);
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
}

.card.dragging {
  transition: none;
  cursor: grabbing;
}


/* Card image placeholder */
.card-image {
  flex: 0 0 58%;
  position: relative;
  overflow: hidden;
}

.card-image-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-image-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Each card gets a unique warm gradient */
.card[data-project="tottli"] .card-image {
  background: linear-gradient(135deg, #E2D8CC 0%, #D4C9BB 40%, #C9BFB2 100%);
}

.card[data-project="timeline"] .card-image {
  background: linear-gradient(135deg, #D8D0C4 0%, #CEC5B8 40%, #C4BAAC 100%);
}

.card[data-project="langsplain"] .card-image {
  background: linear-gradient(135deg, #DDD5C9 0%, #D1C8BC 40%, #C7BDB0 100%);
}


/* Card body */
.card-body {
  flex: 1;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.card-name {
  font-family: var(--font-serif);
  font-size: var(--step-lg);
  line-height: 1.15;
}

.card-desc {
  font-size: var(--step-sm);
  color: var(--text-soft);
  line-height: 1.5;
}

.card-links {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.card-link {
  font-size: var(--step-sm);
  font-weight: 500;
  color: var(--accent-deep);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid transparent;
  transition: border-color 180ms var(--ease-expo), color 180ms var(--ease-expo);
}

.card-link:hover {
  color: var(--text);
  border-bottom-color: var(--text);
}

.card-link svg {
  width: 14px;
  height: 14px;
}

.app-store-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--text);
  color: var(--bg);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: default;
}

.apple-logo {
  width: 18px;
  height: 18px;
  fill: var(--bg);
}

.app-store-badge-text {
  font-size: var(--step-sm);
  font-weight: 500;
  line-height: 1.2;
}

.app-store-badge-small {
  display: block;
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.8;
}

/* Stack hint — dots beneath the stack */
.stack-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: var(--space-lg);
}

.stack-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--surface-strong);
  transition: background 300ms var(--ease-expo);
}

.stack-dot.active {
  background: var(--accent-deep);
}

/* Swipe hint */
.swipe-hint {
  text-align: center;
  margin-top: var(--space-md);
  font-size: var(--step-xs);
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
  opacity: 0.7;
  transition: opacity 600ms var(--ease-expo);
}

.swipe-hint.hidden {
  opacity: 0;
}

/* ══════════════════════════════════════
   About
   ══════════════════════════════════════ */
.about {
  padding: var(--space-lg) 0 var(--space-xl);
  border-top: 1px solid var(--line);
}

.about-content {
  max-width: 48ch;
}

.about-content h2 {
  font-style: italic;
  margin-bottom: var(--space-md);
}

.about-content p {
  color: var(--text-soft);
  font-size: var(--step-base);
  line-height: 1.7;
}

/* ══════════════════════════════════════
   Footer
   ══════════════════════════════════════ */
.site-footer {
  border-top: 1px solid var(--line);
  padding: var(--space-xl) 0;
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-md);
}

.footer-left {
  font-size: var(--step-sm);
  color: var(--text-soft);
}

.footer-left strong {
  color: var(--text);
  font-weight: 500;
}

.footer-right {
  font-size: var(--step-xs);
  color: var(--accent);
  text-align: right;
}

.footer-right a {
  color: var(--accent);
  border-bottom: 1px solid transparent;
  transition: color 180ms var(--ease-expo), border-color 180ms var(--ease-expo);
}

.footer-right a:hover {
  color: var(--text-soft);
  border-bottom-color: var(--text-soft);
}

.footer-sep {
  margin: 0 8px;
  color: var(--accent);
}

/* ══════════════════════════════════════
   Legal Pages
   ══════════════════════════════════════ */
.legal-page {
  padding: var(--space-xl) 0 var(--space-3xl);
}

.legal-page .container {
  max-width: 65ch;
}

.legal-page h1 {
  margin-bottom: var(--space-sm);
}

.legal-page h2 {
  font-size: var(--step-xl);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-sm);
}

.legal-page p {
  color: var(--text-soft);
  line-height: 1.7;
  margin-bottom: var(--space-md);
}

/* ══════════════════════════════════════
   Reveal Animations
   ══════════════════════════════════════ */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 650ms var(--ease-expo), transform 650ms var(--ease-expo);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ══════════════════════════════════════
   Reduced Motion
   ══════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .card {
    transition: opacity 200ms ease !important;
  }
}

/* ══════════════════════════════════════
   Responsive
   ══════════════════════════════════════ */
@media (max-width: 640px) {
  body {
    font-size: var(--step-md);
  }

  .site-header {
    padding: 16px 0;
  }

  .logo-wordmark {
    width: 130px;
  }

  .hero {
    padding: clamp(16px, 3vw, 32px) 0 clamp(16px, 3vw, 32px);
  }

  .hero-rule {
    margin-top: 16px;
  }

  .hero-socials {
    margin-top: 16px;
  }

  .card-stack {
    width: 100%;
    max-width: 360px;
    height: auto;
    aspect-ratio: 3 / 4;
  }

  .site-footer .container {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .footer-right {
    text-align: left;
  }
}

@media (max-width: 480px) {
  .card-stack {
    aspect-ratio: 3 / 4.2;
  }

  .card-body {
    padding: var(--space-md);
  }

  .card-name {
    font-size: 20px;
  }
}
