/* ============================================================
   TYPOGRAPHY + REFINEMENT (branch: typography)
   Loaded after styles.css. One grotesk (Inter Tight) for everything; titles large,
   regular weight, slightly tight, sentence case; body regular and high
   contrast; labels very small, regular, muted. Nothing here touches the
   canvas, the cosmos or the layout of the shapes.
   ============================================================ */

:root {
  --font-ui: 'Inter Tight', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-primary: var(--font-ui);
  --font-system: var(--font-ui);

  --title-tracking: -0.025em;
  --title-weight: 400;
  --label-size: 0.75rem;
  --label-color: rgba(255, 255, 255, 0.5);
  --label-color-light: rgba(0, 0, 0, 0.5);
  --body-color: rgba(255, 255, 255, 0.9);
  --body-color-light: rgba(0, 0, 0, 0.88);

  --card-radius: 14px;
  --card-border: rgba(255, 255, 255, 0.14);
}

body {
  font-family: var(--font-ui);
  font-feature-settings: 'ss01' 0;
}

/* ---------- Sentence case everywhere: no capitals, no wide tracking ---------- */
.nav-logo,
.systems-heading,
.system-name,
.system-explore,
.end-links a,
.about-links a,
.system-page-title,
.system-projects-heading,
.project-card-title,
.project-section-label,
.project-page-title,
.project-section h3,
.project-meta,
.project-link-button,
.project-badge,
.process-label,
.systems-page-heading,
.system-card-title,
.selected-heading,
.contact-heading {
  text-transform: none;
  letter-spacing: 0;
}

/* ---------- Labels: very small, regular, muted, in parentheses ---------- */
.nav-links a,
.systems-heading,
.system-projects-heading,
.contact-heading,
.project-section h3,
.project-section-label,
.project-page-meta {
  font-family: var(--font-ui);
  font-size: var(--label-size);
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: var(--label-color);
}

.nav-links a::before,
.systems-heading::before,
.system-projects-heading::before,
.contact-heading::before,
.project-section h3::before,
.project-section-label::before {
  content: '(';
}

.nav-links a::after,
.systems-heading::after,
.system-projects-heading::after,
.contact-heading::after,
.project-section h3::after,
.project-section-label::after {
  content: ')';
}

/* ---------- Nav ---------- */
.nav-logo {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.nav-links {
  gap: 1.5rem;
}

.nav-links a {
  opacity: 1;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8125rem;
  transition: color 0.3s ease;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: rgba(255, 255, 255, 1);
}

body.cosmos-light .nav-links a {
  color: rgba(0, 0, 0, 0.55);
}

body.cosmos-light .nav-links a:hover {
  color: #111;
}

#entry-text {
  font-size: 0.875rem;
  letter-spacing: 0.01em;
}

/* ---------- Titles: large, regular, slightly tight ---------- */
.project-page-title,
.system-page-title,
.systems-page-heading,
.selected-heading {
  font-weight: var(--title-weight);
  letter-spacing: var(--title-tracking);
  line-height: 1.05;
}

.project-page-title {
  font-size: clamp(2.25rem, 1.4rem + 3vw, 3.75rem);
  margin-bottom: 1.25rem;
}

.system-page-title {
  font-size: clamp(2.25rem, 1.4rem + 3vw, 3.75rem);
}

.systems-page-heading {
  font-size: clamp(3rem, 2rem + 4vw, 5.5rem);
  letter-spacing: -0.04em;
}

.selected-heading {
  font-size: clamp(2.5rem, 1.6rem + 3.5vw, 4.5rem);
  letter-spacing: -0.035em;
}

.philosophy-text,
.end-line,
.about-lead,
.systems-quote {
  font-weight: var(--title-weight);
  letter-spacing: -0.02em;
}

.philosophy-text {
  font-size: clamp(1.375rem, 1rem + 1vw, 1.75rem);
  line-height: 1.35;
}

