/* ==========================================================================
   PALETTE SYSTEM — Semantic Color Tokens
   Swap palettes globally by uncommenting any preset block inside :root,
   or interactively via the [data-theme] attribute on <html>.
   ========================================================================== */

:root {
  /* DEFAULT PRESET: Warm Archival Paper (Light) */
  --bg: #F6F4F0;
  --surface: #EDEAE2;
  --text-primary: #1C1B18;
  --text-muted: #65625A;
  --border: #DCD7CD;
  --accent: #1C1B18;

  /* ALTERNATIVE PRESET 1: Dark Terminal Ink (uncomment to set as default)
  --bg: #111214;
  --surface: #1A1C1F;
  --text-primary: #ECECEC;
  --text-muted: #9498A0;
  --border: #2A2D32;
  --accent: #ECECEC;
  */

  /* ALTERNATIVE PRESET 2: Retro Amber CRT — DEC VT220 (uncomment to set as default)
  --bg: #18120B;
  --surface: #261C10;
  --text-primary: #FFB000;
  --text-muted: #C28218;
  --border: #3D2B14;
  --accent: #FFC94D;
  */

  /* ALTERNATIVE PRESET 3: Retro Dot-Matrix LCD — DMG-01 Olive (uncomment to set as default)
  --bg: #D7E0C5;
  --surface: #C7D4B2;
  --text-primary: #1A2E1A;
  --text-muted: #4B6348;
  --border: #AEBE98;
  --accent: #0F1F0F;
  */

  /* Typography & Layout Tokens */
  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --max-width: 700px;
}

/* Optional runtime theme attributes (matches the :root presets above) */
html[data-theme="dark"] {
  --bg: #111214;
  --surface: #1A1C1F;
  --text-primary: #ECECEC;
  --text-muted: #9498A0;
  --border: #2A2D32;
  --accent: #ECECEC;
}

html[data-theme="amber"] {
  --bg: #18120B;
  --surface: #261C10;
  --text-primary: #FFB000;
  --text-muted: #C28218;
  --border: #3D2B14;
  --accent: #FFC94D;
}

html[data-theme="lcd"] {
  --bg: #D7E0C5;
  --surface: #C7D4B2;
  --text-primary: #1A2E1A;
  --text-muted: #4B6348;
  --border: #AEBE98;
  --accent: #0F1F0F;
}

/* ==========================================================================
   BASE & RESET
   ========================================================================== */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: clamp(0.92rem, 0.89rem + 0.15vw, 0.98rem);
  line-height: 1.6;
  font-feature-settings: "kern" 1, "liga" 1;
  overflow-x: hidden;
}

.cv-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 4rem) clamp(1.25rem, 4vw, 2rem);
}

a {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s ease, color 0.15s ease;
}

a:hover,
a:focus-visible {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* ==========================================================================
   HEADER & CURSOR
   ========================================================================== */

.cv-header {
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--text-primary);
  margin-bottom: 2rem;
}

.cv-name {
  font-family: var(--font-mono);
  font-size: clamp(1.45rem, 1.2rem + 1.2vw, 1.95rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: 0.45rem;
}

.cursor {
  display: inline-block;
  color: var(--accent);
  font-weight: 700;
  animation: cursor-blink 1.1s steps(2, start) infinite;
}

@keyframes cursor-blink {
  0%, 49% {
    opacity: 1;
  }
  50%, 100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cursor {
    animation: none;
    opacity: 1;
  }
}

.cv-role {
  font-family: var(--font-mono);
  font-size: clamp(0.84rem, 0.8rem + 0.15vw, 0.92rem);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.cv-location {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

.cv-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  list-style: none;
  margin-bottom: 1.1rem;
}

.cv-links li {
  display: inline-flex;
  align-items: center;
}

.cv-links li:not(:last-child)::after {
  content: "/";
  color: var(--text-muted);
  margin-left: 0.9rem;
  user-select: none;
}

.cv-links a,
.action-btn {
  display: inline-block;
  padding: 0.15rem 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-primary);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
}

.action-btn:hover,
.action-btn:focus-visible {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.theme-pixel-btn {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 14px;
  padding: 0;
  background-color: var(--surface);
  border: 2px solid var(--text-primary);
  box-shadow: 2px 2px 0 var(--text-primary);
  cursor: pointer;
  vertical-align: middle;
  image-rendering: pixelated;
}

.theme-pixel-btn::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 4px;
  height: 4px;
  background-color: var(--accent);
}

.theme-pixel-btn:hover,
.theme-pixel-btn:focus-visible {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--text-primary);
  outline: none;
}

.theme-pixel-btn:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.cv-summary {
  font-size: 0.92rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
}

/* ==========================================================================
   SECTIONS & ENTRIES
   ========================================================================== */

