/* ==========================================================================
   philipaluck.org — shared stylesheet
   Serif-forward academic design. Light + dark themes. No framework.
   ========================================================================== */

:root {
  /* Light theme (default) */
  --bg:        #fbfaf7;
  --surface:   #ffffff;
  --ink:       #1a1f27;
  --muted:     #5a6470;
  --accent:    #1c6e6a;   /* deep teal — signature accent */
  --accent-ink:#14524f;
  --rule:      #e4e0d7;
  --tag-bg:    #f0eee7;
  --shadow:    0 1px 2px rgba(20, 24, 31, 0.04), 0 8px 24px rgba(20, 24, 31, 0.05);

  --serif: "EB Garamond", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --maxw:  920px;
  --wide:  1100px;

  color-scheme: light;
}

html[data-theme="dark"] {
  --bg:        #14181f;
  --surface:   #1b212b;
  --ink:       #e9ebee;
  --muted:     #9aa4b1;
  --accent:    #5fb8b0;   /* lighter teal for AA contrast on dark */
  --accent-ink:#8fd2cc;
  --rule:      #2b333f;
  --tag-bg:    #232b36;
  --shadow:    0 1px 2px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.30);
  color-scheme: dark;
}

/* Honor OS preference before any JS runs, unless the user has chosen. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --bg:#14181f; --surface:#1b212b; --ink:#e9ebee; --muted:#9aa4b1;
    --accent:#5fb8b0; --accent-ink:#8fd2cc; --rule:#2b333f; --tag-bg:#232b36;
    --shadow:0 1px 2px rgba(0,0,0,.25),0 8px 24px rgba(0,0,0,.30);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 200ms ease, color 200ms ease;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(127, 127, 127, 0.28);
  transition: border-color 120ms ease, color 120ms ease;
}
a:hover { border-bottom-color: currentColor; }
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Skip link for keyboard / screen-reader users */
.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  z-index: 100;
  border: none;
}
.skip:focus { left: 8px; top: 8px; }

/* --------------------------------------------------------------- top nav */
.topnav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.topnav-inner {
  max-width: var(--wide);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 13px clamp(20px, 5vw, 48px);
  font-size: 14px;
}
.brand {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  border: none;
  letter-spacing: 0.01em;
  color: var(--ink);
  white-space: nowrap;
}
.navlinks {
  display: flex;
  align-items: center;
  gap: 22px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.navlinks a {
  border: none;
  color: var(--muted);
  font-weight: 500;
}
.navlinks a:hover { color: var(--ink); }
.navlinks a[aria-current="page"] {
  color: var(--ink);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
}

/* theme + hamburger buttons */
.iconbtn {
  background: none;
  border: 1px solid var(--rule);
  color: var(--muted);
  border-radius: 7px;
  width: 36px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: border-color 120ms ease, color 120ms ease;
}
.iconbtn:hover { color: var(--ink); border-color: var(--muted); }
.navtoggle { display: none; }

/* --------------------------------------------------------------- layout */
.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 48px) 72px;
}

.hero {
  padding: 64px 0 36px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 8px;
}
.eyebrow {
  font-size: 12.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 14px;
}
.hero h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(46px, 8vw, 78px);
  line-height: 1.0;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}
.hero .tagline {
  font-family: var(--serif);
  font-size: clamp(19px, 2.4vw, 25px);
  line-height: 1.3;
  color: var(--accent);
  margin: 0 0 20px;
  max-width: 24ch;
}
.hero .role {
  font-size: 18px;
  color: var(--ink);
  margin: 0 0 6px;
  font-weight: 500;
}
.hero .affil {
  font-size: 16px;
  color: var(--muted);
  margin: 0 0 24px;
  line-height: 1.5;
}

