/*
 * Public mobile and tablet alignment layer.
 * Loaded after route-specific styles so CMS content follows one responsive rule.
 */
@media (max-width: 1024px) {
  #main-content,
  .site-footer {
    text-align: center;
  }

  #main-content :where(section, article, div, header, footer, aside, nav,
    h1, h2, h3, h4, p, span, a, li, dt, dd, blockquote, figcaption) {
    text-align: center;
  }

  #main-content :where(h1, h2, h3, h4, p, blockquote),
  #main-content :where(.reference-hero__content, .hero-credibility, .story-section__content,
    .about-hero__content, .about-section-intro, .about-copy, .about-closing__content,
    .page-intro__copy, .detail-deck, .conference-section__intro, .reading-copy,
    .blog-article-copy, .community-story-reading) {
    margin-inline: auto;
  }

  #main-content :where(.page-kicker, .item-meta, .page-jumps, .filter-list, .breadcrumbs,
    .topic-tags, .contact-social__links, .event-links, .blog-article-byline,
    .blog-author-row__byline, .blog-author-row__footer > div, .conversation-count,
    .hero-credibility__items, .reference-hero__action, .about-closing__actions,
    .about-inline-links, .facts-links, .page-closing__actions) {
    justify-content: center;
  }

  #main-content :where(.reference-hero__visual, .reference-hero__portrait,
    .story-section__image, .about-hero__visual, .about-hero__image,
    .community-story-image, .blog-article-image, figure, .media) {
    margin-inline: auto;
  }

  #main-content :where(.reference-hero__content, .story-section__content,
    .about-hero__content, .page-intro__copy, .portfolio-card__body,
    .story-feature__body, .article-feature__body, .conference-card,
    .community-story-card__body, .facts-panel, .sidebar-card,
    .blog-author-row__body, .blog-author-card__content, .comment-body,
    .comment-composer, .page-closing__panel) {
    align-items: center;
  }

  #main-content .reference-hero__visual {
    margin-inline: auto;
  }

  #main-content .reference-hero__content,
  #main-content .hero-credibility {
    max-width: 680px;
  }

  #main-content .reference-hero__copy,
  #main-content .reference-hero__title,
  #main-content .page-intro h1,
  #main-content .detail-banner h1,
  #main-content .community-story-hero h1,
  #main-content .blog-article-hero h1 {
    margin-inline: auto;
  }

  #main-content .content-cover {
    align-items: center;
  }

  #main-content .content-cover__label,
  #main-content .content-cover__title {
    max-width: min(100%, 22ch);
  }

  #main-content .content-cover__signature,
  #main-content .card-action,
  #main-content .community-story-card__action,
  #main-content .section-top,
  #main-content .form-footer,
  #main-content .comment-list article header,
  #main-content .comment-body header {
    justify-content: center;
  }

  #main-content .section-top,
  #main-content .form-footer {
    align-items: center;
  }

  #main-content .section-top {
    flex-direction: column;
  }

  #main-content .content-cover__signature,
  #main-content .card-action,
  #main-content .community-story-card__action {
    width: 100%;
  }

  #main-content :where(.publication-entry__meta, .conference-card__top,
    .community-story-hero__meta, .blog-article-hero__meta,
    .blog-author-row__footer, .comment-list article header,
    .comment-body header, .blog-like) {
    justify-content: center;
    align-items: center;
  }

  #main-content .record > .text-link,
  #main-content .publication-entry > .text-link {
    justify-self: center;
  }

  #main-content .about-hero__nav,
  #main-content .about-anchor-nav,
  #main-content .about-inline-links,
  #main-content .page-closing__actions {
    align-items: center;
  }

  #main-content :where(ul, ol) {
    list-style-position: inside;
  }

  #main-content .contact-topics li {
    justify-content: center;
    gap: 18px;
  }

  #main-content :where(label, legend, .form-label) {
    text-align: center;
  }

  #main-content :where(input, textarea, select) {
    text-align: left;
  }

  #main-content :where(.reading-copy, .about-reading, .story-feature__content > p) {
    width: 100%;
    max-width: 68ch;
    margin-inline: auto;
  }

  #main-content :where(.reading-copy, .about-reading) :where(ul, ol) {
    padding-inline-start: 0;
    list-style-position: inside;
  }

  #main-content .blog-author-row__portrait,
  #main-content .comment-avatar,
  #main-content .record__mark {
    margin-inline: auto;
  }

  .site-footer .site-footer__grid {
    justify-items: center;
  }

  .site-footer .site-footer__intro,
  .site-footer .site-footer__column {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .site-footer .site-footer__about,
  .site-footer .site-footer__descriptor {
    margin-inline: auto;
  }

  .site-footer .site-footer__links,
  .site-footer .site-footer__social-links,
  .site-footer .site-footer__meta-links {
    justify-content: center;
    align-items: center;
  }

  .site-footer .site-footer__meta {
    justify-content: center;
    text-align: center;
  }

  #main-content .recent-activity-grid:has(> .recent-activity-card:only-child) {
    grid-template-columns: minmax(0, 620px);
    justify-content: center;
  }
}