.systems-quote {
  font-size: clamp(1.375rem, 1rem + 1.2vw, 2rem);
  line-height: 1.35;
}

/* Small titles: cards, system names */
.system-name {
  font-size: 1.625rem;
  font-weight: var(--title-weight);
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: 1rem;
}

.project-card-title {
  font-size: 1.25rem;
  font-weight: var(--title-weight);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.system-card-title {
  font-size: 1.375rem;
  font-weight: var(--title-weight);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.system-card-sub {
  font-size: var(--label-size);
  letter-spacing: 0.01em;
  color: var(--label-color);
}

/* ---------- Body: regular, comfortable, high contrast ---------- */
.system-desc,
.system-page-desc,
.systems-intro-text,
.selected-lede,
.project-page-desc,
.project-card-desc,
.contact-cta {
  font-weight: 400;
  letter-spacing: 0;
  color: var(--body-color);
}

.project-card-desc {
  font-size: 0.9375rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.72);
}

.project-section p,
.project-section-flow ul {
  font-size: 1.125rem;
  line-height: 1.65;
  letter-spacing: -0.005em;
  color: var(--body-color);
}

.project-content-light .project-section p,
.project-content-light .project-section-flow ul {
  font-size: 1.125rem;
  line-height: 1.65;
  color: var(--body-color-light);
}

.project-caption {
  font-size: 0.8125rem;
  line-height: 1.5;
  letter-spacing: 0;
}

/* Small links and buttons read as labels too */
.system-explore,
.end-links a,
.about-links a {
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.project-link-button {
  font-size: 0.875rem;
  font-weight: 400;
  letter-spacing: 0;
  padding: 0.75rem 1.35rem;
}

.project-badge {
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  padding: 0.3rem 0.65rem;
}

.process-num {
  font-weight: 400;
}

.process-label {
  font-size: 0.8125rem;
  font-weight: 400;
}

.project-meta {
  font-size: var(--label-size);
  color: var(--label-color-light);
}

/* ---------- Section headings become small labels ---------- */
/* Homepage: "Systems I work across" is a quiet label on the cosmos (same
   scroll step, so the shapes are unchanged) */
#scroll-container .systems-heading.glass-panel {
  /* a soft dark haze keeps the small label clear over the network */
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.55) 60%, rgba(0, 0, 0, 0));
  border: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 2rem 4rem;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 0 14px rgba(0, 0, 0, 0.9);
}

#scroll-container .systems-heading.glass-panel::before {
  /* the glass shine becomes the opening parenthesis */
  position: static;
  inset: auto;
  background: none;
  border-radius: 0;
}

#scroll-container .systems-heading.glass-panel::after {
  position: static;
  inset: auto;
  background: none;
  border-radius: 0;
}

.system-projects-heading,
.contact-heading {
  margin-bottom: 2rem;
}

.project-section-label {
  margin-bottom: 1.25rem;
}

/* ---------- Cards: less rounded, thinner border, subtle gradient ---------- */
.glass-panel {
  border-radius: var(--card-radius);
  border: 0.5px solid var(--card-border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.065) 0%, rgba(255, 255, 255, 0.015) 55%, rgba(255, 255, 255, 0.03) 100%);
}

.glass-panel::before,
.glass-panel::after {
  border-radius: inherit;
}

#scroll-container .glass-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.015) 55%, rgba(255, 255, 255, 0.035) 100%),
    rgba(8, 8, 10, 0.66);
  border-color: var(--card-border);
}

#scroll-indicator.glass-panel {
  border-radius: 50%;
}

.project-card {
  border-radius: 12px;
  border: 0.5px solid var(--card-border);
  /* frosted glass over a dark fill, so the text stays clear over the cosmos */
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.015) 60%, rgba(255, 255, 255, 0.03) 100%),
    rgba(10, 10, 12, 0.62);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
}

.project-card:hover {
  border-color: rgba(255, 255, 255, 0.26);
}

