:root {
  /* Black and white, high contrast */
  --bg: #f2ede4;      /* warm script-paper ivory */
  --bg-glow: #f8f5ef; /* soft light falling from the top */
  --text: #000000;
  --muted: #4a4a4a;   /* 7.6:1 on the paper tone — passes WCAG AA and AAA */
  --border: rgba(0, 0, 0, 0.16);
  --tile: #e3ddd1;

  /* Typography — font families */
  /* One typeface across the site: Courier Prime, as in the screenplay hero */
  --font-mono: "Courier Prime", "Courier New", Courier, monospace;
  --font-display: var(--font-mono);
  --font-body: var(--font-mono);

  /* Typography — scale */
  --text-hero: clamp(3.25rem, 1.8rem + 6vw, 7.5rem);    /* 52 → 120px */
  --text-section: clamp(2.5rem, 2.1rem + 0.9vw, 3rem);  /* 40 → 48px */
  --text-project: clamp(1.125rem, 0.95rem + 0.55vw, 1.625rem); /* 18 → 26px */
  --stroke-medium: 0.035em; /* thickens regular Courier Prime toward a medium weight */
  --text-body: 1rem;      /* 16px — screenplay size */
  --text-ui: 0.875rem;    /* 14px */
  --text-meta: 0.8125rem; /* 13px */
  --tracking-display: -0.02em;

  --gutter: 40px;
  --content-max: 1200px; /* widest the content gets */
  --side: max(var(--gutter), 6vw); /* page margin on each side */
  --hero-w: min(var(--content-max), calc(100vw - var(--side) * 2));
  --header-h: 88px;   /* updated by script.js to the real header height */
  --edge: 32px;       /* space above the header = space below the footer */
  --section-gap: 120px; /* space above Projects = space above the footer */
  --footer-bottom: 96px; /* extra room at the very end of the page */
}

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

html {
  scroll-behavior: smooth;
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg);
  background-image: radial-gradient(ellipse 120% 100vh at 50% 0%, var(--bg-glow) 0%, transparent 65%);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.6;
  font-kerning: normal;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Faint film grain over the whole page */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0.06;
  transform: translateZ(0); /* own layer: no repaint while scrolling */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 4px;
}

.wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  padding: 10px 16px;
  background: var(--text);
  color: var(--bg);
  font-size: var(--text-ui);
  z-index: 10;
}

.skip-link:focus {
  top: 16px;
}

/* ---------- Header ---------- */
/* Same width as the hero headline, Projects and footer, centered */
.site-header {
  max-width: calc(var(--hero-w, 1170px) + var(--gutter) * 2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-top: var(--edge);
  padding-bottom: var(--edge);
}

.logo {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 8px 0; /* larger tap area, same layout */
  margin: -8px 0;
}

.nav {
  display: flex;
  align-items: center;
  gap: 32px;
  font-size: 1.125rem; /* 18px */
  font-weight: 700;
  line-height: 1;
}

.nav a {
  color: var(--text);
  transition: opacity 0.2s;
}

.nav a:hover {
  opacity: 0.65;
}

/* Contact: secondary (outlined) button at the far right */
.nav .nav-button {
  padding: 10px 18px;
  border: 1.5px solid var(--text);
  border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}

.nav .nav-button:hover {
  opacity: 1;
  background: var(--text);
  color: var(--bg);
}

.socials a {
  color: var(--text);
  transition: opacity 0.2s;
}

.socials a:hover {
  opacity: 0.65;
}

/* ---------- Hero: split screen ---------- */
/* Text on the left (lined up with the header), portrait filling the right half */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  width: var(--hero-w); /* same width as header, Projects and footer */
  margin: 0 auto;
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100svh - var(--header-h));
  font-family: var(--font-mono);
  color: var(--text);
}

.hero-text {
  align-self: center;
  padding: clamp(24px, 5vh, 48px) clamp(32px, 4vw, 64px) clamp(24px, 5vh, 48px) 0;
}

