/* =========================================================================
   Lachie Thompson — Writer & Director
   Ported & simplified from the Cargo template, kept intentionally minimal.
   ========================================================================= */

/* --- Fonts (self-hosted, variable axis) ---------------------------------- */
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/InterVariable.woff2") format("woff2-variations");
}

@font-face {
  font-family: "Inter Variable";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/InterVariable-Italic.woff2") format("woff2-variations");
}

@font-face {
  font-family: "JetBrains Mono Variable";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/assets/fonts/JetBrainsMono-Variable.woff2") format("woff2-variations");
}

/* --- Design tokens ------------------------------------------------------- */
:root {
  --swatch-1: rgba(0, 0, 0, 0.85);
  --swatch-2: rgba(0, 0, 0, 0.75);
  --swatch-3: rgba(0, 0, 0, 0.6);
  --swatch-4: rgba(0, 0, 0, 0.4);
  --swatch-5: rgba(0, 0, 0, 0.25);
  --swatch-active: var(--swatch-1);

  /* Swap to "ABC Diatype Variable", "Diatype Semi-Mono Variable" if you
     ever buy a Dinamo web licence — just change these two values. */
  --font-sans: "Inter Variable", "Inter", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono Variable", "JetBrains Mono",
    ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --page-padding: 1rem;
  --nav-width: 11rem;
  --gap: 0.75rem;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: #fff;
  color: var(--swatch-3);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

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

a:active {
  opacity: 0.7;
}

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

/* --- Type ---------------------------------------------------------------- */
h1 {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.1;
  color: var(--swatch-1);
  margin: 0;
  letter-spacing: 0;
}

p,
.bodycopy {
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 1.1rem;
  line-height: 1.4;
  color: var(--swatch-3);
  margin: 0 0 1em;
}

.caption {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.3;
  color: var(--swatch-4);
  letter-spacing: 0.03em;
  margin: 0;
}

.caption a {
  text-decoration: none;
  color: var(--swatch-4);
}

.caption a:hover {
  color: var(--swatch-2);
}

/* --- Layout: site shell -------------------------------------------------- */
/*
  Nav is fixed; it sits outside the layout flow.
  .site is a simple block — main content gets left padding to clear the nav.
*/
.site {
  display: block;
  padding: var(--page-padding);
  padding-left: calc(var(--nav-width) + 2.5rem);
  min-height: 100vh;
  min-height: 100dvh;
}

/* --- Nav ----------------------------------------------------------------- */
.nav {
  position: fixed;
  top: var(--page-padding);
  left: var(--page-padding);
  z-index: 100;
  width: var(--nav-width);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav__title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--swatch-1);
  cursor: default;
  /* On touch devices this acts as the tap-to-open trigger */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.nav__role {
  font-size: 1rem;
  font-weight: 400;
  color: var(--swatch-3);
  margin-bottom: 1.25rem;
}

.nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav__list a {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4em;
  font-size: 1rem;
  font-weight: 500;
  color: var(--swatch-1);
  transition: color 150ms ease;
}

.nav__list a:hover {
  color: var(--swatch-active);
}

.nav__list a[aria-current="page"] {
  color: var(--swatch-active);
}

.nav__list a::before {
  font-family: var(--font-mono);
  display: inline-block;
  width: 1em;
  color: inherit;
}

.nav__list a.is-internal::before { content: "→"; }
.nav__list a.is-external::before { content: "↗"; }

/*
  Collapse: links after the first fade out by default.
  Desktop hover on the nav container reveals them (CSS-only, no JS needed).
  Mobile: JS adds .is-open to reveal.
*/
.nav__list li:not(:first-child) a {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 1400ms ease, transform 1400ms ease;
}

/* Desktop hover — only fires on devices with a true pointer/hover */
@media (hover: hover) and (pointer: fine) {
  .nav:hover .nav__list li:not(:first-child) a {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }
}

/* Open state applied by JS on touch devices */
.nav.is-open .nav__list li:not(:first-child) a {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* --- Main content ---------------------------------------------------------*/
.main {
  min-width: 0;
}

/* About page: true vertical + horizontal centre */
.main--about {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
}

/* --- Work grid ----------------------------------------------------------- */
/*
  6-column grid produces three span widths:
    full  → span 6  (hero items, one per row)
    half  → span 3  (two items per row)
    third → span 2  (three items per row)
*/
.thumbnails {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--gap);
}

.thumbnail {
  position: relative;
  grid-column: span 2;
  aspect-ratio: 16 / 9;
  background: #111;
  overflow: hidden;
  margin: 0;
}

.thumbnail--full  { grid-column: span 6; }
.thumbnail--half  { grid-column: span 3; }
.thumbnail--third { grid-column: span 2; }

.thumbnail__media {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Title overlays the bottom of the frame — hidden until hover/tap */
.thumbnail__title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.45rem 0.6rem 0.5rem;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  line-height: 1.2;
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
  z-index: 2;
}

.thumbnail__title span {
  display: block;
}

/* Desktop: show on hover */
@media (hover: hover) and (pointer: fine) {
  .thumbnail:hover .thumbnail__title {
    opacity: 1;
  }
}

/* Mobile: show when JS adds .is-active via tap */
.thumbnail.is-active .thumbnail__title {
  opacity: 1;
}

/* --- About page ---------------------------------------------------------- */
.about {
  max-width: 36rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.about h2 {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 1rem;
  color: var(--swatch-1);
  margin: 0 0 0.25rem;
}

.about p {
  font-size: 1.1rem;
  color: var(--swatch-3);
  margin: 0 0 0.5rem;
}

.about a {
  color: var(--swatch-3);
}

.about a:hover {
  color: var(--swatch-1);
}

/* --- Footer / next button ------------------------------------------------ */
.foot {
  grid-column: 2;
  margin-top: 4rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--swatch-1);
}

/* --- Responsive ---------------------------------------------------------- */

/* Tablet: collapse thirds → halves, keep halves and full */
@media (max-width: 1023px) {
  .thumbnail--third { grid-column: span 3; }
}

/* Mobile — nav drops out of fixed position, sits at top of page */
@media (max-width: 639px) {
  :root {
    --page-padding: 0.75rem;
  }

  .site {
    padding-left: var(--page-padding);
    padding-top: 0;
  }

  .nav {
    position: static;
    width: auto;
    margin-bottom: 1rem;
  }

  /* On mobile all links are collapsed until .is-open;
     tap on .nav__title to expand (handled by inline JS). */
  .nav__title {
    cursor: pointer;
  }

  .nav__list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
  }

  .thumbnail,
  .thumbnail--full,
  .thumbnail--half,
  .thumbnail--third {
    grid-column: span 6;
  }

  .about {
    max-width: 100%;
  }
}

/* Stop autoplaying motion if the visitor prefers reduced motion. */
@media (prefers-reduced-motion: reduce) {
  .thumbnail__media {
    animation: none !important;
  }
}