.project-card-body {
  padding: 1.5rem 1.5rem 1.75rem;
}

/* ---------- About: no boxes, text straight on the cosmos ---------- */
.about-panel {
  background: none;
  border: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  overflow: visible;
  isolation: isolate;
}

.about-panel::after {
  content: none;
}

/* A soft dark haze behind the words, fading to nothing at its edges */
.about-panel::before {
  inset: -2.5rem -3.5rem;
  z-index: -1;
  border-radius: 0;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.45) 60%, rgba(0, 0, 0, 0));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  -webkit-mask-image: radial-gradient(closest-side, #000 55%, transparent);
  mask-image: radial-gradient(closest-side, #000 55%, transparent);
}

.about-panel p,
.about-lead {
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.4;
  text-shadow: 0 0 16px rgba(0, 0, 0, 0.85), 0 0 3px rgba(0, 0, 0, 0.6);
}

.about-panel p {
  font-size: clamp(1.375rem, 1rem + 0.9vw, 1.75rem);
}

/* Words reveal from muted grey to white as the panel reaches the centre
   (typography.js sets --w from 0 to 1 on each word) */
.reveal-word {
  color: rgb(255 255 255 / calc(0.3 + 0.66 * var(--w, 1)));
  transition: color 0.15s linear;
}

@media (prefers-reduced-motion: reduce) {
  .reveal-word {
    color: rgba(255, 255, 255, 0.96);
    transition: none;
  }
}

/* ---------- Project pages ---------- */
.project-page-desc {
  max-width: 640px;
  line-height: 1.5;
}

.project-page-light .project-page-intro .project-page-desc {
  font-size: clamp(1.125rem, 1rem + 0.4vw, 1.3125rem);
  color: rgba(0, 0, 0, 0.78);
}

.project-content-light .project-section h3 {
  color: var(--label-color-light);
}

/* Story pages: the text flows between images, no section headings */
.project-page-story .project-section {
  margin-bottom: 2.75rem;
}

.project-page-story .project-section h3 {
  margin-bottom: 0.75rem;
}

.project-page-story .project-page-content {
  padding-top: 3.5rem;
}

/* Images: softly rounded corners, a little more air around them */
.project-case-image img,
.project-case-pair-row img,
.project-case-grid figure img,
.project-case-pdf embed {
  border-radius: 14px;
}

.project-page-story .project-case-image {
  margin-bottom: 3.25rem;
}

.project-page-story .project-case-image + .project-case-image {
  margin-top: -1.5rem;
}

.project-pullquote p {
  font-weight: var(--title-weight);
  letter-spacing: -0.02em;
  line-height: 1.35;
}

.project-page-light .project-closing-line {
  font-size: clamp(1.375rem, 1.1rem + 0.8vw, 1.75rem);
  font-weight: var(--title-weight);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

/* ---------- Phones ---------- */
@media (max-width: 600px) {
  .project-page-title,
  .system-page-title {
    font-size: clamp(2rem, 9vw, 2.5rem);
    letter-spacing: var(--title-tracking);
  }

  .selected-heading {
    font-size: clamp(2.25rem, 10vw, 2.75rem);
    letter-spacing: -0.035em;
  }

  .systems-page-heading {
    font-size: clamp(2.75rem, 13vw, 3.5rem);
    letter-spacing: -0.04em;
  }

  .system-name {
    font-size: clamp(1.25rem, 5.6vw, 1.5rem);
  }

  .project-section p,
  .project-content-light .project-section p,
  .project-content-light .project-section-flow ul {
    font-size: 1.0625rem;
  }

  .about-panel p {
    font-size: 1.25rem;
  }
}

/* ---------- Homepage intro lines: no box, straight on the cosmos ---------- */
/* The two philosophy lines lose their card like About; the system cards
   and the closing card keep theirs. Same scroll steps, so the shapes are
   unchanged. A soft dark haze keeps the words clear. */
#scroll-container .centered-panel:not(.end-panel) {
  background: none;
  border: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  overflow: visible;
  isolation: isolate;
}

#scroll-container .centered-panel:not(.end-panel)::after {
  content: none;
}

