/* ===========================================================
   François-Pierre Paty — personal site
   Academic serif, warm. Minimal, responsive, dark-mode aware.
   =========================================================== */

:root {
  --bg:        #faf9f6;
  --bg-soft:   #f3f1ea;
  --ink:       #33312e;
  --muted:     #6f6a62;
  --faint:     #908a80;
  --rule:      #e6e2d8;
  --accent:    #a4452f;
  --accent-2:  #7d3220;
  --card:      #ffffff;
  --shadow:    0 1px 2px rgba(40,33,25,.05), 0 8px 24px rgba(40,33,25,.04);
  --maxw:      1120px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Spectral", Georgia, "Times New Roman", serif;
  font-size: 18px;
  line-height: 1.62;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 56px 28px 96px; }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 72px;
  align-items: start;
}

/* ---------- sidebar ---------- */
.sidebar { position: sticky; top: 40px; text-align: center; }

.portrait {
  width: 210px; height: 210px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto 22px;
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
}

.name {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: .2px;
  margin: 0 0 4px;
  line-height: 1.2;
}
.tagline { color: var(--muted); font-size: .98rem; margin: 0 0 20px; font-style: italic; text-align: center; }

.social { font-size: 1.18rem; margin: 0 0 26px; text-align: center; }
.social a { color: var(--muted); margin: 0 7px; transition: color .15s ease; }
.social a:hover { color: var(--accent); }

.nav { list-style: none; padding: 0; margin: 0; display: inline-block; text-align: left; }
.nav li { margin: 0; }
.nav a {
  display: block;
  color: var(--muted);
  text-decoration: none;
  font-size: .96rem;
  padding: 3px 0;
  border-left: 2px solid transparent;
  padding-left: 12px;
  transition: color .15s ease, border-color .15s ease;
}
.nav a:hover { color: var(--accent); border-color: var(--accent); }
.nav a.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }

.portrait-link { display: block; }
.name a { color: inherit; }
.name a:hover { color: var(--accent); text-decoration: none; }

/* ---------- main column ---------- */
main { min-width: 0; }

section { margin: 0 0 52px; }
section:first-child { margin-top: 4px; }

h2 {
  font-size: 1.05rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent);
  margin: 0 0 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
  overflow-wrap: break-word;
  text-align: left;
}
h3 { font-size: 1.1rem; font-weight: 600; margin: 0 0 10px; }

p { margin: 0 0 16px; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); text-decoration: underline; text-underline-offset: 2px; }

.lead { font-size: 1.12rem; }
.lead a { font-weight: 500; }

/* ---------- lists ---------- */
ul { margin: 0 0 16px; padding-left: 1.15em; }
li { margin: 0 0 9px; }
.tight li { margin-bottom: 5px; }

.dated > li > strong:first-child,
.news li > strong:first-child,
.talks li > strong:first-child {
  color: var(--ink);
  font-weight: 600;
}

details { margin: 12px 0 0; }
summary { cursor: pointer; color: var(--muted); font-style: italic; }
summary:hover { color: var(--accent); }

/* ---------- publications ---------- */
.pubs { list-style: none; padding: 0; margin: 0; }
.pub {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 18px 20px;
  margin: 0 0 14px;
  box-shadow: var(--shadow);
}
.pub-title { font-weight: 600; font-size: 1.05rem; line-height: 1.35; margin-bottom: 6px; }
.pub-meta { color: var(--muted); font-size: .95rem; margin-bottom: 8px; }
.pub-meta .award { color: var(--accent); font-weight: 600; }
.pub-links { font-size: .9rem; }
.pub-links a {
  display: inline-block;
  margin-right: 6px;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1px 9px;
}
.pub-links a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }

/* ---------- video ---------- */
.video {
  position: relative; width: 100%; padding-top: 56.25%;
  border-radius: 10px; overflow: hidden; box-shadow: var(--shadow);
  border: 1px solid var(--rule);
}
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- SRW demo ---------- */
.demo-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.demo-canvas-wrap { position: relative; width: 100%; }
#srw-canvas, #reg-canvas, #econ-canvas {
  display: block; width: 100%; height: auto;
  max-width: 100%;
  background: var(--bg-soft);
  border-radius: 8px;
  touch-action: none;
}
#srw-canvas { cursor: grab; }
#srw-canvas:active { cursor: grabbing; }

