/* Shared styles for every page */

:root {
  --color: #ea0f00;      /* all text */
  --background: #ffffff;
  --placeholder: #f2f2f2; /* grey boxes until real photos/feed exist */
  --field-fill: rgba(234, 15, 0, 0.02);    /* form boxes: almost white, a touch of grey and red */
  --field-border: rgba(234, 15, 0, 0.8); /* form boxes: faint red outline */
  --text-font: Georgia, "Times New Roman", serif;
  --page-width: 1320px;   /* width of the centered block (menu + content + footer) */
}

/* Full-height digits (0–9) borrowed from Times New Roman.
   Georgia's digits are small "old-style" ones, e.g. the 1 in "1st AC".
   Only digits use this font; letters stay Georgia. */
@font-face {
  font-family: "Lining Digits";
  src: local("Times New Roman"), local("TimesNewRomanPSMT");
  unicode-range: U+0030-0039;
}

@font-face {
  font-family: "Lining Digits";
  src: local("Times New Roman Bold"), local("TimesNewRomanPS-BoldMT");
  font-weight: bold;
  unicode-range: U+0030-0039;
}

* {
  box-sizing: border-box;
}

/* Always keep room for the scrollbar, so short and long pages are
   centered the same way and nothing shifts when you switch pages */
html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--color);
  font-family: var(--text-font);
  font-size: 16px;
  line-height: 1.5;
  /* Stack header, page and footer, so the footer stays at the bottom on short pages */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Avoid a single word sitting alone on the last line of a paragraph */
p {
  text-wrap: pretty;
}

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

a:hover {
  text-decoration: underline;
}

/* Links inside the page content are always underlined */
main a {
  text-decoration: underline;
}

/* Name and job title, centered at the top of the page */
.site-header {
  text-align: center;
  padding: 64px 16px 56px;
}

.site-title {
  font-size: 32px;
  font-weight: bold;
}

.site-title:hover {
  text-decoration: none;
}

.site-subtitle {
  margin: 8px 0 0;
  font-family: "Lining Digits", var(--text-font);
  font-size: 22px;
  font-weight: bold;
}

/* Page frame: menu on the left, content on the right.
   The whole block is centered, so it has the same space on both sides. */
.page {
  display: grid;
  grid-template-columns: 160px 1fr;
  column-gap: 24px;
  width: 100%;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 35px 24px 128px;
  flex: 1;
}

/* Main menu, left column */
.main-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.main-nav li {
  margin-bottom: 16px;
  letter-spacing: 1px;
}

.main-nav .current,
.main-nav a:hover {
  font-weight: 800;
  text-decoration: none;
}

/* About page: photo on the left, text on the right. grid-template-columns defines width, first photo, text fills the rest (1fr).
   Photo is 400px, or 40% of the width when the window is narrower, so the text never gets squeezed */
.intro {
  display: grid;
  grid-template-columns: min(400px, 40%) 1fr;
  column-gap: 22px;
  align-items: start;
}

.intro-text p {
  margin: 0 0 1em;
}

/* No extra space above the first paragraph, so content starts level with the menu */
main > p:first-child {
  margin-top: 0;
}

/* Remove the line-spacing gap above the first line of the menu and text,
   so the tops of the letters line up exactly with the top of the photo */
.main-nav li:first-child,
.intro-text p:first-child,
main > p:first-child {
  text-box: trim-start cap alphabetic;
}

/* Photo fills its column; height follows the photo's own shape */
.about-photo {
  display: block;
  width: 100%;
  height: auto;
}

/* Instagram feed (Behold widget) below the about text */
.instagram {
  margin-top: 64px;
}

/* Kit list below the Instagram feed */
.kit {
  margin-top: 64px;
}

.kit h2 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 0px;
}

.kit ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.kit li::before {
  content: "- ";
}

/* Contact page: intro line on top, then two columns: form on the left, Instagram link on the right */
.contact {
  display: grid;
  grid-template-columns: minmax(0, 600px) auto;
  column-gap: 48px;
  row-gap: 32px;
  align-items: start;
  align-content: start; /* keep rows packed at the top instead of spreading over the page height */
}

/* Intro line spans both columns */
.contact-intro {
  grid-column: 1 / -1;
}

.contact > p {
  margin: 0;
}

/* Contact form: name + email side by side, message below, send button bottom right */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 0.75fr 1fr;
  gap: 12px;
}

.contact-form input,
.contact-form textarea,
.contact-form button {
  font: inherit;
  color: var(--color);
  background: var(--field-fill);
  border: 2px solid var(--field-border);
  border-radius: 2px;
  padding: 8px 10px;
}

.contact-form textarea {
  resize: vertical;
}

