/* ==========================================================================
   weathercitizen.media
   Shared stylesheet. Every page links this one file.
   ========================================================================== */

/* --- 0. Fonts ---------------------------------------------------------
   Homeworld Translator — display face, wordmark only. Caps-only design:
   lowercase input renders as the same forms, so markup stays lowercase.
   DejaVu Sans Mono — body face. This is the font Pure Data uses in its
   patching environment.
   Both are subset to Latin + the punctuation this site actually uses.
   ---------------------------------------------------------------------- */

@font-face {
  font-family: "Homeworld Translator";
  src: url("../fonts/homeworld-translator.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "DejaVu Sans Mono Web";
  src: url("../fonts/dejavusansmono.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "DejaVu Sans Mono Web";
  src: url("../fonts/dejavusansmono-bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* --- 1. Tokens -------------------------------------------------------- */

:root {
  --bg:          #000000;
  --bg-raise:    #0a0a0a;   /* barely-there lift for tiles */
  --text:        #c9c9c9;   /* body: light gray */
  --text-bright: #f2f2f2;   /* headings, hover state */
  --text-dim:    #6e6e6e;   /* captions, metadata */
  --line:        #232323;   /* hairlines */

  --font: "DejaVu Sans Mono Web", "DejaVu Sans Mono", ui-monospace,
          "SFMono-Regular", Menlo, Consolas, monospace;
  --font-display: "Homeworld Translator", var(--font);

  /* Fluid type. Monospace runs wide, so the steps sit a little below
     what they would be for a proportional face. */
  --step--1: clamp(0.66rem, 0.62rem + 0.14vw, 0.74rem);
  --step-0:  clamp(0.78rem, 0.74rem + 0.18vw, 0.88rem);
  --step-1:  clamp(0.92rem, 0.85rem + 0.34vw, 1.14rem);
  --step-2:  clamp(1.25rem, 1.00rem + 1.10vw, 2.05rem);
  --step-3:  clamp(1.80rem, 1.10rem + 3.20vw, 4.40rem);

  --gutter: clamp(1.25rem, 0.8rem + 2.2vw, 3.5rem);
  --stack:  clamp(3.5rem, 2rem + 6vw, 8rem);   /* vertical section rhythm */

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* --- 2. Reset --------------------------------------------------------- */

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--step-0);
  font-weight: 400;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

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

h1, h2, h3, h4 {
  font-weight: 400;
  line-height: 1.24;
  color: var(--text-bright);
  margin: 0;
}

p { margin: 0 0 1.3em; }
p:last-child { margin-bottom: 0; }

::selection { background: var(--text-bright); color: var(--bg); }

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

/* --- 3. Layout primitives --------------------------------------------- */

.wrap {
  width: 100%;
  max-width: 1600px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Narrow reading column, left-anchored so it lines up with everything else */
.wrap--narrow { max-width: 58rem; margin-inline: 0; }

.section { padding-block: var(--stack); }

.rule {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
}

/* Small uppercase label — metadata and section markers */
.label {
  font-size: var(--step--1);
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--text-bright);
  color: var(--bg);
  padding: 0.75rem 1.25rem;
  z-index: 200;
}
.skip-link:focus { left: 0; }

/* --- 4. Header / navigation ------------------------------------------- */

.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: clamp(1.1rem, 0.7rem + 1.4vw, 1.9rem) var(--gutter);
  background: rgba(0, 0, 0, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* Kept for pages that want a transparent header over media */
.site-header--over {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: background-color 0.4s var(--ease);
}
.site-header--over.is-scrolled {
  background: rgba(0, 0, 0, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.wordmark {
  font-size: var(--step--1);
  letter-spacing: 0.12em;
  color: var(--text-bright);
  white-space: nowrap;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: clamp(0.9rem, 0.3rem + 1.3vw, 1.9rem);
}

.nav a {
  position: relative;
  font-size: var(--step--1);
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--text-dim);
  padding-block: 0.2em;
  transition: color 0.3s var(--ease);
}

.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s var(--ease);
}

.nav a:hover,
.nav a:focus-visible { color: var(--text-bright); }
.nav a:hover::after   { transform: scaleX(1); }

.nav a[aria-current="page"] { color: var(--text-bright); }
.nav a[aria-current="page"]::after { transform: scaleX(1); }

/* Mobile: hamburger + full-screen overlay */
.nav-toggle {
  display: none;
  background: none;
  border: 0;
  padding: 0.5rem;
  margin: -0.5rem;
  cursor: pointer;
  color: var(--text-bright);
}
.nav-toggle svg { display: block; }
.nav-toggle .icon-close { display: none; }
.nav-toggle[aria-expanded="true"] .icon-open  { display: none; }
.nav-toggle[aria-expanded="true"] .icon-close { display: block; }

@media (max-width: 960px) {
  .nav-toggle { display: block; }

  .nav {
    position: fixed;
    inset: 0;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 1.5rem;
    padding: var(--gutter);
    background: rgba(0, 0, 0, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s var(--ease), visibility 0.35s;
  }
  .nav.is-open { opacity: 1; visibility: visible; }
  .nav a { font-size: var(--step-1); }
}

/* --- 5. Landing ------------------------------------------------------- */

.lander {
  padding-top: clamp(4.25rem, 3.25rem + 3vw, 6.5rem);
}

/* The source video carries its own black border, so it is shown whole —
   object-fit is contain, never cover, and there is no scrim over it. */
.lander__video {
  width: 100%;
  background: var(--bg);
}

.lander__video video {
  width: 100%;
  height: auto;
  max-height: calc(100svh - 11rem);
  object-fit: contain;
}

.lander__title {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 9.15vw, 14rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.02em;
  text-align: center;
  text-wrap: nowrap;
  color: var(--text-bright);
  margin-block: clamp(1.75rem, 1rem + 2.5vw, 3.5rem) 0;
  /* "weather citizen" measures 10.23em in this face including tracking,
     so 9.15vw sets the line to ~94% of the viewport — near the full width
     of the video above it — and 2vw of padding keeps it off the edges. */
  padding-inline: 2vw;
}

.lander__work {
  margin-top: clamp(3rem, 2rem + 4vw, 6.5rem);
}

/* --- 6. Page header (interior pages) ---------------------------------- */

.page-head {
  padding-top: clamp(7rem, 5rem + 8vw, 11rem);
  padding-bottom: clamp(2.5rem, 1.5rem + 3vw, 4.5rem);
}

.page-head__title {
  font-size: var(--step-2);
  font-weight: 400;
  letter-spacing: -0.01em;
}

.page-head__intro {
  margin-top: 1.1rem;
  max-width: 62ch;
  color: var(--text-dim);
}

/* --- 7. Tile grid ----------------------------------------------------- */

.grid {
  display: grid;
  gap: clamp(1.5rem, 0.8rem + 2.4vw, 3.25rem)
       clamp(1rem, 0.6rem + 1.6vw, 2.25rem);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.grid--two   { grid-template-columns: repeat(auto-fill, minmax(min(100%, 28rem), 1fr)); }
.grid--dense { grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); }

/* Landing page: the projects stack down the page in one centered column */
.grid--stack {
  grid-template-columns: minmax(0, 1fr);
  max-width: 62rem;
  margin-inline: auto;
  text-align: center;
  gap: clamp(2.5rem, 1.5rem + 3.5vw, 5rem);
}

.tile { position: relative; }

.tile__frame {
  position: relative;
  overflow: hidden;
  background: var(--bg-raise);
  aspect-ratio: 16 / 9;
}

.tile--square .tile__frame { aspect-ratio: 1 / 1; }
.tile--tall   .tile__frame { aspect-ratio: 3 / 4; }
.tile--wide   .tile__frame { aspect-ratio: 3 / 2; }

.tile__frame img,
.tile__frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.35) brightness(0.82);
  transform: scale(1.01);
  transition: transform 0.9s var(--ease), filter 0.6s var(--ease);
}

.tile a:hover .tile__frame img,
.tile a:focus-visible .tile__frame img,
.tile a:hover .tile__frame video {
  transform: scale(1.06);
  filter: grayscale(0) brightness(1);
}

.tile__body { padding-top: 0.9rem; }

.tile__title {
  font-size: var(--step-0);
  font-weight: 400;
  color: var(--text-bright);
  transition: opacity 0.3s var(--ease);
}

.tile__meta {
  margin-top: 0.3rem;
  font-size: var(--step--1);
  color: var(--text-dim);
}

.tile a:hover .tile__title { opacity: 0.72; }

/* External-link tiles get a small mark */
.tile__title[data-external]::after {
  content: " \2197";
  font-size: 0.85em;
  color: var(--text-dim);
}


/* --- 7b. Subsections (sound design & score) --------------------------- */

.subsection + .subsection { margin-top: clamp(3.5rem, 2rem + 5vw, 7rem); }

.subsection__title {
  font-size: var(--step-0);
  font-weight: 400;
  letter-spacing: 0.16em;
  color: var(--text-dim);
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: clamp(1.75rem, 1.2rem + 1.6vw, 3rem);
}

/* Film entries: a title over its player */
.films {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 64rem;
  display: grid;
  gap: clamp(2.5rem, 1.5rem + 3vw, 4.5rem);
}

.film__title {
  font-size: var(--step-1);
  font-weight: 400;
  color: var(--text-bright);
  margin-bottom: 0.95rem;
}
.film__title a {
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease);
}
.film__title a:hover { border-color: var(--text-dim); }

/* Aspect comes from each embed's own ratio, set inline per entry. */
.film__player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-raise);
}
.film__player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Entry with nothing to play yet */
.film__player--empty {
  display: grid;
  place-content: center;
  aspect-ratio: auto;
  min-height: clamp(5.5rem, 4rem + 5vw, 8rem);
  background: none;
  border: 1px dashed var(--line);
}
.film__player--empty span {
  font-size: var(--step--1);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Tiles that are not links yet */
.tile--inert .tile__frame img { filter: grayscale(1) brightness(0.55); }

/* --- 8. Text list (sonic theory, live) -------------------------------- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.list li { border-bottom: 1px solid var(--line); }

.list a,
.list > li > .list__row {
  display: grid;
  grid-template-columns: 6rem 1fr auto;
  gap: 1.5rem;
  align-items: baseline;
  padding-block: clamp(1.1rem, 0.8rem + 0.8vw, 1.75rem);
  transition: opacity 0.3s var(--ease), padding-inline 0.4s var(--ease);
}

.list a:hover { opacity: 0.6; padding-inline: 0.5rem 0; }

.list__year {
  font-size: var(--step--1);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.list__title {
  display: block;
  font-size: var(--step-1);
  font-weight: 400;
  color: var(--text-bright);
}

.list__desc {
  display: block;
  margin-top: 0.45rem;
  font-size: var(--step-0);
  color: var(--text-dim);
  max-width: 68ch;
}

.list__kind {
  font-size: var(--step--1);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
}

@media (max-width: 760px) {
  .list a,
  .list > li > .list__row {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
  .list__kind { order: -1; }
}


/* --- 8b. Audio entries (sonic theory) --------------------------------- */

.entries {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.entries > li {
  border-bottom: 1px solid var(--line);
  padding-block: clamp(1.75rem, 1.2rem + 1.6vw, 2.75rem);
}

.entry__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 1.25rem;
  margin-bottom: 1.15rem;
}

.entry__title {
  font-size: var(--step-1);
  font-weight: 400;
  color: var(--text-bright);
}

.entry__year {
  font-size: var(--step--1);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* SoundCloud's player is a fixed 166px tall; it fills the column width. */
.entry__player iframe {
  display: block;
  width: 100%;
  height: 166px;
  border: 0;
}

.entry__credit {
  margin: 0.65rem 0 0;
  font-size: var(--step--1);
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry__credit a {
  border-bottom: 1px solid transparent;
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.entry__credit a:hover {
  color: var(--text-bright);
  border-color: var(--text-dim);
}

/* --- 9. Individual work page ------------------------------------------ */

.work-hero {
  margin-top: clamp(5.5rem, 4rem + 6vw, 8.5rem);
  background: var(--bg-raise);
  overflow: hidden;
}
.work-hero img,
.work-hero video { width: 100%; height: auto; }

/* When the media should fill a fixed frame rather than keep its own shape */
.work-hero--crop { aspect-ratio: 21 / 9; }
.work-hero--crop img,
.work-hero--crop video { height: 100%; object-fit: cover; }

.work-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1.75rem 2.5rem;
  padding-block: clamp(2rem, 1.2rem + 2.4vw, 3.5rem);
  border-bottom: 1px solid var(--line);
}
.work-meta dt {
  font-size: var(--step--1);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}
.work-meta dd { margin: 0; color: var(--text); }

.prose { max-width: 68ch; font-size: var(--step-0); line-height: 1.85; }
.prose h2 {
  font-size: var(--step-1);
  margin-top: 2.5em;
  margin-bottom: 0.85em;
  color: var(--text-bright);
}
.prose a {
  border-bottom: 1px solid var(--text-dim);
  transition: border-color 0.3s var(--ease), color 0.3s var(--ease);
}
.prose a:hover { color: var(--text-bright); border-color: var(--text-bright); }

/* Media blocks inside a work page */
.media-block { margin-block: var(--stack); }
.media-block figure { margin: 0; }
.media-block figcaption {
  margin-top: 0.9rem;
  font-size: var(--step--1);
  color: var(--text-dim);
  max-width: 68ch;
}

/* Responsive video embed (YouTube / Vimeo iframes) */
.embed {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg-raise);
}
.embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.back-link {
  display: inline-block;
  font-size: var(--step--1);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  transition: color 0.3s var(--ease);
}
.back-link:hover { color: var(--text-bright); }

/* --- 10. Footer ------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: clamp(2.5rem, 1.5rem + 3vw, 4.5rem);
  margin-top: clamp(2rem, 1rem + 3vw, 4rem);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 3rem;
  justify-content: space-between;
  align-items: flex-start;
}

.site-footer a {
  color: var(--text-dim);
  transition: color 0.3s var(--ease);
}
.site-footer a:hover { color: var(--text-bright); }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-size: var(--step--1);
}

.colophon {
  font-size: var(--step--1);
  color: var(--text-dim);
}

/* --- 11. Scroll reveal ------------------------------------------------ */

.reveal {
  opacity: 0;
  transform: translateY(1.5rem);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}
.reveal.is-visible { opacity: 1; transform: none; }

/* Stagger children of a revealed grid */
.reveal-stagger > * {
  opacity: 0;
  transform: translateY(1.5rem);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}
.reveal-stagger.is-visible > * { opacity: 1; transform: none; }
.reveal-stagger.is-visible > *:nth-child(1) { transition-delay: 0.00s; }
.reveal-stagger.is-visible > *:nth-child(2) { transition-delay: 0.07s; }
.reveal-stagger.is-visible > *:nth-child(3) { transition-delay: 0.14s; }
.reveal-stagger.is-visible > *:nth-child(4) { transition-delay: 0.21s; }
.reveal-stagger.is-visible > *:nth-child(5) { transition-delay: 0.28s; }
.reveal-stagger.is-visible > *:nth-child(6) { transition-delay: 0.35s; }

/* --- 12. Accessibility ------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal, .reveal-stagger > * { opacity: 1; transform: none; }
}

/* Placeholder marker — delete .is-placeholder once real media is in */
.work-hero.is-placeholder { position: relative; }

.is-placeholder .tile__frame::after,
.work-hero.is-placeholder::after {
  content: "placeholder";
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.65);
  padding: 0.3rem 0.5rem;
  pointer-events: none;
}