.demo-controls {
  display: flex; flex-wrap: wrap; gap: 16px 22px;
  align-items: center; margin-top: 16px;
}
.demo-controls label { font-size: .9rem; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.demo-controls input[type=range] { accent-color: var(--accent); }
.btn {
  font-family: inherit; font-size: .92rem;
  color: var(--bg); background: var(--accent);
  border: 0; border-radius: 7px; padding: 7px 16px; cursor: pointer;
  transition: background .15s ease;
}
.btn:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.ghost:hover { background: var(--accent); color: var(--bg); }

/* dual-thumb range slider (lo <= hi enforced) */
.rangefield { display: flex; flex-direction: column; gap: 6px; min-width: 220px; }
.rangelabel { font-size: .9rem; color: var(--muted); }
.rangelabel b { color: var(--ink); font-variant-numeric: tabular-nums; }
.dualrange { --dr: var(--accent); position: relative; height: 22px; width: 100%; }
.dr-track { position: absolute; top: 9px; left: 7px; right: 7px; height: 4px; background: var(--rule); border-radius: 2px; }
.dr-fill { position: absolute; top: 0; bottom: 0; background: var(--dr); border-radius: 2px; }
.dr-thumb {
  position: absolute; top: 50%; width: 15px; height: 15px; margin-left: -7.5px;
  transform: translateY(-50%); background: #fff; border: 2px solid var(--dr);
  border-radius: 50%; cursor: grab; touch-action: none;
}
.dr-thumb:active { cursor: grabbing; }

.demo-readout {
  margin-top: 14px; font-size: .92rem; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 6px 24px;
}
.demo-readout b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.demo-legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: .88rem; color: var(--muted); margin-top: 10px; }
.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.swatch.square { border-radius: 2px; }
.line-swatch { display: inline-block; width: 22px; border-top: 2px solid; margin-right: 6px; vertical-align: middle; }
.line-swatch.dashed { border-top-style: dashed; }

/* ---------- economics demo ---------- */
.econ-models {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}
.econ-model {
  font-family: inherit;
  font-size: .9rem;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 6px 13px;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.econ-model:hover { color: var(--accent); border-color: var(--accent); }
.econ-model.active {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}

/* ---------- demos: tabs + panels ---------- */
.demo-tabs {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0 0 8px;
}
.demo-tab-btn {
  font-family: inherit; font-size: .92rem;
  color: var(--muted); background: var(--bg-soft);
  border: 1px solid var(--rule); border-radius: 999px;
  padding: 7px 16px; cursor: pointer;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.demo-tab-btn:hover { color: var(--accent); border-color: var(--accent); }
.demo-tab-btn.active {
  color: var(--bg); background: var(--accent); border-color: var(--accent);
}
.demo-panel[hidden] { display: none; }
.demo-panel .demo-heading {
  font-size: 1.25rem; font-weight: 600; margin: 6px 0 14px;
}

/* ---------- featured demo + cross-page links ---------- */
.more-link { font-size: .95rem; }
.more-link a { font-weight: 500; }
#research-teaser p a,
#featured-demo .more-link a { white-space: normal; }
.demo-note { font-size: .9rem; color: var(--muted); margin-top: 12px; }

/* ---------- footer ---------- */
.foot { margin-top: 60px; padding-top: 20px; border-top: 1px solid var(--rule); color: var(--faint); font-size: .85rem; text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 880px) {
  .wrap { padding: 36px 22px 72px; }
  .layout { grid-template-columns: 1fr; gap: 36px; }
  .sidebar { position: static; }
  .sidebar nav { width: 100%; }
  .nav {
    display: flex; flex-wrap: wrap; justify-content: center;
    width: 100%; padding: 0; gap: 2px 16px; text-align: center;
  }
  .nav li { margin: 0; }
  .nav a { display: block; border-left: 0; padding: 4px 0; text-align: center; }
  .nav a:hover { border-color: transparent; }
  p, ul, .pub { text-align: left; }
}

@media (max-width: 480px) {
  body { font-size: 17px; }
  .portrait { width: 170px; height: 170px; }
  .demo-controls { gap: 12px 16px; }
}
