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

/**** Reset ****/

@layer reset {

  *,
  *::before,
  *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

  html {
    hanging-punctuation: first allow-end last;
    word-break: break-word;
  }

  body {
    -webkit-font-smoothing: antialiased;
    min-block-size: 100%;
    line-height: 1.5;
  }

  img,
  picture,
  iframe,
  video,
  audio,
  canvas {
    display: block;
    max-inline-size: 100%;
    block-size: auto;
  }

  iframe {
    border: none;
  }

  svg {
    max-inline-size: 100%;
  }

  svg:not([fill]) {
    fill: currentColor;
  }

  p,
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    overflow-wrap: break-word;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    margin-block-start: 0;
  }

  ul,
  ol,
  dl {
    margin: 0;
    padding: 0;
  }

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

  :target {
    scroll-margin: 3rlh;
  }

  :focus-visible {
    outline-offset: 0.2rem;
  }

}


@layer theme {

  /* Light theme variables */

  :root {

    /* Primary color palette */
    --color-primary100: #EAE9FB;
    --color-primary200: #D5D4F7;
    --color-primary300: #C0BEF3;
    --color-primary600: #413CDC;
    --color-primary800: #1F1B98;
    --color-primary900: #16136C;
    --color-primary1000: #040416;

    /* Background colors */
    --color-light100: #FFFCFA;
    --color-light200: #FEF6F2;
    --color-light300: #F6ECE7;

    /* Greys palette */
    --color-grey100: #F1F2F6;
    --color-grey200: #E0E2EB;
    --color-grey300: #C1C5D7;
    --color-grey400: #A2A9C3;
    --color-grey600: #646F9B;
    --color-grey900: #282C3E;

    /* Semantic tokens — components reference these roles, not raw palette colors.
       Dark mode repoints the same roles below. */
    --color-background: var(--color-light100);
    --color-surface: var(--color-light100);
    --color-text: var(--color-primary1000);
    --color-text-muted: var(--color-grey600);
    --color-link: var(--color-primary600);
    --color-link-hover: var(--color-primary900);
    --color-link-current: var(--color-primary900);
    --color-border: var(--color-primary300);
    --color-border-subtle: var(--color-grey200);
    --color-focus: var(--color-primary600);
    --color-shadow: rgb(40 44 62 / 0.09);
    --color-icon-button-bg: var(--color-grey100);
    --color-icon-button-bg-hover: var(--color-primary100);
    --color-icon-button-outline: var(--color-primary600);
    --color-thumb-border-hover: var(--color-primary300);
    --color-thumb-border-active: var(--color-primary600);
    --color-button-bg: var(--color-background);
    --color-button-accent: var(--color-primary600);
    --color-button-bg-hover: var(--color-primary100);
    --color-button-text-hover: var(--color-primary900);
    --color-button-accent-hover: var(--color-primary900);

    /* Space variables (spacing scale based on 4px increments) */
    --space-1: 0.25rem;  /* 4px */
    --space-2: 0.5rem;   /* 8px */
    --space-3: 0.75rem;  /* 12px */
    --space-4: 1rem;     /* 16px */
    --space-5: 1.25rem;  /* 20px */
    --space-6: 1.5rem;   /* 24px */
    --space-8: 2rem;     /* 32px */
    --space-10: 2.5rem;  /* 40px */
    --space-12: 3rem;    /* 48px */
    --space-16: 4rem;    /* 64px */
    --space-18: 4.5rem;  /* 72px */
    --space-20: 5rem;    /* 80px */
    --space-25: 6.25rem; /* 100px */
    --space-30: 7.5rem;  /* 120px */

    /* Font size variables (based on a 16px base font size) */
    --font-size-12: 0.75rem;  /* 12px */
    --font-size-14: 0.875rem; /* 14px */
    --font-size-base: 1rem;   /* 16px */
    --font-size-20: 1.25rem;  /* 20px */
    --font-size-24: 1.5rem;   /* 24px */
    --font-size-28: 1.75rem;  /* 28px */
    --font-size-32: 2rem;     /* 32px */
    --font-size-40: 2.5rem; /* 40px */
    --font-size-50: 3.125rem; /* 50px */
    --font-size-64: 4rem;     /* 64px */
    --font-size-72: 4.5rem;   /* 72px */

    /* Line height — always unitless so the ratio inherits, not a computed px value */
    --leading-none: 1;
    --leading-tight: 1.1;
    --leading-snug: 1.3;
    --leading-normal: 1.5;
    --leading-relaxed: 1.6;

    /* Weight */
    --weight-light: 300;
    --weight-regular: 400;
    --weight-medium: 600;
    --weight-bold: 700;
    --weight-black: 900;
  }

  /* Dark theme variables */
  :root[data-theme="dark"] {
    --color-background: #090911;
    --color-surface: #131839;
    --color-text: #FFFCFA;
    --color-text-muted: var(--color-grey400);
    --color-link: #5C6CD6;
    --color-link-hover: #9693EC;
    --color-link-current: #9693EC;
    --color-border: #5C6CD6;
    --color-border-subtle: #282C3E;
    --color-focus: #9693EC;
    --color-shadow: rgb(0 0 0 / 0.4);
    --color-icon-button-bg: #5C6CD6;
    --color-icon-button-bg-hover: #9693EC;
    --color-icon-button-outline: #FFFCFA;
    --color-thumb-border-hover: #5C6CD6;
    --color-thumb-border-active: #9693EC;
    --color-button-bg: var(--color-background);
    --color-button-accent: #5C6CD6;
    --color-button-bg-hover: #131839;
    --color-button-text-hover: #FFFCFA;
    --color-button-accent-hover: #9693EC;
  }

  /* Magenta palette variables */
  :root[data-palette="magenta"] {
    --color-primary100: #FFE5FB;
    --color-primary200: #FFCCF7;
    --color-primary300: #FFB2F3;
    --color-primary600: #CC00AD;
    --color-primary800: #660056;
    --color-primary900: #4D0041;
    --color-primary1000: #1A0016;
  }

  /* Dark + magenta — accent tokens re-tinted for magenta on dark backgrounds.
   Inherits everything else from the dark theme block above. */
  :root[data-theme="dark"][data-palette="magenta"] {
    --color-background: #160413;
    --color-surface: #410B39;
    --color-link: #F885E6;
    --color-link-hover: #FFB2F3;
    --color-link-current: #FFB2F3;
    --color-border: #F885E6;
    --color-focus: #FFB2F3;
    --color-icon-button-bg: #E34FCD;
    --color-icon-button-bg-hover: #FFB2F3;
    --color-icon-button-outline: #FFFCFA;
    --color-thumb-border-hover: #F885E6;
    --color-thumb-border-active: #FFB2F3;
    --color-button-accent: #F885E6;
    --color-button-bg-hover: #410B39;
    --color-button-text-hover: #FFFCFA;
    --color-button-accent-hover: #FFB2F3;
}

}

