/* ==========================================================================
   PeraMorphIQ - Page-specific styles
   Only rules that genuinely belong to one page or one page-level block.
   ========================================================================== */

/* ==========================================================================
   Home - hero
   A dark band. The page was previously white end to end, which read as thin
   and left the top of the landing page empty; the inverse ground gives the
   page a anchor and lets the accent register.
   ========================================================================== */

.hero {
  background-color: var(--surface-inverse);
  color: var(--ink-inverse-muted);
  padding-block: var(--space-9) 0;
  position: relative;
  overflow: hidden;
}

/* A faint mesh, echoing the Network-on-Chip work, so the dark band is not flat. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(var(--rule-inverse) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule-inverse) 1px, transparent 1px);
  background-size: 6.4rem 6.4rem;
  opacity: 0.35;
  mask-image: radial-gradient(
    ellipse 90% 70% at 70% 20%,
    var(--mask-opaque) 20%,
    transparent 75%
  );
  pointer-events: none;
}

.hero > * {
  position: relative;
}

.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: var(--space-8);
  align-items: center;
  padding-bottom: var(--space-9);
}

@media (max-width: 68em) {
  .hero__grid {
    grid-template-columns: 1fr;
    gap: var(--space-7);
  }
}

.hero__inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 72rem;
}

/* A real photograph of the group's own hardware. It carries the warmth the
   flat dark band lacked, and it is the group's work rather than stock imagery. */
.hero__media {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--rule-inverse);
}

.hero__media img {
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

/* Sink the photo very slightly into the dark ground so it reads as part of
   the band rather than a pasted-on rectangle. */
.hero__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom right,
    var(--scrim-hero) 0%,
    transparent 45%
  );
  pointer-events: none;
}

@media (max-width: 68em) {
  .hero__media img {
    aspect-ratio: 21 / 9;
  }
}

.hero__eyebrow {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--accent-on-inverse);
}

.hero__title {
  font-size: var(--text-4xl);
  line-height: 1.08;
  letter-spacing: var(--tracking-tight);
  color: var(--ink-inverse);
}

.hero__lead {
  font-size: var(--text-md);
  color: var(--ink-inverse-muted);
  max-width: var(--measure);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.hero .btn--primary {
  background-color: var(--ink-inverse);
  color: var(--ink-900);
}

.hero .btn--primary:hover {
  background-color: var(--surface);
  color: var(--ink-900);
}

.hero .btn--secondary {
  border-color: var(--rule-inverse);
  color: var(--ink-inverse);
}

.hero .btn--secondary:hover {
  border-color: var(--ink-inverse-muted);
  color: var(--ink-inverse);
}

@media (max-width: 46em) {
  .hero {
    padding-block: var(--space-7) 0;
  }
  .hero__title {
    font-size: var(--text-3xl);
  }
}

/* --- Affiliation lock-up in the hero ------------------------------------- */

.hero__affiliation {
  margin-top: var(--space-3);
  padding-top: var(--space-5);
  border-top: 1px solid var(--rule-inverse);
}

.hero__affiliation-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-inverse-muted);
  margin-bottom: var(--space-4);
}

.org-list {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-5) var(--space-8);
}

.org-list li {
  display: flex;
}

.org-list__link {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  color: inherit;
  transition: opacity var(--transition);
}

.org-list__link:hover {
  color: inherit;
  opacity: 0.75;
}

.org-list__text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.org-list__full {
  font-size: var(--text-xs);
  color: var(--ink-inverse-muted);
  line-height: var(--leading-snug);
}

/* On the dark ground the marks read in their own form - ESCAL is already
   white, and PeraCom's colour is the one spot of brand colour on the page. */
.org-list img {
  height: 2.8rem;
  width: auto;
  flex-shrink: 0;
}

.org-list__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--ink-inverse);
}

/* --- Statistics strip along the foot of the hero ------------------------- */

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--rule-inverse);
}

