/* Section eyebrows - a small labelled cue, not a decorative pill. */
.eyebrow {
  display: inline-block;
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin: 0 0 var(--space-2);
}

/* About page header - portrait beside intro on wide screens, stacked on
   narrow ones. */
.about-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.about-header__image {
  width: 8rem;
  height: 8rem;
  border: var(--border-width) solid var(--color-line);
}

@media (min-width: 40rem) {
  .about-header {
    flex-direction: row;
    align-items: flex-start;
  }

  .about-header__image {
    width: 10rem;
    height: 10rem;
    flex-shrink: 0;
  }
}

/* Rich text / prose content */
.richtext h2,
.richtext h3,
.richtext h4 {
  margin-top: var(--space-5);
}

.richtext p,
.richtext ul,
.richtext ol {
  margin: var(--space-3) 0;
}

.richtext a {
  text-underline-offset: 0.2em;
}

.pull-quote {
  border-left: 2px solid var(--color-accent);
  margin: var(--space-4) 0;
  padding: var(--space-2) var(--space-4);
  font-size: var(--step-1);
  font-style: italic;
  color: var(--color-text-muted);
}

.pull-quote cite {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--step--1);
  font-style: normal;
}

.stream-image,
.stream-embed {
  margin: var(--space-4) 0;
}

/* Plain responsive image grid - used for a project's gallery. No card
   chrome here, the photos carry it. */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--space-4);
}

.card-grid .stream-image {
  margin: 0;
}

/* Photo gallery slider (About page) - a horizontal scroll-snap track,
   three photos visible at a time on desktop. Native momentum/swipe
   scrolling does the heavy lifting; the prev/next buttons just nudge the
   scroll position by one "page" of the track. */
.gallery {
  position: relative;
}

.gallery__track {
  display: flex;
  gap: var(--space-4);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gallery__track::-webkit-scrollbar {
  display: none;
}

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

.gallery__item {
  flex: 0 0 calc((100% - 2 * var(--space-4)) / 3);
  scroll-snap-align: start;
  margin: 0;
}

@media (max-width: 64rem) {
  .gallery__item {
    flex-basis: calc((100% - var(--space-4)) / 2);
  }
}

@media (max-width: 40rem) {
  .gallery__item {
    flex-basis: 85%;
  }
}

.gallery__trigger {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.gallery__thumb {
  display: block;
  width: 100%;
  height: auto;
}

.gallery__controls {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.gallery__nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  border: var(--border-width) solid var(--color-line);
  background: none;
  color: var(--color-text);
  font-size: var(--step-0);
  cursor: pointer;
}

.gallery__nav:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.gallery__nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.gallery__nav:disabled:hover {
  border-color: var(--color-line);
  color: var(--color-text);
}

/* Lightbox - a native <dialog> so Escape-to-close, focus-trapping, and
   ::backdrop all come from the browser instead of hand-rolled JS. Every
   photo's full-size rendition is rendered up front (hidden except the
   active one) rather than swapped in via JS, so it still goes through
   Wagtail's normal AVIF/WebP picture output. */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  margin: 0;
  padding: var(--space-4);
  border: 0;
  background: var(--color-bg);
  color: var(--color-text);
}

.lightbox[open] {
  display: flex;
  flex-direction: column;
}

.lightbox::backdrop {
  background: rgba(0, 0, 0, 0.85);
}

.lightbox__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.lightbox__count {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--color-text-muted);
}

.lightbox__close {
  min-width: 2.5rem;
  height: 2.5rem;
  border: var(--border-width) solid var(--color-line);
  background: none;
  color: var(--color-text);
  font-size: var(--step-1);
  line-height: 1;
  cursor: pointer;
}

.lightbox__close:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.lightbox__stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  flex: 1;
  min-height: 0;
}

.lightbox__slide {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
}

/* The [hidden] attribute is how JS switches the active slide, but a plain
   `display: flex` on the class above has the same specificity as the
   browser's own `[hidden] { display: none }` rule and (being an author
   rule) wins regardless of order - without this, every slide showed at
   once instead of just the active one. */
.lightbox__slide[hidden] {
  display: none;
}

.lightbox__slide img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 10rem);
  object-fit: contain;
}

.lightbox__slide figcaption {
  color: var(--color-text-muted);
  font-size: var(--step--1);
  text-align: center;
}

.lightbox__nav {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: var(--border-width) solid var(--color-line);
  background: none;
  color: var(--color-text);
  font-size: var(--step-0);
  cursor: pointer;
}

.lightbox__nav:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* Code blocks (Pygments server-side highlighting, see code.css) */
.code-block {
  margin: var(--space-4) 0;
  overflow: hidden;
  border: var(--border-width) solid var(--color-line);
}

.code-block__filename {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-elevated);
  border-bottom: var(--border-width) solid var(--color-line);
  color: var(--color-text-muted);
}

.code-block__body {
  overflow-x: auto;
}

.code-block__body pre {
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--step--1);
}

.stream-image img {
  width: 100%;
  height: auto;
}

