/* =========================
   Theme variables
========================= */
:root{
  --bg: #C4C4C4;
  --fg: #111111;
  --muted: #444444;
  --border: #e6e6e6;
  --card: #ffffff;
  --line: #e6e6e6;
  --shadow: rgba(0,0,0,0.06);
}

html[data-theme="dark"]{
  --bg: #0b0d10;
  --fg: #e9eef5;
  --muted: #a9b4c0;
  --border: #223040;
  --card: #0f141a;
  --line: #223040;
  --shadow: rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 16px/1.55 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
a:hover { opacity: 0.9; }

.container { max-width: 980px; margin: 0 auto; padding: 20px; }
.muted { color: var(--muted); }

/* =========================
   Header / Nav
========================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-weight: 800;
  text-decoration: none;
  letter-spacing: 0.2px;
}

.nav a {
  margin-left: 14px;
  text-decoration: none;
}
.nav a:hover { text-decoration: underline; }

.theme-toggle{
  margin-left: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  box-shadow: 0 1px 0 var(--shadow);
}

/* =========================
   Page typography
========================= */
h1,h2,h3 { line-height: 1.2; }
h1 { margin: 24px 0 10px; font-size: 2rem; }
h2 { margin: 26px 0 10px; font-size: 1.35rem; }
h3 { margin: 18px 0 8px; font-size: 1.1rem; }

.page-title { margin-top: 10px; }
.page-content { max-width: 100%; }

/* =========================
   UI components
========================= */
.btnrow { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 6px; }

.btn {
  display: inline-block;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  background: var(--card);
  box-shadow: 0 1px 0 var(--shadow);
}

.btn.primary {
  border-color: var(--fg);
  background: var(--fg);
  color: var(--bg);
}

.kv { display: flex; flex-wrap: wrap; gap: 10px 14px; padding: 0; list-style: none; margin: 12px 0 0; }
.kv li {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--card);
}

.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: var(--card);
  box-shadow: 0 1px 0 var(--shadow);
}

.col-6 { grid-column: span 6; }
.col-12 { grid-column: span 12; }

@media (max-width: 820px) {
  .col-6 { grid-column: span 12; }
}

/* =========================
   Footer
========================= */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 18px 0;
  color: var(--muted);
}
.footer-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* =========================
   Timeline (newest at top)
   Center line, education left, work right.
========================= */
.timeline {
  position: relative;
  margin: 18px 0 6px;
  padding: 8px 0;
  display: flex;
  flex-direction: column; /* keep natural order */
}

/* center line */
.timeline::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--line);
  transform: translateX(-1px);
}

.tl-item {
  display: grid;
  grid-template-columns: 1fr 36px 1fr;
  gap: 12px;
  align-items: start;
  margin: 16px 0;
}

.tl-mid {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.tl-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid var(--fg);
  background: var(--bg);
  margin-top: 6px;
}

.tl-date {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.tl-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 12px 10px;
  background: var(--card);
  box-shadow: 0 1px 0 var(--shadow);
}

.tl-card h3 { margin: 0 0 6px; font-size: 1.02rem; }
.tl-card p { margin: 0 0 8px; }
.tl-card ul { margin: 0; padding-left: 18px; }

.tl-left { grid-column: 1; text-align: right; }
.tl-mid  { grid-column: 2; }
.tl-right { grid-column: 3; }

.tl-left .tl-card { margin-left: auto; }
.tl-right .tl-card { margin-right: auto; }

.tl-tag {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-right: 6px;
  background: var(--bg);
}

/* Mobile: stack */
@media (max-width: 820px) {
  .timeline::before { left: 10px; transform: none; }
  .tl-item { grid-template-columns: 20px 1fr; gap: 10px; }
  .tl-mid { grid-column: 1; justify-content: flex-start; }
  .tl-left, .tl-right { grid-column: 2; text-align: left; }
  .tl-left .tl-card, .tl-right .tl-card { margin: 0; }
}

/* Role-based accents */
.tl-card.work { border-left: 4px solid #2563eb; }
.tl-card.research { border-left: 4px solid #9333ea; }
.tl-card.education { border-left: 4px solid #059669; }

.tl-tag.work { color: #2563eb; }
.tl-tag.research { color: #9333ea; }
.tl-tag.education { color: #059669; }

.tl-dot.work { border-color: #2563eb; }
.tl-dot.research { border-color: #9333ea; }
.tl-dot.education { border-color: #059669; }

/* Make timeline cards span full width */
.tl-card.full {
  max-width: 100%;
}

/* Make left-side cards full width instead of narrow */
.tl-left .tl-card.full {
  margin-left: 0;
  text-align: left;
}

/* Remove visual section separation */
.page-content h2 {
  margin-top: 40px;
  border-bottom: none;
}

/* Promotion styling */
.promotion {
  color: #16a34a;
  font-weight: 600;
}

/* Ensure summary and sections use full width */
.page-content p { max-width: 100%; }

/* =========================
   Scroll reveal animation
========================= */
.reveal {
  will-change: opacity, transform;
}
.reveal.is-visible {
  animation: reveal-in 420ms ease both;
}

@keyframes reveal-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { will-change: auto; }
  .reveal.is-visible { animation: none; }
}

/* Role sub-blocks inside a company card */
.role-stack {
  margin: 10px 0 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  overflow: hidden;
}
.role-block {
  padding: 10px 12px;
  background: var(--card);
}
.role-title { margin-bottom: 2px; }
.role-dates { font-size: 0.92rem; }

/* Separator: only show arrow for promotions */
.role-sep {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  background: var(--bg);
}
.role-sep.promoted .role-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: #16a34a;
  font-weight: 800;
}

/* Badges (skills / robots / sensors) */
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin: 10px 0 6px;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font-size: 0.95rem;
  line-height: 1;
}
.badge.badge-group {
  font-weight: 700;
  background: var(--bg);
}

/* One-line-per-type badge rows */
.badge-row{
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
  align-items: start;
  margin: 12px 0;
}
.badge-label{
  font-weight: 700;
  color: var(--muted);
  padding-top: 6px;
}
@media (max-width: 820px){
  .badge-row{ grid-template-columns: 1fr; }
  .badge-label{ padding-top: 0; }
}

/* Role block bullets inside sub-blocks */
.role-block ul{
  margin: 8px 0 0;
  padding-left: 18px;
}
.role-block li{
  margin: 0;
}

/* =========================
   Contact page layout
========================= */
.contact-grid{
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
  align-items: start;
  margin-top: 10px;
}

.contact-panel,
.contact-details{
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  background: var(--card);
  box-shadow: 0 1px 0 var(--shadow);
}

.contact-title{
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.contact-subtitle{
  margin: 0 0 14px;
  max-width: 100%;
}

.contact-form .field{
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.contact-form label{
  font-size: 0.92rem;
  color: var(--muted);
}

.contact-form input,
.contact-form textarea{
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 12px;
  padding: 12px 12px;
  outline: none;
}

.contact-form textarea{
  resize: vertical;
  min-height: 160px;
}

.contact-form input:focus,
.contact-form textarea:focus{
  border-color: var(--fg);
}

.form-row{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.details-list{
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}

.detail-item{
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 14px;
  padding: 12px;
}

.detail-label{
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.detail-value{
  font-size: 1rem;
  word-break: break-word;
}

.tiny{
  font-size: 0.88rem;
  margin-top: 10px;
}

@media (max-width: 900px){
  .contact-grid{
    grid-template-columns: 1fr;
  }
  .form-row{
    grid-template-columns: 1fr;
  }
}