/* Placeholder text ("name", "email"...) in a lighter red */
.contact-form ::placeholder {
  color: var(--color);
  opacity: 0.55;
}

/* Slightly stronger outline on the box you're typing in */
.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--color);
}

.contact-form button {
  align-self: flex-end;
  padding: 6px 20px;
  cursor: pointer;
}

.contact-form button:hover {
  border-color: var(--color);
}

/* Spam trap field, hidden from people */
.hidden-field {
  display: none;
}

/* Bottom bar on every page: copyright on the left, links on the right */
.site-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  width: 100%;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 0 24px 32px;
}

.site-footer p {
  margin: 0;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-links a {
  text-decoration: underline;
}

/* Work page: selected job on the left, list of all jobs on the right */
.work {
  display: grid;
  grid-template-columns: minmax(0, 700px) auto; /* list is as wide as its longest title (never wraps); the video shrinks to make room */
  column-gap: 48px;
  align-items: start;
  align-content: start; /* keep rows packed at the top instead of spreading over the page height */
}

/* Line above the work page, across both columns */
.work-intro {
  grid-column: 1 / -1;
  margin: 0 0 32px;
}

/* Video in a 16:9 box. Grey until a real video is embedded */
.job-video {
  aspect-ratio: 16 / 9;
  background: var(--placeholder);
}

.job-video iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Photo in place of the video: full width, keeps its own shape (never cropped), opens the big view */
.job-hero {
  display: block;
  width: 100%;
  height: auto;
  cursor: zoom-in;
}

/* Title on the left, type and year on the right, same line */
.job-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  column-gap: 24px;
  margin-top: 16px;
}

.job-title {
  margin: 0;
  font-size: 16px;
  font-weight: bold;
  text-transform: uppercase;
}

.job-type {
  margin: 0;
  font-weight: bold;
  font-family: "Lining Digits", var(--text-font);
}

.job-credits {
  margin: 1.5em 0 0;
}

/* Behind-the-scenes photos: one row you can scroll sideways */
.bts {
  display: flex;
  gap: 12px;
  margin-top: 40px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}

.bts img {
  flex: 0 0 auto;
  width: 410px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  scroll-snap-align: start;
  background: var(--placeholder);
  cursor: zoom-in;
}

/* Arrows below the row (added by lightbox.js), right-aligned */
.bts-arrows {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 8px;
}

.bts-arrows[hidden] {
  display: none;
}

.bts-arrows button {
  padding: 6px;
  border: 0;
  background: none;
  color: var(--color);
  cursor: pointer;
}

.bts-arrows svg {
  display: block;
  fill: currentColor;
}

.bts-arrows button:disabled {
  opacity: 0.25;
  cursor: default;
}

/* Big photo view (opened by lightbox.js): photo centered on a dark background,
   arrows just left and right of the photo, X to the right of its top edge */
