@font-face {
  font-family: Quicksand;
  src: url("/fonts/Quicksand-variable.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}

@font-face {
  font-family: "Bruno Ace SC";
  src: url("/fonts/BrunoAceSC-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --canvas: light-dark(#f7f7f4, #242426);
  --ink: light-dark(#292a2c, #f7f7f4);
  --brand: #e28237;
  --brand-ink: #fff;
  --panel: light-dark(#fff, #303034);
  --preview: light-dark(#e8eae6, #38393b);
  --muted: light-dark(#686c72, #b9bdc3);
  --accent: light-dark(#a34d10, #f0a66b);
  --content-width: 79rem;
  --gutter: 1.5rem;
  --section-gap: 3rem;
  --card-radius: 1.125rem;
  --title-size: 1.875rem;
  font-family: Quicksand, sans-serif;
  line-height: 1.5;
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
}

h2 {
  margin: 0;
  font-size: var(--title-size);
  font-weight: 600;
  line-height: 1.35;
}

.software-header {
  position: relative;
  isolation: isolate;

  &::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    z-index: -1;
    height: 3.5625rem;
    background: var(--brand);
    /* Preserve the internal header's original 24 × 29px diagonal step. */
    clip-path: polygon(0 0, 100% 0, 100% 100%, calc(55.347222% + 1.5rem) 100%, 55.347222% 1.75rem, 0 1.75rem);
  }

  .inner {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: var(--gutter);
    width: min(var(--content-width), calc(100% - 2 * var(--gutter)));
    min-height: 11.25rem;
    margin-inline: auto;
    padding-block: 1.25rem 2.5rem;
  }

  .back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    text-decoration: none;

    &:hover {
      text-decoration: underline;
    }
  }

  .heading {
    position: relative;
    top: 0.5rem;
    /* Keep the eyebrow clear of the orange bar; extra title lines grow down. */
    padding-top: 2.5rem;
  }

  h1 {
    margin: 0;
    font-size: 2.5rem;
    line-height: 1.1;
    text-wrap: balance;
  }

  .brand {
    display: flex;
    flex: 0 0 auto;
    align-items: end;
    gap: 3.960396%;
    width: 25.25rem;

    picture {
      width: 54.455446%;
    }

    > img {
      width: 41.584158%;
    }

    img {
      display: block;
      height: auto;
    }

    picture img {
      width: 100%;
    }
  }

  @media (width <= 64rem) {
    .heading {
      top: 0;
      padding-top: 0;
    }

    .inner {
      flex-direction: column;
      align-items: start;
      padding-bottom: 1.5rem;
    }

    .brand {
      order: -1;
      align-self: end;
      width: min(100%, 25.25rem);
    }
  }

  @media (width <= 32rem) {
    h1 {
      font-size: 2rem;
    }
  }
}

.software-index,
.software-detail {
  margin-top: 0;

  .intro {
    margin: 0 0 4rem;
    padding-top: 0.5rem;
    color: var(--muted);
    font-size: 1.125rem;
  }
}

.software-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gutter);

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

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

.software-card {
  --title-size: 1.4375rem;
  min-width: 0;
  border-radius: var(--card-radius);
  background: var(--panel);

  .preview {
    display: grid;
    place-items: center;
    height: 12.5rem;
    padding: 0.75rem;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
    background: var(--preview);
  }

  img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 11rem;
    object-fit: contain;
  }

  .copy {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
  }

  p {
    margin: 0;
    color: var(--muted);
    font-size: 0.875rem;
  }

  > a {
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: inherit;
    color: inherit;
    text-decoration: none;

    &:hover,
    &:focus-visible {
      text-decoration: none;
    }

    &:hover h2,
    &:focus-visible h2 {
      color: var(--accent);
      text-decoration: underline;
    }
  }
}

.software-detail {
  .details {
    display: grid;
    grid-template-columns: 20.625rem minmax(0, 1fr);
    align-items: start;
    gap: 3.5rem;
  }

  aside {
    min-width: 0;
    padding: 1.5rem;
    border-radius: var(--card-radius);
    background: var(--panel);
  }

  .download {
    display: flex;
    align-items: start;
    gap: 0.625rem;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.5;
    text-decoration-thickness: 0.075em;

    &::before {
      content: "";
      flex: 0 0 1.5rem;
      height: 1.5rem;
      margin-top: 0.09375rem;
      background: currentColor;
      mask: url("/assets/icons/download.svg") center / contain no-repeat;
    }
  }

  figure {
    margin: 1.5rem 0;

    img {
      display: block;
      width: auto;
      height: auto;
      max-width: min(100%, 15rem);
      max-height: 20rem;
      margin-inline: auto;
      object-fit: contain;
    }
  }

  .screenshot {
    display: grid;
    place-items: center;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: 0.25rem;
    background: transparent;
    cursor: zoom-in;

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

  }

  figcaption {
    margin-top: 0.5rem;
    color: var(--muted);
    font-size: 0.6875rem;
  }

  dl {
    margin: 0;
    padding-top: 1.5rem;
    border-top: 1px solid var(--preview);
  }

  dt {
    color: var(--muted);
    font-size: 0.6875rem;
    text-transform: uppercase;
  }

  dd {
    margin: 0.5rem 0 1.5rem;

    &:last-child {
      margin-bottom: 0;
    }
  }

  article {
    --title-size: 1.5rem;
    min-width: 0;
    font-size: 1.0625rem;
    line-height: 1.65;

    section + section {
      margin-top: 3rem;
    }

    p {
      margin: 0.875rem 0 0;
    }

    ul,
    ol {
      margin: 0.875rem 0 0;
      padding-left: 1.5rem;
    }

    li + li {
      margin-top: 0.375rem;
    }
  }

  table {
    width: 100%;
    margin-top: 1.25rem;
    border-spacing: 0;
    border-radius: 0.375rem;
    overflow: hidden;
    font-size: 0.875rem;
    text-align: left;
  }

  th,
  td {
    padding: 0.75rem 1.25rem;
    font-weight: 400;
  }

  thead {
    color: var(--muted);
    background: var(--preview);
    font-size: 0.6875rem;
    text-transform: uppercase;
  }

  tbody tr {
    background: var(--panel);

    &:nth-child(even) {
      background: var(--preview);
    }
  }

  audio {
    display: block;
    width: min(100%, 22rem);
  }

  @media (width <= 52rem) {
    .details {
      grid-template-columns: 1fr;
      gap: var(--section-gap);
    }

    aside {
      width: min(100%, 25rem);
    }

    th,
    td {
      padding: 0.75rem;
    }
  }
}

#screenshot-zoom {
  max-width: calc(100% - 2 * var(--gutter));
  max-height: calc(100% - 2 * var(--gutter));
  padding: 1rem;
  border: 0;
  border-radius: 0.5rem;
  color: var(--ink);
  background: var(--panel);

  &::backdrop {
    background: rgb(0 0 0 / 70%);
  }

  .close {
    display: block;
    min-height: 2.75rem;
    margin: 0 0 1rem auto;
    padding: 0.5rem 1rem;
    border: 1px solid currentColor;
    border-radius: 0.375rem;
    color: inherit;
    background: transparent;
    font: inherit;
    cursor: pointer;
  }

  img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
  }
}

.theme-selector {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: #292a2c;
  font-size: 0.875rem;

  &[hidden] {
    display: none;
  }

  button {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    color: inherit;
    background: transparent;
    font: inherit;
    cursor: pointer;

    &[aria-pressed="true"] {
      border-color: currentColor;
      background: rgb(255 255 255 / 25%);
    }

    &:hover {
      background: rgb(255 255 255 / 35%);
    }

    &:focus-visible {
      outline: 2px solid currentColor;
      outline-offset: 3px;
    }
  }

  svg {
    width: 1.125rem;
    height: 1.125rem;
  }
}

.site-footer {
  position: relative;
  isolation: isolate;
  margin-top: 5rem;
  color: var(--brand-ink);
  font-size: 0.875rem;

  &::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--brand);
    /* Exact complement of the software header's 24 × 29px step. */
    clip-path: polygon(0 0, 55.347222% 0, calc(55.347222% + 1.5rem) 1.8125rem, 100% 1.8125rem, 100% 100%, 0 100%);
  }

  .inner {
    position: relative;
    display: flex;
    align-items: center;
    gap: 3rem;
    width: min(var(--content-width), calc(100% - 2 * var(--gutter)));
    min-height: 6.75rem;
    margin-inline: auto;
    padding-block: 1.875rem;
  }

  .copy {
    max-width: calc(100% - 6.75rem);
  }

  .theme-selector {
    flex-shrink: 0;

    @media (width <= 36rem) {
      position: absolute;
      right: 0;
      bottom: 0.75rem;
    }
  }

  img {
    position: absolute;
    top: 0;
    left: calc((100% + 55.347222% + 1.5rem) / 2);
    display: block;
    width: 5.25rem;
    height: auto;
    transform: translateX(-50%);
  }

  p {
    margin: 0.375rem 0 0;
    font-size: 0.75rem;
  }

  nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gutter);
  }

  a {
    color: inherit;
  }
}