.hero-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 3vh, 32px) 0;
  opacity: 0;
  animation: photo-in 1s ease forwards;
}

/* Photo with hand-drawn doodles around it (doodles are drawn on a 600×700 grid) */
.doodle-frame {
  position: relative;
  width: min(100%, calc((100svh - var(--header-h) - 64px) * 6 / 7));
  aspect-ratio: 6 / 7;
  color: var(--text);
}

.portrait {
  position: absolute;
  left: 15%;
  top: 10%;
  width: 70%;
  height: 80%;
  object-fit: cover;
  object-position: 58% 22%; /* keep the face in frame */
  border-radius: 28px;
  z-index: 1;
}

.doodles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.doodles-back { z-index: 0; }
.doodles-front { z-index: 2; }

.doodles .paper { fill: var(--bg); }
.doodles .ink { fill: currentColor; stroke: none; }

.doodles text {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  fill: currentColor;
  stroke: none;
}

.doodles text.big { font-size: 20px; }
.doodles text.note { font-size: 19px; }

/* Doodles appear one by one, once */
.doodles > * {
  opacity: 0;
  animation: photo-in 0.5s ease forwards;
  animation-delay: calc(0.5s + var(--i, 0) * 0.09s);
}

@keyframes photo-in {
  to { opacity: 1; }
}

/* No portrait file yet: fall back to a single, full-width text column */
.hero.no-photo {
  grid-template-columns: minmax(0, 1fr);
}

.hero.no-photo .hero-photo {
  display: none;
}

.speech {
  font-weight: 400;
}

.character {
  display: block;
  text-transform: uppercase;
  /* sized to the half-width text column */
  font-size: max(1.75rem, min(calc((var(--hero-w) / 2 - 64px) / 12), 6vh, 3.5rem));
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: clamp(10px, 2vh, 18px);
}

.dialogue {
  display: block;
  /* "storyteller." fits the half-width column; also shrinks on short screens */
  font-size: max(2.4rem, min(calc((var(--hero-w) / 2 - 64px) / 7.2), 11vh, 6.75rem));
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.03em;
}

/* Typewriter: every letter is laid out from the start, then revealed,
   so the line never reflows while it types */
.dialogue .ch {
  position: relative;
  visibility: hidden;
}

.dialogue .ch.on {
  visibility: visible;
}

.dialogue .ch.caret::after {
  content: "";
  position: absolute;
  left: 100%;
  top: 0.12em;
  width: 0.08em;
  height: 0.85em;
  margin-left: 0.04em;
  background: var(--text);
  visibility: visible;
  animation: blink 1s steps(1) 5; /* blinks ~5 seconds, then stays steady */
}

@keyframes blink {
  50% { opacity: 0; }
}

.action {
  max-width: 54ch;
  padding-top: 4px;
  margin-top: clamp(14px, 2.6vh, 28px);
  font-size: clamp(1.0625rem, 0.95rem + 0.3vw, 1.25rem); /* 17 → 20px */
  line-height: 1.6;
  color: var(--text);
  /* Courier Prime has no medium weight; a hairline stroke thickens the
     regular letters to sit between regular and bold */
  -webkit-text-stroke: var(--stroke-medium) currentColor;
  paint-order: stroke fill;
}

.action p + p {
  margin-top: 22px;
}

/* Lines appear one after another, like a page being read */
.line {
  opacity: 0;
  transform: translateY(8px);
  animation: line-in 0.6s ease forwards;
  animation-delay: calc(var(--d, 0) * 0.2s);
}

@keyframes line-in {
  to { opacity: 1; transform: none; }
}

/* IMDb call to action under the hero paragraph (filled; Contact in the header is outlined) */
.cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: clamp(20px, 3.5vh, 32px);
  padding: 14px 26px;
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  -webkit-text-stroke: 0;
  transition: opacity 0.2s;
}

.cta:hover {
  opacity: 0.85;
}