/**** Base styles ****/

@layer base {

  html {
    font-size: 16px;
    scroll-behavior: smooth;
  }

  body {
    background-color: var(--color-background);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-weight: 400;
    font-style: normal;
    color: var(--color-text);
  }

  a {
    font-weight: 600;
    font-style: normal;
    text-decoration: underline;
    text-decoration-thickness: 0.08rem;
    text-underline-offset: 3px;
    text-decoration-skip-ink: none;
    color: var(--color-link);
    transition: color 0.08s ease-out, text-decoration-thickness 0.08s ease-out;
  }

  a:hover {
    color: var(--color-link-hover);
    text-decoration-thickness: 0.1rem;
  }

  a:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 3px;
    text-decoration: none;
  }

  /*   a:visited {
    color: var(--color-primary800);
  } */

  h1,
  h2 {
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-style: normal;
  }

  h1 {
    font-weight: 900;
  }

  strong {
    font-weight: 600;
  }

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

}

/**** Layout ****/

@layer layout {

  /**** Shared layout ****/

  /* Sticky footer */
  body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
  }

  .site-wrapper {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  .site-wrapper>main {
    flex: 1;
    width: 100%;
  }

  /* Creating a grid with 12 columns */
  .grid-layout {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--space-4);
    align-items: start;
  }

  .main-content {
    grid-column: 1 / 9;
  }

  .sidebar {
    grid-column: 9 / 13;
  }

  .site-wrapper {
    max-width: 1280px;
    margin-inline: auto;
    margin-block-start: var(--space-16);
    padding-inline: var(--space-10);
  }

  /**** Typography scale (desktop) ****/

  .hero h1 {
    font-size: var(--font-size-72);
    line-height: var(--leading-none);
    font-weight: var(--weight-black);
  }

  .project-detail-title,
  .note-detail-title {
    font-size: var(--font-size-64);
    line-height: var(--leading-tight);
    font-weight: var(--weight-black);
  }

  main .projects .section-title,
  .tag-page h1,
  .design-notes h1,
  .page-content h1 {
    font-size: var(--font-size-50);
    line-height: var(--leading-tight);
    font-weight: var(--weight-black);
  }

  .hero .lede {
    font-size: var(--font-size-32);
    line-height: var(--leading-snug);
    font-weight: var(--weight-bold);
  }

  .content-layout h2 {
    font-size: var(--font-size-32);
    line-height: var(--leading-snug);
    font-weight: var(--weight-medium);
  }

  .projects .project-card-title,
  .projects .tag-card-title {
    font-size: var(--font-size-28);
    line-height: var(--leading-snug);
    font-weight: var(--weight-medium);
  }

  .content-layout h3,
  .projects .project-card-subtitle,
  .projects .tag-card-subtitle,
  .at-a-glance #glance-heading {
    font-size: var(--font-size-20);
    line-height: var(--leading-normal);
    font-weight: var(--weight-medium);
  }

  .content-layout p,
  .content-layout > ol,
  .content-layout > ul,
  .hero .intro-text,
  .projects .project-card-blurb,
  .design-notes .note-card p {
    font-size: var(--font-size-20);
    line-height: var(--leading-relaxed);
    font-weight: var(--weight-regular);
  }

  .projects .project-card-meta,
  .project-detail-meta,
  .project-tags {
    font-size: var(--font-size-base);
    line-height: var(--leading-normal);
    font-weight: var(--weight-regular);
  }

  .at-a-glance__row dt {
    font-size: var(--font-size-base);
    line-height: var(--leading-normal);
    font-weight: var(--weight-medium);
  }

  .at-a-glance__row dd {
    font-size: var(--font-size-base);
    line-height: var(--leading-relaxed);
    font-weight: var(--weight-regular);
  }

  .content-figure figcaption {
    font-size: var(--font-size-14);
    line-height: var(--leading-relaxed);
    font-weight: var(--weight-regular);
  }

  .content-layout .section-eyebrow {
    font-size: var(--font-size-base);
    line-height: var(--leading-normal);
    font-weight: var(--weight-medium);
  }

  .note-detail-meta .note-detail-description {
    font-size: var(--font-size-24);
    line-height: var(--leading-normal);
    font-weight: var(--weight-regular);
  }

  .note-card-meta {
    font-size: var(--font-size-base);
    line-height: var(--leading-normal);
    font-weight: var(--weight-regular);
  }

  .projects .keep-reading,
  .back-link,
  .project-index .back-to-top,
  .project-index h3,
  .project-index ul {
    font-size: var(--font-size-14);
    line-height: var(--leading-normal);
    font-weight: var(--weight-medium);
  }

  .back-link,
  .keep-reading,
  .back-to-top {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
  }

  .content-layout blockquote {
    font-size: var(--font-size-32);
    line-height: var(--leading-normal);
    font-weight: var(--weight-light);
  }

  /**** Header and navigation ****/

  .page-header {
    display: flex;
    position: sticky;
    top: 0;
    height: 90px;
    z-index: 100;
    background-color: var(--color-background);
    font-size: var(--font-size-14);
    border-block-end: 1px solid transparent;
    transition: border-color 0.2s, box-shadow 0.2s;
  }

  .page-header.is-scrolled {
    border-block-end-color: var(--color-border-subtle);
    box-shadow: 0 2px 4px var(--color-shadow);
  }

  .main-navigation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1280px;
    width: 100%;
    margin-inline: auto;
    padding-inline: var(--space-10);
  }

  .navigation-logo .vm-logo {
    display: flex;
    align-items: center;
    gap: var(--space-5);
  }

  .navigation-logo .vm-logo svg {
    width: 50px;
    height: 50px;
  }

  .vm-logo[aria-current="page"] {
    text-decoration: none;
  }

  .vm-logo[aria-current="page"] .logo-label {
    text-decoration: underline;
    text-decoration-thickness: 0.14rem;
    text-underline-offset: 3px;
    color: var(--color-link-current);
    font-weight: 700;
  }

  .navigation-menu {
    display: flex;
    align-items: center;
    gap: var(--space-5);
  }

  .navigation-links {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    list-style: none;
    margin: 0;
    margin-inline-end: var(--space-4);
    padding: 0;
  }

  /* Adding decorative dot between nav links */
  .navigation-links li+li::before {
    content: "•" / "";
    margin-inline-end: var(--space-4);
    color: var(--color-link);
    font-weight: 900;
    user-select: none;
  }

  .navigation-links a[aria-current="page"] {
    color: var(--color-link-current);
    font-weight: 700;
    text-decoration-thickness: 0.14rem;
  }

  /* Mobile nav is only visible below 640px */
  .mobile-nav {
    display: none;
  }

  /**** Footer ****/

  footer {
    width: 100%;
    font-size: var(--font-size-14);
    color: var(--color-text-muted);
    text-align: center;
    margin-block-start: var(--space-8);
    margin-block-end: var(--space-8);
    border-block-start: 1px solid var(--color-border);
    padding-block-start: var(--space-8);
  }

  /**** Home: hero ****/

  .hero {
    margin-block-end: var(--space-18);
  }

  .hero h1 {
    margin-block-end: var(--space-4);
  }

  .hero .lede {
    margin-block-end: var(--space-10);
  }

  .hero .intro-text {
    margin-block-end: var(--space-4);
  }

  /**** Home: sidebar icons ****/

  .sidebar-icons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
    padding-inline: var(--space-5);
  }

  /**** Home: project cards ****/

  main .projects .section-title {
    margin-block-end: var(--space-18);
    border-block-start: 1px solid var(--color-border);
    padding-block-start: var(--space-16);
  }

  .project-card {
    margin-block-end: var(--space-25);
  }

  /* Vertical rhythm: every direct child gets space above it, except the first.
     Specific pairs override this below. */
  .project-card-content > * + * {
    margin-block-start: var(--space-2);
  }

  /* Subtitle sits close under the title; the blurb needs more room above it */
  .project-card-content > .project-card-subtitle + .project-card-blurb {
    margin-block-start: var(--space-4);
  }

  /* Blurb to whichever comes next (keep-reading, or straight to the gallery) */
  .project-card-content > .project-card-blurb + .keep-reading,
  .project-card-content > .project-card-blurb + .project-card-gallery {
    margin-block-start: var(--space-4);
  }

  /* Keep-reading needs more breathing room before the gallery */
  .project-card-content > .keep-reading + .project-card-gallery {
    margin-block-start: var(--space-8);
  }

  /* Gallery to tags — stacked selector outranks both the base rule above
     and the shared .project-tags margin rule, regardless of source order */
  .project-card-content > .project-card-gallery + .project-tags {
    margin-block-start: var(--space-8);
  }

  .projects .project-card-meta time::after {
    content: " • ";
  }

  .projects .project-card-blurb > p + p {
    margin-block-start: var(--space-4);
  }

  /**** Home: gallery ****/

  .gallery-main img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: var(--space-2);
  }

  .gallery-thumbs {
    display: flex;
    gap: var(--space-2);
    margin-block-start: var(--space-2);
    list-style: none;
  }

  .gallery-thumbs li {
    flex: 0 0 calc((100% - 3 * var(--space-2)) / 4);
    border-radius: var(--space-2);
  }

  .gallery-thumbs img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: var(--space-2);
    display: block;
  }

  /**** Home: projects index sidebar ****/

  .project-index {
    position: sticky;
    top: calc(100px + var(--space-6));
    margin-inline-start: var(--space-30);
  }

  .project-index h3 {
    margin-block-end: var(--space-2);
  }

  .project-index ul {
    list-style: none;
  }

  .project-index ul li:not(:last-child) {
    margin-block-end: var(--space-3);
  }

  /* Styling the back-to-top button */
  .project-index .back-to-top {
    margin-block-start: var(--space-6);
  }

  /**** Shared: content layout (project detail, note detail, static pages) ****/

  .content-layout .section-eyebrow {
    color: var(--color-text-muted);
  }

  .content-layout blockquote {
    padding-inline-start: var(--space-6);
    border-inline-start: 4px solid var(--color-border);
  }

  /* Detail pages and static pages (About, Contact, Other Projects) are
     their own 12-column grid: text sits in a centered 8-column measure,
     figures break out to the full container width */
  .content-layout {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    column-gap: var(--space-4);
    margin-block-end: var(--space-30);
  }

  .content-layout > * {
    grid-column: 3 / 11;
  }

  /* Vertical rhythm: every direct child gets space above it, except the first.
     Specific pairs override this below. */
  .content-layout > * + * {
    margin-block-start: var(--space-6);
  }

  /* Headings sit close to the text they introduce */
  .content-layout > h2 { margin-block-start: var(--space-12); }
  .content-layout > h3 { margin-block-start: var(--space-8); }
  .content-layout > h2 + *,
  .content-layout > h3 + * { margin-block-start: var(--space-2); }

  /* An eyebrow belongs to the heading that follows it */
  .content-layout > .section-eyebrow { margin-block-start: var(--space-16); }
  .content-layout > .section-eyebrow + h2 { margin-block-start: var(--space-1); }
  .content-layout > .section-eyebrow + h2 + h3 { margin-block-start: var(--space-4); }

  /* At-a-glance top margin */
  .content-layout > .at-a-glance { margin-block-start: var(--space-10); }

  /* Consecutive figures group more tightly than figure-to-text */
  .content-layout > .content-figure { margin-block-start: var(--space-10); }
  .content-layout > .content-figure + .content-figure { margin-block-start: var(--space-8); }
  .content-layout > .content-figure + * { margin-block-start: var(--space-10); }

  /* Paragraphs within a run sit closer than block-level changes */
  .content-layout > p + p { margin-block-start: var(--space-4); }

  .content-layout > .content-figure {
    grid-column: 1 / -1;
  }

  .content-layout > .tag-page {
    grid-column: 1 / -1;
  }

  .content-layout > ol,
  .content-layout > ul {
    padding-inline-start: var(--space-10);
  }

  .content-layout ol li:not(:last-child),
  .content-layout ul li:not(:last-child) {
    margin-block-end: var(--space-2);
  }

  .content-figure img {
    width: 100%;
    height: auto;
    border-radius: var(--space-2);
  }

  .content-figure figcaption {
    margin-block-start: var(--space-4);
    color: var(--color-text-muted);
    text-align: center;
    text-wrap: balance;
  }

  /**** Project detail: banner and header ****/

  /* Project detail opening image banner */

  .project-banner {
    width: 100%;
    background: var(--banner-color, var(--color-surface));
  }

  .project-banner img {
    display: block;
    max-width: 1280px;
    margin-inline: auto;
    width: 100%;
    height: auto;
  }

  .project-detail-header {
    background: var(--color-background);
    margin-block-start: calc(var(--space-16) * -1 - 100px);
    outline: var(--space-10) solid var(--color-background);
    grid-column: 3 / 11;
  }

  .project-detail-title,
  .note-detail-title {
    margin-block-end: var(--space-6);
  }

  .project-detail-meta time::after {
    content: " • ";
  }

  /*** At a glance section on project detail ***/

  .at-a-glance {
    border-inline-start: 4px solid var(--color-border);
    padding-inline-start: var(--space-6);
  }

  /* Creating space between the heading and the list of details. */
  .at-a-glance dl {
    margin-block-start: var(--space-4);
  }
  
  /* Spacing the rows */
  .at-a-glance__row {
    margin-block-end: var(--space-1);
  }

  .at-a-glance__row dt,
  .at-a-glance__row dd {
    display: inline;
    margin: 0;
  }

  .at-a-glance__row dt::after {
    content: " ";
  }

  /**** Note detail specific styles ****/

  .note-detail-meta time {
    display: block;
    margin-block-end: var(--space-12);
  }

  .note-detail-meta .note-detail-description {
    margin-block-end: var(--space-12);
  }

  /**** Design notes index ****/

  .design-notes .note-card h2 {
    margin-block-end: var(--space-2);
  }

  .note-card {
    margin-block-end: var(--space-12);
  }

  .note-card:last-of-type {
    margin-block-end: var(--space-16);
  }

  .note-card-meta {
    margin-block-end: var(--space-2)
  }

  .design-notes h1 {
    margin-block-end: var(--space-6);
  }

  .design-notes .note-card p {
    margin-block-end: var(--space-4);
  }

  /**** Project tags (shared: home cards and detail pages) ****/

  .project-tags {
    list-style: none;
  }

  .content-layout > .project-tags {
    margin-block-start: var(--space-12);
  }

  .project-tags ul,
  .project-tags li {
    display: inline-block;
  }

  .project-tags li a {
    text-transform: lowercase;
  }

  .project-tags li:not(:last-child){
    margin-inline-end: var(--space-3);
  }

  .project-tags li a::before {
    content: "#";
  }

  /*** Tag page ***/

  .tag-card {
    position: relative;
    display: grid;
    grid-template-columns: 4fr 8fr;
    gap: var(--space-6);
    align-items: start;
  }
  
  .tag-page > h1 + .tag-card {
    margin-block-start: var(--space-12);
  }

  .tag-card-content {
    padding-inline-start: var(--space-6);
    padding-inline-end: var(--space-6);
  }
  
  .tag-card-content > * + * {
    margin-block-start: var(--space-2);
  }
  
  .tag-card + .tag-card {
    margin-block-start: var(--space-12);
  }

  .content-layout > .tag-card-title {
    font-size: var(--font-size-28);
    line-height: var(--leading-snug);
    font-weight: var(--weight-medium);
  }

  .tag-card-subtitle {
    font-size: var(--font-size-20);
    line-height: var(--leading-normal);
    font-weight: var(--weight-medium);
  }

  .tag-card-media img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: var(--space-2);
    border: 2px solid transparent;
    transition: border-color 0.08s ease-out;
  }

  .tag-card:hover .tag-card-media img {
    border-color: var(--color-link);
  }

  /* One link, whole card clickable */
  .tag-card-title a::after {
    content: "";
    position: absolute;
    inset: 0;
  }

  .tag-card-blurb {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .content-layout > .back-link,
  .tag-page > .back-link {
    margin-block-start: var(--space-12);
  }

  /* On content-layout pages the button is a grid element, so we need to override the default justify-self: center to align it to the left */
  .content-layout > .back-link {
    justify-self: start;
  }

  /**** Media queries ****/

  /**** Tablet and phones adjustments ****/

  @media (max-width: 1024px) {

    .site-wrapper {
      margin-block-start: var(--space-8);
      padding-inline: var(--space-10);
    }

    .grid-layout {
      grid-template-columns: 1fr;
    }

    .main-content,
    .content-layout > * {
      grid-column: 1 / -1;
    }

    /**** Homepage adjustments ****/

    .hero .lede {
      margin-block-end: var(--space-6);
    }
    
    .hero,
    .projects {
      padding-inline: 0;
    }
    
    .sidebar {
      grid-column: 1 / -1;
      order: -1;
      margin-block-end: var(--space-8);
    }
    
    .sidebar-icons {
      grid-template-columns: repeat(4, 1fr);
      max-width: 480px;
      padding-inline: 0;
    }
    
    /* Hiding the Projects index sidebar */
    .project-index {
      display: none;
    }

    /**** Project detail page adjustments ****/

    /* Detail-page text drops the centered measure and goes full width */
    .project-detail > *,
    .note-detail > * {
      grid-column: 1 / -1;
    }

    /* Shrinking the outline on the project detail header so it doesn't get cut off */
    .project-detail-header {
      outline: var(--space-6) solid var(--color-background)
    }

    /* Reducing the spacing above the eyebrow on project detail and note detail pages */
    .content-layout > .section-eyebrow { margin-block-start: var(--space-10);
    }

    /* Tag page adjustments: the tag cards are stacked vertically, and the spacing between them is reduced. */
    .tag-card {
      grid-template-columns: 1fr;
      gap: var(--space-4);
    }

    .tag-card-content {
      padding-inline: 0;
    }

    .content-layout > .back-link,
    .tag-page .back-link {
      display: inline-flex;
      justify-content: center;
      justify-self: stretch;
    }

  @media (max-width: 840px) {

    /**** Typography scale (mobile) ****/

    .hero h1 {
      font-size: var(--font-size-64);
    }

    .project-detail-title,
    .note-detail-title {
      font-size: var(--font-size-40);
    }

    main .projects .section-title,
    .page-content h1,
    .tag-page h1,
    .design-notes h1 {
      font-size: var(--font-size-40);
    }

    .hero .lede {
      font-size: var(--font-size-20);
      line-height: var(--leading-relaxed);
    }

    .projects .keep-reading,
    .back-link {
      font-size: var(--font-size-base);
      line-height: var(--leading-normal);
      font-weight: var(--weight-medium);
    }

    .content-layout h2 {
      font-size: var(--font-size-28);
      line-height: var(--leading-snug);
      font-weight: var(--weight-medium);
    }

    .content-figure figcaption {
      text-align: left;
      text-wrap: auto;
    }

    .content-figure figcaption {
      font-size: var(--font-size-base);
    }

    .content-layout blockquote {
      font-size: var(--font-size-24);
    }

    .note-detail-meta .note-detail-description {
      font-size: var(--font-size-20);
    }

    .main-navigation {
      padding-inline: var(--space-5);
    }

    .navigation-menu,
    .navigation-logo .logo-label {
      display: none;
    }

    .mobile-nav {
      display: block;
      font-size: initial;
    }

    .mobile-nav summary {
      list-style: none;
      cursor: pointer;
    }

    /* Safari marker removal */
    .mobile-nav summary::-webkit-details-marker {
      display: none;
    }

    /***  Mobile menu styling: the panel that drops down when the hamburger menu is clicked. ***/

    .mobile-menu-panel {
      position: absolute;
      top: 90px;
      left: 0;
      right: 0;
      background-color: var(--color-surface);
      border-block-end: 1px solid var(--color-border-subtle);
      box-shadow: 0 4px 8px var(--color-shadow);
      padding: var(--space-6) var(--space-10);
    }

    .mobile-menu-panel .navigation-links {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: var(--space-4);
      list-style: none;
      margin: 0;
      padding: 0;
      font-size: var(--font-size-24);
    }

    .navigation-links li {
      margin: var(--space-3) 0;
    }

    .navigation-links li+li::before {
      display: none;
    }

    /* Homepage spacing adjustments */

    .hero {
      margin-block-end: var(--space-10);
    }
    
    .hero h1,
    .hero .lede {
      margin-block-end: var(--space-5);
    }

    main .projects .section-title {
      margin-block-end: var(--space-10);
      padding-block-start: var(--space-10);
    }

    .project-card {
      margin-block-end: var(--space-16);
    }

    .project-card-content > .project-card-subtitle + .project-card-blurb,
    .project-card-content > .project-card-gallery + .project-tags{
      margin-block-start: var(--space-4);
    }

    .projects .project-card-blurb > p + p {
      margin-block-start: var(--space-2);
    }

    /*** Project detail and note detail spacing adjustments ***/
    
    /* Spacing adjustments for rhythm */  
    .content-layout > * + * { margin-block-start: var(--space-4); }
    .content-layout > h2 { margin-block-start: var(--space-8); }
    .content-layout > h3 { margin-block-start: var(--space-6); }
    .content-layout > .at-a-glance { margin-block-start: var(--space-8); }
    .content-layout > .content-figure { margin-block-start: var(--space-6); }
    .content-layout > .content-figure + * { margin-block-start: var(--space-6); }
    
    /* Adjusting spacing after heading on at-a-glance section */
    .at-a-glance dl {
      margin-block-start: var(--space-2);
    }
    
    .content-layout > .section-eyebrow {
      margin-block-start: var(--space-8);
    }
    
    .note-detail-meta time {
      margin-block-end: var(--space-8);
    }
    
    .note-detail-meta .note-detail-description {
      margin-block-end: var(--space-8);
    }
    
    .project-detail-header {
      margin-block-start: 0;
      padding-inline: 0;
    }
    
    /*** Footer adjustments ***/

    footer {
      padding-inline-start: var(--space-6);
      padding-inline-end: var(--space-6);
    }

  }

  @media (max-width: 640px) {
    .site-wrapper {
      padding-inline: var(--space-5);
      margin-block-start: var(--space-5);
    }

    .main-content {
      grid-column: 1 / -1;
      /* full width, -1 means last line */
    }

    main .projects .section-title {
      margin-block-end: var(--space-8);
    }

    .sidebar {
      margin-block-end: var(--space-5);
    }
    
    .sidebar-icons {
      max-width: 100%;
      gap: var(--space-2);
    }

    .gallery-thumbs {
      flex-wrap: wrap;
    }

    /*** Gallery thumbs for preview get arranged in 2 columns ****/
    .gallery-thumbs li {
      flex: 0 0 calc((100% - var(--space-2)) / 2);
    }

  }

}

/**** Components ****/

@layer components {

  .primary-button {
    border-radius: 8px;
    border: 1px solid var(--color-button-accent);
    padding: var(--space-2) var(--space-4);
    font-weight: 600;
    font-style: normal;
    text-decoration: none;
    background: var(--color-button-bg);
    color: var(--color-button-accent);
    box-shadow: 4px 4px 0 0 var(--color-button-accent);
    transition: box-shadow 0.08s ease-out, background-color 0.08s ease-out, border-color 0.08s ease-out, color 0.08s ease-out;
    cursor: pointer;
  }

  .primary-button:hover {
    border: 1px solid var(--color-button-accent-hover);
    background: var(--color-button-bg-hover);
    color: var(--color-button-text-hover);
    box-shadow: 4px 4px 0 0 var(--color-button-accent-hover);
  }

  .primary-button:active {
    border: 1px solid var(--color-button-accent-hover);
    background: var(--color-button-bg-hover);
    box-shadow: 2px 2px 0 0 var(--color-button-accent-hover);
    color: var(--color-button-text-hover);
  }

  .primary-button:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 3px;
  }

  .icon-button {
    aspect-ratio: 1;
    width: 100%;
    background: var(--color-icon-button-bg);
    border: none;
    border-radius: var(--space-5);
    cursor: pointer;
    outline: 2px solid transparent;
    transition: background-color 0.08s ease-out, outline 0.08s ease-out;
  }

  .icon-button:hover {
    background: var(--color-icon-button-bg-hover);
    outline-color: var(--color-icon-button-outline);
  }

  .icon-button:focus-visible {
    outline: 2px solid var(--color-focus);
    background: var(--color-icon-button-bg-hover);
  }

  .icon-button img {
    width: 100%;
    height: auto;
  }

  .icon-button {
    position: relative;
  }

  .icon-button::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + var(--space-2));
    left: 50%;
    translate: -50% 0;
    padding: var(--space-1) var(--space-2);
    background: var(--color-text);
    color: var(--color-background);
    font-size: var(--font-size-12);
    white-space: nowrap;
    border-radius: var(--space-1);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease-out;
  }

  .icon-button:hover::after,
  .icon-button:focus-visible::after {
    opacity: 1;
  }

  @media (max-width: 1024px) {
    .icon-button::after {
      content: none;
    }
  }

  .thumb-button {
    display: block;
    width: 100%;
    padding: 0;
    border: 2px solid transparent;
    border-radius: calc(var(--space-2) + 2px);
    background: none;
    cursor: pointer;
    transition: border-color 0.08s ease-out;
  }

  .thumb-button:hover {
    border-color: var(--color-thumb-border-hover);
  }

  .thumb-button.is-active {
    border-color: var(--color-thumb-border-active);
  }

  .thumb-button:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
  }

  /* Custom cursors — opt-in via the mouse icon button.
     Layered last so the custom cursor always wins over the plain
     `cursor: pointer` set on interactive elements in @layer layout. */

  :root[data-cursor="custom"],
  :root[data-cursor="custom"] * {
    cursor: url("/assets/cursors/pixel-cursor.png") 16 0, auto;
    cursor: -webkit-image-set(
      url("/assets/cursors/pixel-cursor.png") 1x,
      url("/assets/cursors/pixel-cursor_2x.png") 2x
    ) 16 0, auto;
    cursor: image-set(
      url("/assets/cursors/pixel-cursor.png") 1x,
      url("/assets/cursors/pixel-cursor_2x.png") 2x
    ) 16 0, auto;
  }

  /* Interactive elements keep a distinct pointer so affordance isn't lost */
  :root[data-cursor="custom"] a,
  :root[data-cursor="custom"] button,
  :root[data-cursor="custom"] summary,
  :root[data-cursor="custom"] [role="button"] {
    cursor: url("/assets/cursors/pixel-pointer.png") 16 16, pointer;
    cursor: -webkit-image-set(
      url("/assets/cursors/pixel-pointer.png") 1x,
      url("/assets/cursors/pixel-pointer_2x.png") 2x
    ) 16 16, pointer;
    cursor: image-set(
      url("/assets/cursors/pixel-pointer.png") 1x,
      url("/assets/cursors/pixel-pointer_2x.png") 2x
    ) 16 16, pointer;
  }

}