@media (max-width: 46em) {
  .hero-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Two columns means the third tile also begins a row, so it needs the same
     flush-left treatment as the first. Without this the lower row sits
     indented by the divider's padding. */
  .hero-stats .stat:nth-child(2n + 1) {
    border-left: none;
    padding-left: 0;
  }

  .hero-stats .stat:nth-child(n + 3) {
    border-top: 1px solid var(--rule-inverse);
  }
}

.hero-stats .stat {
  padding: var(--space-5) var(--space-5) var(--space-6);
  border-left: 1px solid var(--rule-inverse);
  gap: var(--space-1);
}

.hero-stats .stat:first-child {
  border-left: none;
  padding-left: 0;
}

.hero-stats .stat__value {
  color: var(--ink-inverse);
  font-size: var(--text-3xl);
}

.hero-stats .stat__label {
  color: var(--ink-inverse-muted);
}

/* ==========================================================================
   Home - research areas
   ========================================================================== */

.area {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-6);
  border: var(--border);
  border-radius: var(--radius);
  background-color: var(--surface);
  transition: border-color var(--transition);
}

.area:hover {
  border-color: var(--rule-strong);
}

/* --ink-300 on white is 2.5:1, below the 4.5:1 minimum for text. */
.area__index {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-500);
}

.area__title {
  font-size: var(--text-md);
}

.area__text {
  font-size: var(--text-sm);
  color: var(--ink-500);
}

.area__link {
  margin-top: auto;
  padding-top: var(--space-3);
}

/* ==========================================================================
   Home - statistics
   ========================================================================== */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-6);
}

@media (max-width: 46em) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-5);
  }
}

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.stat__value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  color: var(--ink-900);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat__label {
  font-size: var(--text-sm);
  color: var(--ink-500);
}

/* ==========================================================================
   Home - closing call to action
   ========================================================================== */

.cta {
  background-color: var(--surface-inverse);
  color: var(--ink-inverse-muted);
  padding-block: var(--space-9);
}

.cta__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-7);
  flex-wrap: wrap;
}

.cta__title {
  color: var(--ink-inverse);
  font-size: var(--text-xl);
  margin-bottom: var(--space-2);
}

.cta__text {
  font-size: var(--text-sm);
  max-width: 56ch;
}

.cta .btn--primary {
  background-color: var(--ink-inverse);
  color: var(--ink-900);
}

.cta .btn--primary:hover {
  background-color: var(--surface);
  color: var(--ink-900);
}

.cta .btn--secondary {
  border-color: var(--rule-inverse);
  color: var(--ink-inverse);
}

.cta .btn--secondary:hover {
  border-color: var(--ink-inverse-muted);
  color: var(--ink-inverse);
}

/* ==========================================================================
   Home - featured publication
   One accent-tinted band gives the middle of the page a focal point and stops
   the long light stretch between the hero and the footer.
   ========================================================================== */

.highlight {
  background-color: var(--accent-weak);
  border-block: 1px solid var(--rule);
  padding-block: var(--space-8);
}

.highlight__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-7);
  align-items: center;
}

@media (max-width: 62em) {
  .highlight__grid {
    grid-template-columns: 1fr;
    gap: var(--space-5);
  }
}

.highlight__eyebrow {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-3);
}

.highlight__title {
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
  margin-bottom: var(--space-3);
  max-width: 34ch;
}

.highlight__title a {
  color: var(--ink-900);
}

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

.highlight__authors {
  font-size: var(--text-sm);
  color: var(--ink-700);
  margin-bottom: var(--space-2);
}

.highlight__authors .is-group {
  font-weight: var(--weight-semibold);
  color: var(--ink-900);
}

/* --ink-500 on the accent-weak ground measures 4.30:1 - just under the 4.5:1
   minimum - so this band steps up to --ink-700 (8.9:1). */
.highlight__venue {
  font-size: var(--text-sm);
  color: var(--ink-700);
}

.highlight__venue em {
  font-style: italic;
}

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

.highlight__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

