/* ==========================================================================
   Typography
   Two typefaces, used across the whole site:
   Suisse Works – for all regular text (the default, set on <body>)
   Suisse Intl (--font-caps) – the boxes and the About text. .type-caps sets it in capitals, for the
   speech bubble on the About page
   ========================================================================== */

@font-face {
  font-family: "Suisse Works";
  src: url("../Font/SuisseWorks-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Suisse Intl";
  src: url("../Font/SuisseIntl-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* For the menu buttons at the top */
@font-face {
  font-family: "Suisse Intl";
  src: url("../Font/SuisseIntl-Medium.otf") format("opentype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-body: "Suisse Works", serif;
  --font-caps: "Suisse Intl", sans-serif;
  --font-size: 14px;
  --line-height: 18px;
  --letter-spacing: -0.018em; /* Suisse Works, slightly tighter than the font's default spacing */
  --letter-spacing-caps: -0.01em; /* Suisse Intl */
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--font-size);
  line-height: var(--line-height);
  letter-spacing: var(--letter-spacing);
  /* Thinner, grayscale anti-aliasing on Mac */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.type-caps {
  font-family: var(--font-caps);
  letter-spacing: var(--letter-spacing-caps);
  text-transform: uppercase;
  color: var(--caps-color);
}

/* Headings and paragraphs take the text style they are given, without browser defaults */
h2,
p {
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
}

/* Read by search engines and screen readers, not shown */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ==========================================================================
   Layout and components
   ========================================================================== */

:root {
  --gutter: 4px; /* the grid's margins and the space between its columns */
  --header-button-height: 26px;
  --header-room: 74px; /* the room kept for the header at the top of the page */
  --background-color: #ffffff;
  --caps-color: #121212; /* text in capitals: the name, About, titles, labels and the footer */
  --text-color: #757575;
  --link-color: #757575;
  --link-hover-color: #121212;
  --divider-color: #e3e3e3;
  --media-height: 480px;
  --media-height-list: 280px; /* the smaller images in the list projects */
  --hover-preview-height: 160px; /* the image that follows the pointer over the list projects */
  --media-radius: 2px;
  --media-gap: 2px;
  --cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Ccircle cx='4' cy='4' r='4' fill='black'/%3E%3C/svg%3E") 4 4, auto;
  --cursor-clickable: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Ccircle cx='4' cy='4' r='4' fill='black'/%3E%3C/svg%3E") 4 4, pointer;
  --project-padding: 16px; /* above and below each project */
  --space-after-header: 76px; /* + the header's 4px and the project's 16px = 96px to the first project */
  --space-between-projects: 32px; /* + 16px + 16px project padding = 64px in total */
  --space-above-media: 2px; /* between a project's text boxes and its images */
}

* {
  box-sizing: border-box;
}

/* Hidden means hidden, whatever display a class gives it (an About section left out, no figure) */
[hidden] {
  display: none !important;
}

/* Custom cursor: a small black circle, 8×8px, centred on the pointer – used everywhere, also over links */
html {
  cursor: var(--cursor);
}

*,
*::before,
*::after {
  cursor: inherit;
}

/* The same black circle over anything clickable, and over the image rows you can scroll.
   The menu item for the page you are on has no href, so it isn't a button */
a[href],
button,
.project-media {
  cursor: var(--cursor-clickable);
}

body {
  margin: 0;
  padding-top: calc(var(--header-room) + 2 * var(--gutter)); /* room for the fixed header */
  color: var(--text-color);
  background: var(--background-color);
}

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

/* Hover styles only on devices with a real pointer – on touch screens they would stick after a tap */
@media (hover: hover) {
  a[href]:hover {
    color: var(--link-hover-color);
  }

  /* The menu buttons go green on hover */
  .header-button[href]:hover {
    background: #00ff59;
    color: #121212;
  }

  /* A closed list project's row turns grey under its boxes while hovered, since all of it opens the
     project. Open, it stays as it is */
  .is-collapsible:not(.is-open) .project-summary:hover {
    background: #dfdfdf;
  }

  /* Its boxes turn clear meanwhile – all but Expand, and a link while the pointer is on it (green, below) */
  .is-collapsible:not(.is-open) .project-summary:hover .info-box:not(.project-toggle, a:hover) {
    background: transparent;
  }

  /* Links in boxes go green on hover, like the menu – and a list project's Expand while the pointer
     is anywhere over its row */
  a.info-box:hover,
  button.info-box:hover,
  .is-collapsible.is-open .project-summary:hover .info-box.project-toggle,
  .is-collapsible.is-open .project-summary a.info-box:hover,
  .is-collapsible .project-summary:hover .project-toggle {
    background: #00ff59;
    color: #121212;
  }
}

/* 12-column grid (4 on phones), with 4px gutters and outer margins */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--gutter);
  padding: var(--gutter);
}

/* Header – fixed to the top of the window, also on phones (where a sticky header would bounce
   along with the page). The page keeps the same room for it at the top. The name, About and Lab are
   frosted buttons side by side; each is as wide as its text, so the name's button shrinks along with
   P.T.M. Hovering over Lab opens the list of experiments below it */
.header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  gap: 2px;
}

.nav {
  display: flex;
  gap: 2px;
}

.header-button {
  display: flex;
  align-items: center;
  height: var(--header-button-height);
  padding: 0 10px;
  background: rgb(220 220 220 / 50%);
  -webkit-backdrop-filter: blur(20px); /* "40" in Figma – Figma's blur value is twice the CSS one */
  backdrop-filter: blur(20px);
  font-family: var(--font-caps);
  font-weight: 500;
  letter-spacing: var(--letter-spacing-caps);
  color: #121212;
  white-space: nowrap;
}

/* The page you are on */
.header-button[aria-current="page"] {
  background: #121212;
  color: #eeeeee;
}

/* Lab: the list of experiments opens below it while hovered (or while a link in it has keyboard
   focus). The padding keeps the pointer over the menu on its way from Lab down to the list */
.lab-menu {
  position: relative;
}

.lab-menu-list {
  position: absolute;
  top: 100%;
  left: 0;
  display: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding-top: 2px;
}

.lab-menu:hover .lab-menu-list,
.lab-menu:focus-within .lab-menu-list {
  display: flex;
}

/* Projects */
.projects {
  padding-top: var(--space-after-header);
}

/* Vertical spacing in a project doesn't follow the grid's 4px – it has its own values (see :root) */
.project {
  padding-block: var(--project-padding);
  row-gap: var(--project-padding);
}

.project + .project {
  margin-top: var(--space-between-projects);
}

/* Title and text sit on the same columns as the rest of the page */
.project-summary {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  position: relative;
}

/* Each text field is three columns wide */
.project-heading {
  grid-column: 1 / 4;
}

.project-info {
  grid-column: 4 / 7;
}

/* The project text: every field in a box of its own, one under the other, and a label in a box in
   front of its value – [Made at] [Snøhetta]. Boxes that are links are underlined */
.project-heading,
.project-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.project-heading > *,
.project-info > * {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  max-width: 100%;
}

/* 26px high for one line of text, 44px for two */
.info-box {
  flex: none;
  padding: 4px 10px;
  background: rgb(220 220 220 / 50%);
  font-family: var(--font-caps);
  font-weight: 500;
  line-height: 18px;
  letter-spacing: var(--letter-spacing-caps);
  color: #121212;
  white-space: nowrap;
}

/* A long value – a title, the team – wraps onto as many lines as it needs within its field */
.project-heading .info-box:last-child,
.project-info .info-box:last-child {
  flex: 0 1 auto;
  min-width: 0;
  white-space: normal;
  overflow-wrap: break-word;
}

/* Only the web address may be cut: it stays on one line, ending in … if it doesn't fit */
.project-info [data-field="link"] .info-box:last-child {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* The keyboard focus ring inside the box, so a column's edge never cuts it off */
.info-box:focus-visible {
  outline: 2px solid #121212;
  outline-offset: -2px;
}

a.info-box {
  text-decoration: underline;
  text-decoration-thickness: 0.1em;
  text-underline-offset: 0.2em;
  text-decoration-skip-ink: none;
}

/* Text never pushes past its field: long words and web addresses are cut off at the edge */
.project-heading,
.project-info {
  min-width: 0;
  overflow: hidden;
}

/* Images and videos in one horizontal row – scroll sideways to see them all */
.project-media {
  grid-column: 1 / -1;
  margin-top: calc(var(--space-above-media) - var(--project-padding));
  display: flex;
  gap: var(--media-gap);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  /* Extend the row to the screen edges, but keep the first and last image on the grid margin */
  margin-inline: calc(-1 * var(--gutter));
  padding-inline: var(--gutter);
  /* Hide the scrollbar – the row still scrolls */
  scrollbar-width: none;
  /* Click and drag */
  user-select: none;
}

.project-media::-webkit-scrollbar {
  display: none;
}

/* Fixed height, width follows each file's own format (aspect-ratio is set from build.js) */
.media {
  position: relative;
  flex-shrink: 0;
  height: var(--media-height);
  aspect-ratio: 1;
  border-radius: var(--media-radius);
  overflow: hidden;
}

/* The pixelated preview and the real file sit on top of each other */
.media-preview,
.media-file {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-preview {
  image-rendering: pixelated;
}

/* No "Save image" on long-press (iOS) and no dragging images out of the page */
.media,
.about-image {
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
}

.media-file {
  opacity: 0;
  transition: opacity 0.4s ease;
}

.media.is-loaded .media-file {
  opacity: 1;
}

/* Content appears as it scrolls into view – step by step, like the name typing itself: no fading,
   each box or line of text just switches on after its own delay (reveal.js marks them .reveal-line) */
.js .reveal,
.reveal-line {
  opacity: 0;
  transition: opacity 0s; /* switches at the end of its delay – still there for keyboards and screen readers */
}

.reveal.has-lines,
.reveal.is-visible,
.is-visible .reveal-line {
  opacity: 1;
}

/* The images only fade in, softly – they don't move – one after the other, a moment apart (reveal.js numbers the
   first ones in a row: --i) */
.js .project-media.reveal > .media {
  opacity: 0;
  transition: opacity 0.5s ease calc(var(--i, 0) * 220ms);
}

.js .project-media.reveal.is-visible > .media {
  opacity: 1;
}

/* Secondary projects, shown as a list: 2px apart, and the whole text area opens and closes the
   images. Hovered, the row turns grey under its boxes and Expand goes green */
.project.is-collapsible + .project.is-collapsible {
  margin-top: calc(2px - var(--project-padding)); /* 2px after the project above's bottom padding */
  padding-top: 0;
}

.project.is-collapsible {
  --media-height: var(--media-height-list);
}

.project.is-collapsible:not(.is-open) .project-media {
  display: none;
}

/* An open list project: its text inverted – a dark row with dark grey boxes and light text */
.is-collapsible.is-open .project-summary {
  background: #121212;
}

.is-collapsible.is-open .project-summary .info-box {
  background: #474747;
  color: #eeeeee;
}

.is-collapsible.is-open .project-summary .info-box:focus-visible {
  outline-color: #eeeeee;
}

/* The whole row opens and closes the project with a mouse */
.is-collapsible .project-summary:has(.project-toggle) {
  cursor: var(--cursor-clickable);
}

/* Expand (Close while open), a box at the top right */
.project-toggle {
  position: absolute;
  top: 0;
  right: 0;
  border: 0;
  font-size: inherit;
}

/* Small image following the pointer over the list projects (see showPreview in main.js) */
.hover-preview {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.hover-preview .media {
  height: var(--hover-preview-height);
}

.hover-preview.is-shown {
  opacity: 1;
}

/* About page, on the same grid as the projects: About across the left half, Work and Contact side by
   side under it, then Awards. Titles and links are boxes like the project text; the introduction is
   plain Suisse Intl */
.about {
  padding-top: var(--space-after-header);
  row-gap: 40px;
  align-items: start;
}

.about-section {
  grid-column: 1 / 7;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  font-family: var(--font-caps);
  font-weight: 500;
  line-height: 16px;
  letter-spacing: var(--letter-spacing-caps);
  color: #121212;
}

.about-section > p,
.about-title {
  display: flex;
  gap: 2px;
  max-width: 100%;
}

.about-section[data-section="work"] {
  grid-column: 1 / 4;
}

.about-section[data-section="contact"] {
  grid-column: 4 / 7;
}

/* The introduction in large text */
.about-section[data-section="about"] p {
  font-size: 24px;
  line-height: 23px;
}

/* The … under the awards that brings in more */
.awards-more {
  border: 0;
  font-size: inherit;
}

/* An award too long for the window fills the width and wraps onto more lines inside its box */
.about-section[data-section="awards"] p .info-box {
  flex: 0 1 auto;
  min-width: 0;
  white-space: normal;
}

/* The footer: the copyright line at the bottom left of the window (or of the page, if it is longer),
   and the figure at the bottom right, three columns wide */
.page-about {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.page-about .footer {
  position: relative;
  margin-top: auto;
  padding-top: 40px; /* the 40px above it, also when the page is taller than the window */
  overflow-x: clip; /* the figure's corners stick out at the edge while it shakes – no sideways scrolling */
}

/* Round the figure: a frame reaching from the bottom and right edges of the page far up over it, that cuts off
   whatever of the figure passes those edges while it shakes – so it never makes the page scroll, down or sideways,
   and nothing on the page moves. It lets the pointer through (only the figure itself takes it) */
.about-figure-frame {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 300vh;
  overflow: hidden;
  overflow: clip;
  pointer-events: none;
}

.about-figure-frame .about-image {
  pointer-events: auto;
}

.about-image {
  position: absolute;
  right: var(--gutter);
  bottom: var(--gutter);
  display: block;
  width: calc((100% - 13 * var(--gutter)) / 4 + 2 * var(--gutter));
  height: auto;
}

/* The figure shakes every now and then (started from about.js), and keeps shaking while hovered */
.about-image.is-shaking {
  animation: shake 0.5s ease-in-out;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .about-image:hover {
    animation: shake 0.5s ease-in-out infinite;
  }
}

@keyframes shake {
  0%,
  100% {
    transform: none;
  }
  15% {
    transform: translate(-2px, 1px) rotate(-2deg);
  }
  30% {
    transform: translate(2px, -1px) rotate(2deg);
  }
  45% {
    transform: translate(-2px, 0) rotate(-1.5deg);
  }
  60% {
    transform: translate(2px, 1px) rotate(1.5deg);
  }
  75% {
    transform: translate(-1px, 0) rotate(-1deg);
  }
}

/* Over the About image the pointer becomes a speech bubble – its corner is the pointer */
@media (hover: hover) {
  .about-image {
    cursor: none;
  }
}

/* Styled like a header button in its black state (the page you are on); its bottom left corner is the
   pointer */
.speech-bubble {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 30;
  padding: 0 10px;
  line-height: var(--header-button-height);
  background: #121212;
  font-weight: 500;
  color: #eeeeee;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(var(--x, 0), var(--y, 0)) translate(0, -100%);
  transition: opacity 0.15s ease;
}

/* Near the right edge the bubble opens to the left, its bottom right corner on the pointer */
.speech-bubble.is-flipped {
  transform: translate(var(--x, 0), var(--y, 0)) translate(-100%, -100%);
}

.speech-bubble.is-shown {
  opacity: 1;
}

/* Footer at the bottom of every page: the copyright line, bottom left */
.footer {
  margin-top: 40px;
}

.footer-text {
  grid-column: 1 / -1;
  font-family: var(--font-caps);
  font-weight: 500;
  line-height: 16px;
  letter-spacing: var(--letter-spacing-caps);
  color: #121212;
}

/* 404 page: one window high, with tickers across it (put in by not-found.js) – frosted bands like the
   boxes, in the About introduction's text. Each band is wider than the window's diagonal, so its ends
   are never seen, whatever its angle */
.page-not-found {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.not-found {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* The clock man, behind the tickers: he can't be clicked, and fades in once he is made */
.not-found-man {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.not-found-man.is-shown {
  opacity: 1;
}

.ticker {
  position: absolute;
  left: 50%;
  width: 160vmax;
  overflow: hidden;
  padding: 6px 0;
  background: rgb(220 220 220 / 50%);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  font-family: var(--font-caps);
  font-weight: 500;
  font-size: 24px;
  line-height: 23px;
  letter-spacing: var(--letter-spacing-caps);
  color: #121212;
  white-space: nowrap;
}

.ticker-track {
  display: flex;
  width: max-content;
}

.ticker-track span {
  padding-right: 48px; /* the space between one "404 page not found" and the next */
}

.ticker-track.is-running {
  animation: ticker linear infinite;
}

@keyframes ticker {
  to {
    transform: translateX(-50%);
  }
}

/* ==========================================================================
   Mobile – phones and narrow windows (up to 700px wide)
   Everything specific to mobile goes here. The values below are the knobs for
   scaling: change them to resize text, spacing and images on phones only
   ========================================================================== */

@media (max-width: 700px) {
  :root {
    /* Text */
    --font-size: 14px;
    --line-height: 16px;

    /* Spacing */
    --gutter: 4px;
    --project-padding: 16px;
    --space-after-header: 172px; /* about 190px from the buttons to the first project */
    --space-between-projects: 8px; /* + 16px + 16px project padding = 40px in total */
    --space-above-media: 2px;

    /* Images */
    --media-height: 260px;
    --media-height-list: 200px;
    --media-gap: 2px;
  }

  /* A 4-column grid on phones */
  .grid {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Header: the name in columns 1–2, About in columns 3–4 – the buttons line up with the grid's
     columns on phones */
  .header {
    display: grid;
    gap: var(--gutter);
  }

  .name {
    grid-column: 1 / 3;
  }

  .nav {
    grid-column: 3 / 5;
  }

  .nav .header-button {
    flex: 1;
  }

  /* Lab is made for computers – no Lab button on phones */
  .lab-menu {
    display: none;
  }

  /* Project text: title block in columns 1–2, info in columns 3–4 */
  .project-heading {
    grid-column: 1 / 3;
  }

  .project-info {
    grid-column: 3 / 5;
  }

  /* A closed project keeps every box to one line, ending in … if it doesn't fit; open, the whole
     text shows. Projects that can't be opened (only videos) always show it all */
  .is-collapsible:not(.is-open) .project-summary:has(.project-toggle) .info-box:last-child {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* No Expand box on phones – the columns are too narrow; tapping the text opens the project. The
     button is still there for screen readers */
  .project-toggle {
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* About: every section across the whole width, one under the other */
  .about-section[data-section] {
    grid-column: 1 / -1;
  }

  /* The figure across the grid at the end of the page, inside its margins, the copyright line below it. In the
     page like the rest, so its frame is not needed: the copyright line is below it, and the sides are cut off by
     the footer */
  .about-figure-frame {
    display: contents;
  }

  .about-image {
    position: static;
    grid-column: 1 / -1;
    width: 100%;
  }
}
