/* ── Fonts loaded via base.njk (Syne + IBM Plex Sans + IBM Plex Mono) ── */

/* ── Keyframes ─────────────────────────────────────────────────── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Reset ─────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Design tokens - DARK DEFAULT ──────────────────────────────── */
:root {
  /* --accent injected by base.njk: #22d3ee */
  --accent-impact: #fb923c;
  --pill-scope: var(--accent);
  --pill-impact: var(--accent-impact);
  --pill-text: #0d1929;
  --tree-line: rgb(from var(--accent) r g b / 0.25);
  --accent-glow: rgb(from var(--accent) r g b / 0.22);
  --accent-glow-strong: rgb(from var(--accent) r g b / 0.45);

  --bg: #1a2234;
  --bg-sidebar: #1f2a3f;
  --bg-card: #1f2a3f;
  --bg-hover: rgb(from var(--accent) r g b / 0.06);
  --text: #eaf0f8;
  --text-muted: #92a8c0;
  --text-sidebar: #b0c2d8;
  --border: #2d3e56;
  --tag-bg: #162238;
  --tag-text: var(--accent);

  --font-display: "Exo 2", sans-serif;
  --font-body: "Be Vietnam Pro", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;

  --sidebar-w: 250px;
  --gap: 1.5rem;
  --section-gap: 1.75rem;
  --page-pad-v: 12mm;
  --page-pad-h: 14mm;
  --radius: 8px;
}

/* ── Light mode ─────────────────────────────────────────────────── */
[data-theme="light"] {
  /* --accent injected by base.njk: #065f46 (deep emerald) */
  --accent-impact: #c2410c;
  --pill-scope: var(--accent);
  --pill-impact: var(--accent-impact);
  --pill-text: #fff;
  --tree-line: rgb(from var(--accent) r g b / 0.25);
  --accent-glow: rgb(from var(--accent) r g b / 0.18);
  --accent-glow-strong: rgb(from var(--accent) r g b / 0.32);

  --bg: #f5f4f0;
  --bg-sidebar: #ece9e4;
  --bg-card: #ffffff;
  --bg-hover: rgb(from var(--accent) r g b / 0.05);
  --text: #1e2d3d;
  --text-muted: #7b8fa3;
  --text-sidebar: #5a6980;
  --border: #dbd8d0;
  --tag-bg: #cce9df;
  --tag-text: #065f46;
}

/* ── Base ───────────────────────────────────────────────────────── */
html {
  font-size: 15.333px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition:
    background 0.3s,
    color 0.3s;
  min-height: 100vh;
}

/* Dot grid background texture */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(
    circle at 1px 1px,
    rgb(from var(--accent) r g b / 0.07) 1px,
    transparent 0
  );
  background-size: 30px 30px;
  pointer-events: none;
  z-index: 0;
}

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

/* ── UI widget ──────────────────────────────────────────────────── */
#ui-widget {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 99px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  transition:
    background 0.2s,
    border-color 0.2s;
}

#ui-widget button {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  transition: background 0.15s;
  white-space: nowrap;
  line-height: 1;
}
#ui-widget button:hover {
  background: var(--bg-hover);
}

.widget-sep {
  width: 1px;
  height: 1.2rem;
  background: var(--border);
  flex-shrink: 0;
}
.widget-btn-label {
  font-size: 0.75rem;
}

