/* ============================================================
   dariomap.com — design tokens
   Palette: map-ink navy on cool paper, Ionian blue accent,
   muted brass for small highlights.
   Type: Spectral (display), Source Sans 3 (body), IBM Plex Mono (data)
   ============================================================ */

:root {
  --ink: #16233a;        /* map-ink navy — primary text */
  --ink-soft: #3d4a63;   /* secondary text */
  --paper: #fbfbf9;      /* cool paper background */
  --paper-deep: #f1f2ee; /* section alternation */
  --line: #d7dad2;       /* hairlines */
  --sea: #17517e;        /* Ionian blue — links, accents */
  --sea-deep: #0e3a5c;
  --brass: #a9812f;      /* small highlights, eyebrows */

  --font-display: "Spectral", Georgia, serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "Courier New", monospace;

  --w-max: 1060px;
  --w-text: 720px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
}

a { color: var(--sea); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--sea);
  outline-offset: 3px;
  border-radius: 2px;
}

.wrap { max-width: var(--w-max); margin: 0 auto; padding: 0 1.25rem; }

/* ---------- header / nav ---------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  color: var(--ink);
}
.brand:hover { text-decoration: none; }

.brand .monogram {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  color: var(--paper);
  background: var(--ink);
  padding: 0.28rem 0.45rem 0.22rem;
  border-radius: 2px;
}

.brand .name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.02rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

nav.main-nav ul {
  display: flex;
  gap: 1.4rem;
  list-style: none;
}

nav.main-nav a {
  color: var(--ink-soft);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}
nav.main-nav a:hover { color: var(--sea); text-decoration: none; }
nav.main-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom: 2px solid var(--brass);
  padding-bottom: 2px;
}

/* dropdowns */
nav.main-nav li.has-sub { position: relative; }
nav.main-nav .sub-menu {
  display: block;
  position: absolute; top: 100%; left: -0.9rem; z-index: 30;
  min-width: 15rem; margin-top: 0.55rem;
  padding: 0.45rem 0;
  background: var(--paper);
  border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 10px 28px rgba(22,35,58,0.12);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .15s ease, transform .15s ease, visibility 0s linear .15s;
}
/* invisible bridge so the pointer can travel from the label to the menu */
nav.main-nav .sub-menu::before { content: ""; position: absolute; left: 0; right: 0; top: -0.7rem; height: 0.7rem; }
nav.main-nav li.has-sub:hover > .sub-menu,
nav.main-nav li.has-sub:focus-within > .sub-menu {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity .15s ease, transform .15s ease;
}
nav.main-nav .sub-menu li { display: block; }
nav.main-nav .sub-menu a {
  display: block; padding: 0.42rem 0.95rem;
  text-transform: none; letter-spacing: 0; font-weight: 400;
  font-size: 0.93rem; color: var(--ink); white-space: nowrap;
}
nav.main-nav .sub-menu a:hover { background: var(--paper-deep); color: var(--sea); }
h3[id] { scroll-margin-top: calc(var(--header-h, 64px) + 24px); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink);
  cursor: pointer;
}

@media (max-width: 780px) {
  .brand .name { font-size: 0.92rem; }
  .nav-toggle { display: block; }
  nav.main-nav {
    display: none;
    position: absolute;
    top: 64px; left: 0; right: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: 0.75rem 1.25rem 1.1rem;
  }
  nav.main-nav.open { display: block; }
  nav.main-nav ul { flex-direction: column; gap: 0.85rem; }
  nav.main-nav { max-height: calc(100vh - 64px); overflow-y: auto; }
  /* on phones the sub-items are simply listed under each section */
  nav.main-nav .sub-menu {
    position: static; opacity: 1; visibility: visible; transform: none;
    border: none; box-shadow: none; background: none;
    min-width: 0; margin: 0.35rem 0 0; padding: 0 0 0 0.9rem;
    border-left: 2px solid var(--line); gap: 0.1rem;
  }
  nav.main-nav .sub-menu::before { display: none; }
  nav.main-nav .sub-menu a { padding: 0.25rem 0; font-size: 0.9rem; color: var(--ink-soft); white-space: normal; }
  nav.main-nav .sub-menu a:hover { background: none; }
}