@media (max-width: 62em) {
  .highlight__actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

/* ==========================================================================
   Page header (interior pages)
   ========================================================================== */

.page-head {
  padding-block: var(--space-8) var(--space-7);
  border-bottom: var(--border);
}

/* The page head already ends in a rule, so a full section's top padding after
   it leaves a large empty band between two hairlines. */
.page-head + .section {
  padding-top: var(--space-5);
}

.page-head__title {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-3);
}

.page-head__lead {
  font-size: var(--text-md);
  color: var(--ink-500);
  max-width: var(--measure);
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--ink-500);
  margin-bottom: var(--space-4);
}

.breadcrumb__sep {
  color: var(--ink-300);
}

/* ==========================================================================
   Publications
   ========================================================================== */

.pub-year {
  margin-top: var(--space-8);
}

.pub-year:first-of-type {
  margin-top: 0;
}

.pub-year__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--ink-500);
  padding-bottom: var(--space-3);
  border-bottom: var(--border);
  margin-bottom: var(--space-2);
}

.pub {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: var(--space-5);
  padding-block: var(--space-5);
  border-bottom: var(--border);
}

@media (max-width: 46em) {
  .pub {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
}

.pub__aside {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: flex-start;
  min-width: 0;
}

.pub__aside .badge {
  max-width: 100%;
  white-space: normal;
}

.pub__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.pub__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

.pub__title a {
  color: var(--ink-900);
}

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

.pub__authors {
  font-size: var(--text-sm);
  color: var(--ink-700);
}

/* Group members are emphasised - the standard convention on lab pages. */
.pub__authors .is-group {
  font-weight: var(--weight-semibold);
  color: var(--ink-900);
}

.pub__venue {
  font-size: var(--text-sm);
  color: var(--ink-500);
}

.pub__venue em {
  font-style: italic;
}

.pub__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-2);
  font-size: var(--text-xs);
}

.pub__actions a,
.pub__actions button {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--accent);
}

.pub__actions button:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.pub__abstract {
  font-size: var(--text-sm);
  color: var(--ink-500);
  margin-top: var(--space-2);
  padding-left: var(--space-4);
  border-left: 2px solid var(--rule);
}

/* Compact variant used on the home page */
.pub--compact {
  grid-template-columns: 1fr;
  gap: var(--space-2);
}

.pub--compact .pub__aside {
  flex-direction: row;
  align-items: center;
}

/* ==========================================================================
   Project detail
   ========================================================================== */

.project-hero {
  padding-block: var(--space-7) var(--space-6);
  border-bottom: var(--border);
}

.project-hero__title {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-4);
  max-width: 24ch;
}

.project-hero__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.project-hero__summary {
  font-size: var(--text-md);
  color: var(--ink-700);
  max-width: var(--measure);
}

.project-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26rem;
  gap: var(--space-8);
  align-items: start;
  padding-block: var(--space-7);
}

@media (max-width: 62em) {
  .project-layout {
    grid-template-columns: 1fr;
    gap: var(--space-7);
  }
}

.project-aside {
  position: sticky;
  top: calc(var(--header-h) + var(--space-5));
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-5);
  border: var(--border);
  border-radius: var(--radius);
  background-color: var(--surface-2);
}

@media (max-width: 62em) {
  .project-aside {
    position: static;
  }
}

.aside-block__title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-500);
  margin-bottom: var(--space-3);
}

.aside-block ul {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.project-section + .project-section {
  margin-top: var(--space-7);
}

.project-section__title {
  font-size: var(--text-xl);
  padding-bottom: var(--space-3);
  border-bottom: var(--border);
  margin-bottom: var(--space-5);
}

.project-section p {
  max-width: var(--measure);
}

.project-section p + p {
  margin-top: var(--space-4);
}

.project-section ul.bullets {
  list-style: disc;
  padding-left: var(--space-5);
  max-width: var(--measure);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.project-section ul.bullets li {
  padding-left: var(--space-1);
}

.figure {
  margin-top: var(--space-5);
}

.figure img {
  width: 100%;
  border: var(--border);
  border-radius: var(--radius);
  background-color: var(--surface-2);
  cursor: zoom-in;
}

.figure figcaption {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--ink-500);
}

.figure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(24rem, 1fr));
  gap: var(--space-5);
  margin-top: var(--space-5);
}