#scroll-container .centered-panel:not(.end-panel)::before {
  inset: -1rem -2rem;
  z-index: -1;
  border-radius: 0;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.45) 60%, rgba(0, 0, 0, 0));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  -webkit-mask-image: radial-gradient(closest-side, #000 55%, transparent);
  mask-image: radial-gradient(closest-side, #000 55%, transparent);
}

.philosophy-text {
  text-shadow: 0 0 16px rgba(0, 0, 0, 0.85), 0 0 3px rgba(0, 0, 0, 0.6);
}

.philosophy-text {
  font-size: clamp(1.625rem, 1.1rem + 1.4vw, 2.25rem);
  line-height: 1.3;
}

#scroll-container .systems-heading .reveal-word {
  /* the label stays a label: its words reveal to a muted white */
  color: rgb(255 255 255 / calc(0.3 + 0.45 * var(--w, 1)));
}

/* ---------- Movement on scroll (scroll-driven, no script) ---------- */
/* Browsers without scroll-driven animations, and anyone who prefers
   reduced motion, see everything in its final state. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    /* Images start as a slightly inset, more rounded card and grow to the
       full column width as they come into view */
    .project-case-image > img,
    .project-case-pair-row,
    .project-case-grid,
    .project-case-video video {
      animation: settle-in linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 35%;
      transform-origin: 50% 100%;
    }

    /* Labels and titles fade and rise a little as they enter */
    .project-section h3,
    .project-section-label,
    .system-projects-heading,
    .project-closing-line,
    .project-pullquote,
    .selected-row,
    .system-grid-card,
    .project-card {
      animation: rise-in linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 90%;
    }
  }
}

