/* Modern Academic Personal Website - Mauro Marinoni */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --sidebar-bg: #0f172a;
  --sidebar-text: #f1f5f9;
  --sidebar-muted: #94a3b8;
  --text: #1e293b;
  --text-muted: #475569;
  --accent: #0284c7;
  --accent-dark: #0369a1;
  --accent-soft: #e0f2fe;
  --border: #e2e8f0;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.65;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

/* Layout Grid */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 2rem 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.profile-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.avatar-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: inline-block;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.avatar-btn:hover {
  transform: scale(1.03);
}

.avatar {
  width: 136px;
  height: 136px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 15%;
  background: radial-gradient(circle at 50% 38%, #f1f5f9 0%, #cbd5e1 68%, #94a3b8 100%);
  border: 2px solid rgba(125, 211, 252, 0.45);
  box-shadow:
    inset 0 2px 10px rgba(15, 23, 42, 0.25),
    0 6px 16px rgba(0, 0, 0, 0.35);
}

.profile-header h1 {
  font-size: 1.45rem;
  margin: 0.85rem 0 0.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.profile-role {
  font-size: 0.9rem;
  color: #7dd3fc;
  font-weight: 600;
  margin: 0;
}

.profile-sub {
  font-size: 0.85rem;
  color: #e2e8f0;
  margin: 0.25rem 0 0;
}

.sidebar-info {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-info li {
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.85rem;
  color: #f8fafc;
}

.sidebar-info li:last-child {
  border-bottom: none;
}

.info-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.sidebar-info a {
  color: #ffffff;
  word-break: break-word;
  font-weight: 500;
}

.sidebar-info a:hover {
  color: #7dd3fc;
  text-decoration: underline;
}

.academic-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
  margin-top: 1rem;
}

.badge-link {
  display: inline-block;
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all 0.15s ease;
}

.badge-link:hover {
  background: #7dd3fc;
  color: #0f172a;
  border-color: #7dd3fc;
  text-decoration: none;
}

/* Main Content */
.main-wrapper {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 2rem;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.nav-links a {
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.nav-links a:hover,
.nav-links a.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  text-decoration: none;
}

.btn-cv {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent);
  color: #ffffff !important;
  padding: 0.42rem 0.9rem;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
}

.btn-cv:hover {
  background: var(--accent-dark);
  text-decoration: none;
}

.content {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
}

/* Cards & Sections */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.section-title {
  margin: 0 0 1.25rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--sidebar-bg);
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

.bio-text p {
  margin: 0 0 0.9rem;
  color: var(--text);
}

.bio-text p:last-child {
  margin-bottom: 0;
}

/* Tags / Research Interests */
.tag-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.tag {
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Timeline Items (Employment, Education, Projects) */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.item {
  padding-left: 1rem;
  border-left: 3px solid var(--border);
  transition: border-color 0.15s ease;
}

.item:hover {
  border-left-color: var(--accent);
}

.item-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.item-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--sidebar-bg);
}

.item-date {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--accent-soft);
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
}

.item-subtitle {
  margin: 0.2rem 0 0.45rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.item p {
  margin: 0;
  font-size: 0.93rem;
  color: var(--text);
}

/* Skills & Service Grid */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.sub-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.1rem;
}

.sub-box h4 {
  margin: 0 0 0.6rem;
  font-size: 0.98rem;
  color: var(--sidebar-bg);
}

.clean-list {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.92rem;
}

.clean-list li {
  margin-bottom: 0.4rem;
}

/* Publications */
.pub-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.pub-search {
  flex: 1;
  min-width: 220px;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}

.pub-search:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.year-group {
  margin-bottom: 1.75rem;
}

.year-heading {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-dark);
  margin: 0 0 0.75rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.pub-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.pub-item {
  padding: 0.75rem 0.9rem;
  background: var(--bg);
  border-radius: 6px;
  border-left: 3px solid #cbd5e1;
  font-size: 0.92rem;
}

.pub-item.journal {
  border-left-color: var(--accent);
}

.pub-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.pub-badge.journal {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.pub-badge.conf {
  background: #e2e8f0;
  color: #334155;
}

.pub-links {
  display: inline-flex;
  gap: 0.6rem;
  margin-left: 0.4rem;
  font-size: 0.84rem;
  font-weight: 600;
}

/* Native Dialog Photo Modal */
dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem;
  background: var(--surface);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25);
  max-width: 90vw;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.75);
}

dialog img {
  max-width: 100%;
  max-height: 80vh;
  display: block;
  border-radius: 6px;
}

.dialog-close {
  margin-top: 0.6rem;
  width: 100%;
  padding: 0.45rem;
  border: none;
  border-radius: 6px;
  background: var(--sidebar-bg);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.84rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* Responsive Breakpoints */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 1.5rem 1.25rem;
  }

  .sidebar-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem 1rem;
  }

  .sidebar-info li {
    border-bottom: none;
    padding: 0.35rem 0;
  }

  .top-nav {
    padding: 0.65rem 1.25rem;
  }

  .content {
    padding: 1.25rem;
  }

  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .section-card {
    padding: 1.25rem 1rem;
  }

  .avatar {
    width: 108px;
    height: 108px;
  }

  .top-nav {
    justify-content: center;
  }
}

/* Dropdown Download CV */
.cv-dropdown {
  position: relative;
  display: inline-block;
}

.cv-dropdown > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.cv-dropdown > summary::-webkit-details-marker {
  display: none;
}

.cv-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 245px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.15), 0 4px 6px -2px rgba(15, 23, 42, 0.08);
  padding: 0.4rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.cv-menu a {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
}

.cv-menu a:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
  text-decoration: none;
}

.cv-menu a span {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

@media (max-width: 520px) {
  .cv-menu {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
  }
}