/* Tablet and mobile presentation: centred related work and a focused hero portrait. */
@media (max-width: 1024px) {
  #main-content .interior .related-section {
    text-align: center;
  }

  #main-content .interior .related-section .grid {
    justify-items: stretch;
  }

  #main-content .interior .related-section .card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  #main-content .interior .related-section :is(.tag, .card__title, .card__body) {
    align-self: center;
    margin-inline: auto;
    text-align: center;
  }

  #main-content .homepage .reference-hero__visual {
    width: min(62vw, 320px);
    min-width: 0;
    margin-inline: auto;
  }

  #main-content .homepage .reference-hero__portrait.media--4x5 {
    aspect-ratio: 1;
    overflow: hidden;
    border: 7px solid #fff;
    border-radius: 50%;
    background: #e8e2d7;
    box-shadow: 0 18px 42px rgba(25, 30, 34, .16);
  }

  #main-content .homepage .reference-hero__portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 18%;
  }

  #main-content .homepage .story-single-visual {
    width: min(100%, 460px);
    max-width: 460px;
    height: auto;
    aspect-ratio: auto;
    margin-inline: auto;
  }

  #main-content .homepage .story-single-visual img {
    display: block;
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
    object-position: center;
  }
}

@media (max-width: 900px) {
  #main-content .publication-list {
    display: grid;
    gap: 18px;
    border-top: 0;
  }

  #main-content .publication-entry {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 14px;
    padding: 28px 26px;
    border: 1px solid var(--page-line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(35, 37, 32, .045);
  }

  #main-content .publication-entry__meta {
    grid-column: auto;
    flex-direction: row;
    justify-content: center;
    gap: 8px 16px;
    width: 100%;
    margin-bottom: 2px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--page-line);
  }

  #main-content .publication-entry__publisher-logo {
    justify-content: center;
    width: 100%;
  }

  #main-content .publication-entry__publisher-logo img {
    object-position: center;
  }

  #main-content .publication-entry > div {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  #main-content .publication-entry h3,
  #main-content .publication-entry__summary {
    max-width: 58ch;
  }

  #main-content .publication-entry .circle-arrow {
    display: inline-flex;
    width: auto;
    min-width: 168px;
    height: 42px;
    margin-top: 4px;
    padding-inline: 16px;
    gap: 10px;
    border-radius: 7px;
    font-size: .85rem;
    font-weight: 600;
  }

  #main-content .publication-entry .circle-arrow::before {
    content: "Read publication";
  }

  #main-content .conference-grid > .conference-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    justify-self: center;
    width: min(100%, 720px);
  }
}

@media (max-width: 767px) {
  #main-content .interior > .page-intro + .content-section {
    padding-top: 24px;
  }

  #main-content .interior > .page-intro + .content-section > .container > .section-top,
  #main-content .community-journal #initiatives > .container > .section-top,
  #main-content .blog-journal--author-list .blog-section-heading,
  #main-content .case-studies .blog-section-heading {
    display: none;
  }

  #main-content .community-journal #initiatives,
  #main-content .blog-journal--author-list .blog-archive,
  #main-content .case-studies .blog-archive {
    padding-top: 24px;
  }

  #main-content .community-journal .community-intro-strip {
    display: none;
  }

  #main-content .projects-index-page #all-projects {
    padding-top: 24px;
  }

  #main-content .projects-index-page #all-projects > .container > .section-top,
  #main-content .projects-index-page #all-projects > .container > .filter-list {
    display: none;
  }

  #main-content .reference-hero__visual,
  #main-content .story-section__image {
    margin-inline: auto;
  }

  #main-content .homepage .reference-intro,
  #main-content .story-section__intro,
  #main-content .reference-grid-section__intro,
  #main-content .research-showcase__intro,
  #main-content .posts-section__intro {
    text-align: center;
  }

  #main-content .publication-entry,
  #main-content .record,
  #main-content .blog-author-row {
    justify-items: center;
  }

  #main-content .open-source-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 52px;
    max-width: 560px;
  }

  #main-content .open-source-card,
  #main-content .open-source-card__content {
    align-items: center;
  }

  #main-content .open-source-card__image {
    width: 100%;
  }

  #main-content .open-source-card__summary {
    margin-inline: auto;
  }

  #main-content .open-source-card__link {
    align-self: center;
    min-height: 40px;
  }

  #main-content .recent-activity-card {
    overflow: hidden;
    border: 1px solid #dedbd2;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(35, 37, 32, .045);
  }

  #main-content .recent-activity-card__image {
    margin-bottom: 0;
  }

  #main-content .recent-activity-card__content {
    padding: 24px 20px 26px;
  }

  #main-content .publication-entry {
    padding: 24px 20px;
  }

  #main-content .publication-entry__meta {
    flex-direction: column;
    gap: 7px;
  }

  #main-content .publication-entry h3 {
    font-size: 1.35rem;
  }

  #main-content .conference-grid > .conference-card:last-child:nth-child(odd) {
    grid-column: auto;
    width: 100%;
  }

  #main-content :where(.reading-copy, .about-reading, .story-feature__content > p) {
    font-size: max(.98rem, 16px);
    line-height: 1.75;
  }

  #main-content .detail-narrative > h2,
  #main-content .community-story-reading > h2,
  #main-content .case-study-story__content > h2 {
    text-align: center;
  }

  #main-content .publication-entry__meta,
  #main-content .blog-author-row__footer,
  #main-content .blog-like,
  #main-content .comment-list article header,
  #main-content .comment-body header {
    flex-direction: column;
  }

  #main-content .page-closing__actions,
  #main-content .form-footer {
    width: 100%;
  }

  #main-content .page-closing__actions :where(.btn, .text-link),
  #main-content .form-footer .btn {
    width: min(100%, 360px);
    margin-inline: auto;
  }

  .site-footer .site-footer__meta {
    align-items: center;
  }
}