/* ---------- hero with photo + graticule ---------- */

.hero {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-end;
  min-height: 68vh;
  background:
    radial-gradient(ellipse 48% 42% at 27% 74%, rgba(14,23,40,0.55) 0%, rgba(14,23,40,0.32) 45%, rgba(14,23,40,0) 100%),
    linear-gradient(180deg, rgba(14,23,40,0) 70%, rgba(14,23,40,0.25) 100%),
    url("../assets/hero-cortile.jpg") center 40% / cover no-repeat,
    var(--ink);
}

@media (max-width: 700px) {
  .hero {
    min-height: 76vh;
    background:
      linear-gradient(180deg, rgba(14,23,40,0) 0%, rgba(14,23,40,0.35) 40%, rgba(14,23,40,0.82) 100%),
      url("../assets/hero-cortile-mobile.jpg") 30% 40% / cover no-repeat,
      var(--ink);
  }
}

.hero .wrap {
  width: 100%;
  padding: 7rem 1.25rem 3.2rem;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 1rem;
}

.hero .eyebrow { color: #d9b45e; }

.hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.1rem, 5.4vw, 3.4rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  color: var(--paper);
  text-shadow: 0 2px 22px rgba(10,16,28,0.7), 0 1px 3px rgba(10,16,28,0.55);
}

.hero .role {
  margin-top: 1.1rem;
  font-size: 1.15rem;
  color: rgba(251,251,249,0.88);
  max-width: 46ch;
  text-shadow: 0 1px 12px rgba(10,16,28,0.9), 0 1px 2px rgba(10,16,28,0.7);
}

.hero .role a {
  color: #bcd7ee;
  border-bottom: 1px solid rgba(188,215,238,0.45);
}

.hero .fields {
  margin-top: 1.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hero .fields span {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  color: rgba(251,251,249,0.92);
  border: 1px solid rgba(251,251,249,0.35);
  border-radius: 999px;
  padding: 0.24rem 0.7rem;
  background: rgba(14,23,40,0.35);
  backdrop-filter: blur(2px);
}

/* coordinates caption — the cartographic signature */
.hero .coords {
  position: absolute;
  bottom: 0.9rem;
  right: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: rgba(251,251,249,0.55);
}

/* ---------- sections ---------- */

section.block { padding: 3.2rem 0; }
section.block.alt { background: var(--paper-deep); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }

.block h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.7rem;
  letter-spacing: -0.01em;
  margin-bottom: 0.4rem;
}

.block .lede {
  color: var(--ink-soft);
  max-width: var(--w-text);
  margin-bottom: 1.8rem;
}

.block h3 {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 2.2rem 0 1rem;
}
.block h3:first-of-type { margin-top: 1.4rem; }

/* ---------- publication list ---------- */

ol.pub-list { list-style: none; }

.pub {
  display: grid;
  grid-template-columns: 4.2rem 1fr;
  gap: 1.1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
}
.pub:last-child { border-bottom: 1px solid var(--line); }

.pub .year {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--sea-deep);
  padding-top: 0.2rem;
}

.pub .title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.12rem;
  line-height: 1.35;
}

.pub .meta {
  margin-top: 0.25rem;
  font-size: 0.94rem;
  color: var(--ink-soft);
}
.pub .meta .outlet { font-style: italic; }
a.author-link { font-weight: 700; text-decoration: none; }
a.author-link:hover { text-decoration: underline; }

.pub a.doc-link {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
}

@media (max-width: 560px) {
  .pub { grid-template-columns: 1fr; gap: 0.15rem; }
}

.pub.pub-flat { grid-template-columns: 1fr; }