/* ---------- Awards: centered laurels between the hero and Projects ---------- */
.awards {
  width: var(--hero-w);
  margin: 0 auto;
  padding-top: clamp(40px, 7vh, 72px);
}

.award-row {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px 48px;
}

.award {
  display: grid;
  grid-template-columns: 26px auto 26px;
  align-items: center;
  gap: 10px;
  max-width: 280px;
  text-align: center;
  -webkit-text-stroke: 0;
}

.laurel {
  width: 100%;
  height: auto;
  color: var(--text);
}

.laurel.right {
  transform: scaleX(-1);
}

.award-year {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 2px;
}

.award-name {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 2px;
}

.award-detail {
  display: block;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--muted);
  -webkit-text-stroke: var(--stroke-medium) currentColor;
  paint-order: stroke fill;
}

/* ---------- Projects ---------- */
/* Jumping to #work / #contact leaves a little breathing room above the heading */
.work,
.site-footer {
  scroll-margin-top: 24px;
}

/* Same width as the hero headline (measured in script.js), centered */
.work {
  max-width: calc(var(--hero-w, 1170px) + var(--gutter) * 2);
  padding-top: var(--section-gap);
}

.work-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 16px 32px;
  margin-bottom: 48px;
}

.section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-section);
  line-height: 1.1;
  letter-spacing: var(--tracking-display);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 32px;
}

.filters button {
  font: inherit;
  font-size: 1.125rem; /* 18px */
  color: var(--muted);
  -webkit-text-stroke: var(--stroke-medium) currentColor;
  paint-order: stroke fill;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 4px 0;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.filters button:hover {
  color: var(--text);
}

.filters button[aria-pressed="true"] {
  color: var(--text);
  font-weight: 700;
  -webkit-text-stroke: 0;
  border-bottom-color: var(--text);
}

/* Equal grid of covers */
.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 56px 32px;
}

.project[hidden] {
  display: none;
}

.cover {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9; /* wide, like series and film key art */
  overflow: hidden;
  background: var(--tile);
  margin-bottom: 14px;
}

.cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s ease;
}

@media (hover: hover) {
  .project:hover .cover img,
  .project:hover .cover-art {
    transform: scale(1.03);
  }
}

/* Placeholder cover, shown until a real image is added */
.cover-art {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  background:
    radial-gradient(ellipse at 50% 28%, hsl(0 0% var(--light)), transparent 65%),
    linear-gradient(to top, #0a0a0a 8%, #2b2b2b);
  font-family: var(--font-display);
  padding: 14px 16px;
  font-size: clamp(1rem, 0.85rem + 0.4vw, 1.25rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: var(--tracking-display);
  color: #fff;
  transition: transform 0.7s ease;
}

/* Play badge on covers that link to a YouTube trailer or playlist */
.play-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.72);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
  transition: transform 0.25s, background 0.25s;
}

.play-badge svg {
  width: 26px;
  height: 26px;
  margin-left: 3px;
  fill: #fff;
}

@media (hover: hover) {
  .project:hover .play-badge {
    transform: scale(1.08);
    background: #000;
  }
}

.cover.has-image .cover-art {
  display: none;
}

/* Tall poster inside the wide frame: whole poster, centered, over a blurred copy */
.cover.is-poster::before {
  content: "";
  position: absolute;
  inset: -24px;
  background: var(--poster) center / cover no-repeat;
  filter: blur(22px) saturate(1.1) brightness(0.8);
}

.cover.is-poster img {
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.35));
}

@media (hover: hover) {
  .project:hover .cover.is-poster img {
    transform: scale(1.04);
  }
}

.project-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-project);
  line-height: 1.15;
  letter-spacing: var(--tracking-display);
  margin-bottom: 6px;
}

.project-title a {
  padding: 4px 0; /* larger tap area */
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 2px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.25s;
}

.project-title a:hover {
  background-size: 100% 2px;
}

.project-title .arrow {
  font-size: 0.75em;
}

