/* =====================================================================
   Takaaki Sagawa — personal academic site
   Plain CSS, mobile-first. No frameworks.
   ===================================================================== */

:root {
  --max-width: 900px;         /* content column width */
  --text: #1c1c1e;
  --muted: #6b7280;
  --accent: #1b3a6b;          /* dark blue — easy to change */
  --accent-hover: #2a5499;
  --status: #2e7d52;          /* green — for "R&R", "IMF Working Paper", etc. */
  --border: #e5e7eb;
  --bg: #ffffff;
  --header-h: 60px;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

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

/* ============================ STICKY HEADER ============================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}

.nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav__brand {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.15rem;
  letter-spacing: 0.2px;
  color: var(--accent);
}
.nav__brand:hover { text-decoration: none; color: var(--accent-hover); }

.nav__links {
  list-style: none;
  display: flex;
  gap: 26px;
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 0.98rem;
}

.nav__links a { color: var(--text); }
.nav__links a:hover,
.nav__links a[aria-current="page"] { color: var(--accent); text-decoration: none; }

/* Hamburger — hidden on desktop */
.nav__toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}
.nav__toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease;
}

/* ============================== LAYOUT ============================== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 48px 20px 24px;
}

/* Offset anchor jumps so the sticky header doesn't cover section tops */
#top, #research { scroll-margin-top: calc(var(--header-h) + 16px); }

/* ============================== INTRO ============================== */
/* Two columns on desktop: bio on the left, photo + contact on the right. */
.intro {
  display: flex;
  align-items: flex-start;
  gap: 48px;
  text-align: left;
}

/* Right-hand column holding the portrait photo and contact links */
.intro__aside {
  flex: 0 0 290px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.intro__photo {
  width: 290px;
  height: 362px;             /* portrait orientation (4:5) */
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* Contact block under the photo */
.contact {
  text-align: center;
  margin-top: 14px;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  line-height: 1.5;
}
.contact__email { color: var(--muted); }
.contact__email:hover { color: var(--accent); }
.contact__links { margin: 2px 0 0; }
.contact__links a { color: var(--accent); font-weight: 600; }
.contact__links .sep { color: var(--muted); margin: 0 8px; }

/* Bio column */
.intro__bio { flex: 1; font-size: 0.95rem; }
.intro__name {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 2.4rem;
  line-height: 1.1;
  margin: 0 0 22px;
  color: var(--text);
}
.intro__bio p { margin: 0 0 1.1em; }
.intro__bio p:last-child { margin-bottom: 0; }

/* ============================= RESEARCH ============================= */
.research { margin-top: 56px; }

.section-title {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 40px 0 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--text);
}

/* Expandable paper rows (native <details>).
   Title + co-authors + PDF link are always visible (inside <summary>);
   clicking the title expands the abstract. */
.paper {
  border-bottom: 1px solid var(--border);
  padding: 4px 0;
}
.paper summary {
  cursor: pointer;
  list-style: none;            /* hide default triangle */
  padding: 14px 28px 14px 0;
  position: relative;
  outline: none;
}
.paper summary::-webkit-details-marker { display: none; }

/* Custom +/- indicator on the right */
.paper summary::after {
  content: "+";
  position: absolute;
  right: 4px;
  top: 18px;
  font-family: var(--font-sans);
  font-size: 1.3rem;
  line-height: 1;
  color: var(--muted);
}
.paper[open] summary::after { content: "\2013"; /* en dash */ }

.paper summary:hover .paper__title { color: var(--accent); }

.paper__title {
  font-weight: 600;
  font-size: 1.08rem;
  display: block;
}

/* Always-visible info under the title, each on its own line:
   line 1 = co-authors (grey); line 2 = optional status note (green);
   line 3 = "Paper" link (blue) */
.paper__sub {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-top: 5px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}
.paper__meta { color: var(--muted); font-style: italic; }
.paper__meta:empty { display: none; }     /* solo-authored: no empty line */
.paper__status { color: var(--status); font-weight: 600; }
.paper__status:empty { display: none; }   /* no status note: no empty line */
.paper__pdf { font-weight: 600; }

/* Multiple file links (e.g. Paper | Appendix) share one line */
.paper__files { display: flex; align-items: baseline; gap: 8px; }
.paper__files .sep { color: var(--muted); font-weight: 400; }

/* Works in Progress: plain non-expandable rows */
.paper--static { padding: 14px 0; }
/* For these rows, keep a small blank gap where co-authors would go, so the
   spacing stays even without making the empty row a full line taller. */
.paper--static .paper__meta:empty { display: block; height: 0.8em; }

/* Collapsible abstract */
.paper__abstract {
  padding: 2px 28px 18px 0;
  animation: fade 0.25s ease;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #333;
}
.paper__abstract p { margin: 0; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ============================= TEACHING ============================= */
.page-title {
  font-family: var(--font-sans);
  font-size: 1.8rem;
  margin: 0 0 24px;
}
.course-list { list-style: none; padding: 0; margin: 24px 0 0; }
.course-list li {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.course-list__name { font-weight: 600; }
.course-list__meta { color: var(--muted); font-size: 0.95rem; }

/* Make the teaching-evaluations link stand out clearly */
.eval-link { font-weight: 600; }

/* ============================== FOOTER ============================== */
.site-footer {
  max-width: var(--max-width);
  margin: 48px auto 0;
  padding: 24px 20px 40px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  text-align: center;
}

/* ============================ RESPONSIVE ============================ */
@media (max-width: 700px) {
  /* Stack the intro: photo + contact on top, name + bio below */
  .intro {
    flex-direction: column;
    align-items: center;
    gap: 24px;
  }
  .intro__aside { order: -1; }          /* photo first on mobile */
  .intro__name { text-align: center; }
  .intro__bio { text-align: left; }
}

@media (max-width: 600px) {
  body { font-size: 17px; }

  .nav__toggle { display: flex; }

  .nav__links {
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    /* hidden until toggled */
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.28s ease;
  }
  .nav__links.open { max-height: 320px; }
  .nav__links li { width: 100%; }
  .nav__links a {
    display: block;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
  }

  .container { padding-top: 32px; }
}