/* ---------- home two-column about ---------- */

.about-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 2.5rem;
  align-items: start;
}
@media (max-width: 780px) { .about-grid { grid-template-columns: 1fr; } }

.about-grid p + p { margin-top: 0.9rem; }

/* name on one line on wide screens; on phones keep the surname together */
.hero h1 { white-space: nowrap; }
.hero h1 .surname { white-space: nowrap; }
@media (max-width: 700px) {
  .hero h1 { white-space: normal; font-size: clamp(1.75rem, 7.6vw, 2.4rem); }
}

/* portrait next to the About heading */
.about-head { display: flex; align-items: center; gap: 1.1rem; margin-bottom: 0.9rem; }
.about-head h2 { margin: 0; }
.portrait {
  width: 112px; height: 112px; flex: none;
  border-radius: 50%; object-fit: cover;
  border: 3px solid var(--paper);
  box-shadow: 0 0 0 1px var(--line), 0 6px 18px rgba(22,35,58,0.12);
}

.side-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 1.4rem 1.5rem;
}
.side-card h3 { margin: 0 0 0.9rem; }
.side-card ul { list-style: none; }
.side-card li { padding: 0.45rem 0; border-top: 1px solid var(--paper-deep); font-size: 0.96rem; }
.side-card li:first-child { border-top: none; }
.side-card .news-date {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--brass);
  display: block;
  letter-spacing: 0.08em;
}

/* ---------- teaching table ---------- */

.course-list { list-style: none; }
.course {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0;
  border-top: 1px solid var(--line);
}
.course:last-child { border-bottom: 1px solid var(--line); }
.course .cname { font-family: var(--font-display); font-weight: 500; font-size: 1.08rem; }
.course .tags { display: flex; gap: 0.4rem; flex-shrink: 0; }
.course .tags span {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
  background: #fff;
}

/* ---------- resources ---------- */

.res-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
}
.res-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 1.1rem 1.2rem;
}
.res-card h4 { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; margin-bottom: 0.3rem; }
.res-card h4 a { font-weight: 700; text-decoration: none; }
.res-card h4 a:hover { text-decoration: underline; }
.res-card p { font-size: 0.92rem; color: var(--ink-soft); }
.res-card p a { text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }

/* ---------- contact ---------- */

.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
}
@media (max-width: 700px) { .contact-grid { grid-template-columns: 1fr; } }

address { font-style: normal; line-height: 1.8; }
address .lbl {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brass);
  display: block;
  margin: 1.1rem 0 0.15rem;
}
address .lbl:first-child { margin-top: 0; }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 2rem 0 2.4rem;
  margin-top: 3rem;
}
.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.site-footer .coords {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  color: rgba(22,35,58,0.45);
}

.footer-id { display: flex; flex-direction: column; gap: 0.35rem; }
a.orcid {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-mono); font-size: 0.76rem; letter-spacing: 0.04em;
  color: var(--ink-soft);
}
a.orcid:hover { color: var(--sea); }
.orcid-icon { flex: none; }
address a.orcid { font-size: 0.9rem; color: var(--sea); }

.side-card a.news-link {
  font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.04em;
  white-space: nowrap;
}

/* News page */
.news-page { max-width: var(--w-text); }
.news-page .news-year:first-child { margin-top: 0; }
.news-year-list { list-style: none; margin-bottom: 1.6rem; }
.news-year-list li { padding: 0.7rem 0; border-top: 1px solid var(--line); }
.news-year-list li:first-child { border-top: none; }
.news-year-list .news-date {
  display: block; font-family: var(--font-mono); font-size: 0.74rem;
  letter-spacing: 0.08em; color: var(--brass);
}
.news-year-list a.news-link { font-family: var(--font-mono); font-size: 0.8rem; white-space: nowrap; }
.news-toggle {
  display: inline-block; margin-top: 0.8rem;
  font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.08em;
  background: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 0.35rem 0.9rem; color: var(--sea-deep); cursor: pointer;
}
.news-toggle:hover { border-color: var(--sea); text-decoration: none; }