h1.display {
  font-family: "Bruno Ace SC", sans-serif;
  font-weight: 400;
}

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 0.2em;

  &:hover,
  &:focus-visible {
    text-decoration: underline;
  }
}

main {
  width: min(var(--content-width), calc(100% - 2 * var(--gutter)));
  margin: var(--section-gap) auto;
}

a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 8px;
}

.masthead {
  --tab-depth: 3.375rem;
  --tab-half-width: min(25.208333vw, 22.6875rem);
  container-type: inline-size;
  position: relative;
  isolation: isolate;
  color: var(--brand-ink);
  text-align: center;

  /* Mock geometry: 1440 × 444, with a 54px tab and 27px diagonal cuts. */
  &::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--brand);
    clip-path: polygon(
      0 0, 100% 0,
      100% calc(100% - var(--tab-depth)),
      calc(50% + var(--tab-half-width)) calc(100% - var(--tab-depth)),
      calc(50% + var(--tab-half-width) - var(--tab-depth) / 2) 100%,
      calc(50% - var(--tab-half-width) + var(--tab-depth) / 2) 100%,
      calc(50% - var(--tab-half-width)) calc(100% - var(--tab-depth)),
      0 calc(100% - var(--tab-depth))
    );
  }

  h1 {
    margin: 0;
    padding: clamp(2rem, 5.277778vw, 4.75rem) 1.5rem clamp(2rem, 6.111111vw, 5.5rem);
  }

  a {
    display: block;
    width: min(100%, 51.25rem);
    margin-inline: auto;
    color: inherit;
  }

  img {
    display: block;
    width: 100%;
    height: auto;
  }

  p {
    --intro-width: calc(2 * var(--tab-half-width) - var(--tab-depth));
    display: grid;
    place-items: center;
    width: var(--intro-width);
    min-height: var(--tab-depth);
    margin: 0 auto;
    padding: 0 0.5rem 0.5rem;
    font-size: min(1.5rem, calc((var(--intro-width) - 1rem) / 24));
    line-height: 1.35;
    white-space: nowrap;
  }

  @media (width <= 48rem) {
    --tab-half-width: calc(50cqi - 1rem);
  }
}