/* Single-post pages: on tablet and mobile the article and its closing sidebar
   read left-aligned (the site-wide centring above is for landing pages).
   Only pictures stay centred. */
@media (max-width: 1024px) {
  #main-content :is(.detail-narrative, .facts-panel, .blog-article-reading, .blog-article-aside,
    .community-story-reading, .community-story-aside, .case-study-story__content),
  #main-content :is(.detail-narrative, .facts-panel, .blog-article-reading, .blog-article-aside,
    .community-story-reading, .community-story-aside, .case-study-story__content) * {
    text-align: left;
  }

  #main-content :is(.detail-narrative, .facts-panel, .blog-article-reading, .blog-article-aside,
    .community-story-reading, .community-story-aside, .case-study-story__content)
    :is(.facts-panel, .facts-panel__details, .sidebar-card, .blog-author-card__content, .external-resources) {
    align-items: stretch;
  }

  #main-content :is(.facts-panel, .blog-article-aside, .community-story-aside) :is(.topic-tags, .blog-topic-list, .facts-links, .page-kicker) {
    justify-content: flex-start;
  }

  #main-content .facts-panel,
  #main-content .blog-article-aside,
  #main-content .community-story-aside {
    align-items: start;
  }

  #main-content :is(.detail-narrative, .blog-article-reading, .community-story-reading, .case-study-story__content) .reading-copy :is(ul, ol) {
    padding-inline-start: 1.4em;
    list-style-position: outside;
  }

  #main-content :is(.detail-narrative, .blog-article-reading, .community-story-reading, .case-study-story__content) :is(img, video, figure, .content-image, .media) {
    margin-inline: auto;
  }
}

@media (max-width: 1024px) {
  #main-content .detail-narrative > h2,
  #main-content .community-story-reading > h2,
  #main-content .case-study-story__content > h2 {
    text-align: left;
  }
}

/* Homepage on tablet and mobile: section labels and headings stay centred,
   body copy and card content read left-aligned. My Story stacks as
   label, heading, photo, then text (display: contents lets the photo sit
   between the heading and the text without changing the markup). */
@media (max-width: 1024px) {
  #main-content .homepage .story-panel__grid {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  #main-content .homepage .story-panel__content {
    display: contents;
  }

  #main-content .homepage .story-panel__eyebrow {
    order: 1;
    align-self: center;
    justify-content: center;
  }

  #main-content .homepage .story-panel__title {
    order: 2;
    max-width: 30ch;
    margin-inline: auto;
    text-align: center;
  }

  #main-content .homepage .story-panel__visual {
    order: 3;
    position: static;
    width: 100%;
    max-width: 360px;
    margin: 32px auto;
  }

  #main-content .homepage .story-panel__text {
    order: 4;
    width: 100%;
    max-width: 68ch;
    margin: 0 auto;
    text-align: left;
  }

  #main-content .homepage .story-panel__facts {
    order: 5;
    width: 100%;
    max-width: 68ch;
    margin-inline: auto;
  }

  #main-content .homepage .story-panel__link {
    order: 6;
    align-self: center;
  }

  #main-content .homepage :is(.recent-activity__intro, .open-source-section__intro,
    .footer-cta__eyebrow, .footer-cta__title) {
    text-align: center;
  }

  #main-content .homepage :is(.recent-activity-card__content, .open-source-card__content),
  #main-content .homepage :is(.recent-activity-card__content, .open-source-card__content) *,
  #main-content .homepage .footer-cta__copy {
    text-align: left;
  }

  #main-content .homepage :is(.open-source-card, .open-source-card__content, .recent-activity-card__content, .editorial-item) {
    align-items: stretch;
  }

  #main-content .homepage :is(.open-source-card__meta, .editorial-item) {
    justify-content: flex-start;
  }

  #main-content .homepage .open-source-card__summary {
    margin-inline: 0;
  }

  #main-content .homepage .open-source-card__link {
    align-self: flex-start;
  }
}