@keyframes settle-in {
  from {
    transform: scale(0.92);
    border-radius: 26px;
  }
  to {
    transform: none;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    translate: 0 18px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

/* ---------- /selected: a large-type list ---------- */
.selected-intro {
  max-width: 1200px;
  text-align: left;
  padding: 9rem 2rem 2.5rem;
}

.selected-heading {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.selected-count {
  font-size: var(--label-size);
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--label-color);
  margin-top: 0.6em;
}

.selected-lede {
  max-width: 560px;
  color: rgba(255, 255, 255, 0.75);
}

.selected-list {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.selected-row:first-child {
  border-top: 0.5px solid rgba(255, 255, 255, 0.18);
}

.selected-row {
  display: grid;
  grid-template-columns: 5rem 1fr 13rem;
  align-items: baseline;
  gap: 1.5rem;
  padding: 1.6rem 0 1.7rem;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
}

.selected-row-year,
.selected-row-system,
.selected-row-badges {
  font-size: var(--label-size);
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--label-color);
}

.selected-row-system {
  text-align: right;
}

/* No year: no empty slot; the title keeps its column so the list aligns */
.selected-row.no-year .selected-row-main {
  grid-column: 2;
}

.selected-row-main {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.selected-row-title {
  font-size: clamp(1.875rem, 1rem + 3vw, 3.75rem);
  font-weight: var(--title-weight);
  letter-spacing: -0.035em;
  line-height: 1.02;
  text-wrap: balance;
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
  transition: color 0.35s ease, translate 0.35s ease;
}

.selected-row:hover .selected-row-title,
.selected-row:focus-visible .selected-row-title {
  color: #fff;
  translate: 0.5rem 0;
}

.selected-list:hover .selected-row:not(:hover) .selected-row-title {
  color: rgba(255, 255, 255, 0.45);
}

.selected-row:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.7);
  outline-offset: 4px;
}

.selected-row-thumb {
  display: none;
}

/* The image that follows the cursor (desktop) */
.selected-hover {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 5;
  width: 280px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.selected-hover img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  scale: 0.94;
  transition: scale 0.4s ease;
}

.selected-hover.is-visible {
  opacity: 1;
}

.selected-hover.is-visible img {
  scale: 1;
}

@media (hover: none), (pointer: coarse), (max-width: 760px) {
  .selected-hover {
    display: none;
  }

  .selected-row-thumb {
    display: block;
    width: 100%;
    max-width: 360px;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 10px;
    margin-top: 0.4rem;
  }
}

@media (max-width: 760px) {
  .selected-intro {
    padding: 7rem 1.25rem 2rem;
  }

  .selected-list {
    padding: 0 1.25rem;
  }

  /* Year and system become one line of labels above the title */
  .selected-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "year system" "main main";
    row-gap: 0.75rem;
    padding: 1.25rem 0 1.5rem;
  }

  .selected-row-year { grid-area: year; }
  .selected-row-system { grid-area: system; }
  .selected-row-main { grid-area: main; }

  /* No year: the system label takes the whole line above the title */
  .selected-row.no-year {
    grid-template-areas: "system system" "main main";
  }

  .selected-row.no-year .selected-row-main {
    grid-column: auto;
  }

  .selected-row.no-year .selected-row-system {
    text-align: left;
  }

  .selected-row-title {
    font-size: clamp(1.75rem, 8vw, 2.25rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .selected-row-title,
  .selected-hover,
  .selected-hover img {
    transition: none;
  }
}

/* Titles and intros already on screen when a page opens rise in once,
   one after another (pages are shown from display: none, so this replays
   on every visit) */
@media (prefers-reduced-motion: no-preference) {
  .project-page-intro > *,
  .selected-intro > *,
  .system-page-intro > :not(.system-close),
  .systems-intro > * {
    animation: rise-in 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }

  .project-page-intro > :nth-child(2),
  .selected-intro > :nth-child(2),
  .system-page-intro > :nth-child(3),
  .systems-intro > :nth-child(2) {
    animation-delay: 0.08s;
  }

  .project-page-intro > :nth-child(3),
  .system-page-intro > :nth-child(4) {
    animation-delay: 0.16s;
  }

  .project-page-intro > :nth-child(n + 4) {
    animation-delay: 0.24s;
  }
}

/* ---------- Project header: one short meta line, badges beside it ---------- */
.project-page-metarow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.9rem;
  margin-top: 1.5rem;
}

.project-page-metarow .project-page-meta,
.project-page-metarow .project-page-badges {
  margin: 0;
}

.project-page-metarow:not(:has(> :not([hidden]))) {
  display: none;
}

.project-page-light .project-page-meta {
  color: var(--label-color-light);
}

/* ---------- Homepage system cards: title, description, link ---------- */
/* Same square card and size (the cosmos reads the card's width). Centred:
   the title is the first read, "(System)" a muted label beside it, the
   description smaller and narrower than the title, the link a small label
   at the bottom. The same rhythm on all six. */
/* The same inner padding on every side of every card, set so the longest
   one-line title (Human Interaction) just fits; longer titles wrap instead
   of running towards the edges */
#scroll-container .system-panel {
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: 4.5rem;
}

#scroll-container .system-name {
  margin: auto 0 0;
  max-width: 100%;
  /* normal wrapping: balanced lines would make the title, and so the
     description under it, needlessly narrow */
  text-wrap: wrap;
  text-align: center;
  font-size: 1.875rem;
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: #fff;
}

.system-suffix {
  font-size: 0.78em;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: rgba(255, 255, 255, 0.42);
  white-space: nowrap;
}

/* max-width is set by typography.js to the title's widest rendered line,
   so the description is never wider than the title; 28ch until measured */
#scroll-container .system-desc {
  margin-top: 1.1rem;
  max-width: 28ch;
  text-align: center;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.62);
}

