/* ------------------------------------------------------------------
   Brian Hammonds — sound / score portfolio
   Desktop layout is the default; the separate mobile layout kicks in
   at 767px and below (see the bottom of this file).
------------------------------------------------------------------- */

:root {
  --text: rgba(0, 0, 0, 0.85);
  --heading: rgba(0, 0, 0, 0.75);
  --grey: rgba(0, 0, 0, 0.4);
  --bg: #fff;

  --font: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --size: 13.5px;
  --line: 1.25;

  /* Desktop column positions (measured from the live site at 1920px wide) */
  --sidebar-w: 27.7vw;   /* fixed left column                     */
  --col-w: 11.85vw;      /* project number column and name column */
  --gutter: 16px;        /* outer page margin                     */
  --right-margin: 64px;  /* white space right of the desktop images
                            (set back to 16px for the original look) */
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--size);
  line-height: var(--line);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
ol { list-style: none; margin: 0; padding: 0; }
p { margin: 0; }

.label { color: var(--grey); }

/* Shared About / Contact block ------------------------------------- */

.info .label { margin-bottom: 1em; }
.info .about-text { margin-bottom: 1.05em; }
.info .contact-label { margin-bottom: 0; }
.info .icons {
  display: flex;
  gap: 6px;
  margin-top: 1.1em;
}
.info .icons a { display: block; width: 18px; height: 18px; color: var(--text); }
.info .icons svg { width: 100%; height: 100%; display: block; }

/* ==================================================================
   DESKTOP
================================================================== */

.mobile { display: none; }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  padding: 14px var(--gutter) var(--gutter);
  display: flex;
  flex-direction: column;
  z-index: 1;
}

.site-name {
  margin-left: 64px;
  font-size: 23.25px;
  white-space: nowrap;
  font-weight: 500;
  line-height: 1.2;
  color: var(--heading);
}

.sidebar-label {
  margin: 8px 0 0 64px; /* lines up with the first project's Role row */
}

.project-list {
  margin-top: 9px;
}
.project-list a {
  display: grid;
  grid-template-columns: 64px 1fr;
}

.sidebar .info {
  margin-top: auto;
  max-width: 435px;
  padding-top: 24px;
}

/* Project blocks */

.projects {
  margin-left: var(--sidebar-w);
  padding: 15px var(--right-margin) 82px 0;
}

.project + .project { margin-top: 82px; }

.project {
  /* Keeps a little white above the number when jumping to #project */
  scroll-margin-top: 20px;
}

.project-head {
  display: grid;
  /* A long name stays on one line and pushes only its title over */
  grid-template-columns: var(--col-w) minmax(var(--col-w), max-content) 1fr;
  margin-bottom: 16px;
}
.project-num { color: var(--grey); grid-row: 1 / span 2; }
.project-name,
.project-title { padding-right: 16px; }
.project-name { white-space: nowrap; }
.project-meta {
  grid-column: 2 / 4;
  display: grid;
  grid-template-columns: var(--col-w) 1fr;
  /* Share the heading's columns, so the role and year stay under the
     title even when a long name pushes it over */
  grid-template-columns: subgrid;
  margin-top: 18px;
  color: var(--grey);
}

.project-media {
  margin-left: var(--col-w);
  display: flex;
  gap: 14px;
}
/* Each image is its own link (several images can open different videos) */
.project-media > a,
.m-item > a {
  display: block;
  flex: 1 1 0;
  min-width: 0;
}
.project-media img,
.m-item img {
  width: 100%;
  height: auto;
  background: #f2f2f2;
}

/* Reserve space before images load (wide by default, tall when there are
   several side by side) so jumping to a project lands in the right place.
   Once loaded, each image's own shape is used. */
.project-media img,
.m-item img { aspect-ratio: auto 16 / 9; }
.project-media > a:not(:only-child) img,
.m-item > a:not(:only-child) img { aspect-ratio: auto 9 / 16; }

/* Link to the other site, after the last project */
.site-link {
  display: inline-block;
  margin: 82px 0 0 var(--col-w);
  color: var(--grey);
}

/* ==================================================================
   VIDEO VIEWER (desktop + mobile)
================================================================== */

body.viewer-open { overflow: hidden; }

/* The viewer is its own (invisible) scroll area, so a scroll anywhere on
   it, even over the video, can be noticed and passed on to the page. */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--bg);
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.viewer::-webkit-scrollbar { display: none; }
.viewer[hidden] { display: none; }