.home-footer {
  --tab-depth: 3.375rem;
  --tab-half-width: min(25.208333vw, 22.6875rem);
  position: relative;
  isolation: isolate;
  height: calc(2 * var(--tab-depth));
  margin-top: calc(2 * var(--section-gap) + 1.84375rem);

  .theme-selector {
    position: absolute;
    bottom: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
  }

  /* Mock geometry: a 108px footer, with a 54px band and 27px diagonal cuts. */
  &::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--brand);
    clip-path: polygon(
      0 var(--tab-depth),
      calc(50% - var(--tab-half-width)) var(--tab-depth),
      calc(50% - var(--tab-half-width) + var(--tab-depth) / 2) 0,
      calc(50% + var(--tab-half-width) - var(--tab-depth) / 2) 0,
      calc(50% + var(--tab-half-width)) var(--tab-depth),
      100% var(--tab-depth), 100% 100%, 0 100%
    );
  }

  img {
    position: absolute;
    top: -1.84375rem;
    left: 50%;
    display: block;
    width: 5.25rem;
    height: auto;
    transform: translateX(-50%);
  }

  @media (width <= 48rem) {
    --tab-half-width: calc(50% - 1rem);
  }
}

.featured-grid,
.collection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gutter);

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

.collection-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: var(--section-gap);

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