/* CTA button row */
.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14.5px;
  font-weight: 500;
  padding: 8px 15px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.btn:hover { border-color: var(--muted); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
html[data-theme="dark"] .btn-primary { color: #0e1117; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }

/* hero with portrait */
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 196px;
  gap: clamp(24px, 5vw, 52px);
  align-items: center;
}
.portrait {
  width: 100%;
  max-width: 196px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: block;
}

/* feature photo (e.g. with Secretary Blinken) */
.feature { margin: 28px 0 0; }
.feature img {
  width: 100%;
  height: auto;
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: block;
}
.feature figcaption {
  color: var(--muted);
  font-size: 13.5px;
  font-style: italic;
  margin-top: 10px;
  line-height: 1.5;
}

/* "featured in" wordmark strip */
.featuredin {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 24px;
  padding: 0;
}
.featuredin .lab {
  width: 100%;
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 8px;
}
.featuredin span.outlet-wm {
  font-family: var(--serif);
  font-size: 18px;
  color: var(--ink);
  opacity: 0.72;
}

/* --------------------------------------------------------------- sections */
.page-head { padding: 56px 0 4px; }
.page-head h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(32px, 5vw, 44px);
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}
.page-head .lede { color: var(--muted); font-size: 17px; margin: 0; max-width: 56ch; }

section { padding: 32px 0; border-bottom: 1px solid var(--rule); }
section:last-of-type { border-bottom: none; }

h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 27px;
  letter-spacing: 0;
  margin: 0 0 18px;
}
h3 {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 12px;
  color: var(--muted);
  margin: 30px 0 14px;
  font-weight: 700;
}
p { margin: 0 0 16px; }
.bio p { font-size: 17.5px; }

/* research-interest tags */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 6px 0 0;
  list-style: none;
}
.tags li {
  font-size: 13.5px;
  color: var(--ink);
  background: var(--tag-bg);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 5px 13px;
}

.note { color: var(--muted); font-size: 15px; margin-bottom: 18px; }
.muted { color: var(--muted); }

/* --------------------------------------------------------------- pubs */
.pubs { list-style: none; counter-reset: pub; padding: 0; margin: 0; }
.pubs li {
  counter-increment: pub;
  position: relative;
  padding: 14px 0 14px 40px;
  border-top: 1px dotted var(--rule);
}
.pubs li:first-child { border-top: none; }
.pubs li::before {
  content: counter(pub);
  position: absolute;
  left: 0;
  top: 16px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--muted);
  width: 28px;
  text-align: right;
}
.ptitle {
  display: block;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.3;
  margin-bottom: 4px;
}
.ptitle a { border-bottom-color: transparent; }
.ptitle a:hover { border-bottom-color: currentColor; }
.pmeta { display: block; color: var(--muted); font-size: 15px; line-height: 1.5; }
.plinks { margin-top: 5px; font-size: 13.5px; display: flex; flex-wrap: wrap; gap: 14px; }
.plinks a {
  border: none;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 12px;
}
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--tag-bg);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 1px 7px;
  margin-left: 8px;
  vertical-align: middle;
}

/* plain bulletless lists */
.plain { list-style: none; padding: 0; margin: 0; }
.plain li {
  padding: 11px 0;
  border-top: 1px dotted var(--rule);
  font-size: 16.5px;
}
.plain li:first-child { border-top: none; }
.plain .pmeta { display: inline; font-size: 14.5px; }

/* commentary / media rows */
.entries { list-style: none; padding: 0; margin: 0; }
.entries li {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 18px;
  align-items: baseline;
  padding: 12px 0;
  border-top: 1px dotted var(--rule);
  font-size: 16.5px;
}
.entries li:first-child { border-top: none; }
.entries .date,
.entries .outlet {
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  font-size: 14.5px;
}
.entries .etitle a { border-bottom-color: transparent; }
.entries .etitle a:hover { border-bottom-color: currentColor; }
.entries .with { color: var(--muted); font-size: 14px; }

.seeall { margin-top: 22px; font-size: 15px; }

/* --------------------------------------------------------------- footer */
footer {
  border-top: 1px solid var(--rule);
  background: var(--surface);
}
.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px clamp(20px, 5vw, 48px) 40px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 13.5px;
}
.footer-inner a { color: var(--muted); border-bottom-color: transparent; }
.footer-inner a:hover { color: var(--ink); }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }

