/* Readex Pro, variable weight (SIL Open Font License, see /assets/fonts/OFL.txt). */
@font-face {
  font-family: "Readex Pro";
  font-style: normal;
  font-weight: 160 700;
  font-display: swap;
  src: url("/assets/fonts/readex-pro-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Readex Pro";
  font-style: normal;
  font-weight: 160 700;
  font-display: swap;
  src: url("/assets/fonts/readex-pro-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #161616;
  --bg-alt: #111111;
  --fg: #f4f4f4;
  --accent: #2c6b80;
  --accent-light: #4ba3c3;
  --content: 1092px;
  --gutter: 24px;
  --band: 54px;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 18px/1.7 "Readex Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

img {
  height: auto;
}

/* iOS ignores the contextmenu event; this hides its long-press "Save image" menu instead.
   user-drag stops images being dragged out in Chrome and Safari; main.js covers other browsers. */
img,
video {
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

[data-href] {
  cursor: pointer;
}

.text-link {
  text-decoration: underline;
}

a {
  color: inherit;
}

h2 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.35;
}

p {
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 3px;
}

.sprite {
  display: none;
}

/* Full-width colour bands with a centred content column, as on the old site. */
.band {
  padding: var(--band) 0;
}

.band--alt {
  background: var(--bg-alt);
}

.container {
  width: min(var(--content), 100% - 2 * var(--gutter));
  margin-inline: auto;
}

.stack {
  display: grid;
  gap: 24px;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

/* Header and footer */
.site-header,
.site-footer {
  padding: 22px 0;
}

.logo,
.logo img {
  display: block;
  width: 150px;
  height: auto;
}

.social {
  display: flex;
  align-items: center;
  gap: 12px;
}

.social [data-href] {
  display: block;
  color: var(--fg);
  transition: color 0.15s;
}

.social [data-href]:hover {
  color: var(--accent-light);
}

.social svg {
  display: block;
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* Screenshot slider */
.slider {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--bg-alt);
  touch-action: pan-y;
}

.slider:focus-visible {
  outline-offset: 4px;
}

.slider__track {
  display: flex;
  height: 100%;
  transition: transform 0.5s ease;
}

.slider__slide {
  flex: 0 0 100%;
  margin: 0;
}

.slider__slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

.slider__dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14px;
  display: flex;
  justify-content: center;
  gap: 6px;
}

.slider__dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.5);
  cursor: pointer;
}

.slider__dot[aria-selected="true"] {
  background: #fff;
}

.caption {
  font-size: 18px;
}

/* Works tabs */
.tabs__list {
  display: flex;
  flex-wrap: wrap;
}

.tabs__tab {
  padding: 14px 16px;
  border: 0;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  line-height: 1.6;
  cursor: pointer;
}

.tabs__tab[aria-selected="true"] {
  background: var(--bg-alt);
  color: var(--accent-light);
}

.tabs__tab:hover {
  color: var(--accent-light);
}

.tabs__panel {
  padding: 18px;
  background: var(--bg-alt);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.card {
  display: block;
  overflow: hidden;
  cursor: pointer;
}

.card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.card:hover img {
  transform: scale(1.03);
}

/* Personal Works: one block per project, a title and a one-line description above its videos. */
.project__title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.35;
}

.project__desc {
  margin: 4px 0 18px;
  font-size: 15px;
  line-height: 1.5;
  opacity: 0.75;
}

.grid--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

/* Smaller play button and title for the narrow four-column cards. */
.grid--4 .player__big svg {
  width: 22px;
  height: 22px;
  padding: 12px;
}

.grid--4 .player figcaption {
  top: 6px;
  left: 6px;
  max-width: calc(100% - 12px);
  padding: 2px 7px;
  font-size: 12px;
}

/* Modal window for YouTube videos: as large as the screen allows at 16:9. */
.lightbox {
  width: min(92vw, calc(85vh * 16 / 9));
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  overflow: visible;
  background: #000;
}

.lightbox::backdrop {
  background: rgb(0 0 0 / 0.85);
}

html:has(.lightbox[open]) {
  overflow: hidden;
}

.lightbox__frame {
  aspect-ratio: 16 / 9;
}

.lightbox__frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.lightbox__close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  font: 400 34px/1 system-ui, sans-serif;
  cursor: pointer;
}