/* ---------- utilities ---------- */

.btn {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: var(--paper);
  background: var(--sea-deep);
  border-radius: 4px;
  padding: 0.6rem 1.1rem;
  margin-top: 1.4rem;
}
.btn:hover { background: var(--sea); text-decoration: none; }

.page-title { padding: 3rem 0 0.5rem; }
.page-title .eyebrow { margin-bottom: 0.6rem; }
.page-title h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.9rem, 4.5vw, 2.6rem);
  letter-spacing: -0.01em;
}

/* ---------- course detail page ---------- */

.breadcrumb {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.course-tags { display: flex; gap: 0.4rem; margin-top: 0.7rem; }
.course-tags span {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
}

.material-note {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  color: var(--ink-soft);
  font-size: 0.94rem;
  max-width: var(--w-text);
}

.material-list { list-style: none; margin: 0.6rem 0 1.2rem; max-width: var(--w-text); }
.material-list li { border-top: 1px solid var(--line); padding: 0.7rem 0; }
.material-list li:first-child { border-top: none; padding-top: 0; }
.material-list a {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
}
.material-list a:hover { text-decoration: underline; }
.material-list .lecture-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
}
.material-list a.material-tag { color: var(--sea); }
.material-list a.material-tag:hover { color: var(--sea-deep); }
.material-list .material-tag {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--brass);
  margin-left: 0.5rem;
}

/* ---------- routine list (Stata/LaTeX pages) ---------- */

dl.routine-list { margin-top: 0.4rem; }
dl.routine-list dt {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--sea-deep);
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}
dl.routine-list dt:first-child { border-top: none; padding-top: 0; }
dl.routine-list dt a { font-weight: 700; text-decoration: none; }
dl.routine-list dt a:hover { text-decoration: underline; }
dl.routine-list dd {
  margin: 0.15rem 0 0.85rem;
  font-size: 0.96rem;
  color: var(--ink-soft);
  max-width: var(--w-text);
}
dl.routine-list dd a { text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }

/* in-page section nav on Resources */
.subnav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.9rem 0 0;
}
.subnav a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  background: #fff;
  color: var(--sea-deep);
}
.subnav a:hover { border-color: var(--sea); text-decoration: none; }

/* ---------- back-to-top button ---------- */
.back-to-top {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--sea-deep);
  color: var(--paper);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
  box-shadow: 0 3px 12px rgba(22,35,58,0.28);
  z-index: 500;
}
.back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--sea); }
.back-to-top:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; }

@media (max-width: 700px) {
  .back-to-top { right: 1rem; bottom: 1rem; width: 40px; height: 40px; }
}

/* ---------- Resources: sticky section bar ---------- */
.subnav-bar {
  position: sticky; top: var(--header-h, 64px); z-index: 15;
  background: rgba(251,251,249,0.94);
  backdrop-filter: saturate(1.2) blur(6px);
  border-bottom: 1px solid var(--line);
  margin-top: 1.4rem;
}
.subnav-bar .subnav { margin: 0 auto; padding: 0.6rem 1.25rem; }
.subnav a .n { color: var(--ink-soft); opacity: .65; margin-left: .25rem; }
.subnav a.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.subnav a.active .n { color: var(--paper); }
section[id] { scroll-margin-top: calc(var(--header-h, 64px) + 56px); }

/* ---------- Resources: collapsible routine list ---------- */
dl.routine-list.collapsed .extra { display: none; }
.toggle-more {
  margin-top: .4rem;
  font-family: var(--font-mono); font-size: .78rem; letter-spacing: .08em;
  background: none; border: 1px solid var(--line); border-radius: 999px;
  padding: .35rem .9rem; color: var(--sea-deep); cursor: pointer;
}
.toggle-more:hover { border-color: var(--sea); }
