/* ============================================================================
   Themes. All colors and font families are declared as CSS variables on
   [data-theme] blocks; nothing below hardcodes a palette, so the three themes
   swap cleanly. Default is dark.
   ============================================================================ */
:root, [data-theme="dark"] {
  --bg:        #0f1420;
  --panel:     #171d2b;
  --panel-2:   #1e2534;
  --border:    #2a3244;
  --text:      #e8ebf2;
  --muted:     #8b93a7;
  --accent:    #4f8cff;
  --accent-2:  #3ecf8e;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --font-head: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --head-weight: 700;
}
[data-theme="light"] {
  --bg:        #ffffff;
  --panel:     #ffffff;
  --panel-2:   #f5f5f7;
  --border:    #e5e5ea;
  --text:      #1a1a1a;
  --muted:     #6b7280;
  --accent:    #0066cc;
  --accent-2:  #16a34a;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --font-head: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --head-weight: 600;
}
[data-theme="ft"] {
  /* Financial Times signature palette: salmon paper, off-black text, claret accent. */
  --bg:        #fff1e5;
  --panel:     #fff1e5;
  --panel-2:   #f2e5cf;
  --border:    #d9d2c4;
  --text:      #33302e;
  --muted:     #66605c;
  --accent:    #990f3d;   /* FT claret */
  --accent-2:  #0d7680;   /* FT teal */
  --font-body: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-head: Georgia, "Times New Roman", serif;
  --head-weight: 700;
}

/* ============================================================================
   Base
   ============================================================================ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color .15s ease, color .15s ease;
}
main.wrap { flex: 1; }
.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px;
}
main.wrap { padding-top: 40px; padding-bottom: 64px; }

h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: var(--head-weight);
  letter-spacing: -.2px;
  line-height: 1.25;
  margin: 1.6em 0 .6em 0;
}
h1 { font-size: 32px; margin-top: 0; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p, ul, ol { margin: 0 0 1em 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }
code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13.5px;
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 3px;
}
pre {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  overflow-x: auto;
}
pre code { background: none; padding: 0; }
blockquote {
  border-left: 3px solid var(--border);
  color: var(--muted);
  margin: 1em 0;
  padding: .2em 0 .2em 16px;
}

/* ============================================================================
   Site header + nav + theme picker
   ============================================================================ */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.header-row {
  display: flex;
  align-items: center;
  gap: 24px;
  padding-top: 18px;
  padding-bottom: 18px;
}
.site-title {
  font-family: var(--font-head);
  font-weight: var(--head-weight);
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.2px;
}
.site-title:hover { text-decoration: none; color: var(--accent); }
.site-nav {
  display: flex;
  gap: 20px;
  flex: 1;
  margin-left: 8px;
}
.site-nav a {
  color: var(--muted);
  font-size: 14.5px;
  text-decoration: none;
}
.site-nav a:hover { color: var(--text); }

.theme-picker {
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel-2);
}
.theme-picker button {
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  padding: 4px 9px;
  border-radius: 14px;
  transition: background-color .12s ease, color .12s ease;
}
.theme-picker button:hover { color: var(--text); }
.theme-picker button.active {
  background: var(--accent);
  color: #ffffff;
}
[data-theme="ft"] .theme-picker button.active { color: #fff1e5; }

/* ============================================================================
   Homepage sections
   ============================================================================ */
.hero { padding: 20px 0 8px; }
.hero .lede { color: var(--muted); font-size: 17px; max-width: 620px; }

section.section { margin-top: 44px; }
section.section > h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 18px 0;
  font-family: var(--font-body);   /* keep section labels sans even in FT theme */
}

/* Essay list */
ul.essay-list { list-style: none; padding: 0; margin: 0; }
ul.essay-list li {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
ul.essay-list li:last-child { border-bottom: none; }
ul.essay-list a {
  color: var(--text);
  font-family: var(--font-head);
  font-weight: var(--head-weight);
  font-size: 17px;
  text-decoration: none;
}
ul.essay-list a:hover { color: var(--accent); }
ul.essay-list .essay-date {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
  font-family: var(--font-body);
}
ul.essay-list .essay-excerpt {
  color: var(--muted);
  font-size: 14px;
  margin-top: 6px;
  line-height: 1.55;
}

/* CV link block */
.cv-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  transition: border-color .12s ease, background-color .12s ease;
}
.cv-link:hover { border-color: var(--accent); text-decoration: none; }
.cv-link .arrow { color: var(--accent); font-weight: 700; }

/* Tool cards */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
article.tool {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  transition: border-color .12s ease, transform .12s ease;
}
article.tool:hover { border-color: var(--accent); transform: translateY(-1px); }
article.tool .tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  padding: 3px 9px;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--accent);
  border: 1px solid var(--border);
  align-self: flex-start;
  margin-bottom: 12px;
}
article.tool h3 { margin: 0 0 6px 0; font-size: 16px; }
article.tool h3 a { color: var(--text); text-decoration: none; }
article.tool h3 a:hover { color: var(--accent); }
article.tool p {
  margin: 0 0 14px 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
  flex: 1;
}
article.tool .cta {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
}
article.tool .cta:hover { text-decoration: underline; }
article.tool .cta::after { content: "\2192"; transition: transform .12s ease; }
article.tool:hover .cta::after { transform: translateX(3px); }

/* ============================================================================
   Essay page
   ============================================================================ */
article.essay { max-width: 680px; margin: 0 auto; }
.essay-header { margin-bottom: 32px; }
.essay-meta {
  color: var(--muted);
  font-size: 13.5px;
  font-family: var(--font-body);
}
.essay-body { font-size: 17px; line-height: 1.7; }
.essay-body h2 { margin-top: 2em; }
.essay-body h3 { margin-top: 1.8em; }
.essay-body img { max-width: 100%; height: auto; }
.essay-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

/* ============================================================================
   Footer
   ============================================================================ */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  padding: 18px 0;
}
.footer-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.footer-row .dot { color: var(--border); }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }

/* ============================================================================
   Small screens
   ============================================================================ */
@media (max-width: 640px) {
  .header-row { flex-wrap: wrap; gap: 12px 20px; padding-top: 14px; padding-bottom: 14px; }
  .site-nav { flex: 1 1 100%; order: 3; margin-left: 0; }
  .theme-picker { order: 2; }
  h1 { font-size: 26px; }
  .wrap { padding: 0 18px; }
}
