/*
  Rebuilt from the Cargo site design. Sizes are in rem, and the root font size
  scales with the viewport (set by the script in base.njk), so the whole page
  scales like it did on Cargo. html.mobile = portrait / phone layout.
*/

:root {
  --text: rgba(255, 255, 255, 0.85);
  --text-muted: rgba(255, 255, 255, 0.6);
  --rule: rgba(255, 255, 255, 0.25);
  --active: #41715a;
  --background: #000;
  --font-sans: "Geist Variable", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Geist Mono Variable", ui-monospace, Menlo, monospace;
  --pad-scale: 1;
}

html {
  font-size: var(--base-size, 1.44vmin);
}

html.mobile {
  font-size: calc(var(--base-size) * 1.49);
  --pad-scale: 0.35;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--background);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

a:active {
  opacity: 0.7;
}

/* ---------------------------------------------------------------- page frame */

.page {
  display: flex;
  justify-content: center;
}

.page-layout {
  width: 100%;
  max-width: 85%;
}

.mobile .page-layout {
  max-width: 100%;
}

.page-content {
  padding: calc(3rem * var(--pad-scale));
}

main.page {
  flex: 1 0 auto;
}

.home main .page-content {
  padding-top: calc(3.5rem * var(--pad-scale));
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header .page-content {
  padding-top: calc(2rem * var(--pad-scale));
  padding-bottom: 0;
}

.site-header a.active {
  color: var(--active);
}

.site-footer .page-content {
  padding-top: calc(15rem * var(--pad-scale));
}

/* ---------------------------------------------------------------- text */

.bodycopy {
  --font-scale: 1;
  font-family: var(--font-sans);
  font-size: 1.3rem;
  font-weight: 400;
  line-height: 1.2;
  color: var(--text);
  overflow-wrap: break-word;
}

.mobile .bodycopy {
  font-size: 0.6rem;
}

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

[style*="--font-scale"] {
  font-size: calc(var(--font-scale) * 1em);
}

.caption {
  display: block;
  font-family: var(--font-mono);
  font-size: calc(var(--font-scale, 1) * 1.1rem);
  line-height: 1.3;
  color: var(--text-muted);
}

.caption a {
  color: var(--text-muted);
  text-decoration: underline;
}

.heading-3 {
  display: block;
  font-size: 1.85rem;
  line-height: 1.2;
}

hr {
  height: 1px;
  margin: 1rem 0;
  border: 0;
  background: var(--rule);
}

ul {
  margin: 0;
  padding: 0 0 0 2em;
}

ol {
  margin: 0;
  padding: 0 0 0 2.5em;
  list-style-type: decimal-leading-zero;
}

blockquote {
  margin: 0;
  padding: 0 0 0 2em;
}

sub,
sup {
  position: relative;
  vertical-align: baseline;
}

sub {
  top: 0.3em;
}

sup {
  top: -0.4em;
}

/* ---------------------------------------------------------------- columns
   <div class="column-set" style="--columns: 12">
     <div class="column-unit" style="--span: 4">…</div> …
   Stacks vertically on mobile unless the set has .no-stack.
   Gutters shrink on mobile by the same factor as page padding, like Cargo. */

.column-set {
  display: grid;
  grid-template-columns: repeat(var(--columns, 12), minmax(0, 1fr));
  column-gap: calc(var(--gutter, 1rem) * var(--pad-scale));
  align-items: start;
}

.column-unit {
  grid-column: span var(--span, 1);
  min-width: 0;
}

.mobile .column-set:not(.no-stack) {
  display: flex;
  flex-direction: column;
  row-gap: calc(var(--mobile-gutter, var(--gutter, 1rem)) * var(--pad-scale));
}

.mobile .column-set:not(.no-stack) > .column-unit.empty {
  display: none;
}

/* ---------------------------------------------------------------- media */

.media {
  display: inline-block;
  vertical-align: top;
  width: 100%;
  max-width: 100%;
  height: auto;
  border: 0;
}

iframe.media {
  aspect-ratio: 16 / 9;
  background: #111;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(var(--columns, 3), minmax(0, 1fr));
  gap: calc(var(--gutter, 1rem) * var(--pad-scale));
  align-items: start;
}

.mobile .gallery-grid {
  --_mobile-gutter: var(--mobile-gutter, var(--gutter, 1rem));
  grid-template-columns: repeat(var(--mobile-columns, var(--columns, 3)), minmax(0, 1fr));
  column-gap: calc(var(--_mobile-gutter) * var(--pad-scale));
  row-gap: calc(var(--mobile-row-gutter, var(--_mobile-gutter)) * var(--pad-scale));
}

.gallery-grid > .media-link > .media {
  width: 100%;
}

/* Project thumbnails (homepage, Projects page, tag pages) */

.thumbnail {
  margin: 0;
}

.thumbnail .media {
  display: block;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

.thumbnail .caption {
  margin: 1.5em 0 2em;
  text-align: center;
}

.thumbnail .caption .title {
  color: var(--text-muted);
  text-decoration: none;
}

.thumbnail .caption .tags {
  margin-top: 0.25em;
}

/* ---------------------------------------------------------------- homepage hero
   Highlights carousel (src/_includes/hero.njk, src/assets/js/hero.js). */

.hero {
  --hero-interval: 6s;
  margin-bottom: 6rem;
}

.hero-track {
  display: flex;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.hero-track::-webkit-scrollbar {
  display: none;
}

.hero-track:focus-visible {
  outline: 1px solid var(--text-muted);
  outline-offset: 0.5rem;
}

.hero-slide {
  flex: 0 0 100%;
  min-width: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

/* Capped so image, caption and controls all fit in the first screen. */
.hero-media {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 23rem);
  max-height: calc(100svh - 23rem);
  overflow: hidden;
  background: #111;
}

.hero-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-caption {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  column-gap: 2rem;
  align-items: start;
  margin-top: 1.5rem;
}

.hero-caption > * {
  grid-column: 1;
}

.bodycopy .hero-title {
  font-size: 1.85rem;
  line-height: 1.2;
}

.hero-summary {
  margin-top: 0.4em;
}

.hero-caption .hero-highlight {
  grid-column: 2;
  grid-row: 1 / span 2;
  text-align: right;
  color: var(--text);
}

.mobile .hero-caption {
  display: block;
}

.mobile .hero-caption .hero-highlight {
  margin-top: 0.4em;
  text-align: left;
}

.mobile .hero-media {
  aspect-ratio: 4 / 3;
}

.hero-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.hero-controls[hidden] {
  display: none;
}

.mobile .hero-controls {
  flex-wrap: wrap;
  row-gap: 0.5rem;
}

.hero-progress {
  display: flex;
  flex: 1;
  gap: 0.5rem;
}

.mobile .hero-progress {
  flex-basis: 100%;
}

.mobile .hero-count {
  flex: 1;
  margin-left: 0;
}

.hero-progress button {
  flex: 1;
  padding: 0.75rem 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.hero-progress span {
  position: relative;
  display: block;
  height: 1px;
  overflow: hidden;
  background: var(--rule);
}

.hero-progress button:hover span {
  background: var(--text-muted);
}

.hero-progress span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--text);
  transform: scaleX(0);
  transform-origin: left;
}

.hero-progress [aria-current="true"] span::after {
  animation: hero-fill var(--hero-interval) linear forwards;
}

.hero.is-paused .hero-progress span::after,
.hero.is-hidden .hero-progress span::after,
.hero:has(:focus-visible) .hero-progress span::after {
  animation-play-state: paused;
}

@media (hover: hover) {
  .hero:hover .hero-progress span::after {
    animation-play-state: paused;
  }
}

.hero.is-static .hero-progress [aria-current="true"] span::after {
  animation: none;
  transform: scaleX(1);
}

@keyframes hero-fill {
  to {
    transform: scaleX(1);
  }
}

.hero-count {
  margin-left: 0.5rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.hero-button {
  display: inline-flex;
  padding: 0.25rem;
  border: 0;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

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

.hero-button svg {
  width: 1.4rem;
  height: 1.4rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.hero-button .icon-play {
  fill: currentColor;
  stroke: none;
}

.hero-toggle .icon-play,
.hero.is-paused .hero-toggle .icon-pause {
  display: none;
}

.hero.is-paused .hero-toggle .icon-play {
  display: block;
}

.mobile .hero-button svg {
  width: 2.4rem;
  height: 2.4rem;
}

/* ---------------------------------------------------------------- about page CV */

.pdf-iframe {
  display: block;
}

.pdf-link {
  display: none;
}

@media (max-width: 768px) {
  .pdf-iframe {
    display: none;
  }

  .pdf-link {
    display: inline-block;
    margin-top: 10px;
    padding: 12px 16px;
    background: #333;
    color: #fff;
    border-radius: 6px;
    font-weight: bold;
    text-align: center;
  }

  .pdf-link:hover {
    background: #555;
  }
}
