/* ===========================================================================
   SECOMMS — Secure Communications, Università Politecnica delle Marche
   Visual identity
   ---------------------------------------------------------------------------
   Direction: a precise, technical "secure channel" aesthetic grounded in the
   group's own material — error-correcting codes. Signal indigo on cool paper,
   IBM Plex for body/data, Space Grotesk for display, and a sparse parity-check
   matrix (H·eᵀ = s) as the signature motif.
   =========================================================================== */

:root {
  --bg:          #F5F6FA;
  --surface:     #FFFFFF;
  --ink:         #10172A;
  --ink-2:       #283150;
  --muted:       #5E6A82;
  --line:        #E3E7F0;
  --line-strong: #CDD4E4;
  --accent:      #2B36D9;
  --accent-press:#1B23A6;
  --accent-soft: rgba(43, 54, 217, 0.07);
  --signal:      #E0901B;   /* "set bit" — used sparingly */

  --maxw: 1140px;
  --gutter: clamp(20px, 5vw, 56px);
  --radius: 12px;

  --f-display: "Space Grotesk", "IBM Plex Sans", system-ui, sans-serif;
  --f-body:    "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --f-mono:    "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
}

/* ---- reset --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 700; line-height: 1.1; color: var(--ink); margin: 0; letter-spacing: -0.01em; }

/* ---- layout helpers ------------------------------------------------------ */
.wrap { max-width: var(--maxw); margin: 0 auto; padding-inline: var(--gutter); }
.section { padding-block: clamp(48px, 7vw, 88px); }
.section--tight { padding-block: clamp(32px, 4vw, 52px); }
.eyebrow {
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 14px;
  display: flex; align-items: center; gap: 10px;
}
.eyebrow::before {
  content: ""; width: 22px; height: 1px; background: var(--accent); display: inline-block;
}
.lead { font-size: clamp(17px, 1.4vw, 19px); color: var(--ink-2); max-width: 60ch; }

/* =====================  HEADER / NAV  ===================================== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; min-height: 66px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand:hover { text-decoration: none; }
.brand__mark { width: 30px; height: 30px; flex: none; }
.brand__name {
  font-family: var(--f-display); font-weight: 700; font-size: 17px;
  color: var(--ink); letter-spacing: 0.01em;
}
.brand__sub {
  display: block; font-family: var(--f-mono); font-size: 10.5px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 400;
}
.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  font-family: var(--f-mono); font-size: 13px; letter-spacing: 0.02em;
  color: var(--ink-2); padding: 8px 12px; border-radius: 8px;
}
.nav a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.nav a.is-active { color: var(--accent); }
.nav a.is-active::after {
  content: ""; display: block; height: 2px; background: var(--accent);
  margin-top: 5px; border-radius: 2px;
}
.nav-toggle {
  display: none; background: none; border: 1px solid var(--line-strong);
  border-radius: 8px; width: 42px; height: 38px; cursor: pointer; color: var(--ink);
}
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after {
  content: ""; display: block; width: 18px; height: 2px; background: currentColor;
  margin: 0 auto; position: relative; transition: .2s;
}
.nav-toggle span::before { position: absolute; top: -6px; }
.nav-toggle span::after  { position: absolute; top: 6px; }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .nav {
    position: absolute; top: 66px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding: 8px var(--gutter) 16px; display: none;
  }
  .nav.is-open { display: flex; }
  .nav a { padding: 12px 8px; border-radius: 0; border-bottom: 1px solid var(--line); }
  .nav a.is-active::after { display: none; }
}

/* =====================  HERO (home)  ====================================== */
.hero { padding-block: clamp(40px, 6vw, 80px) clamp(36px, 5vw, 64px); }
.hero__grid {
  display: grid; grid-template-columns: 1.15fr 0.85fr; gap: clamp(28px, 4vw, 64px);
  align-items: center;
}
.hero__title {
  font-size: clamp(40px, 6.4vw, 76px); line-height: 0.98; letter-spacing: -0.025em;
  margin: 6px 0 0;
}
.hero__title .accent { color: var(--accent); }
.hero__lead { margin-top: 22px; font-size: clamp(17px, 1.5vw, 20px); color: var(--ink-2); max-width: 46ch; }
.hero__meta {
  margin-top: 26px; display: flex; flex-wrap: wrap; gap: 10px;
  font-family: var(--f-mono); font-size: 12px; color: var(--muted);
}
.hero__meta span {
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 5px 12px;
  background: var(--surface);
}
.hero__cta { margin-top: 30px; display: flex; flex-wrap: wrap; gap: 12px; }

