/* ============================================================
   DESIGN AFTER DARK
   ============================================================ */

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

:root {
  --bg:     #FFFEF8;
  --fg:     #18160B;
  --muted:  rgba(24, 22, 11, 0.35);
  --accent: #0696F6;
  --pad:    clamp(1.2rem, 2.5vw, 2.8rem);
}

html {
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  cursor: none;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  width: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  cursor: none;
  -webkit-font-smoothing: antialiased;
}

/* ── Cursor ──────────────────────────────────────────────── */
.cursor {
  position: fixed;
  width: 8px;
  height: 8px;
  background: var(--fg);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: background 0.2s, width 0.2s, height 0.2s;
}
.cursor.on-link {
  width: 5px;
  height: 5px;
  background: var(--accent);
}

/* ── Page shell ──────────────────────────────────────────── */
.page {
  position: relative;
  width: 100%;
  height: 100dvh;
  max-width: 2000px;
  margin: 0 auto;
  padding: var(--pad);
  display: flex;
  flex-direction: column;
}

/* ── Section defaults ────────────────────────────────────── */
.section {
  width: 100%;
  max-width: 2000px;
  margin: 0 auto;
  padding: clamp(4rem, 10vh, 8rem) var(--pad);
}

/* ── Header ──────────────────────────────────────────────── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-shrink: 0;
}

.header-left,
.header-right {
  font-family: 'DM Mono', 'Courier New', monospace;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(0.6rem, 0.85vw, 0.8rem);
  letter-spacing: 0.1em;
  color: var(--muted);
  text-decoration: none;
}
.header-right:hover { color: var(--accent); }

/* ── Logo ────────────────────────────────────────────────── */
.logo-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0; /* allow flex shrink */
}

#logo-svg {
  /* Size relative to the available vertical space — will never overflow */
  width:  clamp(140px, 30vh, 380px);
  height: clamp(140px, 30vh, 380px);
  overflow: visible;
  filter: url(#logo-distort);
}

/* ── Hero click-to-scroll affordance ─────────────────────── */
.logo-wrap,
.word {
  cursor: pointer;
}
@media (hover: hover) {
  .logo-wrap,
  .word { cursor: none; }
}

/* ── Headline ────────────────────────────────────────────── */
.headline-wrap {
  flex-shrink: 0;
}

.headline {
  font-family: 'ClashDisplay-Variable', 'Clash Display', sans-serif;
  font-variation-settings: 'wght' 700;
  text-transform: uppercase;
  line-height: 0.9;
  letter-spacing: -0.01em;
  user-select: none;
  white-space: nowrap;

  /*
    KEY INSIGHT: use display:flex + justify-content:space-between
    to spread the three words. Font-size in vw is tuned so
    "DESIGN AFTER DARK" at wght 600 fills ~100% of the container.
    We then use a ResizeObserver to apply a small scaleX correction
    on top — but the vw value does the heavy lifting so the
    correction is always tiny (< 5%) and invisible.
  */
  display: flex;
  justify-content: space-between;
  align-items: baseline;

  /* JS sets the exact font-size via binary search after fonts load.
     This vw is just a reasonable pre-load approximation. */
  font-size: 10.5vw;
}

.word {
  display: inline-block;
  /* letter hover: variable font weight morph */
  /* Each word's letters are split by JS */
}

.letter {
  display: inline-block;
  font-variation-settings: 'wght' 700;
  /* No CSS transition — JS lerp handles all smoothing */
}

.tagline {
  font-family: 'ClashDisplay-Variable', 'Clash Display', sans-serif;
  font-variation-settings: 'wght' 500;
  font-size: 1.2em;
  letter-spacing: 0.01em;
  color: var(--fg);
  margin-top: 0.7em;
  text-align: center;
}

/* ── Footer ──────────────────────────────────────────────── */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-shrink: 0;
  padding-top: clamp(0.4rem, 1vw, 0.8rem);
}

.footer-left {
  font-family: 'ClashDisplay-Variable', 'Clash Display', sans-serif;
  font-variation-settings: 'wght' 600;
  font-size: clamp(0.6rem, 0.9vw, 0.82rem);
  letter-spacing: 0.4em;
  color: var(--muted);
  text-transform: uppercase;
  transition: letter-spacing 0.5s cubic-bezier(0.16,1,0.3,1), color 0.25s;
}
.footer-left:hover {
  letter-spacing: 1em;
  color: var(--accent);
}

.footer-right {
  font-family: 'DM Mono', 'Courier New', monospace;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(0.55rem, 0.8vw, 0.72rem);
  color: var(--muted);
}

