/*
  justinmaurer.net
  One stylesheet, no framework. Layers keep specificity predictable:
  reset → base → layout → components → pages.
*/

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

/* Fonts (self-hosted) */

@font-face {
  font-family: "Roboto";
  src: url("../fonts/roboto-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Playfair Display";
  src: url("../fonts/playfair-display-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Nexa Bold";
  src: url("../fonts/nexa-bold.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* Page-to-page crossfade (replaces the old jQuery fade) */

@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.35s;
}

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

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

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

  ul[role="list"],
  ol[role="list"] {
    list-style: none;
    padding: 0;
  }

  img,
  svg,
  iframe {
    display: block;
    max-width: 100%;
  }

  img {
    height: auto;
  }

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

  button {
    cursor: pointer;
  }
}

@layer base {
  :root {
    --page: #2a5f60;
    --panel: #438384;
    --menu: #915880;
    --ink: #fff;
    --ink-soft: rgb(255 255 255 / 0.85);
    --ink-muted: rgb(255 255 255 / 0.6);
    --ink-faint: rgb(255 255 255 / 0.45);
    --line: rgb(255 255 255 / 0.12);
    --breadcrumb: #9dc1c2;

    --sans: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --serif: "Playfair Display", Georgia, serif;
    --label: "Nexa Bold", Verdana, sans-serif;

    --gutter: 30px;
    --pill: 999px;

    color-scheme: dark;
    background: var(--page);
  }

  @media (prefers-reduced-motion: no-preference) {
    :root {
      scroll-behavior: smooth;
    }
  }

  body {
    font-family: var(--sans);
    font-size: 0.875rem;
    font-weight: 300;
    line-height: 1.43;
    color: var(--ink);
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  p {
    font-size: 1.3em;
    line-height: 1.7;
  }

  ::selection {
    background: #fff;
    color: #000;
  }

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

  .icon {
    display: inline-block;
    width: auto;
    height: 1em;
    fill: currentColor;
    vertical-align: -0.125em;
  }

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

  @media (max-width: 768px) {
    p {
      font-size: 1.1em;
    }
  }
}

@layer layout {
  body {
    padding: 30px;
  }

  .frame {
    max-width: 1340px;
    margin: 0 auto 30px;
    padding: 0 60px;
    background: var(--panel);
  }

  .container {
    width: min(100%, 1230px);
    margin-inline: auto;
    padding-inline: 15px;
  }

  @media (max-width: 768px) {
    body {
      padding: 0 10px;
    }

    .frame {
      margin-top: 10px;
      padding: 0;
    }
  }
}

@layer components {
  /* Skip link */

  .skip-link {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 100;
    padding: 10px 16px;
    font-family: var(--label);
    font-size: 0.8em;
    letter-spacing: 2px;
    text-transform: uppercase;
    background: var(--ink);
    color: var(--page);
    border-radius: var(--pill);
    translate: 0 -200%;

    &:focus-visible {
      translate: 0 0;
    }
  }

  /* Header */

  .site-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-block: 40px;

    @media (max-width: 768px) {
      padding-block: 20px;
    }
  }

  .brand {
    display: block;

    @media (max-width: 768px) {
      margin-top: -2px;
    }
  }

  .brand-name {
    display: block;
    padding-top: 3px;
    font-family: var(--label);
    font-size: 0.8em;
    letter-spacing: 2px;
    text-transform: uppercase;
  }

  .brand-mark {
    display: flex;
    align-items: center;
    gap: 0.3em;
    font-size: 1.2em;
  }

  /* Menu trigger (three bars) */

  .nav-trigger {
    width: 40px;
    height: 40px;
    margin: 5px 0;
    padding: 0;
    background: none;
    border: 0;

    & span {
      display: block;
      width: 40px;
      height: 3px;
      margin-top: 6px;
      background: var(--ink);
    }
  }

  /* Slide-out menu (native popover) */

  .site-menu {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(500px, 100vw);
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 120px 80px 60px;
    border: 0;
    background: var(--menu);
    color: var(--ink);
    overflow-y: auto;
    translate: 100% 0;
    transition:
      translate 0.4s,
      display 0.4s allow-discrete,
      overlay 0.4s allow-discrete;

    &:popover-open {
      translate: 0 0;

      @starting-style {
        translate: 100% 0;
      }
    }

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

    & hr {
      margin: 40px 0;
      border: 0;
      border-top: 1px solid rgb(255 255 255 / 0.3);
    }

    @media (max-width: 768px) {
      width: min(350px, 100vw);
      padding: 80px 30px 40px;

      & hr {
        margin: 20px 0;
      }
    }
  }

  .menu-close {
    position: absolute;
    top: 40px;
    right: 40px;
    width: 40px;
    height: 40px;
    padding: 0;
    background: none;
    border: 0;

    & span {
      position: absolute;
      top: 50%;
      left: 0;
      width: 40px;
      height: 3px;
      background: var(--ink);
      rotate: 45deg;

      & + span {
        rotate: -45deg;
      }
    }
  }

  .menu-links {
    display: grid;
    gap: 15px;

    & a {
      font-family: var(--label);
      font-size: 0.8em;
      letter-spacing: 2px;
      text-transform: uppercase;
      transition: opacity 0.4s;

      &:hover {
        opacity: 0.5;
      }
    }
  }

  /* LinkedIn badge */

  .pill.badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;

    & .icon {
      height: 1.4em;
      vertical-align: 0;
    }
  }

  /* Footer */

  .site-footer {
    margin-top: 100px;
    padding: 30px 0;
    border-top: 1px solid rgb(150 150 150 / 0.2);
    font-family: var(--label);
    font-size: 0.8em;
    letter-spacing: 2px;
    text-align: center;
    text-transform: uppercase;

    & p {
      font-size: inherit;
      line-height: inherit;
      opacity: 0.3;
    }

    @media (max-width: 768px) {
      margin-top: 30px;
      padding: 30px;
    }
  }

  /* Pill link / button */

  .pill {
    display: inline-block;
    padding: 12px 20px;
    font-family: var(--label);
    font-size: 12px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--ink);
    background: transparent;
    border: 1px solid rgb(255 255 255 / 0.35);
    border-radius: var(--pill);
    transition:
      background-color 0.2s ease,
      color 0.2s ease,
      border-color 0.2s ease;

    &:hover,
    &:focus-visible {
      background: var(--ink);
      border-color: var(--ink);
      color: var(--page);
    }

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

  .pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 6px 0 36px;
  }

  /* Labels */

  .section-heading {
    margin-bottom: 18px;
    font-family: var(--serif);
    font-size: 36px;
    font-weight: 400;
    line-height: 1.2;

    @media (max-width: 768px) {
      font-size: 28px;
    }
  }

  .group-label {
    margin-bottom: 20px;
    font-family: var(--label);
    font-size: 11px;
    font-weight: normal;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--ink-muted);
  }

  /* Work tiles */

  .tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--gutter);
    row-gap: 50px;

    @media (min-width: 992px) {
      grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    @media (max-width: 768px) {
      row-gap: 20px;
    }
  }

  .tile {
    display: block;

    @media (prefers-reduced-motion: no-preference) {
      animation: tile-in 1s both;

      li:nth-child(1) > & { animation-delay: 0.4s; }
      li:nth-child(2) > & { animation-delay: 0.5s; }
      li:nth-child(3) > & { animation-delay: 0.6s; }
      li:nth-child(4) > & { animation-delay: 0.7s; }
      li:nth-child(n + 5) > & { animation-delay: 0.8s; }
    }
  }

  .thumb {
    position: relative;
    overflow: hidden;

    & img {
      width: 100%;
      aspect-ratio: 1;
      object-fit: cover;
    }

    &::after {
      content: "";
      position: absolute;
      inset: 0;
      background: #000;
      opacity: 0;
      transition: opacity 0.3s;
    }
  }

  .caption {
    position: relative;
    display: block;

    &::before,
    &::after {
      content: "";
      position: absolute;
      left: 0;
      right: 0;
      bottom: -20px;
      height: 3px;
    }

    &::before {
      background: rgb(0 0 0 / 0.1);
    }

    &::after {
      right: 100%;
      background: #000;
      transition: right 0.3s;
    }
  }

  .tile-title {
    display: block;
    margin-top: 19px;
    font-size: 1.5em;
    line-height: 1.3;

    @media (max-width: 768px) {
      margin-top: 10px;
      font-size: 1.3em;
    }
  }

  .tile-tag {
    display: block;
    margin: 10px 0 20px;
    font-family: var(--label);
    font-size: 0.8em;
    letter-spacing: 2px;
    text-transform: uppercase;

    @media (max-width: 768px) {
      margin: 10px 0;
    }
  }

  .tile:hover {
    & .thumb::after {
      opacity: 0.2;
    }

    & .caption::after {
      right: 0;
    }
  }

  @keyframes tile-in {
    from {
      opacity: 0;
      translate: 0 10px;
    }
  }

  /* Diagram / image panel */

  .media-panel {
    border-radius: 12px;
    background: rgb(0 0 0 / 0.12);
    overflow: hidden;

    & img {
      width: 100%;
    }
  }

  /* Contact form */

  .contact-form {
    margin-top: 40px;

    &.is-sent .form-fields {
      display: none;
    }
  }

  .form-choice {
    min-width: 0;
    margin-bottom: 24px;
    padding: 0;
    border: 0;

    & legend {
      margin-bottom: 10px;
      padding: 0;
    }

    & label {
      display: inline-block;
      margin: 0 8px 8px 0;
      cursor: pointer;
    }

    & input {
      position: absolute;
      width: 1px;
      height: 1px;
      opacity: 0;
    }

    & span {
      display: inline-block;
      padding: 8px 16px;
      font-size: 14px;
      font-weight: 400;
      color: var(--ink-soft);
      border: 1px solid rgb(255 255 255 / 0.3);
      border-radius: var(--pill);
      transition:
        background-color 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease;
    }

    & label:hover span {
      border-color: rgb(255 255 255 / 0.7);
    }

    & input:checked + span {
      background: var(--ink);
      border-color: var(--ink);
      color: var(--page);
    }

    & input:focus-visible + span {
      outline: 2px solid var(--ink);
      outline-offset: 2px;
    }
  }

  .form-choice legend,
  .form-field > span {
    display: block;
    font-size: 15px;
    font-weight: 400;
    color: var(--ink-soft);
  }

  .form-field {
    display: block;
    margin-bottom: 20px;

    & > span {
      margin-bottom: 10px;
    }

    & input,
    & textarea {
      display: block;
      width: 100%;
      padding: 12px 14px;
      font-size: 16px;
      background: rgb(0 0 0 / 0.14);
      border: 1px solid transparent;
      border-radius: 8px;
      outline: none;
      transition: border-color 0.2s ease;

      &:focus {
        border-color: rgb(255 255 255 / 0.6);
      }
    }

    & textarea {
      min-height: 120px;
      resize: vertical;
    }
  }

  .form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;

    @media (max-width: 768px) {
      grid-template-columns: minmax(0, 1fr);
      gap: 0;
    }
  }

  .form-trap {
    position: absolute;
    left: -9999px;
  }

  .form-status {
    margin-top: 16px;
    font-size: 16px;
    color: var(--ink-soft);

    &:empty {
      margin: 0;
    }
  }
}

