/* ============================================================
   Alexandre Menezes Barroso — site stylesheet
   Refined dark theme. Shared by index.html and materials.html.
   ============================================================ */

:root {
  /* Surfaces */
  --bg:          #141417;
  --bg-2:        #17171b;
  --surface:     #1c1c21;
  --surface-2:   #212127;
  --rule:        #2a2a30;
  --rule-soft:   #232329;

  /* Ink */
  --text:        #ECEAE4;
  --text-2:      #B6B3AB;
  --text-muted:  #86847D;

  /* Accent — soft steel blue */
  --accent:      #8FBAD1;
  --accent-2:    #A7CCE0;
  --accent-dim:  #1d2c35;
  --accent-line: #2c4653;

  /* Type */
  --font-serif:  'EB Garamond', Georgia, 'Times New Roman', serif;
  --font-sans:   'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono:   'DM Mono', ui-monospace, 'SF Mono', 'Courier New', monospace;

  --max-w:       740px;
  --nav-h:       58px;
}

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

html { font-size: 18px; scroll-padding-top: calc(var(--nav-h) + 12px); }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 300;
  line-height: 1.72;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-dim); color: var(--accent-2); }

.container { max-width: var(--max-w); margin: 0 auto; padding: 0 28px; }

a { color: var(--accent); text-decoration: none; transition: color .15s, opacity .15s, border-color .15s; }
a:hover { color: var(--accent-2); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--surface); color: var(--text);
  padding: 10px 16px; border: 1px solid var(--rule); border-radius: 3px;
  font-size: .82rem;
}
.skip-link:focus { left: 12px; top: 10px; }

/* ── Nav ─────────────────────────────────────────────────── */
nav {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--rule-soft);
  display: flex; align-items: center;
}
/* Full-width nav bar: name at the left gutter, menu grouped at the right,
   so it never squishes and adapts at any width. The reading column below
   stays narrow; the bar intentionally spans wider. */
nav .container {
  max-width: none;
  padding-left: clamp(22px, 3.5vw, 46px);
  padding-right: clamp(22px, 3.5vw, 46px);
}
.nav-inner { display: flex; align-items: center; justify-content: flex-start; gap: 22px; width: 100%; }
.nav-links { margin-left: auto; }   /* push the menu to the right of the name */

.nav-name {
  font-family: var(--font-serif);
  font-size: 1.08rem; font-weight: 500; letter-spacing: 0.01em;
  color: var(--text); flex-shrink: 0;
}
.nav-name:hover { color: var(--accent-2); }

.nav-links { display: flex; gap: 26px; list-style: none; flex-shrink: 0; }
.nav-links a {
  position: relative; white-space: nowrap;
  font-family: var(--font-mono);
  font-size: .70rem; font-weight: 400; letter-spacing: 0.11em; text-transform: uppercase;
  color: var(--text-muted);
  padding-bottom: 3px;
}
.nav-links a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1.5px;
  background: var(--accent-line); opacity: 0;
}
.nav-links a:hover { color: var(--accent); }
.nav-links a[aria-current="page"],
.nav-links a.is-active { color: var(--accent-2); }
.nav-links a[aria-current="page"]::after,
.nav-links a.is-active::after { opacity: 1; }

.page-body { padding-top: 22px; }

.lang-switcher { display: flex; align-items: center; gap: 1px; flex-shrink: 0; }
.lang-switcher button {
  font-family: var(--font-mono);
  font-size: .66rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted); background: none; border: none; cursor: pointer;
  padding: 4px 6px; border-radius: 3px; line-height: 1;
  transition: color .15s, background .15s;
}
.lang-switcher button:hover { color: var(--accent); }
.lang-switcher button.active { color: var(--accent-2); background: var(--accent-dim); }
.lang-switcher .sep { font-size: .58rem; color: var(--rule); user-select: none; }