/* signature: parity-check matrix panel */
.matrix-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
  box-shadow: 0 1px 0 var(--line), 0 24px 48px -34px rgba(16,23,42,.5);
}
.matrix-panel__cap {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 14px;
}
#matrix { width: 100%; height: auto; display: block; }
.matrix-panel__eq {
  margin-top: 14px; font-family: var(--f-mono); font-size: 13px; color: var(--ink-2);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.matrix-panel__eq b { color: var(--accent); font-weight: 500; }

@media (max-width: 820px) {
  .hero__grid { grid-template-columns: 1fr; }
  .matrix-panel { order: -1; max-width: 420px; }
}

/* =====================  BUTTONS  ========================================== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--f-mono); font-size: 13px; letter-spacing: 0.02em;
  padding: 11px 18px; border-radius: 9px; border: 1px solid transparent; cursor: pointer;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-press); }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }

/* =====================  PAGE HEADER (interior)  =========================== */
.page-head { padding-block: clamp(40px, 6vw, 72px) clamp(20px, 3vw, 36px); }
.page-head__title { font-size: clamp(34px, 5vw, 54px); letter-spacing: -0.02em; }
.page-head__lead { margin-top: 18px; }

/* =====================  SECTION TITLE  ==================================== */
.s-head { margin-bottom: 28px; }
.s-head__title { font-size: clamp(22px, 2.6vw, 30px); }

/* =====================  TOPIC CARDS  ====================================== */
.topics {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px;
}
.topic {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px 22px; overflow: hidden;
  transition: border-color .18s, transform .18s;
}
.topic:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.topic__code {
  position: absolute; top: 16px; right: 18px; font-family: var(--f-mono);
  font-size: 12px; letter-spacing: 0.14em; color: var(--accent);
}
.topic__title { font-size: 20px; margin-bottom: 10px; padding-right: 48px; }
.topic__summary { font-size: 15px; color: var(--muted); line-height: 1.6; margin: 0; }
.topic__tags { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-family: var(--f-mono); font-size: 11px; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; background: var(--bg);
}

/* =====================  PEOPLE  =========================================== */
.people-group { margin-top: 8px; }
.people-group + .people-group { margin-top: 44px; }
.people-group__label {
  font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 18px; padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
.people {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(244px, 1fr)); gap: 16px;
}
.person {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 4px;
  transition: border-color .18s, transform .18s;
}
.person:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.person--lead { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.person__avatar {
  width: 44px; height: 44px; border-radius: 10px; background: var(--accent-soft);
  color: var(--accent); display: grid; place-items: center; font-family: var(--f-display);
  font-weight: 700; font-size: 17px; margin-bottom: 8px;
}
.person__name { font-family: var(--f-display); font-weight: 700; font-size: 18px; }
.person__role { font-size: 13.5px; color: var(--muted); }
.person__links { margin-top: 12px; display: flex; gap: 14px; }
.person__links a {
  font-family: var(--f-mono); font-size: 12px; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 5px;
}
.person__links a:hover { color: var(--accent); text-decoration: none; }

/* =====================  PUBLICATIONS  ===================================== */
.pub-toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-bottom: 26px; padding: 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.pub-toolbar input, .pub-toolbar select {
  font-family: var(--f-body); font-size: 14px; color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 9px 12px; background: var(--bg);
}
.pub-toolbar input { flex: 1 1 220px; }
.pub-toolbar input:focus, .pub-toolbar select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.pub-count { font-family: var(--f-mono); font-size: 12px; color: var(--muted); margin-left: auto; }

.pub-year {
  font-family: var(--f-display); font-weight: 700; font-size: 22px; color: var(--ink);
  margin: 34px 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--ink);
  display: flex; align-items: baseline; justify-content: space-between;
}
.pub-year span { font-family: var(--f-mono); font-size: 12px; font-weight: 400; color: var(--muted); }

.pub {
  display: grid; grid-template-columns: auto 1fr; gap: 16px;
  padding: 16px 0; border-bottom: 1px solid var(--line);
}
.pub__type {
  font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); border: 1px solid var(--accent); border-radius: 5px;
  padding: 3px 6px; height: fit-content; white-space: nowrap;
}
.pub__type[data-t="i"] { color: var(--signal); border-color: var(--signal); } /* informal / preprint */
.pub__title { font-weight: 600; color: var(--ink); }
.pub__authors { font-size: 14.5px; color: var(--muted); margin-top: 3px; }
.pub__authors .me { color: var(--ink); font-weight: 600; }
.pub__venue { font-family: var(--f-mono); font-size: 12.5px; color: var(--ink-2); margin-top: 5px; }
.pub__links { margin-top: 8px; display: flex; gap: 14px; }
.pub__links a { font-family: var(--f-mono); font-size: 12px; }

