/* ==========================================================================
   site.css: navigation, page shells, cards, footer.
   ========================================================================== */

/* Containers --------------------------------------------------------------- */

.page {
  padding-bottom: 5.625rem;
  animation: rise 0.45s ease-out both;
}

/* Each width token describes the *content* width; the gutter is added on top
   so the measure stays constant while the margins breathe. */
.measure,
.page--wide,
.page--reading {
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.measure {
  max-width: calc(var(--measure) + var(--gutter) * 2);
}

.page--wide {
  max-width: calc(var(--wide) + var(--gutter) * 2);
}

/* The home page's sidebar-plus-index layout needs more breathing room than
   the hero's reading measure: wider than even the wide pages, with a
   slimmer side margin, so the index column can hold a real row of text. */
.home-sections {
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 3rem);
  max-width: 64rem;
}

.home-sections .section-label {
  text-align: left;
}

.page--reading {
  max-width: calc(var(--reading) + var(--gutter) * 2);
}

.stack {
  margin-top: 2.125rem;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.press-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.625rem;
}

/* Navigation --------------------------------------------------------------- */

.site-nav__list {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0 1.875rem;
  max-width: 64rem;
  margin-inline: auto;
  padding: 1.25rem clamp(1.25rem, 4vw, 3rem) 0;
}

.site-nav__link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding-inline: 0.25rem;
  font-size: var(--fs-eyebrow);
  letter-spacing: var(--tracking);
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.18s;
}

.site-nav__link:hover {
  color: var(--ink);
}

.site-nav__link.is-current {
  color: var(--ink);
}

/* Home page sidebar -------------------------------------------------------- */

.page--home .home-sections {
  padding-top: 2.75rem;
}

/* Press and the footer follow the grid, so they need the usual stack gap back. */
.page--home .measure {
  margin-top: 2.125rem;
}

/* A single rail: portrait and name, quick links, then the section index,
   each block set off by a hairline — no box around it, just the column.
   Below `900px` it drops out of the grid and reflows as a compact header
   instead. */
.home-layout {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: 3.5rem;
  align-items: start;
}

.home-sidebar {
  position: sticky;
  top: 2rem;
}

/* Clears the numbered headings from the top of the viewport when the
   sidebar index scrolls the page to one of them. */
.home-main > .stack {
  scroll-margin-top: 2rem;
}

/* Below `900px` the sidebar and main column collapse into one flow. Both
   wrappers unwrap via `display: contents` so their children become direct
   items of `.home-layout` and can be reordered with `order`: the index
   moves from "under the links" to "under the intro sentences", ahead of
   the numbered sections it points to. */
@media (max-width: 56.25rem) {
  .home-layout {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .home-sidebar,
  .home-main {
    display: contents;
  }

  .profile {
    order: 1;
  }

  .profile__links {
    order: 2;
  }

  .home-intro {
    order: 3;
  }

  .home-index {
    order: 4;
  }

  .home-main > .stack {
    order: 5;
  }
}

/* Rail profile: portrait, name, role. Stacked in the rail; becomes a
   compact inline header once the layout collapses. */
.profile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.profile__avatar {
  width: 9.5rem;
  height: 9.5rem;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 28%;
  border: 1px solid var(--hairline);
}

.profile__id {
  margin-top: 1.25rem;
}

.profile__name {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.5625rem;
  line-height: 1.1;
  text-wrap: balance;
}

.profile__role {
  margin-top: 0.25rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: var(--tracking-tight);
  color: var(--muted);
}

@media (max-width: 56.25rem) {
  .profile {
    flex-direction: column;
    align-items: center;
    align-self: stretch;
    text-align: center;
    gap: 0.75rem;
  }

  .profile__id {
    align-self: stretch;
    margin-top: 0;
  }

  .profile__avatar {
    width: 7rem;
    height: 7rem;
  }

  .profile__name {
    font-size: 1.4375rem;
  }

  .profile__role {
    font-size: 0.6875rem;
  }
}

/* Rail quick links ----------------------------------------------------------- */

.profile__links {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-top: 1.25rem;
  padding-top: 1.125rem;
  border-top: 1px solid var(--hairline);
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.profile__link {
  color: var(--ink-soft);
  transition: color 0.18s;
}

.profile__link:hover,
.profile__link:focus-visible {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 56.25rem) {
  .profile__links {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-self: stretch;
    gap: 0.875rem;
    margin-top: 1.75rem;
    padding-top: 1.5rem;
    font-size: 0.625rem;
  }
}

/* Home page main column intro: the tagline and standfirst that used to sit
   in the hero, now leading the main column instead of the rail. */
.home-intro__tagline {
  font-family: var(--serif);
  font-size: 1.5rem;
  line-height: 1.5;
  color: var(--ink);
  max-width: 34rem;
  text-wrap: pretty;
}

.home-intro__standfirst {
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 34rem;
  margin-top: 0.875rem;
  text-wrap: pretty;
}

/* Home page entry cards: the shared `.card--stack` shape (also used by the
   CV page), pinned to the spec's exact sizes here rather than in the shared
   rule so the CV page keeps its own fluid type scale. */
.home-main .card--stack {
  padding: 1.25rem 1.5rem;
  row-gap: 0.375rem;
}

.home-main .card__name {
  font-size: 1.4375rem;
}

.home-main .card__year {
  color: var(--muted);
}

.home-main .card__strapline {
  font-size: 0.75rem;
}

@media (max-width: 56.25rem) {
  .home-main .card--stack {
    padding: 1rem 1.125rem;
  }

  .home-main .card__name {
    font-size: 1.25rem;
  }

  .home-main .card__year {
    font-size: 0.625rem;
  }
}

@media (max-width: 56.25rem) {
  .home-intro {
    margin-top: 1.75rem;
    text-align: center;
  }

  .home-intro__tagline,
  .home-intro__standfirst {
    margin-inline: auto;
  }

  .home-intro__tagline {
    font-size: 1.1875rem;
  }

  .home-intro__standfirst {
    font-size: 1rem;
  }
}

/* Sidebar contact links ---------------------------------------------------- */

.cta-stack {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--edge);
}

/* The home page's "Contact" section reuses the sidebar's row shape, but
   should not stretch to the full width of the wide main column. */
.cta-stack--wide {
  max-width: 26rem;
}

.cta-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9375rem 1.125rem;
  font-size: var(--fs-eyebrow);
  letter-spacing: var(--tracking);
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--hairline);
  transition: color 0.18s, background 0.18s;
}