/* ── Collapsible nav ─────────────────────────────────────────
   JS adds body.nav-collapsed whenever the inline links would not
   fit (any width, incl. portrait monitors), so it never squishes
   and the language switcher is never pushed off-screen. */
.nav-burger {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 12px 4px; flex-shrink: 0;
}
.nav-burger span {
  display: block; width: 22px; height: 1.5px; background: var(--text-2); border-radius: 1px;
}
.nav-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); background: var(--accent); }
.nav-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); background: var(--accent); }

.mobile-menu { display: none; }

/* Compact mode: inline links hide, burger + drawer appear, language pins right */
body.nav-collapsed .nav-links { display: none !important; }
body.nav-collapsed .nav-burger { display: flex; }
body.nav-collapsed .lang-switcher { margin-left: auto; }
body.nav-collapsed .mobile-menu {
  display: none; position: fixed; top: var(--nav-h); left: 0; right: 0; bottom: 0;
  background: var(--bg); z-index: 99; overflow-y: auto; overscroll-behavior: contain;
  border-top: 1px solid var(--rule-soft);
}
body.nav-collapsed .mobile-menu.open { display: block; }
.mobile-links { list-style: none; padding: 8px 0 40px; }
.mobile-links li { border-bottom: 1px solid var(--rule-soft); }
.mobile-links a {
  display: block; padding: 17px 24px;
  font-family: var(--font-serif); font-size: 1.3rem; font-weight: 400; color: var(--text);
}
.mobile-links a:hover, .mobile-links a:active,
.mobile-links a[aria-current="page"] { color: var(--accent); }
body.menu-open { overflow: hidden; }

/* ── Sections ────────────────────────────────────────────── */
section { padding: 64px 0; border-top: 1px solid var(--rule-soft); }
section:first-of-type { border-top: none; }

h2 {
  font-family: var(--font-serif);
  font-weight: 500; font-size: 1.5rem; letter-spacing: -0.01em;
  margin-bottom: 34px; color: var(--text);
  position: relative; padding-left: 18px;
}
h2::before {
  content: ""; position: absolute; left: 0; top: 0.18em; bottom: 0.18em;
  width: 2px; background: var(--accent-line); border-radius: 2px;
}

/* ── Hero / masthead ─────────────────────────────────────── */
.hero-section { padding: clamp(44px, 7vw, 76px) 0 clamp(40px, 5vw, 60px); border-top: none; }

.masthead {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: clamp(24px, 4vw, 40px);
  align-items: center;
}
.hero-figure { position: relative; }
.hero-photo, .hero-photo-placeholder {
  width: clamp(120px, 15vw, 156px); aspect-ratio: 1 / 1; height: auto;
  border-radius: 5px; display: block;
  object-fit: cover; object-position: center;
  background: var(--surface);
  border: 1px solid var(--rule);
  box-shadow: 0 20px 44px -28px rgba(0,0,0,0.85);
}
.hero-photo-placeholder {
  align-items: center; justify-content: center;
  color: var(--text-muted); font-size: .74rem; font-family: var(--font-mono);
}

.masthead-id { min-width: 0; }
.hero-citation {
  font-family: var(--font-mono); font-size: .70rem; font-weight: 500;
  letter-spacing: 0.16em; color: var(--accent); margin-bottom: 12px;
}
.hero-name, .masthead-id h1 {
  font-family: var(--font-serif); font-weight: 600;
  font-size: clamp(1.85rem, 4.4vw, 2.5rem); line-height: 1.08; letter-spacing: -0.02em;
  margin-bottom: 10px;
}
.hero-role { font-size: .88rem; color: var(--text-2); letter-spacing: 0.01em; }

.hero-text {
  margin-top: clamp(28px, 4vw, 40px);
  font-size: 1.02rem; color: var(--text-2); line-height: 1.78;
  max-width: 64ch;
}
.hero-text p { margin-bottom: 1rem; }
.hero-text p:last-child { margin-bottom: 0; }
.hero-text p:first-child { color: var(--text); }
.hero-text a { color: var(--accent); border-bottom: 1px solid var(--accent-line); }
.hero-text a:hover { color: var(--accent-2); border-bottom-color: var(--accent); }