/* Dark default: show sun icon (click to switch to light) */
.icon-sun {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.icon-moon {
  display: none;
}
/* Light mode: show moon icon (click to switch to dark) */
[data-theme="light"] .icon-sun {
  display: none;
}
[data-theme="light"] .icon-moon {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.print-page-nav { display: none; }

/* ── CV wrapper ─────────────────────────────────────────────────── */
.cv-wrapper {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Entrance animations ────────────────────────────────────────── */
.cv-header {
  animation: fadeUp 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}
.cv-body {
  animation: fadeUp 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s both;
}
.cv-credentials {
  animation: fadeUp 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.2s both;
}

/* ── Header ─────────────────────────────────────────────────────── */
.cv-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.3);
  margin-bottom: var(--gap);
}

.header-body {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
}

.header-left {
  padding: 1.75rem 2rem;
}

.header-icon {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  box-shadow:
    0 0 0 4px var(--bg-card),
    0 4px 20px var(--accent-glow);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: rgba(255, 255, 255, 0.92);
  flex-shrink: 0;
  transition: box-shadow 0.25s;
}
.header-icon:hover {
  box-shadow:
    0 0 0 4px var(--bg-card),
    0 4px 28px var(--accent-glow-strong);
}
.header-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-identity {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.header-text {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.header-name {
  font-family: var(--font-display);
  font-size: 2.05rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1.05;
}

.header-tree {
  position: relative;
  margin-top: 0.7rem;
  padding-left: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.header-tree::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.3em;
  height: calc(100% - 0.7em);
  width: 2px;
  background: linear-gradient(to bottom, var(--accent) 0%, transparent 100%);
  border-radius: 2px;
}

.tree-item {
  position: relative;
  line-height: 1.4;
}
.tree-item::before {
  content: "";
  position: absolute;
  left: calc(-1.4rem - 3px);
  top: 0.38em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--accent);
  opacity: 0.7;
}
.tree-item.header-role-primary::before {
  background: var(--accent);
  width: 8px;
  height: 8px;
  opacity: 1;
  box-shadow: 0 0 8px var(--accent-glow-strong);
}

.header-role-primary {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.01em;
}
.header-role-secondary {
  font-size: 0.93rem;
  color: var(--text-muted);
}
.header-role-tertiary {
  font-size: 0.83rem;
  color: var(--accent);
  letter-spacing: 0.04em;
  font-weight: 500;
  opacity: 0.72;
}

.header-contact {
  border-left: 1px solid var(--border);
  background: var(--bg-sidebar);
  padding: 1.25rem 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.header-contact-pill {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.header-contact-pill i {
  width: 13px;
  text-align: center;
  color: var(--accent);
  flex-shrink: 0;
  font-size: 0.75rem;
}
.header-contact-pill a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.header-contact-pill a:hover {
  color: var(--accent);
}

/* ── Body layout ────────────────────────────────────────────────── */
.cv-body {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  gap: var(--gap);
  align-items: start;
}

/* ── Sections ───────────────────────────────────────────────────── */
.section {
  margin-bottom: var(--section-gap);
}

.section-title {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
  display: block;
}

/* ── Summary ────────────────────────────────────────────────────── */
.summary-text p {
  margin-bottom: 0.8rem;
  color: var(--text);
  font-size: 0.93rem;
  line-height: 1.72;
}
.summary-text p:last-child {
  margin-bottom: 0;
}

/* ── Work ───────────────────────────────────────────────────────── */
.job {
  position: relative;
  margin: 0 -0.75rem 0;
  padding: 0.85rem 0.75rem 1.4rem 1rem;
  border-radius: 6px;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}
.job::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.85rem;
  bottom: 1.4rem;
  width: 2px;
  background: transparent;
  border-radius: 2px;
  transition: background 0.2s;
}
.job:last-child {
  border-bottom: none;
}
.job:hover {
  background: var(--bg-hover);
}
.job:hover::before {
  background: var(--accent);
}

.job-header {
  margin-bottom: 0.55rem;
}

.job-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.job-title {
  font-family: var(--font-display);
  font-size: 0.97rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.job-meta {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}

.job-dates {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.job-duration {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  opacity: 0.75;
  letter-spacing: 0.02em;
  margin-top: 0.05rem;
}

.present {
  color: var(--accent);
  font-weight: 600;
}

.job-company {
  font-size: 0.87rem;
  color: var(--accent);
  font-weight: 500;
  margin-top: 0.15rem;
}

.job-summary {
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-bottom: 0.7rem;
  font-style: italic;
}

.job-section {
  display: flex;
  align-items: stretch;
  gap: 0.65rem;
  margin-top: 0.55rem;
}

.job-section-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  gap: 3px;
}

.job-section-indicator::before {
  content: "";
  flex: 1;
  width: 2px;
  min-height: 4px;
  border-radius: 2px 2px 0 0;
}
.scope .job-section-indicator::before {
  background: var(--pill-scope);
}
.impact .job-section-indicator::before {
  background: var(--pill-impact);
}

.job-section-indicator::after {
  content: "";
  flex: 1;
  width: 2px;
  min-height: 4px;
  border-radius: 0 0 2px 2px;
}
.scope .job-section-indicator::after {
  background: var(--pill-scope);
}
.impact .job-section-indicator::after {
  background: var(--pill-impact);
}

.job-section-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  font-family: 'Fira Code', monospace;
  font-size: 0.60rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.4rem 0.2rem;
  border-radius: 999px;
  color: var(--pill-text);
  flex-shrink: 0;
}
.scope .job-section-pill {
  background: var(--pill-scope);
}
.impact .job-section-pill {
  background: var(--pill-impact);
}

.job-section-list {
  list-style: none;
  padding: 0;
  font-size: 0.88rem;
  flex: 1;
  align-self: flex-start;
}
.job-section-list li {
  position: relative;
  padding-left: 0.9rem;
  margin-bottom: 0.4rem;
  line-height: 1.55;
  color: var(--text);
}
.job-section-list li::before {
  content: "›";
  position: absolute;
  left: 0;
  color: var(--text-muted);
  font-size: 0.9em;
  line-height: inherit;
}
.job-section-list li:last-child {
  margin-bottom: 0;
}

/* ── Credentials (full-width edu + cert row) ────────────────────── */
.cv-credentials {
  margin-top: var(--section-gap);
  padding-top: var(--section-gap);
}

.credentials-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-top: 1rem;
}

.cred-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
  padding: 1.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition:
    border-color 0.2s,
    transform 0.2s,
    box-shadow 0.2s;
}
.cred-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.2),
    0 0 0 1px var(--accent);
}

