/* Giorgio Dini — academic site; brand #104e99, accent #f8bf3e */
:root {
  --color-primary: #104e99;
  --color-accent: #f8bf3e;
  --bg: #f7f8fa;
  --bg-elevated: #ffffff;
  --text: #2c2c2c;
  --text-muted: #5c6370;
  --border: #dde1e8;
  --link-hover: #0d3d7a;
  --shadow: rgba(16, 78, 153, 0.08);
}
[data-theme="dark"] {
  --color-primary: #5b9fd4;
  --color-accent: #e5ac2e;
  --bg: #14161a;
  --bg-elevated: #1c2028;
  --text: #e8eaef;
  --text-muted: #a8b0bd;
  --border: #2e3542;
  --link-hover: #8ec4f0;
  --shadow: rgba(0, 0, 0, 0.35);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  padding: 2rem 1.5rem 4rem;
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
h1, h2, h3 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.2;
  margin: 0 0 0.75em;
  font-weight: 600;
}
h1 { font-size: 1.65rem; color: var(--text); }
h2 {
  font-size: 1.2rem;
  color: var(--color-primary);
  border-bottom: 2px solid var(--color-accent);
  padding-bottom: 0.35rem;
  margin-top: 2rem;
}
h2:first-of-type { margin-top: 0; }
h3 { font-size: 1.05rem; color: var(--text); }
p, ul, ol { margin: 0 0 1rem; }
a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}
a:hover { color: var(--link-hover); text-decoration: underline; }
strong { color: var(--text); font-weight: 600; }
.wrapper {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
}
header {
  flex: 0 0 230px;
  position: sticky;
  top: 1.5rem;
  padding: 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 24px var(--shadow);
}
header h1 {
  font-size: 1.35rem;
  margin-bottom: 0.5rem;
  color: var(--color-primary);
  text-align: center;
}
header .tagline {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
  line-height: 1.4;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-align: center;
}
.profile-img {
  margin: 0 0 1rem;
  text-align: center;
}
.profile-img img {
  display: inline-block;
  max-width: 168px;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.office-address {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0 0 1rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.header-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}
.header-toolbar .theme-toggle-wrap {
  margin-bottom: 0;
}
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  flex-shrink: 0;
  cursor: pointer;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.nav-toggle:hover {
  border-color: var(--color-primary);
  background: var(--bg-elevated);
  box-shadow: 0 2px 8px var(--shadow);
}
.nav-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  margin: 0;
  padding: 0;
  border: none;
  background: rgba(15, 20, 28, 0.45);
  cursor: pointer;
}
[data-theme="dark"] .nav-backdrop {
  background: rgba(0, 0, 0, 0.55);
}
.theme-toggle-wrap {
  text-align: center;
  margin-bottom: 1rem;
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  cursor: pointer;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.theme-toggle:hover {
  border-color: var(--color-primary);
  background: var(--bg-elevated);
  box-shadow: 0 2px 8px var(--shadow);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.theme-toggle .theme-icon {
  display: block;
  flex-shrink: 0;
}
.theme-toggle .theme-icon-moon {
  display: none;
}
[data-theme="dark"] .theme-toggle .theme-icon-sun {
  display: none;
}
[data-theme="dark"] .theme-toggle .theme-icon-moon {
  display: block;
}
.site-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0 0 1.25rem;
  padding: 1rem 0 0;
  border-top: 1px solid var(--border);
}
.site-nav a {
  display: block;
  padding: 0.35rem 0;
  font-size: 0.9rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  border-left: 3px solid transparent;
  padding-left: 0.5rem;
  margin-left: -0.5rem;
}
.site-nav a:hover {
  border-left-color: var(--color-accent);
  text-decoration: none;
}
.site-nav a[aria-current="page"] {
  border-left-color: var(--color-primary);
  font-weight: 700;
  color: var(--color-primary);
}
.external-links {
  margin: 0;
  padding: 1rem 0 0;
  list-style: none;
  border-top: 1px solid var(--border);
}
.external-links li {
  margin-bottom: 0.45rem;
  font-size: 0.88rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.show-mobile-only {
  display: none;
}
.contact-footer {
  display: none;
  margin-top: 2.5rem;
  padding: 1.35rem 1.15rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px var(--shadow);
}
.contact-footer-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 0.4rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
.header-contact-icons {
  margin: 0 0 1rem;
}
.contact-footer-icons {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.65rem 1rem;
}
.contact-footer-icons li {
  margin: 0;
}
/* Must follow .contact-footer-icons so flex does not override .show-mobile-only on desktop */
ul.header-contact-icons.contact-footer-icons.show-mobile-only {
  display: none;
}
.contact-footer-icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  color: var(--color-primary);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none !important;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.contact-footer-icon-link:hover {
  background: var(--bg-elevated);
  border-color: var(--color-primary);
  box-shadow: 0 2px 10px var(--shadow);
}
.contact-footer-icon-link:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.contact-footer-icon-link svg {
  display: block;
  flex-shrink: 0;
}
.contact-footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  line-height: 1.35;
}
.contact-footer-links li {
  margin: 0;
  font-size: 0.92rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.contact-footer-links a {
  display: block;
  padding: 0.22rem 0.25rem;
  border-radius: 6px;
  font-weight: 500;
  line-height: 1.35;
}
.contact-footer-links a:hover {
  background: var(--bg);
  text-decoration: none;
}
.contact-footer-contacts {
  margin: 0 0 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
  text-align: left;
}
.contact-footer-contacts-heading {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.contact-footer-contacts-lines {
  margin: 0 0 0.45rem;
}
.contact-footer-contacts-email {
  margin: 0;
  font-size: 0.88rem;
}
.contact-footer-contacts-email a {
  word-break: break-word;
}
section {
  flex: 1;
  min-width: 0;
  padding: 0.25rem 0 2rem;
}
section > h2:first-child { margin-top: 0; }
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.75rem 0;
}
.news-block {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 4px solid var(--color-accent);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.news-block h3 {
  margin-top: 0;
  font-size: 1rem;
  color: var(--color-primary);
}
.news-block ul { margin: 0; padding-left: 1.2rem; }
.news-block li { margin-bottom: 0.85rem; }
.news-block li:last-child { margin-bottom: 0; }
.paper {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.paper:last-child { border-bottom: none; }
.orcid-note {
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.paper p { margin-bottom: 0.5rem; }
details summary {
  color: var(--color-primary);
  cursor: pointer;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.9rem;
}
.paper details {
  margin-top: 0.35rem;
}
details[open] summary { margin-bottom: 0.5rem; }
details p { font-size: 0.95rem; color: var(--text-muted); }
.teaching-item { margin-bottom: 1.25rem; }
.outside-page p {
  margin-bottom: 1.1rem;
  line-height: 1.7;
}
.outside-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.75rem;
}
.outside-gallery figure {
  margin: 0;
}
.outside-gallery img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.outside-gallery figcaption {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.teaching-item h3 { margin-bottom: 0.35rem; }
.cv-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.btn-download {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--color-primary);
  color: #fff !important;
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.9rem;
  text-decoration: none !important;
}
.btn-download:hover {
  background: var(--link-hover);
  color: #fff !important;
}
.cv-frame-wrap {
  width: 100%;
  min-height: 70vh;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-elevated);
}
.cv-frame-wrap iframe {
  width: 100%;
  min-height: 70vh;
  border: none;
}
.cv-fallback {
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}
footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-align: center;
}
footer a { font-weight: 500; }
@media print, screen and (max-width: 800px) {
  .wrapper { flex-direction: column; }
  header {
    position: static;
    width: 100%;
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
    text-align: center;
  }
  header .office-address-desktop {
    display: none;
  }
  .header-toolbar {
    justify-content: center;
  }
  .nav-toggle {
    display: inline-flex;
    position: fixed;
    top: max(1rem, env(safe-area-inset-top, 0px));
    left: max(1rem, env(safe-area-inset-left, 0px));
    z-index: 1002;
    background: var(--bg-elevated);
    box-shadow: 0 2px 14px var(--shadow);
  }
  .external-links {
    display: none;
  }
  .show-mobile-only:not(ul) {
    display: block;
  }
  ul.header-contact-icons.contact-footer-icons.show-mobile-only {
    display: flex;
  }
  .contact-footer {
    display: block;
  }
  .site-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: min(85vw, 320px);
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: max(1rem, env(safe-area-inset-top, 0px)) 1rem 1.25rem
      max(1rem, env(safe-area-inset-left, 0px));
    z-index: 1003;
    background: var(--bg-elevated);
    border: none;
    border-right: 1px solid var(--border);
    border-top: none;
    box-shadow: 4px 0 28px var(--shadow);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    text-align: left;
  }
  body.nav-open .site-nav {
    transform: translateX(0);
  }
  .site-nav a {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0.4rem 0.5rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  .site-nav {
    transition: none;
  }
}
@media print {
  body { padding: 0; }
  header {
    padding-left: 0 !important;
  }
  .theme-toggle-wrap,
  .theme-toggle,
  .nav-toggle,
  .nav-backdrop,
  .site-nav,
  .contact-footer,
  .show-mobile-only {
    display: none !important;
  }
  header .office-address {
    display: block !important;
  }
  .external-links {
    display: block !important;
  }
}
code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.88em;
  background: var(--bg);
  padding: 0.15em 0.35em;
  border-radius: 4px;
  border: 1px solid var(--border);
}