.hero-links { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; margin-top: 20px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 9px; }

.hero-action {
  display: inline-flex; align-items: center; justify-content: center; min-height: 34px; gap: 6px;
  font-family: var(--font-mono);
  font-size: .72rem; font-weight: 400; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-2); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 3px; padding: 6px 14px;
  transition: border-color .15s, color .15s, background .15s;
}
.hero-action:hover { border-color: var(--accent-line); color: var(--accent-2); background: var(--surface-2); }
.hero-action.primary { color: var(--bg); background: var(--accent); border-color: var(--accent); font-weight: 500; }
.hero-action.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--bg); }

.hero-profile-links { display: flex; flex-wrap: wrap; column-gap: 18px; row-gap: 7px; align-items: center; }
.hero-profile-links a {
  font-family: var(--font-mono); font-size: .70rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted); border-bottom: 1px solid transparent;
}
.hero-profile-links a:hover { color: var(--accent); border-bottom-color: var(--accent-line); }

/* ── Explore cards (homepage) ────────────────────────────── */
.explore-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.explore-card {
  position: relative;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 6px;
  padding: 22px 22px 20px;
}
.explore-card::after {
  content: "→"; position: absolute; top: 20px; right: 20px;
  font-family: var(--font-mono); color: var(--text-muted);
}
.explore-card:hover { border-color: var(--accent-line); background: var(--surface-2); }
.explore-card:hover::after { color: var(--accent); }
.explore-name {
  font-family: var(--font-serif); font-size: 1.22rem; font-weight: 500; color: var(--text);
  letter-spacing: -0.01em; padding-right: 22px;
}
.explore-card:hover .explore-name { color: var(--accent-2); }
.explore-desc { font-size: .84rem; color: var(--text-2); line-height: 1.5; flex: 1; }
.explore-count {
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted); margin-top: 8px;
}

/* ── Publication groups ──────────────────────────────────── */
.pub-group + .pub-group { margin-top: 40px; }
.pub-group-title {
  font-family: var(--font-mono); font-size: .70rem; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent);
  margin-bottom: 22px; padding-bottom: 10px; border-bottom: 1px solid var(--rule-soft);
}
.pub-group .paper-list { gap: 30px; }
.pub-group .paper + .paper { margin-top: 30px; }

/* ── Papers ──────────────────────────────────────────────── */
.paper-list { display: flex; flex-direction: column; gap: 34px; }
.paper { display: block; }
.paper-title { font-family: var(--font-serif); font-size: 1.14rem; font-weight: 500; line-height: 1.34; color: var(--text); margin-bottom: 3px; }
.paper-authors { font-size: .80rem; color: var(--text-muted); }
.paper-venue { font-size: .80rem; color: var(--text-muted); font-style: italic; }
.paper-summary { font-size: .87rem; color: var(--text-2); margin-top: 8px; line-height: 1.68; }
.paper-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.paper-links a, .talk-link, .material-link {
  font-family: var(--font-mono); font-size: .70rem; letter-spacing: 0.05em;
  color: var(--accent); border: 1px solid var(--rule); border-radius: 3px; padding: 3px 9px;
  transition: background .15s, border-color .15s, color .15s;
}
.paper-links a:hover, .talk-link:hover, .material-link:hover { background: var(--accent-dim); border-color: var(--accent-line); color: var(--accent-2); }
/* "cite" chip — a subtle, borderless variant that reads as a secondary action. */
.paper-links a.paper-cite { color: var(--text-muted); border-style: dashed; }
.paper-links a.paper-cite:hover { color: var(--accent-2); border-style: solid; }
.me { font-weight: 500; color: var(--text); }

