/* ==========================================================================
   Tesi di Laurea — Fisica Atomica e Meccanica Quantistica
   Foglio di stile del sito statico
   ========================================================================== */

:root {
  --bg: #f5f3ee;
  --paper: #ffffff;
  --ink: #1f2328;
  --ink-soft: #4a4f57;
  --accent: #7b2d26;      /* rosso mattone, come i titoli della tesi */
  --accent-soft: #a8443b;
  --line: #e0dccf;
  --link: #1a5276;
  --link-hover: #7b2d26;
  --sidebar-bg: #2b2622;
  --sidebar-ink: #e9e4d8;
  --sidebar-ink-soft: #b3ab99;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06);
  --maxw: 820px;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, "Times New Roman", serif;
  --font-sans: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ----- Layout ----- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 300px;
  flex: 0 0 300px;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  padding: 1.6rem 1.2rem 3rem;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  font-family: var(--font-sans);
}

.sidebar .brand {
  display: block;
  color: var(--sidebar-ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.3;
  margin-bottom: .3rem;
}
.sidebar .brand small {
  display: block;
  font-weight: 400;
  color: var(--sidebar-ink-soft);
  font-size: .8rem;
  margin-top: .35rem;
}

.sidebar nav { margin-top: 1.4rem; }
.sidebar nav a {
  display: block;
  color: var(--sidebar-ink-soft);
  text-decoration: none;
  padding: .42rem .55rem;
  border-radius: 6px;
  font-size: .92rem;
  line-height: 1.35;
  transition: background .15s, color .15s;
}
.sidebar nav a .num {
  display: inline-block;
  min-width: 1.5em;
  color: var(--accent-soft);
  font-weight: 700;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.sidebar nav a.active .num { color: #f3d9d5; }

.content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  justify-content: center;
  padding: 3rem 2.5rem 6rem;
}

.page {
  background: var(--paper);
  max-width: var(--maxw);
  width: 100%;
  padding: 3.5rem clamp(1.5rem, 5vw, 4rem);
  box-shadow: var(--shadow);
  border-radius: 4px;
}

/* ----- Typography ----- */
.eyebrow {
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .72rem;
  color: var(--accent-soft);
  font-weight: 700;
  margin: 0 0 .6rem;
}

h1.title {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.15;
  margin: 0 0 1.6rem;
  color: var(--accent);
  font-weight: 700;
}

h2 {
  font-size: 1.5rem;
  color: var(--accent);
  margin: 2.4rem 0 .8rem;
  font-weight: 700;
  font-style: italic;
}
h3 {
  font-size: 1.2rem;
  color: var(--ink);
  margin: 1.8rem 0 .6rem;
  font-weight: 700;
}

p { margin: 0 0 1rem; text-align: justify; hyphens: auto; }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

em, i { font-style: italic; }
strong, b { font-weight: 700; }

ul, ol { margin: 0 0 1rem; padding-left: 1.6rem; }
li { margin: .3rem 0; }

blockquote {
  margin: 1.4rem 0;
  padding: .4rem 1.2rem;
  border-left: 3px solid var(--accent-soft);
  color: var(--ink-soft);
  font-style: italic;
}

/* ----- Figures ----- */
figure {
  margin: 2rem auto;
  text-align: center;
}
figure img {
  max-width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 6px;
}
figure.plain img { border: none; padding: 0; }

/* Inline images (equations/small figures) keep their original document size */
.content p img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
  margin: 0 .12em;
}
figcaption {
  font-family: var(--font-sans);
  font-size: .85rem;
  color: var(--ink-soft);
  margin-top: .6rem;
  font-style: italic;
}

/* Display equations */
.equation, mjx-container[display="true"] {
  margin: .7rem 0 !important;
}
.equation {
  text-align: center;
  overflow-x: auto;
  overflow-y: hidden;
  padding: .15rem 0;
}
/* Original Equation-Editor images extracted from the thesis */
.eq-block {
  display: inline-block;
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}
.eq-inline {
  display: inline-block;
  vertical-align: -0.18em;
  margin: 0 .12em;
}
/* tall inline math (fractions, roots) aligns to the math axis instead */
.eq-inline.eq-axis {
  vertical-align: middle;
}
/* a large image anchored inline in the source -> show it as a centred block */
.eq-figure {
  display: block;
  margin: 1.2rem auto;
  max-width: 100%;
}

/* Figure gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.4rem;
  margin: 1.8rem 0;
}
.gallery figure { margin: 0; }

/* ----- Cross references + hover preview ----- */
a.ref {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-soft);
  cursor: help;
  font-weight: 600;
  white-space: nowrap;
}
a.ref:hover { background: var(--accent-soft); color: #fff; border-radius: 3px; }
figure.fig-inline { scroll-margin-top: 5rem; }
figure.fig-inline.flash img { animation: figflash 1.8s ease; }
@keyframes figflash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168,68,59,0); }
  12%      { box-shadow: 0 0 0 5px var(--accent-soft); }
}
.ref-pop {
  position: fixed;
  z-index: 1000;
  max-width: 560px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, .24);
  padding: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s ease;
}
.ref-pop.show { opacity: 1; }
.ref-pop .pv { text-align: center; }
.ref-pop .pv img,
.ref-pop .pv svg {
  max-width: 540px;
  max-height: 460px;
  width: auto;
  height: auto;
  display: block;
  margin: 0 auto;
  background: #fff;
}
.ref-pop .pv math { font-size: 1.15rem; }
.ref-pop .cap {
  font-family: var(--font-sans);
  font-size: .8rem;
  color: var(--ink-soft);
  text-align: center;
  margin-top: 8px;
  font-style: italic;
}
/* Floating "return to reading position" button after a reference jump */
.ref-return {
  position: fixed;
  right: 1.2rem;
  bottom: 1.4rem;
  z-index: 1001;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: .65rem 1.1rem;
  font-family: var(--font-sans);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.ref-return.show { opacity: 1; transform: none; pointer-events: auto; }
.ref-return:hover { background: var(--accent-soft); }

/* Lightbox: click a figure image to see it enlarged */
figure img.zoomable { cursor: zoom-in; }
.zoom-link {
  display: inline-block;
  margin-top: .35rem;
  font-family: var(--font-sans);
  font-size: .82rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  cursor: zoom-in;
}
.zoom-link:hover { text-decoration: underline; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 3vh 3vw;
  background: rgba(0, 0, 0, .82);
  cursor: zoom-out;
}
.lightbox.show { display: flex; }
body.lightbox-open { overflow: hidden; }
.lightbox-inner {
  max-width: 94vw;
  max-height: 94vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.lightbox-inner img {
  display: block;
  width: min(92vw, 980px);
  height: auto;
  max-height: 90vh;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1.2rem;
  z-index: 2001;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  color: #111;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
}
.lightbox-close:hover { background: #fff; }

/* Data tables */
table.data {
  border-collapse: collapse;
  margin: 1.2rem auto;
  font-family: var(--font-sans);
  font-size: .95rem;
  min-width: 60%;
}
table.data th, table.data td {
  border: 1px solid var(--line);
  padding: .45rem .9rem;
  text-align: center;
}
table.data thead th {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
table.data tbody tr:nth-child(even) { background: #faf8f2; }

/* ----- Chapter navigation footer ----- */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-sans);
  font-size: .92rem;
}
.chapter-nav a {
  display: inline-flex;
  flex-direction: column;
  max-width: 45%;
  padding: .7rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-soft);
  transition: border-color .15s, color .15s;
}
.chapter-nav a:hover { border-color: var(--accent-soft); color: var(--accent); text-decoration: none; }
.chapter-nav a.next { text-align: right; margin-left: auto; }
.chapter-nav a span { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--accent-soft); }

/* ----- Cover / intro header ----- */
.cover {
  text-align: center;
  padding: 4rem clamp(1.5rem, 5vw, 4rem) 5rem;
}
#introduzione .kicker,
.cover .kicker {
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: .2em;
  font-size: .8rem;
  color: var(--accent-soft);
  font-weight: 700;
  text-align: center;
}
#introduzione .cover-title,
.cover h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  color: var(--accent);
  margin: 1rem 0;
  line-height: 1.1;
  text-align: center;
}
#introduzione .subtitle,
.cover .subtitle { font-size: 1.2rem; color: var(--ink-soft); font-style: italic; text-align: center; }
.intro-sep {
  border: 0;
  border-top: 1px solid var(--line);
  width: min(160px, 40%);
  margin: 2.75rem auto;
}

/* ----- Mobile ----- */
.menu-toggle { display: none; }

@media (max-width: 900px) {
  body { font-size: 17px; }
  .layout { flex-direction: column; }
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 40;
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .content { padding: 1.2rem .8rem 4rem; }
  .page { padding: 2rem 1.2rem; }
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    position: fixed;
    top: .8rem; left: .8rem;
    z-index: 50;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: .55rem .8rem;
    font-family: var(--font-sans);
    font-size: .9rem;
    cursor: pointer;
    box-shadow: var(--shadow);
  }
  .scrim { display: none; }
  body.nav-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 30;
  }
}

@media print {
  .sidebar, .chapter-nav, .menu-toggle { display: none; }
  .content { padding: 0; }
  .page { box-shadow: none; max-width: none; }
  body { background: #fff; }
}