.project-meta {
  font-family: var(--font-mono);
  font-size: 0.8125rem; /* 13px */
  letter-spacing: 0.06em;
  -webkit-text-stroke: var(--stroke-medium) currentColor;
  paint-order: stroke fill;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.project-tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.project-tags li {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  padding: 7px 12px;
  border: 1.5px solid var(--text);
  border-radius: 999px;
}

.project-desc {
  font-size: 1rem; /* 16px */
  line-height: 1.5;
  /* Keep cards even: three lines at most */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--muted);
  -webkit-text-stroke: var(--stroke-medium) currentColor;
  paint-order: stroke fill;
}

/* Shown when a filter tab has no projects yet */
.empty-state {
  padding: 48px 0;
  text-align: center;
  font-size: 1.125rem;
  color: var(--muted);
}

/* ---------- Media ---------- */
.media-list {
  list-style: none;
  border-top: 1px solid var(--border);
}

.media-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 32px;
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}

.media-title {
  font-size: clamp(1.125rem, 1rem + 0.4vw, 1.375rem);
  font-weight: 700;
  line-height: 1.3;
}

.media-title a:hover {
  opacity: 0.65;
}

.media-meta {
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  -webkit-text-stroke: var(--stroke-medium) currentColor;
  paint-order: stroke fill;
}

/* ---------- Footer ---------- */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center; /* email and links middle-aligned */
  gap: 16px 32px;
  max-width: calc(var(--hero-w, 1170px) + var(--gutter) * 2); /* same width as Projects */
  margin-top: var(--section-gap);
  padding-bottom: var(--footer-bottom);
}

.footer-title {
  flex-basis: 100%;
  margin-bottom: 16px;
}

.email {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 1rem + 1vw, 1.75rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: var(--tracking-display);
  overflow-wrap: anywhere;
  padding: 4px 0; /* larger tap area, same layout */
  margin: -4px 0;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

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

.socials {
  display: flex;
  gap: 32px;
  font-size: 1.125rem; /* same as the header links */
  font-weight: 700;
}

.copyright {
  flex-basis: 100%;
  line-height: 1;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cover img, .cover-art { transition: none; }
  .hero-photo, .doodles > * { opacity: 1; animation: none; }
  .line { opacity: 1; transform: none; animation: none; }
  .dialogue .ch.caret::after { animation: none; }
}

/* ---------- Responsive ---------- */
/* Phones and narrow tablets: portrait full width on top, text below */
@media (max-width: 900px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }
  .hero-photo {
    order: -1;
    padding: 16px 0 0;
  }
  .doodle-frame { width: min(100%, 460px); }
  .hero-text {
    padding: 32px 0 8px;
  }
  .character { font-size: clamp(1.75rem, 1rem + 3.5vw, 2.75rem); }
  .dialogue { font-size: clamp(2.4rem, 1rem + 7vw, 4.5rem); }
}

@media (max-width: 1024px) {
  :root { --gutter: 32px; --section-gap: 100px; }
  .project-grid { grid-template-columns: repeat(2, 1fr); gap: 48px 24px; }
}

@media (max-width: 640px) {
  :root { --gutter: 16px; }
  :root { --edge: 20px; --section-gap: 80px; --footer-bottom: 56px; --side: var(--gutter); }
  .logo { font-size: 1.25rem; }
  .nav { gap: 12px; font-size: 0.8125rem; }
  .nav a { padding: 12px 0; margin: -12px 0; } /* bigger tap targets, same layout */
  .nav .nav-button { padding: 8px 12px; margin: -8px 0; }
  .filters button { padding: 8px 0; }
  .character { margin-bottom: 14px; }
  .award { grid-template-columns: 18px auto 18px; gap: 6px; max-width: 46%; }
  .award-row { gap: 20px 16px; }
  .cta { padding: 13px 22px; }
  .work-head { margin-bottom: 32px; }
  .project-grid { grid-template-columns: 1fr; gap: 40px; }
}