/* ── Talks ───────────────────────────────────────────────── */
.talk-list { display: flex; flex-direction: column; }
.talk {
  display: grid; grid-template-columns: 66px 1fr; gap: 22px;
  padding: 20px 0; border-bottom: 1px solid var(--rule-soft);
}
.talk:first-child { border-top: 1px solid var(--rule-soft); }
.talk-year { font-family: var(--font-mono); font-size: .78rem; color: var(--text-muted); padding-top: 2px; font-variant-numeric: tabular-nums; }
.talk-title { font-size: .95rem; font-weight: 400; color: var(--text); line-height: 1.45; }
.talk-venue { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }
.talk-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }

/* ── Software ─────────────────────────────────────────────── */
.software-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.software-card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 5px; padding: 22px;
  transition: border-color .15s, background .15s;
}
.software-card:hover { border-color: var(--accent-line); background: var(--surface-2); }
.software-name { font-family: var(--font-mono); font-size: .86rem; font-weight: 500; color: var(--accent); margin-bottom: 8px; letter-spacing: 0.02em; }
.software-desc { font-size: .84rem; color: var(--text-2); line-height: 1.62; margin-bottom: 14px; }
.software-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Projects (industry-framed case studies) ─────────────────── */
.projects-grid { display: flex; flex-direction: column; gap: 20px; }
.project-card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 26px 26px 24px;
  transition: border-color .15s, background .15s;
}
.project-card:hover { border-color: var(--accent-line); }
.project-head { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; }
.project-name { font-family: var(--font-serif); font-weight: 500; font-size: 1.32rem; color: var(--text); margin: 0; }
.project-period { font-family: var(--font-mono); font-size: .72rem; color: var(--text-muted); white-space: nowrap; }
.project-tagline { color: var(--accent-2); font-size: .98rem; line-height: 1.5; margin: 6px 0 0; }
.project-desc { color: var(--text-2); font-size: .9rem; line-height: 1.65; margin: 12px 0 0; }
.project-metrics { display: flex; flex-wrap: wrap; gap: 28px; margin: 18px 0 2px; padding: 16px 0 4px; border-top: 1px solid var(--rule-soft); }
.metric { display: flex; flex-direction: column; gap: 3px; }
.metric-value { font-family: var(--font-serif); font-size: 1.55rem; line-height: 1; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.metric-label { font-family: var(--font-mono); font-size: .62rem; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.project-stack { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.project-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.project-links a {
  font-family: var(--font-mono); font-size: .70rem; letter-spacing: 0.05em;
  color: var(--accent); border: 1px solid var(--rule); border-radius: 4px; padding: 4px 11px;
  transition: background .15s, border-color .15s, color .15s;
}
.project-links a:hover { background: var(--accent-dim); border-color: var(--accent-line); color: var(--accent-2); }

.tag {
  font-family: var(--font-mono); font-size: .64rem; letter-spacing: 0.04em;
  color: var(--text-muted); background: var(--bg-2); border: 1px solid var(--rule-soft);
  border-radius: 3px; padding: 2px 7px;
}
.software-links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 16px; }
.software-links a { font-family: var(--font-mono); font-size: .74rem; letter-spacing: 0.03em; }

/* ── CV ──────────────────────────────────────────────────── */
.cv-body { font-size: .96rem; color: var(--text-2); margin-bottom: 26px; max-width: 62ch; }

.cv-downloads { display: flex; flex-wrap: wrap; gap: 12px; }
.cv-download {
  display: inline-flex; align-items: baseline; gap: 9px;
  min-height: 44px; padding: 10px 18px;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--surface);
}
.cv-download:hover { border-color: var(--accent-line); background: var(--surface-2); }
.cv-download-lang { font-family: var(--font-serif); font-size: 1rem; color: var(--text); }
.cv-download:hover .cv-download-lang { color: var(--accent-2); }
.cv-download-meta {
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted);
}
.cv-download.primary { border-color: var(--accent-line); background: var(--accent-dim); }
.cv-download.primary .cv-download-lang { color: var(--accent-2); }
.cv-download::after { content: "↓"; font-family: var(--font-mono); color: var(--text-muted); align-self: center; }
.cv-download:hover::after, .cv-download.primary::after { color: var(--accent); }