/* =====================  PROJECTS  ========================================= */
.project {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(22px, 3vw, 34px); margin-bottom: 22px;
}
.project--lead { border-left: 4px solid var(--accent); }
.project__top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; }
.project__name { font-family: var(--f-display); font-weight: 700; font-size: clamp(24px, 3vw, 34px); }
.project__status {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.project__title { font-size: 17px; color: var(--ink-2); margin-top: 6px; font-weight: 400; font-family: var(--f-body); line-height: 1.4; }
.project__summary { color: var(--muted); margin-top: 16px; }
.project__meta {
  margin-top: 22px; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.project__meta div { background: var(--surface); padding: 12px 16px; }
.project__meta dt { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.project__meta dd { margin: 4px 0 0; font-size: 14.5px; color: var(--ink); }
.project__link { margin-top: 20px; }

/* ---- project partners: clean tag list + collapsible overflow ------------ */
.project__partners { margin-top: 22px; }
.project__partners-label {
  display: block;
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 10px;
}
.partner-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.partner-tag {
  font-family: var(--f-mono); font-size: 12.5px; color: var(--ink-2);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 12px; line-height: 1.3;
}
.partner-more { margin-top: 10px; }
.partner-more summary {
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--f-mono); font-size: 12.5px; color: var(--accent);
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}
.partner-more summary::-webkit-details-marker { display: none; }
.partner-more summary::marker { content: ""; }
.partner-more summary::before {
  content: "▸";
  display: inline-block;
  transition: transform .15s ease;
  font-size: 10px;
  color: var(--accent);
}
.partner-more[open] summary::before { transform: rotate(90deg); }
.partner-more summary:hover { color: var(--accent-press); }
.partner-more summary:hover::before { color: var(--accent-press); }
.partner-list--expanded { margin-top: 10px; }

/* =====================  REPOSITORIES  ===================================== */
.repos { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.repo {
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
  transition: border-color .18s, transform .18s;
}
.repo:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.repo__name { font-family: var(--f-mono); font-weight: 500; font-size: 16px; color: var(--accent); word-break: break-word; }
.repo__desc { font-size: 14px; color: var(--muted); margin-top: 8px; flex: 1; }
.repo__foot { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 14px; font-family: var(--f-mono); font-size: 12px; color: var(--ink-2); }
.repo__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); display: inline-block; margin-right: 5px; vertical-align: middle; }

/* =====================  CONTACTS  ========================================= */
.contact-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: clamp(24px, 4vw, 56px); align-items: start; }
.contact-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; }
.contact-row { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.contact-row:last-child { border-bottom: 0; }
.contact-row dt { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); min-width: 96px; padding-top: 2px; }
.contact-row dd { margin: 0; }
.map-embed { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; min-height: 320px; }
.map-embed iframe { width: 100%; height: 100%; min-height: 320px; border: 0; display: block; }
@media (max-width: 760px) { .contact-grid { grid-template-columns: 1fr; } }

/* =====================  STATE / FALLBACK MESSAGES  ======================== */
.state { padding: 28px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); font-size: 14.5px; background: var(--surface); }
.state b { color: var(--ink); }
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--line-strong); border-top-color: var(--accent);
  border-radius: 50%; display: inline-block; vertical-align: -3px; margin-right: 8px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================  FOOTER  =========================================== */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 40px; }
.site-footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 24px; padding-block: 36px; }
.site-footer__brand { max-width: 36ch; }
.site-footer__brand p { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.site-footer__cols { display: flex; gap: 48px; flex-wrap: wrap; }
.site-footer__col h4 { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 400; margin-bottom: 10px; }
.site-footer__col a { display: block; font-size: 14px; color: var(--ink-2); padding: 3px 0; }
.site-footer__col a:hover { color: var(--accent); text-decoration: none; }
.site-footer__legal { border-top: 1px solid var(--line); padding-block: 16px; font-family: var(--f-mono); font-size: 11.5px; color: var(--muted); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }


.site-footer__brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.site-footer__logos {
  display: flex;
  align-items: center;
  gap: 0;
}

.site-footer__logos::before,
.site-footer__logos::after {
  content: none;
}

.site-footer__logo {
  width: clamp(48px, 8vw, 80px);
  height: clamp(48px, 8vw, 80px);
  object-fit: contain;
}

.site-footer__logo + .site-footer__logo {
  padding-left: 1rem;
  margin-left: 1rem;
}


/* =====================  A11Y  ============================================= */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition: none !important; }
}