/* ── Section reveal animation ────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(2rem);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Scroll indicator ────────────────────────────────────── */
.scroll-indicator {
  position: absolute;
  bottom: var(--pad);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  opacity: 0.4;
  transition: opacity 0.4s;
}
.scroll-indicator:hover { opacity: 0.7; }

.scroll-indicator span {
  font-family: 'DM Mono', 'Courier New', monospace;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(0.55rem, 0.75vw, 0.7rem);
  letter-spacing: 0.15em;
  color: var(--muted);
  text-transform: uppercase;
}

.scroll-indicator .arrow {
  width: 1px;
  height: 24px;
  background: var(--muted);
  position: relative;
  animation: scrollPulse 2s ease-in-out infinite;
}
.scroll-indicator .arrow::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 6px;
  height: 6px;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
}

@keyframes scrollPulse {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(4px); }
}

/* ── WORK SECTION ────────────────────────────────────────── */
.section--work {
  padding-top: clamp(6rem, 12vh, 10rem);
  border-top: 1px solid rgba(24, 22, 11, 0.08);
}

.section-label {
  font-family: 'DM Mono', 'Courier New', monospace;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(0.6rem, 0.8vw, 0.75rem);
  letter-spacing: 0.2em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

.section-title {
  font-family: 'ClashDisplay-Variable', 'Clash Display', sans-serif;
  font-variation-settings: 'wght' 600;
  font-size: clamp(2rem, 5vw, 4.5rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  max-width: 18ch;
  margin-bottom: clamp(3rem, 6vh, 5rem);
}

/* Project grid */
.work-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(1.5rem, 3vw, 3rem);
}

/* Individual project card */
.work-card {
  position: relative;
  border: 1px solid rgba(24, 22, 11, 0.08);
  border-radius: 1rem;
  padding: clamp(1.5rem, 3vw, 2.5rem);
  background: var(--bg);
  transition: border-color 0.3s, box-shadow 0.3s;
  overflow: hidden;
}
.work-card:hover {
  border-color: rgba(24, 22, 11, 0.15);
  box-shadow: 0 8px 40px rgba(24, 22, 11, 0.04);
}

.work-card__number {
  font-family: 'DM Mono', 'Courier New', monospace;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(0.55rem, 0.7vw, 0.65rem);
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.work-card__title {
  font-family: 'ClashDisplay-Variable', 'Clash Display', sans-serif;
  font-variation-settings: 'wght' 600;
  font-size: clamp(1.2rem, 2vw, 1.8rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 0.6rem;
}

.work-card__desc {
  font-family: 'ClashDisplay-Variable', 'Clash Display', sans-serif;
  font-variation-settings: 'wght' 400;
  font-size: clamp(0.85rem, 1vw, 1rem);
  line-height: 1.55;
  color: var(--muted);
  margin-bottom: clamp(1.5rem, 2.5vw, 2.5rem);
  max-width: 38ch;
}

/* Stat row inside a card */
.work-card__stats {
  display: flex;
  gap: clamp(1.5rem, 3vw, 3rem);
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stat__value {
  font-family: 'ClashDisplay-Variable', 'Clash Display', sans-serif;
  font-variation-settings: 'wght' 700;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat__value--accent {
  color: var(--accent);
}

.stat__label {
  font-family: 'DM Mono', 'Courier New', monospace;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(0.5rem, 0.65vw, 0.6rem);
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}

/* Mini chart decoration inside cards */
.work-card__chart {
  margin-top: clamp(1.5rem, 2.5vw, 2rem);
  height: 80px;
  position: relative;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 100%;
}

.chart-bar {
  flex: 1;
  background: rgba(24, 22, 11, 0.06);
  border-radius: 2px 2px 0 0;
  transition: background 0.3s, height 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  height: 0;
}
.chart-bar.is-visible {
  /* height set via inline style */
}
.work-card:hover .chart-bar {
  background: rgba(6, 150, 246, 0.15);
}
.chart-bar.chart-bar--accent {
  background: var(--accent);
  opacity: 0.3;
}
.work-card:hover .chart-bar.chart-bar--accent {
  background: var(--accent);
  opacity: 0.5;
}

/* Sparkline SVG */
.work-card__sparkline {
  margin-top: clamp(1.5rem, 2.5vw, 2rem);
  width: 100%;
  height: 60px;
}
.sparkline-path {
  fill: none;
  stroke: rgba(24, 22, 11, 0.12);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.3s;
}
.work-card:hover .sparkline-path {
  stroke: var(--accent);
  opacity: 0.5;
}
.sparkline-area {
  fill: rgba(24, 22, 11, 0.03);
  transition: fill 0.3s;
}
.work-card:hover .sparkline-area {
  fill: rgba(6, 150, 246, 0.06);
}
.sparkline-dot {
  fill: var(--fg);
  r: 2.5;
  transition: fill 0.3s;
}
.work-card:hover .sparkline-dot {
  fill: var(--accent);
}

/* Feature card (larger, spans 2 cols) */
.work-card--feature {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 4vw, 4rem);
  align-items: center;
}

.work-card--feature .work-card__visual {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Donut chart */
.donut-chart {
  width: clamp(160px, 18vw, 220px);
  height: clamp(160px, 18vw, 220px);
}
.donut-track {
  fill: none;
  stroke: rgba(24, 22, 11, 0.06);
  stroke-width: 8;
}
.donut-segment {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transform-origin: center;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.16, 1, 0.3, 1),
              stroke 0.3s;
}
.donut-label {
  font-family: 'ClashDisplay-Variable', 'Clash Display', sans-serif;
  font-variation-settings: 'wght' 700;
  font-size: 1.5rem;
  fill: var(--fg);
}
.donut-sublabel {
  font-family: 'DM Mono', 'Courier New', monospace;
  font-style: italic;
  font-weight: 300;
  font-size: 0.5rem;
  letter-spacing: 0.1em;
  fill: var(--muted);
}
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}
.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'DM Mono', 'Courier New', monospace;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(0.5rem, 0.65vw, 0.6rem);
  letter-spacing: 0.08em;
  color: var(--muted);
}
.donut-legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── CONTACT SECTION ─────────────────────────────────────── */
.section--contact {
  padding-top: clamp(6rem, 12vh, 10rem);
  padding-bottom: clamp(6rem, 12vh, 10rem);
  border-top: 1px solid rgba(24, 22, 11, 0.08);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.contact-headline {
  font-family: 'ClashDisplay-Variable', 'Clash Display', sans-serif;
  font-variation-settings: 'wght' 600;
  font-size: clamp(2.5rem, 6vw, 5.5rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: clamp(1.5rem, 3vh, 2.5rem);
}

.contact-body {
  font-family: 'ClashDisplay-Variable', 'Clash Display', sans-serif;
  font-variation-settings: 'wght' 400;
  font-size: clamp(0.95rem, 1.2vw, 1.15rem);
  line-height: 1.6;
  color: var(--muted);
  max-width: 50ch;
  margin-bottom: clamp(2rem, 4vh, 3.5rem);
}

.contact-email {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  font-family: 'ClashDisplay-Variable', 'Clash Display', sans-serif;
  font-variation-settings: 'wght' 600;
  font-size: clamp(1.1rem, 2vw, 1.6rem);
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.01em;
  padding: 0.8em 0;
  position: relative;
  transition: color 0.3s;
}
.contact-email::after {
  content: '';
  position: absolute;
  bottom: 0.5em;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--fg);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              background 0.3s;
}
.contact-email:hover {
  color: var(--accent);
}
.contact-email:hover::after {
  transform: scaleX(1);
  transform-origin: left;
  background: var(--accent);
}

.contact-email__arrow {
  display: inline-block;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.contact-email:hover .contact-email__arrow {
  transform: translateX(4px);
}

/* Contact footer */
.contact-footer {
  margin-top: clamp(4rem, 8vh, 6rem);
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: clamp(1rem, 2vh, 1.5rem);
  border-top: 1px solid rgba(24, 22, 11, 0.08);
}

.contact-footer__left {
  font-family: 'DM Mono', 'Courier New', monospace;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(0.55rem, 0.7vw, 0.65rem);
  letter-spacing: 0.1em;
  color: var(--muted);
}

.contact-footer__right {
  font-family: 'DM Mono', 'Courier New', monospace;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(0.55rem, 0.7vw, 0.65rem);
  color: var(--muted);
}

/* ── Responsive: stack on mobile ─────────────────────────── */
@media (max-width: 768px) {
  .work-grid {
    grid-template-columns: 1fr;
  }
  .work-card--feature {
    grid-template-columns: 1fr;
  }
  .work-card--feature .work-card__visual {
    order: -1;
  }
  .contact-footer {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* ── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .letter { transition: none; }
  .reveal { transition: none; opacity: 1; transform: none; }
  .chart-bar { transition: none; }
  .donut-segment { transition: none; }
  .scroll-indicator .arrow { animation: none; }
}

/* ── Touch: restore native cursor ───────────────────────── */
@media (hover: none) {
  html, body { cursor: auto; }
  .cursor { display: none; }
}