/* Listing cards (recognition, judging & speaking, community) read left-aligned
   on tablet and mobile, the same as desktop. Images keep their own layout. */
@media (max-width: 1024px) {
  #main-content :is(.honours-award__content, .honours-mention, .judging-card, .talk-card__content, .community-story-card__body),
  #main-content :is(.honours-award__content, .honours-mention, .judging-card, .talk-card__content, .community-story-card__body) * {
    text-align: left;
  }

  #main-content :is(.honours-award__content, .honours-mention, .honours-mention__footer, .community-story-card__body, .judging-card, .talk-card__content) {
    align-items: stretch;
  }

  #main-content :is(.honours-award__content, .honours-mention, .judging-card, .talk-card__content, .community-story-card__body,
    .homepage .open-source-card__content, .homepage .recent-activity-card__content) :is(h2, h3, h4, p, blockquote) {
    margin-inline: 0;
  }

  #main-content :is(.honours-award__meta, .honours-mention__footer) {
    align-items: flex-start;
    justify-content: flex-start;
  }

  #main-content :is(.honours-mention__type, .community-story-card__body .item-meta) {
    justify-content: flex-start;
  }

  #main-content .honours-mention__top {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
  }

  #main-content .honours-mention__mark {
    margin-inline: 0;
  }

  #main-content .honours-mention__number {
    margin-left: auto;
  }

  #main-content :is(.judging-card__masthead, .talk-card__top) {
    justify-content: space-between;
  }

  #main-content .honours-links {
    align-items: stretch;
  }

  #main-content .honours-links a {
    max-width: none;
  }
}

/* Remaining content cards (projects, publications, conference presentations,
   education, case studies, related content) read left-aligned on tablet and
   mobile. Card content only: section headings and panels keep their layout. */
@media (max-width: 1024px) {
  #main-content :is(.portfolio-card, .publication-entry, .conference-card__content, .story-feature__body, .blog-story-card, .related-section .card),
  #main-content :is(.portfolio-card, .publication-entry, .conference-card__content, .story-feature__body, .blog-story-card, .related-section .card) * {
    text-align: left;
  }

  #main-content :is(.portfolio-card, .publication-entry, .conference-card__content, .story-feature__body, .blog-story-card, .related-section .card) :is(h2, h3, h4, p) {
    margin-inline: 0;
  }

  #main-content :is(.portfolio-card__body, .story-feature__body, .blog-story-card__body, .conference-card__content),
  #main-content .interior .related-section .card {
    align-items: stretch;
  }

  #main-content .publication-entry {
    justify-items: stretch;
  }

  #main-content :is(.portfolio-card, .publication-entry, .story-feature__body, .blog-story-card, .related-section .card) :is(.item-meta, .blog-story-meta, .topic-tags),
  #main-content :is(.publication-entry__meta, .conference-card__location) {
    justify-content: flex-start;
  }

  #main-content .publication-entry__meta {
    align-items: flex-start;
  }

  #main-content .interior .related-section .card,
  #main-content .interior .related-section :is(.tag, .card__title, .card__body) {
    text-align: left;
  }

  #main-content .interior .related-section :is(.tag, .card__title, .card__body) {
    align-self: flex-start;
    margin-inline: 0;
  }

  #main-content :is(.portfolio-card, .blog-story-card, .story-feature__body, .related-section .card) .card-action {
    justify-content: space-between;
  }

  #main-content .publication-entry > div {
    align-items: flex-start;
  }

  #main-content .publication-entry .publication-entry__publisher-logo {
    justify-content: flex-start;
  }

  #main-content .publication-entry .publication-entry__publisher-logo img {
    object-position: left center;
  }

  /* Conference cards: calmer on small screens. The conference name drops the
     heavy uppercase treatment, the description steps down to body size, and the
     "Official conference page" label goes (the button already says it). */
  #main-content .conference-card__organisation {
    margin-top: 6px;
    color: var(--page-muted);
    font-size: .8rem;
    font-weight: 500;
    letter-spacing: 0;
    line-height: 1.45;
    text-transform: none;
  }

  #main-content .conference-card__description,
  #main-content .conference-card__description p {
    font-size: .9rem;
    line-height: 1.65;
  }

  #main-content .conference-card__official {
    display: none;
  }

  #main-content .conference-card__footer {
    justify-content: flex-start;
  }
}