#scroll-container .system-explore {
  margin-top: auto;
  padding: 0.35rem 0;
  font-size: var(--label-size);
  color: var(--label-color);
  opacity: 1;
  transition: color 0.3s ease, border-color 0.3s ease;
}

#scroll-container .system-explore:hover,
#scroll-container .system-explore:focus-visible {
  color: #fff;
}

/* ---------- Homepage ending card and the contact card: one card ---------- */
/* Both share every rule here, so they stay identical */
:is(#scroll-container .end-panel, #contact-page .contact-panel) {
  width: 480px;
  max-width: 90vw;
  aspect-ratio: 1 / 1;
  padding: 2.25rem 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* Heading and links as one block, centred in the card */
:is(#scroll-container .end-line, #contact-page .contact-heading) {
  margin: 0;
  font-weight: var(--title-weight);
  font-size: clamp(1.875rem, 1.3rem + 1.1vw, 2.375rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: #fff;
}

:is(#scroll-container .end-panel, #contact-page .contact-panel) .end-links {
  display: grid;
  grid-template-columns: repeat(2, auto);
  justify-content: center;
  justify-items: center;
  gap: 0.35rem 2rem;
  margin-top: 2rem;
}

:is(#scroll-container .end-panel, #contact-page .contact-panel) .end-links span {
  display: none;
}

:is(#scroll-container .end-panel, #contact-page .contact-panel) .end-links a {
  font-size: var(--label-size);
  color: var(--label-color);
  opacity: 1;
  padding: 0.35rem 0;
  transition: color 0.3s ease, border-color 0.3s ease;
}

:is(#scroll-container .end-panel, #contact-page .contact-panel) .end-links a:hover,
:is(#scroll-container .end-panel, #contact-page .contact-panel) .end-links a:focus-visible {
  color: #fff;
}

@media (max-width: 768px) {
  #scroll-container .system-panel,
  :is(#scroll-container .end-panel, #contact-page .contact-panel) {
    width: 340px;
    padding: 2.5rem;
  }

  #scroll-container .system-name {
    font-size: 1.5rem;
  }

  :is(#scroll-container .end-line, #contact-page .contact-heading) {
    font-size: 1.625rem;
  }

  #scroll-container .system-desc {
    font-size: 0.875rem;
  }
}

/* ---------- Contact: the ending card's fill (the rest is shared above) ---------- */
#contact-page .contact-panel {
  /* never wider than the page's content column (the homepage card is
     shrunk the same way by its flex section) */
  max-width: min(90vw, 100%);
  margin-left: auto;
  margin-right: auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.015) 55%, rgba(255, 255, 255, 0.035) 100%),
    rgba(8, 8, 10, 0.66);
  border: 0.5px solid var(--card-border);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
}

/* Six links: three per row on wide screens, two per row on phones, so no
   link is ever alone on the last row */
#contact-page .contact-panel .end-links-six {
  grid-template-columns: repeat(3, auto);
  column-gap: 1.75rem;
}

@media (max-width: 768px) {
  #contact-page .contact-panel .end-links-six {
    grid-template-columns: repeat(2, auto);
  }
}

/* The heading is a title here, not a label */
#contact-page .contact-heading::before,
#contact-page .contact-heading::after {
  content: none;
}

/* ---------- Document pages as images (Period's activities) ---------- */
.pdf-pages-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.pdf-pages-grid a {
  display: block;
  cursor: zoom-in;
  border-radius: 14px;
}

.pdf-pages-grid a:focus-visible {
  outline: 1px solid #111;
  outline-offset: 3px;
}

.pdf-pages-grid img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 14px;
}

.pdf-open {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 0.5px;
}

@media (max-width: 600px) {
  .pdf-pages-grid {
    grid-template-columns: 1fr;
  }
}

/* Lightbox: the image at full size, scrollable when larger than the screen */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(10, 10, 12, 0.94);
  overflow: auto;
}

.lightbox::backdrop {
  background: transparent;
}