.project-card {
  --padding: 1.5rem;
  min-width: 0;
  border-radius: var(--card-radius);
  background: var(--panel);

  &.compact {
    --title-size: 1.4375rem;

    .copy {
      min-height: 10rem;
    }
  }

  a {
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: inherit;
    color: inherit;
    text-decoration: none;

    &:hover,
    &:focus-visible {
      text-decoration: none;
    }

    &:hover h2,
    &:focus-visible h2 {
      color: var(--accent);
      text-decoration: underline;
      text-underline-offset: 0.15em;
    }
  }

  .preview {
    overflow: hidden;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
    background: var(--preview);
  }

  picture,
  img {
    display: block;
    width: 100%;
  }

  picture {
    aspect-ratio: 620 / 272;
  }

  img {
    height: 100%;
    object-fit: cover;
    object-position: center;
  }

  .copy {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 14.25rem;
    padding: var(--padding);
  }

  p {
    margin: 0;
  }

  .eyebrow {
    color: var(--accent);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
  }

  .tagline {
    max-width: 32ch;
    font-size: 1.375rem;
    line-height: 1.35;
  }

  .description {
    margin-top: auto;
    padding-top: 0.5rem;
    color: var(--muted);
    font-size: 0.875rem;
  }
}

.cover-gallery {
  --cover-height: clamp(12rem, 20vw, 16.875rem);
  --cover-gap: var(--section-gap);
  margin-top: var(--section-gap);

  & + & {
    padding-top: var(--section-gap);
    border-top: 1px solid var(--preview);
  }

  &.square {
    --cover-height: clamp(10rem, 16vw, 14rem);
    --cover-gap: var(--gutter);

    img {
      border-radius: 0.5rem;
    }
  }

  .actions,
  .controls:not([hidden]) {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .actions {
    flex-wrap: wrap;
    justify-content: end;
    margin-inline-start: auto;
    gap: var(--gutter);

    > a {
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      min-height: 2.75rem;
      padding: 0.625rem 1rem;
      border: 1px solid currentColor;
      border-radius: 0.5rem;
      background: var(--panel);
      font-weight: 600;
      text-decoration: none;

      &:hover {
        background: var(--preview);
      }
    }
  }

  button {
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: var(--ink);
    background: transparent;
    font: inherit;
    font-size: 1.5rem;
    cursor: pointer;

    &:hover:enabled {
      background: var(--preview);
    }

    &:disabled {
      opacity: 0.3;
      cursor: default;
    }

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

  header {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: space-between;
    gap: var(--gutter);

    p {
      margin: 0.75rem 0 0;
      color: var(--muted);
    }
  }

  ul {
    display: flex;
    gap: var(--cover-gap);
    overflow-x: auto;
    margin: var(--section-gap) 0 0;
    padding: var(--gutter);
    border-radius: 0.75rem;
    background: var(--preview);
    list-style: none;
    scroll-snap-type: x proximity;
    scroll-padding-inline: var(--gutter);
    scrollbar-width: none;

    &::-webkit-scrollbar {
      display: none;
    }

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

  li {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  li a,
  img {
    display: block;
  }

  img {
    width: auto;
    height: var(--cover-height);
  }
}