.cv-section {
  margin-bottom: 2rem;
}

.section-heading {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.1rem;
  font-variant-numeric: tabular-nums;
}

.entry {
  margin-bottom: 1.35rem;
}

.entry:last-child {
  margin-bottom: 0;
}

.entry-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.2rem;
}

.entry-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-primary);
}

.entry-subtitle-inline {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.entry-date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.entry-org {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

.entry-list {
  list-style: none;
}

.entry-list li {
  position: relative;
  padding-left: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.entry-list li:last-child {
  margin-bottom: 0;
}

.entry-list li::before {
  content: "-";
  position: absolute;
  left: 0;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.entry-label {
  font-weight: 600;
  color: var(--text-primary);
}

.tech-meta {
  font-family: var(--font-mono);
  font-size: 0.82em;
  color: var(--text-primary);
}

/* ==========================================================================
   TECHNICAL STACK (Plain Comma-Separated Layers)
   ========================================================================== */

.stack-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

.stack-row {
  display: grid;
  grid-template-columns: 190px 1fr;
  align-items: baseline;
  gap: 0.75rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border);
}

.stack-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.stack-layer {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.stack-items {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ==========================================================================
   PUBLICATIONS, CERTIFICATIONS & LANGUAGES
   ========================================================================== */

.pub-list {
  list-style: none;
}

.pub-item {
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.pub-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.pub-title {
  font-weight: 600;
  font-size: 0.93rem;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
}

.pub-title a {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--text-muted);
  text-underline-offset: 3px;
}

.pub-title a:hover,
.pub-title a:focus-visible {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.pub-index {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-right: 0.35rem;
  font-variant-numeric: tabular-nums;
}

.pub-desc {
  font-size: 0.86rem;
  color: var(--text-muted);
}

.compact-list {
  list-style: none;
}

.compact-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
}

.compact-list li:last-child {
  border-bottom: none;
}

.compact-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.lang-line {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-primary);
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.lang-muted {
  color: var(--text-muted);
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

.cv-footer {
  margin-top: 2.5rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   MOBILE RESPONSIVENESS (< 600px)
   ========================================================================== */

@media (max-width: 600px) {
  .entry-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }

  .entry-date {
    white-space: normal;
  }

  .stack-row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .compact-list li {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
  }

  .compact-meta {
    white-space: normal;
  }

  .cv-links {
    gap: 0.5rem 0.75rem;
  }

  .cv-links li:not(:last-child)::after {
    margin-left: 0.75rem;
  }

  .cv-links a,
  .action-btn {
    padding: 0.35rem 0;
  }
}

/* ==========================================================================
   PRINT RULES (1-Page Crisp Dark-on-White PDF)
   ========================================================================== */

@media print {
  :root,
  html[data-theme] {
    --bg: #FFFFFF;
    --surface: #FFFFFF;
    --text-primary: #000000;
    --text-muted: #333333;
    --border: #CCCCCC;
    --accent: #000000;
  }

  @page {
    size: A4;
    margin: 10mm 12mm;
  }

  body {
    font-size: 8.8pt;
    line-height: 1.35;
  }

  .cv-container {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  .cursor,
  .no-print,
  .cv-footer {
    display: none !important;
  }

  .cv-header {
    padding-bottom: 0.55rem;
    margin-bottom: 0.75rem;
  }

  .cv-name {
    font-size: 15pt;
    margin-bottom: 0.15rem;
  }

  .cv-role {
    font-size: 8.8pt;
    margin-bottom: 0.1rem;
  }

  .cv-location {
    font-size: 8pt;
    margin-bottom: 0.35rem;
  }

  .cv-links {
    margin-bottom: 0.45rem;
    font-size: 7.8pt;
  }

  .cv-summary {
    font-size: 8.3pt;
    padding-top: 0.4rem;
  }

  .cv-section {
    margin-bottom: 0.75rem;
    break-inside: avoid;
  }

  .section-heading {
    font-size: 7.8pt;
    margin-bottom: 0.4rem;
    padding-bottom: 0.15rem;
  }

  .entry {
    margin-bottom: 0.5rem;
  }

  .entry-org {
    margin-bottom: 0.3rem;
  }

  .entry-list li {
    margin-bottom: 0.2rem;
  }

  .stack-grid {
    gap: 0.2rem;
  }

  .stack-row {
    grid-template-columns: 155px 1fr;
    padding-bottom: 0.2rem;
  }

  .pub-item {
    padding-bottom: 0.25rem;
    margin-bottom: 0.25rem;
  }

  .compact-list li {
    padding: 0.12rem 0;
  }

  .lang-line {
    margin-top: 0.35rem;
    padding-top: 0.3rem;
  }

  a {
    text-decoration: none;
  }
}
