/* ---------------------------------------------------------------------
   Stephen Clinton — CV site
   Design system matches the account's other small apps (bus-stop, car-
   dashboard, energy-dashboard): CSS custom-property tokens, light theme
   by default with an automatic dark variant, rounded cards, no heavy
   corporate branding (deliberately lighter-touch than the portfolio site).
--------------------------------------------------------------------- */

:root {
  --app-bg: #f4f5f8;
  --surface: #ffffff;
  --surface-soft: #eef0f4;
  --text: #16181d;
  --muted: #6f7480;
  --faint: #9095a1;
  --border: rgba(28, 32, 39, 0.11);
  --accent: #2457c5;
  --accent-soft: #e8f0ff;
  --accent-ink: #163a86;
  --ring: rgba(36, 87, 197, 0.35);
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, 0.14);
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 880px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --app-bg: #0b0c0f;
    --surface: #16181d;
    --surface-soft: #1e2127;
    --text: #f2f3f7;
    --muted: #9ca1ad;
    --faint: #6c7280;
    --border: rgba(255, 255, 255, 0.1);
    --accent: #7ba3ff;
    --accent-soft: rgba(45, 91, 197, 0.18);
    --accent-ink: #cddcff;
    --ring: rgba(123, 163, 255, 0.35);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--app-bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter,
    system-ui, sans-serif;
  line-height: 1.5;
}

a {
  color: var(--accent);
}

img {
  max-width: 100%;
}

/* ---------------- Top bar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 60px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--accent), var(--accent-ink));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand-name {
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-role {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

.pill-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pill-btn:active {
  transform: translateY(1px);
}

.pill-btn.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pill-btn.accent:hover {
  color: #fff;
  opacity: 0.92;
}

@media (max-width: 640px) {
  .pill-btn .pill-label {
    display: none;
  }
  .pill-btn {
    padding: 8px;
  }
}

/* ---------------- Layout ---------------- */

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px 80px;
}

section {
  margin-top: 40px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-head h2 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0;
}

.section-actions {
  display: flex;
  gap: 8px;
}

.section-actions button {
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  cursor: pointer;
  padding: 4px 2px;
}

.section-actions button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------------- Hero ---------------- */

.hero {
  padding-top: 40px;
}

.hero-name {
  margin: 0 0 4px;
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.hero-tagline {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 500;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-bottom: 22px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
}

.meta-chip svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.meta-chip.link {
  color: var(--accent);
  font-weight: 600;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 26px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.stat-card .num {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.stat-card .label {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.stat-card.clickable {
  position: relative;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.stat-card.clickable:hover,
.stat-card.clickable:focus-visible {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.stat-card.clickable:active {
  transform: translateY(0);
}

.stat-hint {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 13px;
  height: 13px;
  color: var(--faint);
  transition: transform 0.2s ease;
}

.stat-card.clickable[aria-expanded="true"] .stat-hint {
  transform: rotate(180deg);
  color: var(--accent);
}

.world-map-panel {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.25s ease, margin-bottom 0.3s ease;
}

.world-map-panel.open {
  max-height: 460px;
  opacity: 1;
  margin-bottom: 26px;
}

.world-map-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px 18px;
}

.world-map-head {
  margin-bottom: 12px;
}

.world-map-head h3 {
  margin: 0 0 3px;
  font-size: 14.5px;
  font-weight: 700;
}

.world-map-head p {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.world-map {
  height: 320px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

/* Leaflet's default popup is a plain white speech bubble regardless of
   theme; match it to the page's own light/dark palette. */
.leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}
.leaflet-popup-tip {
  background: var(--surface);
}
.leaflet-popup-close-button {
  color: var(--muted) !important;
}

.wm-popup .wm-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--accent-ink);
  margin-bottom: 3px;
}

.wm-popup .wm-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}

.summary-card p {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.65;
}

.summary-card p:last-child {
  margin-bottom: 0;
}

/* ---------------- Timeline / experience ---------------- */

.timeline {
  position: relative;
  padding-left: 22px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}

.company {
  position: relative;
  margin-bottom: 14px;
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.company-summary {
  border-radius: var(--radius) var(--radius) 0 0;
}

.company:not([open]) .company-summary {
  border-radius: var(--radius);
}

.company::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 22px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
}

.company > summary,
.role > summary {
  list-style: none;
  cursor: pointer;
}

.company > summary::-webkit-details-marker,
.role > summary::-webkit-details-marker {
  display: none;
}

.company-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
}

.company-summary:hover {
  background: var(--surface-soft);
}

.company-heading h3 {
  margin: 0 0 3px;
  font-size: 17px;
  font-weight: 700;
}

.company-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 12.5px;
  color: var(--muted);
}

.company-sub .dot {
  opacity: 0.5;
}

.company-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding-top: 2px;
}

.date-range {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
}

.role-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

.chevron {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  color: var(--faint);
}

.company[open] > summary .chevron,
.role[open] > summary .chevron {
  transform: rotate(180deg);
}

.company-body {
  border-top: 1px solid var(--border);
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Info panel: company- or role-level description/stats/map */

.info-panel {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.info-panel p {
  margin: 0 0 10px;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.6;
}

.info-panel p:last-of-type {
  margin-bottom: 0;
}

.info-panel p + .mini-stats {
  margin-top: 12px;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.mini-stats .stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.mini-stats .stat .num {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-ink);
  line-height: 1.2;
}

.mini-stats .stat .label {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 1px;
}

.mini-map {
  height: 160px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-top: 4px;
}

.mini-map.leaflet-container {
  background: var(--surface);
}

/* Roles list nested inside a company */

.roles {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.role {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--app-bg);
}

.role-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
}

.role-summary:hover {
  background: var(--surface-soft);
}

.role-heading h4 {
  margin: 0 0 2px;
  font-size: 14.5px;
  font-weight: 650;
}

.role-heading .date-range {
  font-weight: 600;
}

.role-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding-top: 1px;
}

.role-body {
  border-top: 1px solid var(--border);
  padding: 14px 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
}

.achievements h5,
.responsibilities h5,
.info-label {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
}

.achievements ul,
.responsibilities ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.achievements li,
.responsibilities li {
  position: relative;
  padding-left: 18px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
}

.achievements li::before,
.responsibilities li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------------- Education / designations ---------------- */

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 620px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.info-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
}

.info-card ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.info-card li {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.5;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.info-card li .yr {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  font-size: 12.5px;
  flex-shrink: 0;
}

/* ---------------- Footer ---------------- */

footer {
  border-top: 1px solid var(--border);
  padding: 28px 20px 40px;
  text-align: center;
  color: var(--faint);
  font-size: 12px;
}

footer a {
  color: var(--muted);
}

/* ---------------- Back to top ---------------- */

.back-to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 25;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top svg {
  width: 18px;
  height: 18px;
}

/* ---------------- Print ---------------- */

@media print {
  .topbar,
  .back-to-top,
  .section-actions {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .company-card,
  .role,
  .summary-card,
  .info-card {
    box-shadow: none !important;
    border-color: #ccc !important;
  }
  details:not([open]) > *:not(summary) {
    display: block !important;
  }
  .mini-map {
    display: none !important;
  }
  .chevron {
    display: none !important;
  }
  .timeline::before,
  .company::before {
    display: none !important;
  }
}