.figure-grid .figure {
  margin-top: 0;
}

/* ==========================================================================
   News
   ========================================================================== */

.article {
  padding-block: var(--space-7);
}

.article__title {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-4);
}

.article__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--ink-500);
  padding-bottom: var(--space-5);
  border-bottom: var(--border);
  margin-bottom: var(--space-6);
}

.article__body {
  max-width: var(--measure);
  font-size: var(--text-md);
}

.article__body p + p {
  margin-top: var(--space-5);
}

.article__lead {
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
  color: var(--ink-900);
  margin-bottom: var(--space-6);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-7);
}

.gallery img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  border: var(--border);
  cursor: zoom-in;
  transition: opacity var(--transition);
}

.gallery img:hover {
  opacity: 0.88;
}

/* ==========================================================================
   News - list rows (home page)
   A three-column card grid looks broken when only one item exists; these rows
   read correctly at any count.
   ========================================================================== */

.news-row {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: var(--space-5);
  padding-block: var(--space-5);
  border-bottom: var(--border);
}

.news-row:first-child {
  border-top: var(--border);
}

@media (max-width: 46em) {
  .news-row {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }
}

.news-row__date {
  font-size: var(--text-sm);
  color: var(--ink-500);
  font-variant-numeric: tabular-nums;
}

.news-row__title {
  font-size: var(--text-md);
  line-height: var(--leading-snug);
  margin-bottom: var(--space-2);
}

.news-row__title a {
  color: var(--ink-900);
}

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

.news-row__text {
  font-size: var(--text-sm);
  color: var(--ink-500);
  max-width: var(--measure);
}

/* ==========================================================================
   Article resources (slide decks, reports, off-site coverage)
   ========================================================================== */

.resources {
  margin-top: var(--space-8);
  padding: var(--space-5);
  border: var(--border);
  border-radius: var(--radius);
  background-color: var(--surface-2);
  max-width: var(--measure);
}

.resources__title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-500);
  margin-bottom: var(--space-4);
}

.resources__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.resources__list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

.resources__list a {
  font-weight: var(--weight-medium);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.resource__meta {
  font-size: var(--text-xs);
  color: var(--ink-500);
}

/* ==========================================================================
   Contact
   ========================================================================== */

.contact-layout {
  display: grid;
  grid-template-columns: 1fr 34rem;
  gap: var(--space-8);
  align-items: start;
}

@media (max-width: 62em) {
  .contact-layout {
    grid-template-columns: 1fr;
  }
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.contact-form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

@media (max-width: 46em) {
  .contact-form__row {
    grid-template-columns: 1fr;
  }
}

.info-block {
  padding: var(--space-5);
  border: var(--border);
  border-radius: var(--radius);
  background-color: var(--surface-2);
}

.info-block + .info-block {
  margin-top: var(--space-4);
}

.info-block__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-500);
  margin-bottom: var(--space-2);
}

.info-block__value {
  font-size: var(--text-sm);
  color: var(--ink-700);
  line-height: var(--leading-normal);
}

.form-status {
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: var(--border);
  background-color: var(--surface-2);
}

.form-status[data-state="error"] {
  border-color: var(--ink-300);
  color: var(--ink-900);
}

/* ==========================================================================
   Tools page (content authoring helper)
   ========================================================================== */

.tool-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-7);
  align-items: start;
}

@media (max-width: 62em) {
  .tool-layout {
    grid-template-columns: 1fr;
  }
}

.tool-output {
  position: sticky;
  top: calc(var(--header-h) + var(--space-5));
}

.tool-output pre {
  background-color: var(--surface-2);
  border: var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
  max-height: 52vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.repeater__item {
  border: var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.repeater__item + .repeater__item {
  margin-top: var(--space-3);
}

.repeater__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.validate-row {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: var(--border);
  font-size: var(--text-sm);
}

.validate-row__badge {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-500);
}