.lightbox {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* While the big view is open, the page behind it can't scroll */
html:has(.lightbox[open]) {
  overflow: hidden;
}

/* Touch-screen strip and its X: only shown on touch screens (see the end of the file) */
.lightbox-strip,
.lightbox .lightbox-strip-close {
  display: none;
}

.lightbox::backdrop {
  background: rgba(0, 0, 0, 0.91);
}

.lightbox-frame {
  position: relative;
}

/* Leave room around the photo for the arrows and the X */
.lightbox img {
  display: block;
  max-width: calc(100vw - 140px);
  max-height: calc(100vh - 140px);
}

.lightbox button {
  position: absolute;
  display: flex;
  justify-content: center;
  width: 44px; /* same width for all three, so the right arrow sits exactly under the X */
  padding: 12px 0;
  border: 0;
  background: none;
  color: #b80c00; /* darker than the text red: on the dark background the normal red looks too bright */
  cursor: pointer;
}

/* No arrows when there is only one photo (lightbox.js sets "hidden") */
.lightbox button[hidden] {
  display: none;
}

/* No focus ring: the X gets focus automatically when the big view opens */
.lightbox button:focus {
  outline: none;
}

/* top: -12px cancels the button padding, so the top of the X is level with the top of the photo */
.lightbox-close {
  top: -12px;
  left: 100%;
}

.lightbox-close svg,
.lightbox-strip-close svg {
  display: block;
  stroke: currentColor;
  stroke-width: 2.5;
}

/* Arrows side by side under the photo, centred (beside it they jumped around with photos of different shapes).
   Vertically in the middle of the space between the photo and the bottom of the screen:
   100% = photo height, so that space is (100vh - 100%) / 2 and its middle is half of that below the photo */
.lightbox-prev,
.lightbox-next {
  top: calc(100% + (100vh - 100%) / 4);
  transform: translateY(-50%);
}

/* The triangles and the X are drawn shapes (SVG): exact sizes, no extra space like a text character has */
.lightbox-prev svg,
.lightbox-next svg {
  display: block;
  fill: currentColor;
}

.lightbox-prev {
  right: 50%;
}

.lightbox-next {
  left: 50%;
}

/* Job list: right-aligned, scrolls with the page */
.job-list {
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: right;
}

.job-list li {
  margin-bottom: 16px;
}

.job-list li:first-child {
  text-box: trim-start cap alphabetic;
}

.job-list a,
.job-list span {
  display: block;
  text-decoration: none;
}

.job-list .job-list-title {
  text-transform: uppercase;
}

/* Titles never wrap onto a second line */
.job-list .job-list-title,
.project-list a {
  white-space: nowrap;
}

.job-list .current,
.job-list a:hover {
  font-weight: 800;
}

/* Projects page: all projects one below the other on the left, list of projects on the right */
.projects {
  display: grid;
  grid-template-columns: minmax(0, 800px) auto;
  column-gap: 48px;
  align-items: start;
  align-content: start; /* keep rows packed at the top instead of spreading over the page height */
}

/* Space between one project and the next */
.project + .project {
  margin-top: 120px;
}

/* When jumping to a project from the list, leave a little space above its title */
.project {
  scroll-margin-top: 32px;
}

.project-title {
  margin: 0;
  font-size: 20px;
  font-weight: bold;
}

.project-feed > .project:first-child .project-title {
  text-box: trim-start cap alphabetic;
}

.project-title a {
  text-decoration: none;
}

.project-title a:hover {
  text-decoration: underline;
}

.project-date {
  margin: 4px 0 16px;
  font-size: 14px;
  font-family: "Lining Digits", var(--text-font);
}

/* Main photo: two thirds of the width, keeps its own shape (never cropped) */
.project-cover {
  display: block;
  width: 66%;
  height: auto;
  cursor: zoom-in;
}

.project-text {
  margin-top: 24px;
}

.project-text p {
  margin: 0 0 1em;
}

/* Other photos: three per row, all the same shape (cropped to fit), click to see them whole */
.project-photos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 24px;
}

.project-photos img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  background: var(--placeholder);
  cursor: zoom-in;
}

/* Project list: right-aligned, stays in view while the page scrolls (few projects, so it fits) */
.project-nav {
  position: sticky;
  top: 32px;
}

.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: right;
}

.project-list li {
  margin-bottom: 16px;
}

.project-list li:first-child {
  text-box: trim-start cap alphabetic;
}

.project-list a {
  display: block;
  text-decoration: none;
  text-transform: uppercase;
}

.project-list a:hover {
  font-weight: 800;
}

/* Dropdown list of jobs/projects: only on tablet and phone (see below) */
.picker {
  display: none;
}

/* Tablet width: menu moves above the content as a 3x2 grid, the rest stays as on desktop */
@media (max-width: 960px) {
  :root {
    --menu-height: 84px; /* height of the sticky menu grid, so the dropdown can stick right under it */
  }

  /* minmax(0, ...) lets the column be narrower than its content (e.g. the BTS photo row),
     otherwise the whole page gets as wide as that row and runs off the screen */
  .page {
    grid-template-columns: minmax(0, 1fr);
    padding: 0 24px 112px;
  }

  /* Menu: even 3x2 grid that sticks to the top of the screen once the name has scrolled away.
     White background (stretched to the screen edges) hides the text scrolling underneath. */
  .main-nav {
    position: sticky;
    top: 0;
    z-index: 1;
    margin: 0 -24px 32px;
    padding: 12px 24px;
    background: var(--background);
  }

  .main-nav ul {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px 0;
    max-width: 480px; /* keeps the grid compact on wider screens */
    margin: 0 auto;
    text-align: center;
  }

  /* Undo the desktop trim, otherwise "about" sits higher than the other links */
  .main-nav li {
    margin-bottom: 0;
  }

  .main-nav li:first-child {
    text-box: normal;
  }

  /* Work and projects: one column; the list on the right is replaced by the dropdown */
  .work,
  .projects {
    grid-template-columns: minmax(0, 1fr);
  }

  .job-nav,
  .project-nav {
    display: none;
  }

  /* Jumping to a project: land below the sticky menu and dropdown */
  .project {
    scroll-margin-top: calc(var(--menu-height) + 72px);
  }

  /* Projects: the dropdown comes after the projects in the page, move it to the top */
  .projects .picker {
    order: -1;
  }

  /* Dropdown (test design): a bordered bar with the current job/project, list opens over the page.
     On work it sits below the intro line, which scrolls away while the dropdown sticks */
  .picker {
    display: block;
    grid-column: 1 / -1;
    position: sticky;
    top: calc(var(--menu-height) - 1px);
    z-index: 1;
    margin: 0 -24px 24px;
    padding: 0 24px 12px;
    background: var(--background);
  }

  .picker summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    border: 2px solid var(--field-border);
    border-radius: 2px;
    background: var(--field-fill);
    text-transform: uppercase;
    list-style: none;
    cursor: pointer;
  }

  .picker summary::-webkit-details-marker {
    display: none;
  }

  .picker summary::after {
    content: "▾";
  }

  .picker[open] summary::after {
    content: "▴";
  }

  .picker ul {
    position: absolute;
    top: calc(100% - 14px);
    left: 24px;
    right: 24px;
    max-height: 60vh;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 4px 12px;
    border: 2px solid var(--field-border);
    border-radius: 0 0 2px 2px;
    background: var(--background);
  }

  .picker li {
    margin: 14px 0;
  }

  /* One line per entry: the title gets shortened with "..." so the type always fits after it */
  .picker a {
    display: flex;
    align-items: baseline;
    gap: 0.3em;
    text-decoration: none;
  }

  .picker-title {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-transform: uppercase;
  }

  .picker-type {
    flex-shrink: 0;
    font-size: 14px;
  }
}