.cta-button:last-child {
  border-bottom: none;
}

.cta-button__label {
  display: flex;
  align-items: center;
  gap: 0.6875rem;
}

.cta-button__icon {
  flex: none;
  color: var(--faint);
  transition: color 0.18s;
}

.cta-button::after {
  content: '→';
  color: var(--faint);
  transition: color 0.18s, transform 0.18s;
}

.cta-button:hover,
.cta-button:focus-visible {
  color: var(--accent);
  background: var(--surface);
}

.cta-button:hover .cta-button__icon,
.cta-button:focus-visible .cta-button__icon {
  color: var(--accent);
}

.cta-button:hover::after,
.cta-button:focus-visible::after {
  color: var(--accent);
  transform: translateX(2px);
}

/* Rail mini table of contents ---------------------------------------------- */

.home-index {
  margin-top: 1.25rem;
  padding-top: 1.125rem;
  border-top: 1px solid var(--hairline);
}

.home-index .section-label {
  font-size: 0.625rem;
}

.home-index__list {
  display: flex;
  flex-direction: column;
  gap: 0.5625rem;
}

.home-index__link {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-soft);
  transition: color 0.18s;
}

.home-index__link:hover,
.home-index__link:focus-visible {
  color: var(--ink);
}

.home-index__link.is-active,
.home-index__link.is-active .home-index__num {
  color: var(--ink);
}

.home-index__num {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: inherit;
  color: var(--faint);
}

@media (max-width: 56.25rem) {
  .home-index {
    margin-top: 1.75rem;
    padding-top: 1.5rem;
    text-align: center;
  }

  .home-index .section-label {
    text-align: center;
  }

  .home-index__list {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem 1.25rem;
  }
}

/* Page heads --------------------------------------------------------------- */

.page-head {
  padding-top: 2.5rem;
  margin-bottom: 2.75rem;
  text-align: center;
}

/* The projects page puts a labelled rule directly under the head instead. */
.page--wide .page-head {
  margin-bottom: 0;
}

.page-head__title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: var(--fs-page);
  line-height: 1;
  margin-bottom: 0.875rem;
  text-wrap: balance;
}

.page-head__lede,
.page-head__sub {
  font-family: var(--serif);
  font-size: var(--fs-sub);
  line-height: 1.6;
  color: var(--muted);
  text-wrap: pretty;
}

.meta-rule {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin: 1.5rem 0 1.875rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.65625rem;
  letter-spacing: var(--tracking-tight);
  text-transform: uppercase;
  color: var(--faint);
}

/* Home page section headings: a number, the title, and a rule that fills
   the rest of the row. */
.index-head {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  margin: 2.5rem 0 1.25rem;
}

.index-head__title {
  display: flex;
  flex: none;
  align-items: baseline;
  gap: 0.5625rem;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.875rem;
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
}

.index-head__num {
  font-family: var(--mono);
  font-size: var(--fs-eyebrow);
  letter-spacing: var(--tracking-tight);
  color: var(--faint);
}

.index-head__rule {
  flex: 1 1 auto;
  align-self: center;
  min-width: 1.5rem;
  height: 1px;
  background: var(--rule);
}