.stream-image figcaption,
.stream-embed figcaption {
  font-size: var(--step--1);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

.stream-embed .responsive-embed {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
}

.stream-embed .responsive-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Buttons - reserved for the one or two real actions on a page. A solid
   ink block reads as a poster, not a UI widget; everything else is a
   plain underlined link so it doesn't compete with it. */
.button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--color-ink);
  color: var(--color-paper);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--step--1);
  border: var(--border-width) solid var(--color-ink);
  cursor: pointer;
}

@media (prefers-color-scheme: dark) {
  .button {
    background: var(--color-text);
    color: var(--color-graphite);
    border-color: var(--color-text);
  }
}
:root[data-theme="dark"] .button {
  background: var(--color-text);
  color: var(--color-graphite);
  border-color: var(--color-text);
}
/* Cancels the prefers-color-scheme rule above when the viewer's system is
   dark but they've explicitly picked light via the theme toggle - without
   this, .button fell back to the OS-dark colors regardless of the choice,
   pairing a dark background with equally-dark text. */
:root[data-theme="light"] .button {
  background: var(--color-ink);
  color: var(--color-paper);
  border-color: var(--color-ink);
}

.button:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-accent-contrast);
}

.button:active {
  transform: translateY(1px);
}

.button--outline {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-line);
}

.button--outline:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: transparent;
}

.button-row {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
  flex-wrap: wrap;
}

/* A plain text action - underline plus a nudge arrow, for anything that
   isn't the page's one primary action. Underlined via border-bottom, not
   text-decoration: the flex `gap` below puts real empty space between the
   text and the arrow, and text-decoration only draws under actual text
   runs - it left a gap in the line exactly where the flex gap was. A
   border spans the whole box regardless of what's inside it. */
.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border-bottom: var(--border-width) solid currentColor;
  padding-bottom: 0.2em;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
}

.link-arrow::after {
  content: "\2192";
  display: inline-block;
}

@media (prefers-reduced-motion: no-preference) {
  .link-arrow::after {
    transition: transform 0.15s ease;
  }

  .link-arrow:hover::after {
    transform: translateX(0.2em);
  }
}

/* Index list - projects and posts read as a table of contents, not a
   grid of product cards. The row number is real ordering information
   (featured order / reverse chronological), not decoration. */
.index-list {
  border-top: var(--border-width) solid var(--color-line);
}

.index-row {
  position: relative;
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: var(--space-1) var(--space-4);
  padding-block: var(--space-4);
  border-bottom: var(--border-width) solid var(--color-line);
}

.index-row__index {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--color-text-muted);
  padding-top: 0.3em;
}

.index-row__title {
  margin: 0;
  font-size: var(--step-2);
}

.index-row__title a {
  text-decoration: none;
  color: var(--color-text);
}

.index-row__title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.index-row:hover .index-row__title a {
  color: var(--color-accent);
}

.index-row__summary {
  grid-column: 2 / 3;
  margin: var(--space-1) 0 0;
  max-width: 40rem;
  color: var(--color-text-muted);
}

.index-row__meta {
  grid-column: 2 / 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
  font-size: var(--step--1);
  color: var(--color-text-muted);
}

.index-row__thumb {
  display: none;
}

@media (min-width: 56rem) {
  .index-row {
    grid-template-columns: 3rem 1fr auto;
    align-items: start;
  }

  .index-row__meta {
    grid-column: 3 / 4;
    grid-row: 1 / 3;
    margin-top: 0;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    width: 9rem;
  }

  .index-row__thumb {
    display: block;
    position: absolute;
    right: var(--space-4);
    top: 50%;
    width: 11rem;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    transform: translateY(-50%);
    opacity: 0;
    pointer-events: none;
    z-index: 1;
  }

  @media (prefers-reduced-motion: no-preference) {
    .index-row__thumb {
      transition: opacity 0.2s ease;
    }
  }

  .index-row:hover .index-row__thumb {
    opacity: 1;
  }
}

/* Tags - plain bordered labels, not coloured pills. */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
}

.tag {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  text-decoration: none;
  border: var(--border-width) solid var(--color-line);
}

a.tag:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.tag[aria-current="true"] {
  background: var(--color-ink);
  border-color: var(--color-ink);
  color: var(--color-paper);
}

@media (prefers-color-scheme: dark) {
  .tag[aria-current="true"] {
    background: var(--color-text);
    border-color: var(--color-text);
    color: var(--color-graphite);
  }
}
:root[data-theme="dark"] .tag[aria-current="true"] {
  background: var(--color-text);
  border-color: var(--color-text);
  color: var(--color-graphite);
}
/* Same cancellation as .button above, for the same reason. */
:root[data-theme="light"] .tag[aria-current="true"] {
  background: var(--color-ink);
  border-color: var(--color-ink);
  color: var(--color-paper);
}

/* Forms - underlined fields read as a considered document, not a boxed
   web form. */
.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.form-field label {
  font-weight: 600;
  font-size: var(--step--1);
}