/* --------------------------------------------------------------- mobile */
@media (max-width: 680px) {
  .navtoggle { display: inline-flex; }
  .navlinks {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
    padding: 6px clamp(20px, 5vw, 48px) 14px;
    display: none;
  }
  .navlinks.open { display: flex; }
  .navlinks li { width: 100%; }
  .navlinks a { display: block; padding: 11px 0; width: 100%; }
  .navlinks a[aria-current="page"] { border-bottom: none; color: var(--accent); }
  .hero { padding: 44px 0 30px; }
  .entries li { grid-template-columns: 78px 1fr; gap: 12px; }
  .hero-grid { grid-template-columns: 1fr; }
  .portrait { width: 132px; order: -1; }
  .featuredin span.outlet-wm { font-size: 16px; }
}

/* =========================================================================
   Visual enhancements: heading accents, research cards, reveal-on-scroll,
   topic-tile post lists
   ========================================================================= */

/* #2 — short accent rule under section headings */
h2::after {
  content: "";
  display: block;
  width: 36px;
  height: 3px;
  margin-top: 10px;
  background: var(--accent);
  border-radius: 2px;
}

/* #3 — selected-research cards */
.pubs.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}
.pubs.cards li {
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color 120ms ease, transform 120ms ease;
}
.pubs.cards li::before { display: none; }       /* drop the running number */
.pubs.cards li:hover { border-color: var(--muted); transform: translateY(-2px); }
.pubs.cards .ptitle { font-size: 18px; }

/* #4 — reveal on scroll (progressive enhancement; only active with JS) */
.js .reveal { opacity: 0; transform: translateY(14px); }
.js .reveal.is-visible {
  opacity: 1;
  transform: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; }
}

/* #5 — topic-tile post list (writing page) */
.postlist { list-style: none; padding: 0; margin: 0; }
.postlist li {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 16px;
  align-items: center;
  padding: 13px 0;
  border-top: 1px dotted var(--rule);
}
.postlist li:first-child { border-top: none; }
.thumb {
  height: 54px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 4px;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.post-title { display: block; font-family: var(--serif); font-size: 18.5px; line-height: 1.32; }
.post-title a { border-bottom-color: transparent; }
.post-title a:hover { border-bottom-color: currentColor; }
.post-meta { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
.t-trade  { background: #1f3a5f; }
.t-china  { background: #6d3b3b; }
.t-ai     { background: #2f6b6b; }
.t-mig    { background: #3a6b4a; }
.t-sec    { background: #44506b; }
.t-fin    { background: #8a6d3b; }
.t-allies { background: #4b3f72; }

@media (max-width: 680px) {
  .postlist li { grid-template-columns: 56px 1fr; gap: 12px; }
  .thumb { height: 50px; font-size: 8.5px; }
}

/* #6 — ambient hero background (faded photo with Secretary Blinken) */
.hero { position: relative; overflow: hidden; }
.hero-bg {
  position: absolute;
  inset: 0;
  background-image: url("../assets/luck-blinken.jpg");
  background-size: cover;
  background-position: 60% 22%;
  opacity: 0.20;
  -webkit-mask-image: linear-gradient(to left, #000 0%, rgba(0,0,0,0.65) 42%, rgba(0,0,0,0) 78%);
  mask-image: linear-gradient(to left, #000 0%, rgba(0,0,0,0.65) 42%, rgba(0,0,0,0) 78%);
  pointer-events: none;
  z-index: 0;
}
html[data-theme="dark"] .hero-bg { opacity: 0.16; }
.hero-grid { position: relative; z-index: 1; }
.hero-credit {
  position: relative;
  z-index: 1;
  margin: 22px 0 0;
  font-size: 13px;
  font-style: italic;
  color: var(--muted);
  max-width: 60ch;
}
@media (max-width: 680px) {
  .hero-bg { opacity: 0.10; background-position: 58% 18%; }
}

/* wider container — keep prose at a comfortable measure; lists/cards span full width */
.hero-content { position: relative; z-index: 1; max-width: 44em; }
.bio p { max-width: 70ch; }
.page-head .lede { max-width: 64ch; }
.post-title { max-width: 64ch; }