/* Phone width: smaller header, photo above the text */
@media (max-width: 760px) {
  .site-header {
    padding: 40px 16px 32px;
  }

  .page {
    padding: 0 16px 112px;
  }

  .site-title {
    font-size: 22px;
  }

  .site-subtitle {
    font-size: 15px;
  }

  /* Footer: centered, smaller, links on top and copyright below */
  .site-footer {
    flex-direction: column-reverse;
    align-items: center;
    text-align: center;
    padding: 0 16px 24px;
    font-size: 14px;
  }

  .site-footer p {
    font-size: 12px;
  }

  /* Same gutter as the page edges */
  .main-nav {
    margin: 0 -16px 32px;
    padding: 12px 16px;
  }

  .picker {
    margin: 0 -16px 24px;
    padding: 0 16px 12px;
  }

  .picker ul {
    left: 16px;
    right: 16px;
  }

  .intro {
    grid-template-columns: 1fr;
    row-gap: 24px;
  }

  .about-photo {
    max-width: 240px;
    justify-self: center;
  }

  /* Body text of every page 1px smaller on phones */
  main {
    font-size: 15px;
  }

  .intro-text {
    text-align: justify;
  }

  /* Name and email stacked on narrow screens, Instagram link below the form */
  .form-row {
    grid-template-columns: 1fr;
  }

  .contact {
    grid-template-columns: 1fr;
    row-gap: 32px;
  }

  .bts img {
    width: 240px;
  }

  .project-cover {
    width: 100%;
  }

  .project-photos {
    grid-template-columns: repeat(2, 1fr);
  }

}

/* Big photo view on phones: photo as wide as the screen, X above its top-right corner */
@media (max-width: 760px) {
  /* 100% = the visible width (100vw would also count a scrollbar and scroll sideways) */
  .lightbox-frame,
  .lightbox img {
    max-width: 100%;
  }

  .lightbox img {
    max-height: calc(100dvh - 120px); /* dvh = the screen height actually visible on a phone */
  }

  .lightbox-close {
    top: auto;
    bottom: 100%;
    left: auto;
    right: 0;
  }

}

/* Touch screens (phones, tablets): photos are swiped with a finger, so no arrows in the BTS row.
   The big view becomes a strip of photos you swipe through: each photo at most 80% of the screen
   width and centred, so the edge of the next one shows; it snaps to one photo at a time. */
@media (pointer: coarse) {
  .bts-arrows,
  .lightbox .lightbox-frame {
    display: none;
  }

  .lightbox-strip {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative; /* so the script can measure where each photo sits */
    width: 100%;
    height: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }

  .lightbox-strip::-webkit-scrollbar {
    display: none;
  }

  /* Empty space before the first and after the last photo, so those can be centred too */
  .lightbox-strip::before,
  .lightbox-strip::after {
    content: "";
    flex: 0 0 50%;
    height: 1px;
  }

  .lightbox .lightbox-strip img {
    flex: 0 0 auto;
    width: auto;
    height: auto;
    max-width: 80vw;
    max-height: calc(100dvh - 160px);
    scroll-snap-align: center;
    scroll-snap-stop: always; /* one photo per swipe, even a fast one */
  }

  .lightbox .lightbox-strip-close {
    display: flex;
    top: 8px;
    right: 4px;
  }
}