.cred-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  flex-shrink: 0;
}

/* Apply white backdrop to logos in dark mode (default) */
.cred-logo {
  filter: url(#logo-bg-fill);
}
[data-theme="light"] .cred-logo {
  filter: none;
}

.cred-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.cred-program {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.cred-title {
  line-height: 1.3;
}

.cred-name {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}
a.cred-name {
  color: var(--accent);
}
a.cred-name:hover {
  text-decoration: underline;
}

.cred-issuer {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.cred-date {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--text-muted);
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.cv-sidebar {
  background: var(--bg-sidebar);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  border: 1px solid var(--border);
  position: sticky;
  top: 1.5rem;
  transition:
    background 0.3s,
    border-color 0.3s;
}

.sidebar-section {
  margin-bottom: 1.75rem;
}
.sidebar-section:last-child {
  margin-bottom: 0;
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

/* Skills */
.skill-group {
  margin-bottom: 0.85rem;
}
.skill-group:last-child {
  margin-bottom: 0;
}

.skill-name {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.skill-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.skill-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 3px;
  padding: 0.15rem 0.45rem;
  line-height: 1.55;
  border: 1px solid transparent;
  transition: border-color 0.15s;
}
.skill-tag:hover {
  border-color: var(--accent);
}

.skill-tag--featured {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-glow-strong);
  font-weight: 600;
}
[data-theme="light"] .skill-tag--featured {
  border-color: rgb(from var(--accent) r g b / 0.45);
}
.skill-tag--featured:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

/* Languages */
.lang-list {
  list-style: none;
}
.lang-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
  color: var(--text-sidebar);
}
.lang-item:last-child {
  margin-bottom: 0;
}
.lang-name {
  font-weight: 600;
}
.lang-fluency {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 3px;
  padding: 0.15rem 0.45rem;
  line-height: 1.55;
}

/* ── Tablet (<850px) ────────────────────────────────────────────── */
@media screen and (max-width: 849px) {
  body {
    padding: 1rem 0;
  }

  .cv-wrapper {
    width: 100%;
    min-height: unset;
    box-shadow: none;
  }

  .header-body {
    grid-template-columns: 1fr;
  }

  .header-contact {
    border-left: none;
    border-top: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1rem var(--page-pad-h);
  }

  .cv-body {
    grid-template-columns: 1fr;
  }

  .cv-sidebar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
  }

  .cv-sidebar .sidebar-section {
    margin-bottom: 0;
  }
}

/* ── Mobile (<560px) ────────────────────────────────────────────── */
@media screen and (max-width: 559px) {
  .header-name {
    font-size: 1.65rem;
  }
  .cv-sidebar {
    grid-template-columns: 1fr;
  }
  .job-title-row {
    flex-direction: column;
    gap: 0.2rem;
  }
  .credentials-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Print ──────────────────────────────────────────────────────── */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 0 14mm;
  }

  html {
    font-size: 15.333px;
  }

  :root {
    /* --accent injected by base.njk from meta.json */
    --accent-impact: #c2410c;
    --pill-text: #fff;
    --bg: #ffffff;
    --bg-sidebar: #f5f4f0;
    --bg-card: #ffffff;
    --bg-hover: transparent;
    --text: #111827;
    --text-muted: #4b5563;
    --text-sidebar: #374151;
    --border: #d1d5db;
    --tag-bg: #e0f2fe;
    --tag-text: #0e7490;
  }

  .job-section-pill,
  .job-section-indicator::before,
  .job-section-indicator::after {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body {
    background: white !important;
  }
  body::before {
    display: none;
  }

  #ui-widget {
    display: none !important;
  }

  /* Traits (Part 4) must stay on one line in print; tighten spacing and lock no-wrap. See ADR-0005. */
  .header-role-tertiary {
    letter-spacing: 0.01em;
    white-space: nowrap;
  }

  .cv-header,
  .cv-body,
  .cv-credentials {
    animation: none !important;
  }
  .job::before {
    display: none;
  }
  .job:hover {
    background: none;
  }

  /* Restore logo filters for print (light background) */
  .cred-logo {
    filter: none;
  }

  .cv-wrapper {
    position: relative;
    width: 1000px;
    max-width: none;
    min-height: unset;
    margin: 0;
    padding: 1rem 3rem;
    zoom: 0.795;
    transform-origin: top left;
  }

  .print-page-nav {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    padding: 2px 6px;
    background: #ffffff;
    z-index: 10;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .pn-box {
    width: 18px;
    height: 18px;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: #9ca3af;
    font-family: sans-serif;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .pn-box.pn-current {
    background-color: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
    font-weight: 600;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .cv-sidebar {
    position: static;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }

  .job {
    margin-bottom: 1.1rem;
    padding-bottom: 1.1rem;
  }

  .job-section {
    position: relative;
    padding-left: 0;
    display: flex;
  }
  .job-section-indicator {
    position: absolute;
    left: -1.6rem;
    top: 0;
    bottom: 0;
    width: 14px;
    gap: 2px;
  }
  .job-section-pill {
    font-size: 0.48rem;
    padding: 0.3rem 0.15rem;
  }
  .job-section-list {
    width: 100%;
    flex: 1;
  }
  .job-section-list li {
    padding-left: 0;
  }
  .job-section-list li::before {
    display: none;
  }

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

  .job,
  .cred-card {
    page-break-inside: avoid;
  }
  .cv-credentials {
    break-before: avoid;
  }
  .job-header {
    break-after: avoid;
    page-break-after: avoid;
  }
  .section-title {
    break-after: avoid;
    page-break-after: avoid;
  }
  .sidebar-section {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
