:root {
  --ink: #1a1a1a;
  --muted: #666;
  --line: #e2e2e2;
  --bg: #fdfdfc;
  --accent: #2b4c3f;
  --link: #3ba0e0;
}

* {
  box-sizing: border-box;
}

html,
body {
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.langswitch {
  position: relative;
  display: inline-flex;
  margin-bottom: 1.75rem;
  padding: 3px;
  background: #f0efec;
  border-radius: 999px;
  font-size: 0.78rem;
}

.lang-opt {
  position: relative;
  z-index: 1;
  border: none;
  background: transparent;
  padding: 0.32rem 0.75rem;
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  cursor: pointer;
  border-radius: 999px;
  transition: color 0.25s ease;
}

.lang-opt.is-active {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.lang-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: var(--accent);
  border-radius: 999px;
  transition: transform 0.3s cubic-bezier(0.65, 0, 0.35, 1);
}

/* Flag gradients crossfade as the thumb slides between languages */
.lang-thumb::before,
.lang-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transition: opacity 0.35s ease;
}

.lang-thumb::before {
  background: linear-gradient(115deg, #3c3b6e 0%, #6b6a8f 50%, #b22234 100%);
  box-shadow: -2px 0 6px rgba(60, 59, 110, 0.28), 2px 0 6px rgba(178, 34, 52, 0.28);
  opacity: 1;
}

.lang-thumb::after {
  background: linear-gradient(115deg, #008c45 0%, #6a9a72 50%, #cd212a 100%);
  box-shadow: -2px 0 6px rgba(0, 140, 69, 0.28), 2px 0 6px rgba(205, 33, 42, 0.28);
  opacity: 0;
}

.lang-opt[data-lang="it"].is-active ~ .lang-thumb {
  transform: translateX(100%);
}

.lang-opt[data-lang="it"].is-active ~ .lang-thumb::before {
  opacity: 0;
}

.lang-opt[data-lang="it"].is-active ~ .lang-thumb::after {
  opacity: 1;
}

.header {
  margin-bottom: 2.5rem;
}

.avatar-frame {
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  overflow: hidden;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
}

.avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 10%;
  transform: scale(1.15) translate(-3%, 4%);
}

.header h1 {
  font-size: 1.75rem;
  margin: 0 0 0.15rem;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0 0 1rem;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
}

.contact {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.contact a,
.entry p a,
.course-list a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.contact a:hover,
.entry p a:hover,
.course-list a:hover {
  border-bottom-color: var(--link);
}

.contact a::before,
.entry p a::before,
.course-list a::before {
  content: "\2197";
  display: inline-block;
  margin-right: 0.2em;
  color: var(--link);
}

.section {
  margin-bottom: 2.25rem;
}

.section h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.entry {
  display: flex;
  gap: 0.85rem;
  margin-bottom: 1.3rem;
}

.entry:last-child {
  margin-bottom: 0;
}

.entry-logo {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 9px;
  object-fit: cover;
  margin-top: 0.1rem;
}

.entry-body {
  min-width: 0;
  flex: 1;
}

.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.entry-head h3 {
  font-size: 1rem;
  margin: 0;
  font-weight: 600;
}

.date {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.entry p {
  margin: 0.3rem 0 0;
  color: #3a3a3a;
  font-size: 0.92rem;
}

.coursework {
  margin-top: 0.6rem;
}

.coursework + .coursework {
  margin-top: 0.4rem;
}

.coursework summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}

.coursework summary::-webkit-details-marker {
  display: none;
}

.coursework summary::before {
  content: "";
  flex: none;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent var(--accent);
  transition: transform 0.25s cubic-bezier(0.65, 0, 0.35, 1);
}

.coursework[open] summary::before {
  transform: rotate(90deg);
}

.coursework-content {
  overflow: hidden;
}

.coursework:not([open]) .coursework-content {
  height: 0;
}

.coursework h4 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0.9rem 0 0.4rem;
}

.course-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.course-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.28rem 0;
  border-bottom: 1px dotted var(--line);
  font-size: 0.88rem;
  color: #3a3a3a;
}

.course-list li:last-child {
  border-bottom: none;
}

.course-status {
  flex: none;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.course-status.is-passed {
  color: var(--accent);
}

.course-status.is-progress {
  color: #b8860b;
}

.course-status.is-waiting {
  color: #4a6fa5;
}

.course-status.is-planned {
  color: var(--muted);
}

.highlights {
  list-style: none;
  padding: 0;
  margin: 0.7rem 0 0;
  display: grid;
  gap: 0.35rem;
}

.highlights li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: #3a3a3a;
}

.highlight-num {
  flex: none;
  font-weight: 700;
  color: var(--accent);
  min-width: 3.2em;
}

.coursework p {
  margin: 0;
  font-size: 0.88rem;
  color: #3a3a3a;
}

.entry-shot {
  display: block;
  max-width: 100%;
  margin-top: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.skills {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.skills li {
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #333;
}

.i18n {
  display: inline-block;
  will-change: transform, opacity, filter;
  transition: opacity 0.28s ease, transform 0.28s ease, filter 0.28s ease;
}

.i18n.is-swapping {
  opacity: 0;
  transform: translateY(5px);
  filter: blur(3px);
}

@media (max-width: 560px) {
  .entry-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }
  .date {
    order: 2;
    font-size: 0.82rem;
  }
  .entry-head h3 {
    order: 1;
  }
}

@media (max-width: 420px) {
  main {
    padding: 2rem 1.2rem 3rem;
  }
  .header h1 {
    font-size: 1.5rem;
  }
}
