@layer reset, base, layout, components, utilities;

/* ---------------------------------------------------------------- fonts -- */

@font-face {
  font-family: "Albert Sans";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/albert-sans-normal-300-700-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;
}

@font-face {
  font-family: "Albert Sans";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/albert-sans-normal-300-700-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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Albert Sans";
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/albert-sans-italic-300-700-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;
}

@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/rubik-normal-300-700-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;
}

@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/rubik-normal-300-700-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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------------------------------------------------------------- reset -- */

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

  body,
  h1,
  h2,
  h3,
  h4,
  p,
  figure,
  ul,
  ol {
    margin: 0;
  }

  ul[class],
  ol[class] {
    padding: 0;
    list-style: none;
  }

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

  button,
  input,
  a {
    font: inherit;
    color: inherit;
  }

  button {
    padding: 0;
    background: none;
    border: 0;
    cursor: pointer;
  }

  :target {
    scroll-margin-top: 6rem;
  }

  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }
}

/* ----------------------------------------------------------------- base -- */

@layer base {
  :root {
    /* Colours, carried over from the original theme's palette. */
    --bg: #fff;
    --ink: #0c0c0e;
    --ink-body: rgb(12 12 14 / 0.75);
    --ink-muted: rgb(12 12 14 / 0.55);
    --rule: rgb(12 12 14 / 0.1);
    --shadow: 12px 12px 50px rgb(0 0 0 / 0.25);

    /* Type */
    --font-body: "Albert Sans", ui-sans-serif, system-ui, sans-serif;
    --font-display: "Rubik", ui-sans-serif, system-ui, sans-serif;
    --step--1: clamp(0.82rem, 0.79rem + 0.14vw, 0.9rem);
    --step-0: clamp(0.95rem, 0.91rem + 0.19vw, 1.06rem);
    --step-1: clamp(1.1rem, 1rem + 0.5vw, 1.4rem);
    --step-2: clamp(1.35rem, 1.15rem + 1vw, 2rem);
    --step-3: clamp(1.75rem, 1.35rem + 2vw, 3rem);

    /* Rhythm */
    --gutter: clamp(1.25rem, 0.9rem + 1.75vw, 2.5rem);
    --gallery-gap: clamp(1.25rem, 2.5vw, 2.25rem);
    --section-gap: clamp(4rem, 2.5rem + 7vw, 8.5rem);
    --content: 720px;
    --wide: 1200px;
  }

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

  body {
    background: var(--bg);
    color: var(--ink-body);
    font-family: var(--font-body);
    font-size: var(--step-0);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  h1,
  h2,
  h3,
  h4 {
    color: var(--ink);
    font-family: var(--font-display);
    font-weight: 400;
    line-height: 1.15;
    text-wrap: balance;
  }

  p {
    text-wrap: pretty;
  }

  a {
    color: inherit;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.25em;
  }

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

/* --------------------------------------------------------------- layout -- */

@layer layout {
  .page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .page > main {
    flex: 1;
  }

  /* Every direct child sits in the content column; `.wide` opts out.
     Based on the "content grid" pattern. */
  .flow {
    display: grid;
    /* `main` is flex-grown to push the footer down; without this its rows
       would stretch to fill the leftover height and spread the content out. */
    align-content: start;
    grid-template-columns:
      [full-start] minmax(var(--gutter), 1fr)
      [wide-start] minmax(0, calc((var(--wide) - var(--content)) / 2))
      [content-start] min(var(--content), 100% - var(--gutter) * 2) [content-end]
      minmax(0, calc((var(--wide) - var(--content)) / 2)) [wide-end]
      minmax(var(--gutter), 1fr) [full-end];
  }

  .flow > * {
    grid-column: content;
  }

  .flow > .wide {
    grid-column: wide;
  }

  .skip-link {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 100;
    padding: 0.6rem 1rem;
    background: var(--ink);
    color: var(--bg);
    border-radius: 4px;
    text-decoration: none;
    transform: translateY(-200%);
    transition: transform 150ms ease;
  }

  .skip-link:focus-visible {
    transform: translateY(0);
  }
}

/* ----------------------------------------------------------- site header -- */

@layer components {
  /* Anchors the mobile nav panel, which is positioned against the header. */
  .site-header {
    position: relative;
  }

  .masthead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    max-width: var(--wide);
    margin-inline: auto;
    padding: clamp(1.25rem, 3vh, 2.25rem) var(--gutter);
  }

  .masthead__logo img {
    width: clamp(200px, 26vw, 300px);
    filter: grayscale(1);
  }

  /* ---- navigation ---- */

  /* Shown only on narrow screens, and only once the script that reopens
     the panel is present (see below). */
  .nav__toggle {
    display: none;
  }

  .nav__list {
    display: flex;
    font-family: var(--font-display);
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .nav__link {
    display: block;
    padding-block: 0.4rem;
    color: var(--ink);
    text-decoration: none;
    transition: opacity 150ms ease;
  }

  .nav__link:hover {
    opacity: 0.55;
  }

  .nav__link[aria-current="page"] {
    text-decoration: underline;
    text-underline-offset: 0.4em;
  }

  .nav__submenu {
    display: grid;
    gap: 0.35rem;
  }

  /* Wide screens: one row, with each group's children in a dropdown. */
  @media (width >= 48rem) {
    .nav__list {
      align-items: center;
      gap: clamp(1.25rem, 3vw, 2.5rem);
      font-size: var(--step--1);
    }

    .nav__group {
      position: relative;
    }

    .nav__submenu {
      position: absolute;
      top: 100%;
      left: 50%;
      z-index: 20;
      min-width: max-content;
      padding: 0.9rem 1.25rem;
      background: var(--bg);
      border: 1px solid var(--rule);
      box-shadow: 0 12px 32px rgb(0 0 0 / 0.08);
      translate: -50% 0;
      transition:
        opacity 150ms ease,
        translate 150ms ease,
        visibility 150ms;
    }

    /* Hidden until the group is hovered or something inside it has focus.
       `visibility` keeps it out of the tab order while closed. */
    .nav__group:not(:hover, :focus-within) > .nav__submenu {
      opacity: 0;
      visibility: hidden;
      translate: -50% -0.4rem;
    }

    .nav__group > .nav__link::after {
      content: "";
      display: inline-block;
      width: 0.4em;
      height: 0.4em;
      margin-left: 0.5em;
      border-right: 1px solid currentColor;
      border-bottom: 1px solid currentColor;
      rotate: 45deg;
      translate: 0 -0.15em;
    }
  }

  /* Narrow screens: a stacked list under the logo, children shown inline.
     Only once the script is present — and can reopen it — is the panel
     collapsed behind the button and lifted out of the flow. */
  @media (width < 48rem) {
    .masthead {
      flex-wrap: wrap;
    }

    .nav__panel {
      flex-basis: 100%;
      padding-top: 1.25rem;
    }

    .js .nav__toggle {
      display: block;
      padding: 0.5rem;
      margin-right: -0.5rem;
      color: var(--ink);
    }

    .nav__toggle svg {
      display: block;
    }

    .nav__toggle .nav__icon--close,
    .nav__toggle[aria-expanded="true"] .nav__icon--open {
      display: none;
    }

    .nav__toggle[aria-expanded="true"] .nav__icon--close {
      display: block;
    }

    .js .nav__panel {
      position: absolute;
      inset: auto 0 auto 0;
      z-index: 30;
      padding: 1.5rem var(--gutter) 2rem;
      background: var(--bg);
      border-bottom: 1px solid var(--rule);
    }

    .nav__panel[hidden] {
      display: none;
    }

    .nav__list {
      flex-direction: column;
      gap: 0.25rem;
      font-size: var(--step-0);
      text-align: center;
    }

    .nav__submenu {
      padding: 0.25rem 0 0.75rem;
      color: var(--ink-muted);
      font-size: var(--step--1);
    }
  }

  /* ------------------------------------------------------- site footer -- */

  .site-footer {
    margin-top: var(--section-gap);
    padding: 2.5rem var(--gutter) 3rem;
    border-top: 1px solid var(--rule);
    color: var(--ink-muted);
    font-size: var(--step--1);
  }

  .site-footer__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem 2rem;
    max-width: var(--wide);
    margin-inline: auto;
  }

  .site-footer__links {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
  }

  /* ------------------------------------------------------------ hero ---- */

  .page-header {
    margin-block: clamp(2rem, 6vh, 4.5rem) clamp(2.5rem, 6vh, 4rem);
    text-align: center;
  }

  .page-header h1 {
    font-size: var(--step-3);
    letter-spacing: -0.01em;
  }

  .page-header__lede {
    max-width: 46ch;
    margin: 1.25rem auto 0;
    color: var(--ink-muted);
    font-size: var(--step-1);
  }

  .breadcrumb {
    margin-bottom: 1rem;
    color: var(--ink-muted);
    font-family: var(--font-display);
    font-size: var(--step--1);
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  /* ------------------------------------------------- home: cover cards -- */

  /* Two cards per row once there is room; one per row on phones. */
  .cards {
    display: grid;
    gap: clamp(1.5rem, 3vw, 2.75rem);
    margin-block: clamp(2rem, 5vh, 4rem);
    /* Two across the full wide column makes each card huge; keep them to a
       comfortable size and centre the pair. */
    width: min(100%, 60rem);
    margin-inline: auto;
  }

  @media (width >= 30rem) {
    .cards {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  /* The link clips the image while it scales on hover. */
  .card a {
    display: block;
    overflow: hidden;
  }

  .card img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    transition: scale 500ms cubic-bezier(0.2, 0, 0.2, 1);
  }

  .card a:hover img,
  .card a:focus-visible img {
    scale: 1.04;
  }

  /* ---------------------------------------------------------- sections -- */

  /* Sections span the wide column so galleries have room; their headers
     stay narrow so prose keeps a readable measure. */
  .flow > .section {
    grid-column: wide;
  }

  .section + .section {
    margin-block-start: var(--section-gap);
  }

  .section__header {
    max-width: var(--content);
    margin-inline: auto;
    margin-bottom: clamp(1.75rem, 4vw, 3rem);
    text-align: center;
  }

  .section__header h2 {
    font-size: var(--step-2);
    letter-spacing: 0.01em;
  }

  .section__header h2 a {
    text-decoration: none;
  }

  .section__header h2 a:hover {
    text-decoration: underline;
    text-underline-offset: 0.2em;
  }

  .section__header p {
    max-width: 58ch;
    margin: 1rem auto 0;
    color: var(--ink-muted);
  }

  .section__more {
    display: inline-block;
    margin-top: 1.25rem;
    font-family: var(--font-display);
    font-size: var(--step--1);
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  /* ----------------------------------------------------------- gallery -- */

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

  @media (width < 48rem) {
    .grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  @media (width < 30rem) {
    .grid {
      grid-template-columns: 1fr;
    }
  }

  /* A single image introducing a series — sized like a plate, not a banner. */
  .section__lead {
    width: min(34rem, 100%);
    margin: 0 auto clamp(1.5rem, 3vw, 2.5rem);
  }

  /* A piece shown on its own, at the width of a masonry column. */
  .plate {
    width: min(34rem, 100%);
    margin-inline: auto;
  }

  /* Mixed portrait/landscape work reads best in balanced columns. */
  .masonry {
    columns: 2 18rem;
    gap: var(--gallery-gap);
  }

  .masonry > * {
    margin-bottom: var(--gallery-gap);
    break-inside: avoid;
  }

  .artwork {
    position: relative;
    display: block;
    width: 100%;
    overflow: hidden;
    background: rgb(12 12 14 / 0.03);
  }

  .artwork img {
    width: 100%;
    transition: scale 600ms cubic-bezier(0.2, 0, 0.2, 1);
  }

  .artwork:hover img {
    scale: 1.03;
  }

  .artwork--shadow {
    box-shadow: var(--shadow);
  }

  /* ---------------------------------------------------------- carousel -- */

  .carousel {
    position: relative;
  }

  .carousel__track {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
    padding-inline: var(--gutter);
    padding-bottom: 1rem;
    /* Firefox / standards; WebKit falls back to the ::-webkit rule below. */
    scrollbar-width: thin;
    scrollbar-color: var(--rule) transparent;
    overscroll-behavior-x: contain;
  }

  .carousel__track::-webkit-scrollbar {
    height: 6px;
  }

  .carousel__track::-webkit-scrollbar-thumb {
    background: var(--rule);
    border-radius: 3px;
  }

  .carousel__slide {
    flex: 0 0 min(26rem, 82vw);
    scroll-snap-align: center;
  }

  .carousel__button {
    position: absolute;
    top: 50%;
    z-index: 5;
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    background: rgb(255 255 255 / 0.9);
    border-radius: 50%;
    box-shadow: 0 2px 14px rgb(0 0 0 / 0.14);
    color: var(--ink);
    translate: 0 -50%;
    transition:
      opacity 200ms ease,
      scale 200ms ease;
  }

  .carousel__button:hover {
    scale: 1.08;
  }

  .carousel__button[disabled] {
    opacity: 0;
    pointer-events: none;
  }

  .carousel__button--prev {
    left: max(0.5rem, calc(var(--gutter) - 3.25rem));
  }

  .carousel__button--next {
    right: max(0.5rem, calc(var(--gutter) - 3.25rem));
  }

  /* The buttons are progressive enhancement: the track scrolls and snaps
     on its own, so they only appear once the script wires them up. */
  .carousel:not([data-ready]) .carousel__button {
    display: none;
  }

  /* ----------------------------------------------------------- feature -- */

  .feature {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr));
    gap: clamp(1.75rem, 4vw, 3.5rem);
    align-items: center;
  }

  .feature__body h2 {
    font-size: var(--step-2);
  }

  .feature__body p {
    margin-top: 1rem;
    color: var(--ink-muted);
  }

  /* ------------------------------------------------------------- video -- */

  .video {
    width: 100%;
    background: #000;
  }

  /* ------------------------------------------------------------- about -- */

  .about {
    display: grid;
    justify-items: center;
    gap: 2rem;
    margin-block: clamp(2rem, 6vh, 4rem);
    text-align: center;
  }

  .about__portrait {
    width: min(289px, 70vw);
    border-radius: 50%;
  }

  .about__body {
    display: grid;
    gap: 1.1rem;
    max-width: 52ch;
    font-size: var(--step-1);
  }

  .about__contact {
    margin-top: 0.5rem;
    font-family: var(--font-display);
    font-size: var(--step-0);
    letter-spacing: 0.04em;
  }

  /* -------------------------------------------------------- lightbox -- */

  .lightbox {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    padding: 0;
    border: 0;
    background: rgb(255 255 255 / 0.98);
    color: var(--ink);
  }

  .lightbox::backdrop {
    background: rgb(255 255 255 / 0.9);
  }

  .lightbox__figure {
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 1rem;
    height: 100%;
    padding: clamp(2.5rem, 6vw, 4rem);
  }

  .lightbox__figure img {
    max-width: 100%;
    max-height: calc(100dvh - 9rem);
    width: auto;
    object-fit: contain;
  }

  .lightbox__count {
    color: var(--ink-muted);
    font-size: var(--step--1);
    letter-spacing: 0.08em;
  }

  .lightbox__close,
  .lightbox__nav {
    position: absolute;
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    transition: background 150ms ease;
  }

  .lightbox__close:hover,
  .lightbox__nav:hover {
    background: rgb(12 12 14 / 0.07);
  }

  .lightbox__close {
    top: 1rem;
    right: 1rem;
  }

  .lightbox__nav {
    top: 50%;
    translate: 0 -50%;
  }

  .lightbox__nav--prev {
    left: 0.75rem;
  }

  .lightbox__nav--next {
    right: 0.75rem;
  }
}

/* ------------------------------------------------------------ utilities -- */

@layer utilities {
  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
