/* ==========================================================================
   Base — Reset, Custom Properties, Typography
   Every page on the site imports this file.
   ========================================================================== */

/* --- Font Face --- */

@font-face {
  font-family: 'Pixelify Sans';
  src: url('/shared/fonts/pixelify-sans-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Pixelify Sans';
  src: url('/shared/fonts/pixelify-sans-bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* --- Custom Properties (Light Theme — default) --- */

:root {
  /* Palette */
  --bg: #f5f0e8;
  --bg-card: #ffffff;
  --text-primary: #2c2c2c;
  --text-secondary: #8a8078;
  --border: #e0d8cc;
  --callout-bg: #e8f0e5;
  --callout-text: #3a7a3a;
  --callout-border: #b8d4b0;

  /* Accent — overridden per-project */
  --accent: #2c2c2c;
  --accent-soft: #2c2c2c22;
  --accent-dark: #2c2c2c;

  /* Hero band */
  --hero-bg: #ede6d8;
  --hero-pattern: #b8a88a;

  /* Typography */
  --font-pixel: 'Pixelify Sans', 'Courier New', monospace;
  --font-system: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;

  /* Sizing */
  --content-width: 680px;
  --radius: 4px;
}

/* --- Dark Theme --- */

[data-theme="dark"] {
  --bg: #1c1a16;
  --bg-card: #2a2720;
  --text-primary: #e8e0d0;
  --text-secondary: #998f80;
  --border: #3d3830;
  --callout-bg: #1a2e1a;
  --callout-text: #6abf6a;
  --callout-border: #2a4a2a;
  --hero-bg: #2a2720;
  --hero-pattern: #3d3830;
}

/* Auto dark when no explicit theme is set */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1a16;
    --bg-card: #2a2720;
    --text-primary: #e8e0d0;
    --text-secondary: #998f80;
    --border: #3d3830;
    --callout-bg: #1a2e1a;
    --callout-text: #6abf6a;
    --callout-border: #2a4a2a;
    --hero-bg: #2a2720;
    --hero-pattern: #3d3830;
  }
}

/* --- Reset --- */

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

/* --- Base Elements --- */

body {
  font-family: var(--font-system);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- Typography --- */

.pixel {
  font-family: var(--font-pixel);
  image-rendering: pixelated;
}

h1 {
  font-family: var(--font-pixel);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

h2 {
  font-family: var(--font-pixel);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}

.hero-title {
  font-family: var(--font-pixel);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
}

.subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.caption {
  font-size: 13px;
  color: var(--text-secondary);
}

/* --- Layout --- */

.container {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* --- Hero Band --- */

.hero-band {
  width: 100%;
  background: var(--hero-bg);
  border-bottom: 2px solid var(--border);
  position: relative;
  overflow: hidden;
}

.hero-band::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.12;
  background-image:
    repeating-linear-gradient(90deg, var(--hero-pattern) 0px, var(--hero-pattern) 2px, transparent 2px, transparent 8px),
    repeating-linear-gradient(0deg, var(--hero-pattern) 0px, var(--hero-pattern) 2px, transparent 2px, transparent 8px);
  background-size: 8px 8px;
  pointer-events: none;
}

.hero-band__inner {
  /* 640px matches the pixel art scene width (spec: 480–640px native).
     Intentionally narrower than --content-width (680px) for the hero. */
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 20px;
  position: relative;
  text-align: center;
}

/* Project hero vignette — smaller, accent-tinted */
.hero-band--project {
  background: linear-gradient(180deg, var(--accent-soft), var(--hero-bg));
}

.hero-band--project .hero-band__inner {
  max-width: 480px;
  padding: 32px 20px;
}

/* --- Pixel Art Images --- */

.pixel-art {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* --- Sprite Sheet Animation --- */

.sprite-anim {
  overflow: hidden;
  position: relative;
  display: block;
}

.sprite-anim__strip {
  display: block;
  max-width: none; /* override global img { max-width: 100% } */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  will-change: transform;
}

.sprite-anim--landing .sprite-anim__strip {
  /* steps() does not accept CSS custom properties — frame count hardcoded.
     --duration is a variable (timing position works fine). */
  animation: sprite-play var(--duration, 4s) steps(8) infinite;
}

.sprite-anim--relive .sprite-anim__strip {
  animation: sprite-play var(--duration, 3s) steps(8) infinite;
}

@keyframes sprite-play {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

/* Hero scene: layered background + CSS-animated overlays */
.hero-scene {
  position: relative;
  max-width: 640px;
  width: 100%;
  line-height: 0;
  margin: 0 auto;
}

.hero-scene > img {
  width: 100%;
  height: auto;
  display: block;
}

/* Cursor blink — 1×3 native px at 4× scale = 0.625%×3% of scene */
.hero-cursor {
  display: block;
  position: absolute;
  left: 62.5%;
  top: 38%;
  width: 0.625%;
  height: 3%;
  background: #ffffff;
  animation: hero-cursor-blink 3s step-start infinite;
}

@keyframes hero-cursor-blink {
  0%, 49.9% { opacity: 1; }
  50%, 100%  { opacity: 0; }
}

/* Coffee steam layer — exact steam pixels extracted from hero-static.png.
   Fades in from slightly below, drifts up, fades out. Loops every 8s. */
.hero-steam {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  animation: hero-steam-rise 8s ease-in-out infinite;
  will-change: transform, opacity;
}

@keyframes hero-steam-rise {
  0%   { opacity: 0;   transform: translateY(1%);  }
  20%  { opacity: 1;   transform: translateY(0);   }
  75%  { opacity: 0.7; transform: translateY(-4%); }
  100% { opacity: 0;   transform: translateY(-6%); }
}

/* Dogs — sprite sheet animation */
.hero-dog {
  position: absolute;
  bottom: 0;
  width: 35%;
  overflow: hidden;
}

.hero-dog--golden { left: 5%; top: 55%; }
.hero-dog--brown  { left: 50%; top: 53%; }

.hero-dog__strip {
  display: block;
  width: 800%; /* 8 frames × 100% of container */
  max-width: none; /* override global img { max-width: 100% } */
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  animation: sprite-play var(--duration, 8s) steps(8) infinite;
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  .sprite-anim__strip,
  .hero-dog__strip,
  .hero-cursor,
  .hero-steam { animation: none !important; }
}