.lightbox__close:hover {
  color: var(--accent-light);
}

/* Video player: poster image until the first play, then a native video with custom controls. */
.player {
  position: relative;
  margin: 0;
}

.player__frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #000;
}

.player__frame:fullscreen {
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
}

/* In full screen the controls hide after a few idle seconds, so the cursor hides with them. */
.player.is-playing:not(.is-active) .player__frame:fullscreen,
.player.is-playing:not(.is-active) .player__frame:fullscreen * {
  cursor: none;
}

.player video,
.player__poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.player video {
  object-fit: contain;
}

.player__poster {
  object-fit: cover;
  transition: opacity 0.3s;
}

.player.is-started .player__poster {
  opacity: 0;
  pointer-events: none;
}

.player button {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  cursor: pointer;
}

.player svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Covers the whole frame, so a click anywhere toggles playback. */
.player__big {
  position: absolute;
  inset: 0;
  width: 100%;
}

.player__big svg {
  box-sizing: content-box;
  width: 34px;
  height: 34px;
  padding: 18px;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.55);
  transition: background 0.15s, opacity 0.2s;
}

.player__big:hover svg {
  background: var(--accent);
}

.player.is-playing .player__big svg,
.player.is-loading .player__big svg {
  opacity: 0;
}

.player__spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border: 3px solid rgb(255 255 255 / 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.player.is-loading .player__spinner {
  opacity: 1;
  animation: player-spin 0.8s linear infinite;
}

@keyframes player-spin {
  to {
    transform: rotate(360deg);
  }
}

.player__bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(transparent, rgb(0 0 0 / 0.75));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.player.is-started:hover .player__bar,
.player.is-started.is-active .player__bar,
.player.is-started:focus-within .player__bar,
.player.is-started:not(.is-playing) .player__bar {
  opacity: 1;
  visibility: visible;
}

.player__bar input[type="range"] {
  margin: 0;
  accent-color: var(--accent-light);
  cursor: pointer;
}

.player__seek {
  flex: 1 1 auto;
  min-width: 60px;
}

.player__vol {
  flex: 0 0 80px;
  width: 80px;
}

.player[data-no-audio] .player__mute,
.player[data-no-audio] .player__vol {
  display: none;
}

.player .i-pause,
.player .i-muted,
.player .i-fullscreen-exit {
  display: none;
}

.player.is-playing .i-play,
.player.is-muted .i-volume,
.player.is-fullscreen .i-fullscreen {
  display: none;
}

.player.is-playing .i-pause,
.player.is-muted .i-muted,
.player.is-fullscreen .i-fullscreen-exit {
  display: block;
}

.player__error {
  position: absolute;
  inset: auto 0 0;
  padding: 10px 12px;
  background: rgb(0 0 0 / 0.75);
  font-size: 14px;
}

/* Title over the top-left corner of the frame; it fades out while the video plays, like the control bar. */
.player figcaption {
  position: absolute;
  top: 10px;
  left: 10px;
  max-width: calc(100% - 20px);
  padding: 4px 10px;
  background: rgb(0 0 0 / 0.65);
  font-size: 14px;
  line-height: 1.4;
  pointer-events: none;
  transition: opacity 0.2s;
}

.player.is-playing:not(:hover):not(:focus-within) figcaption {
  opacity: 0;
}

@media (hover: none) {
  .player.is-started .player__bar {
    opacity: 1;
    visibility: visible;
  }

  .player__vol {
    display: none;
  }
}

@media (max-width: 760px) {
  :root {
    --gutter: 16px;
    --band: 36px;
  }

  body {
    font-size: 16px;
  }

  h2 {
    font-size: 24px;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .project__title {
    font-size: 20px;
  }

  .tabs__panel {
    padding: 12px;
  }

  .social {
    gap: 10px;
  }

  .social svg {
    width: 22px;
    height: 22px;
  }

  .logo,
  .logo img {
    width: 120px;
  }

  .slider__dots {
    bottom: 8px;
    gap: 4px;
  }

  .slider__dot {
    width: 7px;
    height: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .slider__track,
  .card img {
    transition: none;
  }

  .player.is-loading .player__spinner {
    animation-duration: 2s;
  }
}
