/* ============================================================
   Benedict Weichselbaum — personal site
   Custom design system (light + dark, system-font, no external deps)
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  --bg:            #ffffff;
  --bg-alt:        #f5f6f8;
  --surface:       #ffffff;
  --surface-2:     #f8f9fb;
  --border:        #e6e8ec;
  --border-strong: #d3d7de;
  --text:          #14181f;
  --text-2:        #4a5261;
  --text-3:        #6b7280;
  --accent:        #2f6bed;
  --accent-2:      #1f56d6;
  --accent-soft:   rgba(47, 107, 237, 0.10);
  --shadow:        0 1px 2px rgba(16, 24, 40, .04), 0 10px 28px rgba(16, 24, 40, .06);
  --shadow-lg:     0 2px 6px rgba(16, 24, 40, .06), 0 24px 48px rgba(16, 24, 40, .10);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --radius:    14px;
  --radius-sm: 9px;
  --maxw:      1080px;
  --maxw-read: 760px;
}

:root[data-theme="dark"] {
  --bg:            #0d1017;
  --bg-alt:        #12161f;
  --surface:       #151a24;
  --surface-2:     #1a2029;
  --border:        #242b38;
  --border-strong: #313a4a;
  --text:          #e7eaf0;
  --text-2:        #b3bccb;
  --text-3:        #8792a3;
  --accent:        #5f8bff;
  --accent-2:      #7aa0ff;
  --accent-soft:   rgba(95, 139, 255, 0.14);
  --shadow:        0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-lg:     0 2px 6px rgba(0, 0, 0, .35), 0 24px 48px rgba(0, 0, 0, .5);
}

/* No-JS / system fallback: honour OS dark unless the user chose light explicitly */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0d1017;
    --bg-alt:        #12161f;
    --surface:       #151a24;
    --surface-2:     #1a2029;
    --border:        #242b38;
    --border-strong: #313a4a;
    --text:          #e7eaf0;
    --text-2:        #b3bccb;
    --text-3:        #8792a3;
    --accent:        #5f8bff;
    --accent-2:      #7aa0ff;
    --accent-soft:   rgba(95, 139, 255, 0.14);
    --shadow:        0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
    --shadow-lg:     0 2px 6px rgba(0, 0, 0, .35), 0 24px 48px rgba(0, 0, 0, .5);
  }
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

img { max-width: 100%; height: auto; display: block; }

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

h1, h2, h3, h4 {
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 2rem 0 0.75rem;
}
h1 { font-size: clamp(2rem, 5vw, 3rem); margin-top: 0; }
h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); }
h3 { font-size: 1.2rem; }
p  { margin: 0 0 1.1rem; }

hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.12em 0.4em;
  border-radius: 6px;
}
pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.15rem;
  overflow-x: auto;
}
pre code { background: none; border: 0; padding: 0; }

blockquote {
  margin: 1.5rem 0;
  padding: 0.4rem 1.2rem;
  border-left: 3px solid var(--accent);
  color: var(--text-2);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 1.5rem; }