/* Leaving by scrolling: fade out while drifting in the scroll direction */
.viewer.is-leaving {
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.viewer.is-leaving .viewer-screen {
  transform: translateY(var(--leave-shift, 0));
  transition: transform 0.3s ease-out;
}
/* What's on screen stays pinned while the viewer scrolls underneath it */
.viewer-screen {
  position: sticky;
  top: 0;
  height: 100%;
  overflow: hidden; /* carousel cards past the edge are cut off */
}
.viewer-scroll-space { height: 400px; }

.viewer-stage {
  position: absolute;
  left: 30.3vw;
  top: 50%;
  transform: translateY(-50%);
}

.viewer-frame {
  /* Width and height are set by script.js to fit the video's shape */
  width: 47.8vw;
  aspect-ratio: 16 / 9;
  position: relative;
}

/* One card per video. A project with several videos shows them as a
   carousel: the others sit smaller and faded to the sides (placed by
   script.js) and slide over when picked. */
.viewer-card {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: center;
  background: #f2f2f2;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.12);
  opacity: 0;
  pointer-events: none;
}
.viewer-card.is-current { opacity: 1; pointer-events: auto; }
.viewer-card.is-near { opacity: 0.45; pointer-events: auto; cursor: pointer; }
.viewer-card.is-near:hover { opacity: 0.7; }
.viewer-frame.is-sliding .viewer-card {
  transition: transform 0.45s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.45s ease;
}
.viewer-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Invisible layer over the video (but not its control bar) so a scroll
   over the video still reaches the page. Clicking it plays / pauses. */
.viewer-catcher {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: max(64px, 25%);
  cursor: pointer;
}
.viewer-card iframe {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Desktop viewer text is the same size as the home page body text */
/* Title in bold italic; role and year match the About text */
.viewer-caption {
  margin-top: 10px;
  color: var(--text);
}
.viewer-caption .cap-title { font-weight: 600; font-style: italic; }

/* Sits exactly where the About block is on the home page */
.viewer-info {
  position: absolute;
  left: var(--gutter);
  bottom: var(--gutter);
  width: calc(var(--sidebar-w) - 2 * var(--gutter));
  max-width: 435px;
}

/* ==================================================================
   MOBILE (separate layout)
================================================================== */

@media (max-width: 767px) {
  .desktop { display: none; }
  .mobile { display: block; }

  .m-header {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px var(--gutter) 0;
    font-size: 13.5px;
    line-height: 1.17;
  }
  .m-name { display: flex; flex-direction: column; }
  .m-tagline { color: var(--grey); }
  .m-about-link { color: var(--grey); }

  /* Which mobile screen is showing is set on <body data-mobile-view> */
  .m-landing, .m-feed, .m-about { display: none; }
  [data-mobile-view="landing"] .m-landing { display: flex; }
  [data-mobile-view="projects"] .m-feed { display: block; }
  [data-mobile-view="about"] .m-about { display: block; }
  [data-mobile-view="landing"] .m-about-link { visibility: hidden; }

  /* Landing: big centered PROJECTS */
  .m-landing {
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
  }
  .m-projects-link {
    font-size: 24.2px;
    font-weight: 600;
    color: var(--heading);
    padding: 16px;
  }

  /* Feed: one column of large images */
  .m-feed {
    padding: 70px var(--gutter) 66px;
  }
  .m-item {
    display: flex;
    gap: 7px;
  }
  .m-item + .m-item { margin-top: 66px; }

  /* Several images: a sideways carousel inside the usual side margins.
     Images overlap a little; script.js shrinks and fades the ones
     off-center. --card is the middle image's width (cqw = % of the
     carousel's width). */
  .m-item.carousel {
    --card: 60cqw;
    container-type: inline-size;
    position: relative;
    gap: 0;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .carousel::-webkit-scrollbar { display: none; }
  .m-item.carousel > a {
    flex: 0 0 var(--card);
    scroll-snap-align: center;
  }
  .carousel > a + a { margin-left: calc(var(--card) * -0.32); }
  /* Room either side so the first and last images can sit in the middle */
  .carousel > a:first-child { margin-left: calc(50cqw - var(--card) / 2); }
  .carousel > a:last-child { margin-right: calc(50cqw - var(--card) / 2); }
  .m-feed .site-link { margin: 66px 0 0; }

  /* About */
  .m-about {
    padding: 70px var(--gutter) 40px;
  }

  /* Viewer: inset video, centered a little above the middle */
  .viewer-stage {
    left: 50%;
    top: 44%;
    transform: translate(-50%, -50%);
  }
  .viewer-caption { margin-top: 12px; font-size: 8.2px; }
  .viewer-info { display: none; }
}