@layer pages {
  /* Home: intro */

  .intro {
    margin-bottom: 70px;

    & h1 {
      margin-top: 20px;
      font-family: var(--serif);
      font-size: clamp(2.1875rem, 1.2rem + 3.6vw, 3.5rem);
      font-weight: 400;
      line-height: 1.1;
      color: var(--ink-faint);
      max-width: 975px;
      text-wrap: balance;
    }

    & h1 a {
      color: var(--ink);
    }

    /* Break after the greeting on wide screens only */
    @media (max-width: 768px) {
      & h1 br {
        display: none;
      }
    }

    @media (max-width: 992px) {
      margin-bottom: 55px;
    }
  }


  /* Home: work */

  .work-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    margin-bottom: 30px;
    padding: 14px 0 4px;
    background: var(--panel);

    & ul {
      display: flex;
      flex-wrap: wrap;
      column-gap: 20px;
      row-gap: 10px;
    }

    & a {
      font-family: var(--label);
      font-size: 11px;
      letter-spacing: 2px;
      text-transform: uppercase;
      opacity: 0.6;
      transition: opacity 0.3s;

      &:hover,
      &:focus-visible {
        opacity: 1;
      }
    }
  }

  .work-group {
    padding-top: 10px;
    scroll-margin-top: 50px;

    & + & {
      margin-top: 30px;
    }
  }

  /* Home: consulting */

  .consulting {
    max-width: 760px;
    margin: 30px 0 60px;
    padding-top: 60px;
    border-top: 1px solid var(--line);

    & p {
      margin-bottom: 14px;
      font-size: 18px;
      color: var(--ink-soft);

      @media (max-width: 768px) {
        font-size: 16px;
      }
    }

    /* Who clients contract with: a plain fact, not branding */
    & .entity {
      font-size: 14px;
      color: var(--ink-muted);
    }
  }

  /* Home: let's connect */

  .connect {
    display: flex;
    align-items: center;
    gap: 24px;
    max-width: 760px;
    padding-top: 50px;
    border-top: 1px solid var(--line);

    & .section-heading {
      margin-bottom: 12px;
    }
  }

  .connect-photo {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    filter: grayscale(1);
  }

  /* Detail pages */

  .page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 12px;
    margin-bottom: 20px;
    font-size: clamp(1.75rem, 1.3rem + 1.4vw, 2.1875rem);
    font-weight: 400;
    line-height: 1.3;

    & a {
      color: var(--breadcrumb);
    }

    & h1 {
      font: inherit;

      &::before {
        content: "/";
        margin-right: 12px;
        color: var(--breadcrumb);
      }
    }
  }

  .page-body {
    max-width: 975px;
    margin-bottom: 70px;

    & > p {
      margin-bottom: 10px;
    }

    & > .media-panel,
    & > figure {
      margin-top: 33px;
    }
  }

  .project {
    max-width: 760px;
    margin-top: 30px;
  }

  .project-logo {
    width: 150px;
    margin-bottom: 24px;

    @media (max-width: 768px) {
      width: 120px;
    }
  }

  .project-meta {
    margin-bottom: 18px;
    font-family: var(--label);
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--ink-muted);
  }

  .project-lede {
    margin-bottom: 22px;
    font-size: 24px;
    line-height: 1.4;

    @media (max-width: 768px) {
      font-size: 20px;
    }
  }

  .project-body p:not(.project-lede) {
    margin-bottom: 18px;
    font-size: 18px;
    color: var(--ink-soft);

    @media (max-width: 768px) {
      font-size: 16px;
    }
  }

  .project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 6px 0 36px;

    & li {
      padding: 5px 12px;
      font-size: 12px;
      font-weight: 400;
      color: rgb(255 255 255 / 0.75);
      border: 1px solid rgb(255 255 255 / 0.2);
      border-radius: var(--pill);
    }
  }

  .project .pill {
    margin-bottom: 40px;
  }

  .slides {
    width: 100%;
    max-width: 595px;
    aspect-ratio: 595 / 485;
    border: 1px solid #ccc;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }

  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}