.site-main { flex: 1 0 auto; padding: 3rem 0 4.5rem; }
.reading { max-width: var(--maxw-read); }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
}
.brand {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 1.02rem;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.nav-links { display: flex; align-items: center; gap: 0.35rem; }
.nav-links a {
  color: var(--text-2);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav-links a.active { color: var(--accent); }

.theme-toggle {
  margin-left: 0.4rem;
  width: 38px; height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 9px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun  { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun  { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ---------- Buttons & chips ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.65rem 1.15rem;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .15s, border-color .15s, background .15s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); border-color: var(--accent); color: var(--text); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
}
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn-ghost { background: transparent; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.3rem 0.65rem;
  border-radius: 7px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

/* ---------- Hero (home) ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.35fr 0.9fr;
  gap: 3rem;
  align-items: center;
  padding: 1rem 0 2.5rem;
}
.hero h1 { margin: 0 0 0.4rem; }
.hero-role {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-2);
  margin: 0 0 1rem;
}
.hero-tagline { color: var(--text-2); font-size: 1.05rem; max-width: 46ch; margin-bottom: 1.6rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.8rem; }
.hero-photo { position: relative; }
.hero-photo img {
  width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  aspect-ratio: 4 / 5;
  object-fit: cover;
}
.hero-photo::after {
  content: "";
  position: absolute;
  inset: auto -14px -14px auto;
  width: 64%; height: 64%;
  border-radius: var(--radius);
  background: var(--accent-soft);
  z-index: -1;
}

/* ---------- Section headers ---------- */
.section { margin-top: 3.5rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.section-head h2 { margin: 0; }
.section-head .more { font-size: 0.92rem; font-weight: 600; }

/* ---------- Cards / post list ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.2rem; }
.post-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem;
  transition: transform .14s ease, box-shadow .18s, border-color .15s;
}
.post-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--border-strong); text-decoration: none; }
.post-card .meta { font-family: var(--font-mono); font-size: 0.76rem; color: var(--text-3); margin-bottom: 0.6rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.post-card h3 { margin: 0 0 0.4rem; font-size: 1.15rem; color: var(--text); }
.post-card p { color: var(--text-2); font-size: 0.95rem; margin: 0; }
.post-card .read-more { margin-top: auto; padding-top: 0.9rem; color: var(--accent); font-weight: 600; font-size: 0.9rem; }

.tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
}

/* Writing index (grouped list) */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-list li { border-bottom: 1px solid var(--border); }
.post-list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.2rem;
  padding: 1.15rem 0.25rem;
  color: var(--text);
}
.post-list a:hover { text-decoration: none; color: var(--accent); }
.post-list .p-title { font-weight: 600; font-size: 1.1rem; }
.post-list .p-date { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-3); white-space: nowrap; }

/* ---------- Page header ---------- */
.page-header { margin-bottom: 2rem; }
.page-header h1 { margin-bottom: 0.5rem; }
.page-header .lead { color: var(--text-2); font-size: 1.1rem; margin: 0; }

/* ---------- CV timeline ---------- */
.cv-photo {
  float: right;
  width: 150px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin: 0 0 1rem 1.5rem;
}
.timeline { border-left: 2px solid var(--border); margin: 0.5rem 0 1rem; padding: 0; }
.timeline-item { position: relative; padding: 0 0 1.8rem 1.7rem; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -7px; top: 6px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
}
.timeline-item:last-child { padding-bottom: 0.4rem; }
.tl-period { font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent); letter-spacing: 0.02em; }
.tl-role { font-size: 1.12rem; font-weight: 700; margin: 0.15rem 0 0.1rem; }
.tl-org { color: var(--text-2); font-weight: 500; font-size: 0.98rem; margin-bottom: 0.5rem; }
.timeline-item ul { margin: 0.4rem 0 0; padding-left: 1.15rem; color: var(--text-2); }
.timeline-item ul li { margin-bottom: 0.25rem; }

.skill-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }
.skill-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.25rem;
}
.skill-card h3 { margin: 0 0 0.7rem; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); }

.lang-list { display: flex; flex-direction: column; gap: 0.6rem; }
.lang-row { display: flex; align-items: center; gap: 0.75rem; }
.lang-row .lang-name { font-weight: 600; width: 90px; }
.lang-row .lang-level { color: var(--text-2); font-size: 0.95rem; }

/* ---------- Post (article) ---------- */
.post-hero { margin-bottom: 2rem; }
.post-hero .meta { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-3); margin-bottom: 0.6rem; display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.post-content { font-size: 1.06rem; }
.post-content img { border-radius: var(--radius); border: 1px solid var(--border); margin: 1.5rem auto; }
.post-content h2, .post-content h3, .post-content h4 { margin-top: 2.2rem; }
.post-content table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: 0.95rem; display: block; overflow-x: auto; }
.post-content th, .post-content td { border: 1px solid var(--border); padding: 0.6rem 0.85rem; text-align: left; }
.post-content th { background: var(--surface-2); font-weight: 600; }
.post-content tr:nth-child(even) td { background: var(--surface-2); }
.post-nav { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }

/* ---------- Contact ---------- */
.contact-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.contact-card {
  display: flex; align-items: center; gap: 0.9rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.25rem;
  transition: transform .14s ease, box-shadow .18s, border-color .15s;
}
.contact-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); text-decoration: none; }
.contact-card .ci { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.contact-card .ci svg { width: 20px; height: 20px; }
.contact-card > span:last-child { min-width: 0; }
.contact-card .cl { color: var(--text-3); font-size: 0.8rem; }
.contact-card .cv { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }

/* ---------- Footer ---------- */
.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text-3);
  font-size: 0.9rem;
}
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.6rem 0; flex-wrap: wrap; }
.footer-links { display: flex; gap: 1.2rem; }
.footer-links a { color: var(--text-3); }
.footer-links a:hover { color: var(--accent); text-decoration: none; }

/* ---------- 404 ---------- */
.notfound { text-align: center; padding: 5rem 0; }
.notfound .code { font-size: clamp(4rem, 14vw, 8rem); font-weight: 800; letter-spacing: -0.04em; color: var(--accent); line-height: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; gap: 2rem; }
  .hero-photo { max-width: 320px; }
  .hero-photo::after { display: none; }
}
@media (max-width: 620px) {
  body { font-size: 16px; }
  .nav-links a { padding: 0.4rem 0.5rem; }
  .cv-photo { float: none; width: 140px; margin: 0 0 1.25rem; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 460px) {
  .brand span.full { display: none; }
}