.form-field input,
.form-field textarea,
.form-field select {
  font: inherit;
  padding: var(--space-2) 0;
  border: none;
  border-bottom: var(--border-width) solid var(--color-line);
  border-radius: 0;
  background: transparent;
  color: var(--color-text);
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--color-accent);
}

.form-field textarea {
  min-height: 8rem;
  resize: vertical;
}

.form-field--required label::after {
  content: " *";
  color: var(--color-danger);
}

.form-field__error {
  color: var(--color-danger);
  font-size: var(--step--1);
}

.form-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form-errors {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
}

/* Search */
.search-form {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: end;
}

.search-form input[type="search"] {
  flex: 1;
  min-width: 12rem;
  font: inherit;
  padding: var(--space-2) 0;
  border: none;
  border-bottom: var(--border-width) solid var(--color-line);
  background: transparent;
  color: var(--color-text);
}

.search-form input[type="search"]:focus {
  outline: none;
  border-color: var(--color-accent);
}

.search-results {
  border-top: var(--border-width) solid var(--color-line);
}

.search-results li {
  padding-block: var(--space-4);
  border-bottom: var(--border-width) solid var(--color-line);
}

.search-results h2 {
  font-size: var(--step-1);
  margin: 0 0 var(--space-1);
}

.search-results h2 a {
  text-decoration: none;
}

.search-results h2 a:hover {
  color: var(--color-accent);
}

/* Pagination */
.pagination {
  display: flex;
  gap: var(--space-2);
  list-style: none;
  padding: 0;
  margin: var(--space-5) 0 0;
  justify-content: center;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  text-decoration: none;
  color: var(--color-text);
  border: var(--border-width) solid transparent;
}

.pagination a:hover {
  border-color: var(--color-line);
}

.pagination [aria-current="page"] {
  border-color: var(--color-ink);
}

/* CV rows (about page) - a narrow date column beside the content, the
   way a well-set résumé is typeset in print, rather than a dot timeline. */
.cv-timeline {
  border-top: var(--border-width) solid var(--color-line);
}

.cv-entry {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2) var(--space-5);
  padding-block: var(--space-5);
  border-bottom: var(--border-width) solid var(--color-line);
}

@media (min-width: 40rem) {
  .cv-entry {
    grid-template-columns: 9rem 1fr;
  }

  .cv-entry__dates {
    padding-top: 0.3em;
  }
}

.cv-entry__dates {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  margin: 0;
  white-space: nowrap;
}

.cv-entry__title {
  margin: 0 0 var(--space-1);
  font-size: var(--step-2);
}

.cv-entry__org {
  color: var(--color-text-muted);
  margin: 0 0 var(--space-3);
}

.cv-entry .richtext ul {
  padding-left: 1.1em;
}

.cv-entry .richtext li + li {
  margin-top: var(--space-1);
}

.cv-entry--current .cv-entry__dates {
  color: var(--color-accent);
}

/* Skills - plain labelled lines of text rather than coloured chips. */
.skill-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-1);
  padding-block: var(--space-3);
  border-bottom: var(--border-width) solid var(--color-line);
}

.skill-row:first-child {
  border-top: var(--border-width) solid var(--color-line);
}

@media (min-width: 40rem) {
  .skill-row {
    grid-template-columns: 10rem 1fr;
    gap: var(--space-4);
  }
}

.skill-row dt {
  margin: 0;
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.skill-row dd {
  margin: 0;
}

/* Certificates - a spec-sheet style list, name/issuer left, date right */
.cert-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: var(--border-width) solid var(--color-line);
}

.cert-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding-block: var(--space-3);
  border-bottom: var(--border-width) solid var(--color-line);
}

.cert-item__name {
  margin: 0;
  font-weight: 600;
}

.cert-item__name a {
  color: var(--color-text);
  text-decoration: none;
}

.cert-item__name a:hover {
  color: var(--color-accent);
}

.cert-item__issuer {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--step--1);
}

.cert-item__date {
  margin: 0;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  white-space: nowrap;
}

@media (max-width: 30rem) {
  .cert-item {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
  }
}

/* Hero (home page) - an asymmetric composition: the statement runs full
   width, the lede and CTA sit offset in the right column, leaving
   deliberate empty space on the left rather than a centred stack. */
.hero {
  padding-block: var(--space-7) var(--space-6);
}

.hero__body {
  display: grid;
  gap: var(--space-4);
}

@media (min-width: 56rem) {
  .hero__body {
    grid-template-columns: 1fr 1fr;
  }

  .hero__title {
    grid-column: 1 / 3;
  }

  .hero__meta {
    grid-column: 2 / 3;
  }
}

.hero__title {
  margin: 0;
  font-size: var(--step-5);
}

.lede {
  font-size: var(--step-1);
  color: var(--color-text-muted);
  max-width: 32rem;
  margin: 0;
}

.hero__image {
  margin-top: var(--space-4);
  max-width: 12rem;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.cta {
  border-top: var(--border-width) solid var(--color-line);
}