@media (max-width: 56.25rem) {
  .page--home .index-head__title {
    font-size: 1.5625rem;
  }
}

/* Section labels sit centred on the home page and ranged left on the
   document-like pages, matching how each page is read. */
.page--reading .section-label {
  text-align: left;
}

/* Cards -------------------------------------------------------------------- */

.card {
  display: grid;
  width: 100%;
  padding: 1.0625rem 1.5rem;
  background: var(--bg);
  border: 1px solid var(--edge);
  border-radius: 0;
  box-shadow: var(--shadow-rest);
  -webkit-appearance: none;
  appearance: none;
  text-align: left;
  overflow-wrap: break-word;
  cursor: pointer;
  transition: transform 0.22s, box-shadow 0.22s, border-color 0.22s;
}

/* Hover styles are deliberately not gated behind any hover media query.
   A Windows laptop with a touchscreen can report `(hover: none)` *and*
   `(any-hover: none)` in Chrome despite having a perfectly good trackpad, so
   either guard silently kills every lift on a machine that can plainly hover.
   The cost of leaving them ungated is that a real touch device keeps a card
   lifted until the next tap elsewhere, which is a far smaller problem than a
   site whose hover states do nothing. */
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card);
  border-color: var(--edge);
}

/* Keyboard users get the same affordance as the mouse. */
.card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card);
}

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

.card__name {
  display: flex;
  align-items: center;
  gap: 0.5625rem;
  min-width: 0;
  font-family: var(--serif);
  font-size: var(--fs-row);
  line-height: 1.25;
  color: var(--ink);
}

.card__logo {
  flex: none;
  width: 1.1875rem;
  height: 1.1875rem;
  object-fit: contain;
}

.card__role {
  font-size: var(--fs-meta);
  color: var(--muted);
}

.card__year {
  justify-self: end;
  font-size: var(--fs-eyebrow);
  color: var(--faint);
  white-space: nowrap;
}

/* Persistent arrow, borrowed from `.cta-button::after`: visible at rest so
   touch (which never sees `:hover`) still gets the affordance, brightening
   further on hover/focus the way the contact rows already do. */
.card__arrow {
  justify-self: end;
  color: var(--faint);
  transition: color 0.18s, transform 0.18s;
}

.card:hover .card__arrow,
.card:focus-visible .card__arrow {
  color: var(--accent);
  transform: translateX(2px);
}

/* Row: organisation · role · year ------------------------------------------ */

.card--row {
  grid-template-columns: minmax(0, 11rem) minmax(0, 1fr) auto;
  gap: 0.25rem 1rem;
  align-items: baseline;
}

.card--row > .card__name {
  grid-area: 1 / 1;
}

.card--row > .card__role {
  grid-area: 1 / 2;
}

.card--row > .card__year {
  grid-area: 1 / 3;
}

/* Row: title · year -------------------------------------------------------- */

.card--row-wide {
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.25rem 0.875rem;
  align-items: baseline;
  padding-block: 0.9375rem;
}

/* `.card--row`'s `> .card__year` rule above puts the year in the row's last
   explicit column, which is column 3 there but column 2 here — override so
   the arrow (auto-placed, no rule of its own) doesn't land ahead of it. */
.card--row-wide > .card__year {
  grid-area: 1 / 2;
}

.card--row-wide > .card__arrow {
  grid-area: 1 / 3;
}

/* Stacked row for the CV --------------------------------------------------- */

.card--stack {
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 1.125rem;
  row-gap: 0.3125rem;
  padding: 1.25rem 1.625rem;
}

/* Every stacked child but the arrow stays in the text column; the arrow
   spans the full card height in its own column so it sits centred on the
   card rather than pinned to the head row. */
.card--stack > *:not(.card__arrow) {
  grid-column: 1;
}

.card--stack > .card__arrow {
  grid-column: 2;
  grid-row: 1 / -1;
  align-self: center;
}

.card__stack-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.card__strapline {
  font-size: var(--fs-meta);
  color: var(--accent);
}

.card__summary {
  font-family: var(--serif);
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--ink-soft);
  text-wrap: pretty;
}

/* Plate card for the projects grid ----------------------------------------- */

.card--plate {
  padding: 0.75rem;
  align-content: start;
}

.card--plate:hover,
.card--plate:focus-visible {
  transform: translateY(-5px) rotate(-1deg);
  box-shadow: var(--shadow-lift);
}

.card__art-img {
  width: 100%;
  height: 5rem;
  object-fit: cover;
  image-rendering: pixelated;
}

.card__title {
  margin-top: 0.875rem;
  font-family: var(--serif);
  font-size: var(--fs-title);
  line-height: 1.15;
  color: var(--ink);
}

.card__kicker {
  margin-top: 0.375rem;
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--muted);
}