.cv-group-label {
  display: block; font-family: var(--font-mono); font-size: .64rem;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 11px;
}
.cv-online { margin-bottom: 28px; }
.cv-online-btn {
  display: inline-flex; align-items: center; gap: 10px; min-height: 46px; padding: 12px 24px;
  font-family: var(--font-sans); font-size: .92rem; font-weight: 500; letter-spacing: 0.01em;
  color: var(--bg); background: var(--accent); border: 1px solid var(--accent); border-radius: 7px;
}
.cv-online-btn::after { content: "→"; font-family: var(--font-mono); }
.cv-online-btn:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--bg); }
@media (max-width: 560px) { .cv-online-btn { width: 100%; justify-content: center; } }

/* ── Contact ─────────────────────────────────────────────── */
.contact-block { display: grid; gap: 22px; }
.contact-row {
  display: grid; grid-template-columns: 130px 1fr; gap: 18px; align-items: start;
  padding-bottom: 22px; border-bottom: 1px solid var(--rule-soft);
}
.contact-row:last-child { border-bottom: none; padding-bottom: 0; }
.contact-label {
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--text-muted); padding-top: 4px;
}
.contact-value { min-width: 0; }
.contact-email {
  font-family: var(--font-serif); font-size: 1.15rem; color: var(--accent-2);
  border-bottom: 1px solid var(--accent-line); padding-bottom: 1px;
}
.contact-email:hover { border-bottom-color: var(--accent); }
.contact-note { color: var(--text-2); font-size: .92rem; line-height: 1.65; }
.profile-links { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-links a {
  font-family: var(--font-mono); font-size: .72rem; letter-spacing: 0.03em;
  color: var(--text-2); border: 1px solid var(--rule); border-radius: 5px; padding: 7px 12px;
  min-height: 34px; display: inline-flex; align-items: center;
}
.profile-links a:hover { border-color: var(--accent-line); color: var(--accent-2); background: var(--surface); }

/* ── Footer ──────────────────────────────────────────────── */
footer { border-top: 1px solid var(--rule-soft); padding: 30px 0 40px; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
footer p { font-family: var(--font-mono); font-size: .70rem; letter-spacing: 0.04em; color: var(--text-muted); }

.empty-note { color: var(--text-muted); font-size: .9rem; font-style: italic; }

/* ============================================================
   MATERIALS PAGE
   ============================================================ */
.materials-header { padding: 56px 0 8px; }
.materials-eyebrow {
  font-family: var(--font-mono); font-size: .70rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 14px;
}
.materials-header h1 {
  font-family: var(--font-serif); font-weight: 600; font-size: 2.3rem; letter-spacing: -0.02em; line-height: 1.1;
  margin-bottom: 18px;
}
.materials-intro { font-size: .98rem; color: var(--text-2); max-width: 64ch; line-height: 1.75; }

.materials-list { display: flex; flex-direction: column; gap: 8px; padding-top: 28px; }

.collection { border-top: 1px solid var(--rule-soft); padding: 40px 0 12px; }
.collection:first-child { border-top: none; padding-top: 8px; }
.collection-head { margin-bottom: 22px; }
.collection-title {
  font-family: var(--font-serif); font-size: 1.35rem; font-weight: 500; letter-spacing: -0.01em;
  display: flex; align-items: baseline; gap: 12px;
}
.collection-count { font-family: var(--font-mono); font-size: .70rem; color: var(--text-muted); font-weight: 400; }
.collection-desc { font-size: .88rem; color: var(--text-muted); margin-top: 6px; max-width: 62ch; }

.material { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: start;
  padding: 18px 0; border-bottom: 1px solid var(--rule-soft); }
.material-main { min-width: 0; }
.material-title { font-size: 1rem; font-weight: 400; color: var(--text); line-height: 1.4; }
.material-desc { font-size: .86rem; color: var(--text-2); margin-top: 5px; line-height: 1.6; }
.material-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.material-date { font-family: var(--font-mono); font-size: .68rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.material-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.material-side { display: flex; align-items: center; padding-top: 2px; }
.material-kind {
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted); margin-right: 2px;
}
.material-link::after { content: " ↗"; font-size: .8em; }
.material-link.is-file::after { content: " ↓"; }

.materials-empty { padding: 60px 0; text-align: center; color: var(--text-muted); font-style: italic; }

/* Back link on materials */
.back-link {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: .70rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted); margin-top: 4px;
}
.back-link::before { content: "←"; }
.back-link:hover { color: var(--accent); }

/* ============================================================
   RESPONSIVE  — fluid first; breakpoints refine
   ============================================================ */

/* Larger screens & portrait monitors: a slightly more generous measure */
@media (min-width: 1024px) { :root { --max-w: 768px; } }

/* Condense the inline links a little before they collapse to the drawer */
@media (max-width: 940px) {
  .nav-links { gap: 16px; }
  .nav-links a { font-size: .64rem; letter-spacing: .07em; }
}

/* Tablet padding */
@media (max-width: 760px) {
  .container { padding: 0 22px; }
}

/* Phones */
@media (max-width: 560px) {
  html { font-size: 16px; }
  .container { padding: 0 18px; }
  section { padding: 44px 0; }

  .masthead { gap: 18px; }
  .explore-grid { grid-template-columns: 1fr; gap: 12px; }
  .software-grid { grid-template-columns: 1fr; gap: 14px; }
  .cv-downloads { gap: 10px; }
  .cv-download { flex: 1 1 130px; justify-content: space-between; }

  .contact-row { grid-template-columns: 1fr; gap: 7px; }
  .contact-label { padding-top: 0; }

  .footer-inner { flex-direction: column; align-items: flex-start; gap: 6px; }

  .material { grid-template-columns: 1fr; gap: 10px; }
  .material-side { padding-top: 0; }
}

/* Very narrow: stack the masthead */
@media (max-width: 400px) {
  .masthead { grid-template-columns: 1fr; gap: 20px; }
  .hero-photo, .hero-photo-placeholder { width: 104px; }
}

/* Touch devices: comfortable hit targets, no hover-only affordances */
@media (hover: none) and (pointer: coarse) {
  .nav-links a, .mobile-links a, .profile-links a, .paper-links a,
  .talk-link, .material-link, .cv-download, .hero-action, .hero-profile-links a {
    min-height: 40px; display: inline-flex; align-items: center;
  }
  .explore-card::after { color: var(--accent); }
}

/* ── Notes nav: hidden until at least one post is published ── */

/* ── Notes page ────────────────────────────────────────────── */
/* Client-side notes search */
.notes-search {
  width: 100%; margin: 8px 0 4px; padding: 11px 14px;
  background: transparent; color: var(--text);
  border: 1px solid var(--rule); border-radius: 8px;
  font-family: var(--font-sans, inherit); font-size: .95rem;
  transition: border-color .15s;
}
.notes-search::placeholder { color: var(--text-muted); }
.notes-search:focus { outline: none; border-color: var(--accent-line); }
/* Notes pager (archive navigation) */
.notes-pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; margin: 28px 0 8px; }
.notes-page-btn {
  min-width: 34px; height: 34px; padding: 0 9px;
  font-family: var(--font-mono); font-size: .82rem;
  color: var(--text-2); background: transparent;
  border: 1px solid var(--rule); border-radius: 7px; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.notes-page-btn:hover:not(.disabled):not(.active) { border-color: var(--accent-line); color: var(--accent-2); }
.notes-page-btn.active { background: var(--accent-dim); border-color: var(--accent-line); color: var(--accent-2); cursor: default; }
.notes-page-btn.disabled { opacity: .35; cursor: default; }
.notes-page-gap { color: var(--text-muted); padding: 0 2px; }
.notes-list { display: flex; flex-direction: column; }
.note { border-top: 1px solid var(--rule-soft); padding: 34px 0 30px; }
.note:first-child { border-top: none; padding-top: 8px; }
.note-head { margin-bottom: 12px; }
.note-date { font-family: var(--font-mono); font-size: .70rem; letter-spacing: 0.03em; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.note-title { font-family: var(--font-serif); font-size: 1.4rem; font-weight: 500; line-height: 1.28; color: var(--text); margin-top: 4px; }
.note-summary { font-size: .96rem; color: var(--text-2); line-height: 1.7; margin-bottom: 6px; }
.note-body { font-size: .92rem; color: var(--text-2); line-height: 1.75; }
.note-body p { margin-top: 14px; }
.note-body p:first-child { margin-top: 0; }
.note-body a { border-bottom: 1px solid var(--accent-line); }
.note-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.note-body .katex-display { margin: 16px 0; overflow-x: auto; overflow-y: hidden; }

/* Interactive notes: sandboxed iframe */
.note-frame-wrap {
  margin-top: 16px; border: 1px solid var(--rule); border-radius: 8px;
  overflow: hidden; background: var(--bg-2); width: 100%;
}
.note-frame { width: 100%; height: 100%; border: 0; display: block; background: var(--bg); }
.note-foot { margin-top: 10px; }
.note-open { font-family: var(--font-mono); font-size: .72rem; letter-spacing: 0.03em; color: var(--text-muted); }
.note-open:hover { color: var(--accent-2); }

/* ── Notes INDEX (notes.html): date · title · summary · button ── */
.note-index-item {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 20px;
  padding: 26px 0; border-top: 1px solid var(--rule-soft); color: var(--text);
}
.note-index-item:first-child { border-top: none; }
.note-index-item:hover .note-index-title { color: var(--accent-2); }
.note-index-item:hover .note-index-cta { color: var(--accent-2); border-color: var(--accent-line); background: var(--accent-dim); }
.note-index-main { min-width: 0; }
.note-index-date { font-family: var(--font-mono); font-size: .70rem; letter-spacing: 0.03em; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.note-index-title { font-family: var(--font-serif); font-size: 1.28rem; font-weight: 500; line-height: 1.28; color: var(--text); margin: 3px 0 4px; transition: color .15s; }
.note-index-summary { font-size: .92rem; color: var(--text-2); line-height: 1.6; }
.note-index-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.note-index-cta {
  font-family: var(--font-mono); font-size: .72rem; letter-spacing: 0.05em; white-space: nowrap;
  color: var(--accent-2); border: 1px solid var(--accent-line); background: var(--accent-dim);
  border-radius: 6px; padding: 8px 18px;
  transition: color .15s, border-color .15s, background .15s;
}
.note-index-item:hover .note-index-cta { background: var(--accent-2); border-color: var(--accent-2); color: var(--bg); }
@media (max-width: 560px) {
  .note-index-item { grid-template-columns: 1fr; gap: 12px; }
  .note-index-cta { justify-self: start; }
}

/* ── 404 ───────────────────────────────────────────────────── */
.notfound { padding: 100px 0 120px; text-align: center; }
.notfound-code { font-family: var(--font-mono); font-size: 3.2rem; color: var(--rule); font-weight: 500; line-height: 1; }
.notfound-title { font-family: var(--font-serif); font-size: 1.7rem; font-weight: 500; color: var(--text); margin: 14px 0 10px; }
.notfound-body { font-size: .96rem; color: var(--text-2); max-width: 46ch; margin: 0 auto 28px; }