.lightbox img {
  display: block;
  width: min(1600px, 96vw);
  height: auto;
  margin: 4rem auto;
  border-radius: 10px;
  cursor: zoom-out;
}

.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  padding: 0.5rem 0.9rem;
  border: 0.5px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: rgba(20, 20, 22, 0.8);
  color: #fff;
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
}

/* ---------- PDF viewers: Fullscreen label and Open PDF link ---------- */
.project-case-pdf {
  position: relative;
}

.pdf-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}

.pdf-fullscreen {
  padding: 0.35rem 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: var(--label-size);
  letter-spacing: 0.01em;
  color: var(--label-color-light);
  cursor: pointer;
  transition: color 0.2s ease;
}

.pdf-fullscreen::before { content: '('; }
.pdf-fullscreen::after { content: ')'; }

.pdf-fullscreen:hover,
.pdf-fullscreen:focus-visible {
  color: #111;
}

.pdf-fullscreen:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 3px;
  border-radius: 2px;
}

.pdf-open-line {
  margin: -2.25rem 0 3rem;
}

/* Fullscreen (Fullscreen API) and the window-filling overlay share a look */
.project-case-pdf:fullscreen,
.project-case-pdf.is-pdf-overlay {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0.5rem 1rem 1rem;
  background: #161618;
}

.project-case-pdf:-webkit-full-screen {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0.5rem 1rem 1rem;
  background: #161618;
}

.project-case-pdf.is-pdf-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  width: 100vw;
  height: 100dvh;
}

.project-case-pdf:fullscreen .pdf-fullscreen,
.project-case-pdf:-webkit-full-screen .pdf-fullscreen,
.project-case-pdf.is-pdf-overlay .pdf-fullscreen {
  color: rgba(255, 255, 255, 0.75);
}

.project-case-pdf:fullscreen .pdf-fullscreen:hover,
.project-case-pdf.is-pdf-overlay .pdf-fullscreen:hover {
  color: #fff;
}

.project-case-pdf:fullscreen embed,
.project-case-pdf:fullscreen iframe,
.project-case-pdf:-webkit-full-screen embed,
.project-case-pdf.is-pdf-overlay embed,
.project-case-pdf.is-pdf-overlay iframe {
  flex: 1;
  width: 100%;
  height: auto;
  min-height: 0;
  border-radius: 6px;
}

/* The page behind the overlay doesn't scroll */
html.pdf-overlay-open,
html.pdf-overlay-open body {
  overflow: hidden;
}

/* The overlay sits inside the project page; the site nav would cover it */
html.pdf-overlay-open #main-nav {
  display: none;
}

/* ============================================================
   PHONES (≤ 480px) ONLY: desktop is unchanged
   ============================================================ */
/* About: long panels show as two halves on phones (see index.html) */
.about-step-part,
.about-progress .about-dot-part {
  display: none;
}

@media (max-width: 480px) {
  .about-step-whole,
  .about-progress .about-dot-whole {
    display: none;
  }

  .about-step-part {
    display: flex;
  }

  .about-progress .about-dot-part {
    display: grid;
  }

  /* Comfortable reading: 18px, even lines, at most about 34 characters
     each (15em; ch is the width of a zero, wider than an average letter) */
  .about-panel p {
    max-width: 15em;
    margin: 0 auto;
    font-size: 1.125rem;
    line-height: 1.5;
    text-wrap: balance;
  }

  /* System cards: descriptions wrap into even lines */
  #scroll-container .system-desc {
    text-wrap: balance;
  }
}

/* About never scrolls sideways: the scroller only moves vertically (its
   snap is unchanged), and on phones the haze behind each panel stays
   inside the screen */
.about-scroll {
  overflow-x: hidden;
}

@media (max-width: 600px) {
  .about-panel::before,
  .about-lead::before,
  .about-step[data-step="8"] .about-links::before {
    inset: -1.75rem -1rem;
  }
}