/* The home page's plate cards put a prose description in this slot rather
   than a short kicker label, so it reads as a sentence, not metadata. */
.card__kicker--prose {
  font-family: var(--serif);
}

.card__stamp {
  margin-top: 0.5625rem;
  font-size: var(--fs-eyebrow);
  letter-spacing: 0.12em;
  color: var(--accent);
}

/* Feature card for writing ------------------------------------------------- */

.feature-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card--feature {
  padding: 0;
  align-content: start;
}

.card--feature:hover,
.card--feature:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lift);
}

.card__banner-img {
  width: 100%;
  height: clamp(8rem, 22vw, 10.625rem);
  object-fit: cover;
  image-rendering: pixelated;
}

.card__feature-body {
  display: grid;
  gap: 0.5rem;
  padding: 1.375rem clamp(1.25rem, 4vw, 1.75rem) 1.625rem;
}

.card__meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

/* A press card's image is a real photo or a logo, not a decorative plate:
   same footprint as `card__banner-img`, but without the pixelated rendering. */
.card__photo {
  width: 100%;
  height: clamp(8rem, 22vw, 10.625rem);
  object-fit: cover;
}

.card__banner--logo {
  height: clamp(8rem, 22vw, 10.625rem);
  padding: 1.5rem;
  background: var(--surface-2);
  box-sizing: border-box;
}

/* Percentage height needs the sized box above; `contain` then keeps a tall or
   wide logo inside it either way, instead of the fixed-height crop `cover` gives. */
.card__photo--contain {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card__foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-top: 0.375rem;
  font-size: var(--fs-eyebrow);
  color: var(--faint);
}

.card__cta {
  letter-spacing: 0.1em;
  color: var(--accent);
}

.card__eyebrow {
  font-size: 0.65625rem;
  letter-spacing: var(--tracking-tight);
  text-transform: uppercase;
  color: var(--accent);
}

.card__headline {
  font-family: var(--serif);
  font-size: var(--fs-headline);
  line-height: 1.14;
  color: var(--ink);
}

/* Press card: a compact row, image on the left and meta/headline/foot
   stacked on the right, rather than the writing page's banner-on-top shape. */
.card--press {
  grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr);
}

.card--press .card__photo,
.card--press .card__banner--logo,
.card--press .card__art-img {
  height: 100%;
}

.card--press .card__headline {
  font-size: var(--fs-title);
}

.card__excerpt {
  font-family: var(--serif);
  font-size: var(--fs-sub);
  line-height: 1.55;
  color: var(--ink-soft);
  text-wrap: pretty;
}

/* CV extras ---------------------------------------------------------------- */

.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: 2.125rem;
  margin-top: 2.125rem;
}

.columns__col .eyebrow {
  margin-bottom: 0.5rem;
  letter-spacing: 0.22em;
}

/* 20rem is chosen so the 940px page holds exactly two plates, as designed,
   while a tablet still gets two and a phone drops to one. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: 1.625rem;
}

/* Footer ------------------------------------------------------------------- */

.site-footer {
  margin-top: 2.875rem;
}

.site-footer__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.625rem;
  font-size: var(--fs-small);
  color: var(--muted);
}

.page--home .site-footer__list {
  justify-content: center;
}

.site-footer__link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 2.75rem;
  padding: 0.8125rem 0;
  transition: color 0.18s;
}

.site-footer__icon {
  flex: none;
  color: var(--faint);
  transition: color 0.18s;
}

.site-footer__link:hover {
  color: var(--accent);
}

.site-footer__link:hover .site-footer__icon {
  color: var(--accent);
}

/* Narrow screens ----------------------------------------------------------- */

@media (max-width: 34rem) {
  .card--row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .card--row > .card__year {
    grid-area: 1 / 2;
  }

  .card--row > .card__role {
    grid-area: 2 / 1 / 3 / -1;
  }

  /* `.card--row` above resets the shared grid to two columns for the
     org/role/year row; `--row-wide` (honours) never has a role, so it keeps
     its own three-column track for the arrow. */
  .card--row-wide {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  /* Tighten only the padded row variants. A bare `.card` rule here would have
     the same specificity as the modifiers and, coming later, would undo the
     edge-to-edge images on `--plate` and `--feature`. */
  .card--row,
  .card--row-wide {
    padding: 1rem 1.125rem;
  }

  .card--stack {
    padding: 1.125rem 1.25rem;
  }

  .card__stack-head {
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
  }

  /* The fixed thumb column leaves too little room for the text at this
     width, so byline and CTA drop to their own line instead of squeezing
     onto the meta row. */
  .card--press {
    grid-template-columns: minmax(6rem, 7.5rem) minmax(0, 1fr);
  }

  .card--press .card__feature-body {
    padding: 0.875rem 1rem;
  }

  .card--press .card__foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
}
