@layer reset, global, base, layout, components, motion, utility;

@layer reset {
  *,
  *::before,
  *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  img {
    display: block;
    max-width: 100%;
  }
}

@layer global {
  /* Start — Fonts */
  @font-face {
    font-family: "Rubik";
    src: url("../fonts/Rubik-SemiBold.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
  }
  @font-face {
    font-family: "Rubik";
    src: url("../fonts/Rubik-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
  }
  @font-face {
    font-family: "Google Sans Flex";
    src: url("../fonts/GoogleSansFlex-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
  }
  @font-face {
    font-family: "Google Sans Flex";
    src: url("../fonts/GoogleSansFlex-SemiBold.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
  }
  @font-face {
    font-family: "Roboto Mono";
    src: url("../fonts/RobotoMono-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
  }
  /* End — Fonts */

  /* Start — Type Scale */
  :root {
    /* Font families */
    --font-heading: "Rubik", "Arial", sans-serif;
    --font-mono: "Roboto Mono", monospace;
    --font-body: "Google Sans Flex", "Helvetica Neue", sans-serif;

    /* Font weights */
    --fw-regular: 400;
    --fw-semibold: 600;
    --fw-bold: 700;

    /* Font sizes */
    --fs-nav: 13px;
    --fs-contact: 18px;
    --fs-tag: 24px;
    --fs-h1: 48px;
    --fs-h2: 32px;
    --fs-h3: 24px;
    --fs-h4: 20px;
    --fs-h5: 16px;
    --fs-p: 16px;
  }
  /* End — Type Scale */

  /* Start — Colors */
  :root {
    --color-bg-light: #f2f7ff;
    --color-bg-dark: #0e1b3d; /* hero background */
    --color-primary: #1e5fe0; /* primary accent */
    --color-accent: #5faef5; /* secondary accent */
    --color-accent-hover: #ff6b4a; /* hover accent */
    --color-bg-section: #fcfcfa; /* body background */
    --dot: #ececec; /* dot grid */
    --dot-viewer: #f4f5f6; /* dot grid in pdf viewer */
    --color-body-text: #1a1a1a; /* body text */
    --color-nav-text: #eaebed; /* text on navy/azure */
  }
  /* End — Colors */

  /* Start — Main Rules */
  :root {
    /* Layout — matches main site measurements */
    --max-width: 1440px;
    --pad-x: 120px;
    --pad-y: 60px;
  }

  @media (max-width: 1200px) {
    :root {
      --pad-x: 80px;
    }
  }

  @media (max-width: 992px) {
    :root {
      --pad-x: 48px;
    }
  }

  @media (max-width: 767px) {
    :root {
      --pad-x: 20px;
      --pad-y: 40px;
    }
  }

  .wrapper {
    max-width: var(--max-width);
    margin: auto;
    padding-left: var(--pad-x);
    padding-right: var(--pad-x);
    box-sizing: border-box;
  }

  a {
    color: #7f8590;
    text-decoration: underline;
  }
  a:hover,
  a:focus-visible {
    color: var(--color-accent-hover);
  }

  /* Determines color of cursor highlighted text */
  ::selection {
    background: #5fd3c4;
    color: var(--color-body-text);
  }
  /* End — Base Elements */
  /* End — Main Rules */
}

@layer base {
  /* Start — Base Elements */
  html {
    scroll-behavior: smooth;
  }

  body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--color-body-text);
    background: var(--color-bg-section);
  }

  h1,
  h2,
  h3 {
    line-height: 1.2;
    font-family: var(--font-heading);
  }

  h1 {
    font-weight: var(--fw-bold);
    font-size: var(--fs-h1);
  }

  h2 {
    font-weight: var(--fw-semibold);
    font-size: var(--fs-h2);
    padding-bottom: 15px;
  }

  h3 {
    font-weight: var(--fw-semibold);
    font-size: var(--fs-h3);
  }

  h4 {
    font-weight: var(--fw-semibold);
    font-size: var(--fs-h4);
  }

  /* Start — Paragraph Text */
  .overview__lede,
  .artifacts__lede,
  .impact__lede {
    margin-top: 0.25rem;
    margin-bottom: 0.75rem;
    line-height: 1.5;
  }

  .list__indent {
    padding-left: 50px;
    margin-bottom: 20px;
  }
  /* End — Paragraph Text */

  /* Start — Side note */
  .side-note {
    display: flex;
    align-items: stretch;
    border-radius: 8px;
    overflow: hidden; /* clips the tab's corners to the parent radius */
    margin-block: 1.5rem;
  }

  .side-note__tab {
    flex: 0 0 90px;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 1rem 0.5rem;
    background-color: var(--color-primary);
    color: #ffffff;
    font-weight: 700;
    font-style: normal;
    font-size: 14px;
    text-align: center;
  }

  .side-note__body {
    flex: 1 1 auto;
    padding: 1.25rem 1.5rem;
    background-color: var(--color-bg-light);
    color: var(--color-body-text);
    font-size: 14px;
    line-height: 1.7;
  }

  .side-note__body > :first-child {
    margin-block-start: 0;
  }
  .side-note__body > :last-child {
    margin-block-end: 0;
  }

  .side-note__body a {
    color: var(--color-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
  }

  .side-note__body a:hover,
  .side-note__body a:focus-visible {
    color: var(--color-primary);
  }

  @media (max-width: 767px) {
    .side-note {
      flex-direction: column;
    }
    .side-note__tab {
      flex: 0 0 auto;
      padding: 0.5rem 1rem;
    }
  }
  /* End — Side note */

  /* Start — Highlighting */
  .highlight-yellow {
    background-color: hsl(46, 100%, 65%);
  }

  .highlight-orange {
    background-color: hsl(28, 100%, 72%);
  }

  .highlight-green {
    background-color: hsl(162, 100%, 68%);
  }

  .highlight-pink {
    background-color: hsl(307, 91%, 82%);
  }

  .highlight-purple {
    background-color: hsl(263, 100%, 83%);
  }
  /* End — Highlighting */

  /* Start — Marker highlight */
  .marker-yellow {
    margin: 0 -0.4em;
    padding: 0.1em 0.4em;
    border-radius: 0.8em 0.3em;
    background: transparent;
    background-image: linear-gradient(
      to right,
      hsla(46, 100%, 65%, 0.1),
      hsla(46, 100%, 65%, 0.7) 4%,
      hsla(46, 100%, 65%, 0.3)
    );
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
  .marker-orange {
    margin: 0 -0.4em;
    padding: 0.1em 0.4em;
    border-radius: 0.8em 0.3em;
    background: transparent;
    background-image: linear-gradient(
      to right,
      hsla(28, 100%, 72%, 0.1),
      hsla(28, 100%, 72%, 0.7) 4%,
      hsla(28, 100%, 72%, 0.3)
    );
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
  .marker-green {
    margin: 0 -0.4em;
    padding: 0.1em 0.4em;
    border-radius: 0.8em 0.3em;
    background: transparent;
    background-image: linear-gradient(
      to right,
      hsla(162, 100%, 68%, 0.1),
      hsla(162, 100%, 68%, 0.7) 4%,
      hsla(162, 100%, 68%, 0.3)
    );
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
  .marker-pink {
    margin: 0 -0.4em;
    padding: 0.1em 0.4em;
    border-radius: 0.8em 0.3em;
    background: transparent;
    background-image: linear-gradient(
      to right,
      hsla(307, 91%, 82%, 0.1),
      hsla(307, 91%, 82%, 0.7) 4%,
      hsla(307, 91%, 82%, 0.3)
    );
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
  .marker-purple {
    margin: 0 -0.4em;
    padding: 0.1em 0.4em;
    border-radius: 0.8em 0.3em;
    background: transparent;
    background-image: linear-gradient(
      to right,
      hsla(263, 100%, 83%, 0.1),
      hsla(263, 100%, 83%, 0.7) 4%,
      hsla(263, 100%, 83%, 0.3)
    );
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
  .marker-blue {
    margin: 0 -0.4em;
    padding: 0.1em 0.4em;
    border-radius: 0.8em 0.3em;
    background: transparent;
    background-image: linear-gradient(
      to right,
      hsla(203, 100%, 83%, 0.1),
      hsla(203, 93%, 71%, 0.7) 4%,
      hsla(203, 100%, 83%, 0.3)
    );
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
  /* End — Marker highlight */

  /* Start — On-page images */
  .img-right-v {
    float: right;
    width: 280px;
    max-width: 40%;
    height: auto;
    max-height: 320px;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    margin-left: 32px;
    margin-bottom: 16px;
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(112, 112, 112, 0.25);
  }

  .img-right-h {
    float: right;
    width: 360px;
    max-width: 50%;
    height: auto;
    max-height: 320px;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    margin-left: 32px;
    margin-bottom: 16px;
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(112, 112, 112, 0.25);
  }
  .img-cap-right-v {
    float: right;
    width: 280px;
    max-width: 40%;
    margin-left: 32px;
    margin-bottom: 16px;
  }

  .img-cap-right-v img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 320px;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(112, 112, 112, 0.25);
  }

  .img-cap-right-v figcaption {
    font-style: italic;
    font-size: 14px;
    color: #7f8590;
    text-align: left;
    margin-top: 8px;
  }

  @media (max-width: 767px) {
    .img-right-v,
    .img-right-h {
      float: none;
      width: 100%;
      max-width: 100%;
      margin-left: 0;
      margin-bottom: 20px;
    }

    .img-cap-right-v {
      float: none;
      width: 100%;
      max-width: 100%;
      margin-left: 0;
      margin-bottom: 20px;
    }
  }
  /* End — On-page images */

  /* Start — On-page video */
  .video-on-page {
    width: 100%;
    border-radius: 15px;
  }
  /* End — On-page video */

  @media (max-width: 992px) {
    h1 {
      font-size: 40px;
    }
  }

  @media (max-width: 767px) {
    h1 {
      font-size: 32px;
    }
    h2 {
      font-size: 26px;
    }
  }
}

@layer layout {
  @media (max-width: 767px) {
    .hero {
      padding-bottom: 60px;
    }

    .footer {
      padding-block: 40px;
    }

    .footer__wrapper {
      flex-direction: column;
      align-items: flex-start;
      gap: 24px;
    }
  }

  /* Start — Hero */
  .hero {
    background: var(--color-bg-dark);
    color: var(--color-nav-text);
    padding-block: 60px 80px;
  }
  /* End — Hero */

  /* Start — Page Body */
  .page-body {
    background-color: var(--color-bg-section);
    background-image: radial-gradient(circle, var(--dot) 2px, transparent 2px);
    background-size: 24px 24px;
  }
  /* End — Page Body */

  /* Start — Main Icons */
  .main__icon {
    position: relative;
    z-index: 1;
    color: inherit;
  }

  .main__icon {
    width: 1.25em;
    height: 1.25em;
    flex-shrink: 0;
  }
  /* End — Main Icons */

  /* Start — Section Padding */
  #overview,
  #artifacts {
    padding-block-start: 50px;
    padding-block-end: 50px;
  }
  #impact {
    padding-block-start: 50px;
    padding-block-end: 100px; /* Increased space between the final section and footer. */
  }
  /* End — Section Padding */

  /* Start — Footer */
  .footer {
    background: var(--color-primary);
    color: var(--color-nav-text);
    min-height: 150px;
    padding-block: 30px;
  }

  .footer__wrapper {
    display: flex;
    align-items: flex-start; /* "Return to Top" lines up with line 1 */
    justify-content: space-between;
    gap: 32px;
  }

  .footer__credits p,
  .footer__gototop {
    margin: 0;
    font-family: var(--font-body);
    font-weight: var(--fw-regular);
    font-size: 14px;
    line-height: 1.6;
  }

  .footer a {
    color: var(--color-nav-text);
    text-decoration: underline;
    text-underline-offset: 4px;
  }
  .footer a:focus-visible {
    outline: 2px solid var(--color-nav-text);
    outline-offset: 3px;
    border-radius: 2px;
  }
  /* End — Footer */
}

@layer components {
  /* Start — Heading Accent */
  .heading-accent {
    display: block;
    width: 100px;
    height: 10px;
    margin-bottom: 16px;
    background: linear-gradient(
      180deg,
      var(--color-primary) 0%,
      var(--color-accent) 100%
    );
  }
  /* End — Heading Accent */

  /* Start — Breadcrumb */
  .breadcrumb {
    font-family: var(--font-mono);
    font-size: 13px;
    margin-bottom: 40px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--color-accent);
  }
  .breadcrumb a {
    color: var(--color-nav-text);
    text-underline-offset: 4px;
  }
  .breadcrumb a:hover,
  .breadcrumb a:focus-visible {
    color: var(--color-accent-hover);
  }
  .breadcrumb [aria-current] {
    color: var(--color-accent);
  }
  /* End — Breadcrumb */

  /* Start — Hero Meta (tag + lede) */
  .hero-tag {
    font-family: var(--font-mono);
    font-size: 18px;
    color: var(--color-accent);
    margin-top: 8px;
  }

  .hero__lede {
    margin-top: 20px;
    padding-right: 30%;
    font-size: 18px;
  }
  /* End — Hero Meta */

  /* Start — Card Grid */
  .experience-group {
    margin: 30px 0 0 0;
  }

  .card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 24px;
  }

  .card {
    position: relative;
    display: block;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(112, 112, 112, 0.25);
    transition:
      transform 0.25s ease,
      box-shadow 0.25s ease;
  }

  .card-img-43 {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    transition: filter 0.25s ease;
  }

  .card-img-169 {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    transition: filter 0.25s ease;
  }

  .card-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 16px;
    background: linear-gradient(
      180deg,
      transparent 40%,
      rgba(14, 27, 61, 0.85) 100%
    );
    opacity: 0;
    transition: opacity 0.25s ease;
  }

  .card-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 15px;
    color: #ffffff;
  }

  .card-sub {
    font-family: var(--font-heading);
    font-weight: var(--fw-regular);
    font-size: 13px;
    color: var(--color-nav-text);
    margin-top: 4px;
    transition: color 0.25s ease;
  }

  .card:hover,
  .card:focus-visible {
    transform: scale(1.05);
    box-shadow: 0 10px 24px rgba(14, 27, 61, 0.18);
  }
  .card:hover img,
  .card:focus-visible img {
    filter: grayscale(1);
  }
  .card:hover .card-overlay,
  .card:focus-visible .card-overlay {
    opacity: 1;
  }

  @media (max-width: 767px) {
    .card-grid {
      grid-template-columns: 1fr;
    }

    .viewer {
      width: 100vw;
      height: 100vh;
      border-radius: 0;
    }
    .viewer-pages {
      padding: 12px;
    }
  }
  /* End — Card Grid */

  /* Start — PDF Viewer */
  .viewer {
    margin: auto;
    width: min(94vw, 1100px);
    height: 94vh;
    display: none;
    padding: 0;
    border: none;
    border-radius: 12px;
    overflow: hidden;
    background: var(--color-bg-dark);
    box-shadow: 0 20px 60px rgba(14, 27, 61, 0.45);
  }
  .viewer[open] {
    display: flex;
    flex-direction: column;
  }

  .viewer::backdrop {
    background: rgba(14, 27, 61, 0.72);
  }

  .viewer-titlebar {
    flex: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    background: var(--color-bg-dark);
    color: var(--color-nav-text);
  }

  .viewer-caption {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 18px;
  }

  .viewer-close {
    font-family: var(--font-mono);
    font-size: 16px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-nav-text);
    white-space: nowrap;
  }
  .viewer-close:hover,
  .viewer-close:focus-visible {
    color: var(--color-accent-hover);
  }

  .viewer-pages {
    flex: 1;
    min-height: 0; /* allow scrolling inside flex */
    overflow-y: auto;
    padding: 24px;
    display: grid;
    gap: 20px;
    justify-items: center;
    /* Dot grid inside the viewer, tying it to the page design */
    background-color: var(--color-bg-section);
    background-image: radial-gradient(
      circle,
      var(--dot-viewer) 2px,
      transparent 2px
    );
    background-size: 24px 24px;
  }

  .viewer-pages canvas {
    max-width: 100%;
    box-shadow: 0 4px 16px rgba(14, 27, 61, 0.15);
  }

  .viewer-status {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--color-bg-dark);
    align-self: center;
    padding: 24px 0;
    text-align: center;
  }

  .viewer-hint {
    flex: none;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-nav-text);
    background: var(--color-bg-dark);
    padding: 8px 16px;
  }
  /* End — PDF Viewer */

  /* Start — PDF Embed */
  .pdf-embed {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin-top: 24px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--color-bg-dark);
    box-shadow: 0 2px 8px rgba(112, 112, 112, 0.25);
  }

  .pdf-embed__frame {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .pdf-embed__frame canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
  }

  .pdf-embed__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(14, 27, 61, 0.55);
    color: var(--color-nav-text);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition:
      background 0.2s ease,
      opacity 0.2s ease;
  }
  .pdf-embed__nav--prev {
    left: 12px;
  }
  .pdf-embed__nav--next {
    right: 12px;
  }
  .pdf-embed__nav:hover:not(:disabled),
  .pdf-embed__nav:focus-visible:not(:disabled) {
    background: var(--color-accent-hover);
  }
  .pdf-embed__nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
  }

  .pdf-embed__page {
    position: absolute;
    right: 12px;
    bottom: 10px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-nav-text);
    background: rgba(14, 27, 61, 0.55);
    padding: 2px 8px;
    border-radius: 10px;
  }
  /* End — PDF Embed */
}

@layer motion {
  @media (prefers-reduced-motion: reduce) {
    html {
      scroll-behavior: auto;
    }
    .card,
    .card img,
    .card-overlay {
      transition: none;
    }
    .card:hover,
    .card:focus-visible {
      transform: none;
    }
  }
}

@layer utility {
  .visually-hidden {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    white-space: nowrap;

    &.skip:focus {
      left: 0;
      width: auto;
      height: auto;
      background: var(--color-bg-section);
      padding: 5px;
      border: 1px solid #000;
      color: #000;
    }
  }
}
