/* ==========================================================================
   Duy viber — sổ tay nghề
   Be Vietnam Pro (giao diện, tiêu đề) + Literata (thân bài)
   ========================================================================== */

:root {
  --paper: #F3F5F2;
  --paper-2: #E6ECE8;
  --ink: #14302F;
  --muted: #5A6E6A;
  --rule: #D3DCD8;
  --link: #1D6B66;
  --lamp: #E9A23B;
  --code-bg: #132E2D;
  --code-ink: #DCE7E3;

  --sans: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Literata", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --measure: 40rem;
  --wide: 68rem;
  --gutter: clamp(1rem, 4vw, 2rem);
  --radius: 6px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0F2523;
    --paper-2: #16302E;
    --ink: #E4ECE8;
    --muted: #9BB2AD;
    --rule: #24413E;
    --link: #82CCC3;
    --lamp: #F2B550;
    --code-bg: #0A1B1A;
    --code-ink: #DCE7E3;
    color-scheme: dark;
  }
}

/* Reset ------------------------------------------------------------------ */

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

/* <picture> only wraps <source>; let the <img> lay out as if it were the direct child */
picture { display: contents; }
picture > source { display: none; }

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

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -3rem;
  background: var(--ink);
  color: var(--paper);
  padding: .5rem .875rem;
  border-radius: var(--radius);
  z-index: 10;
}
.skip-link:focus { top: 1rem; }

/* Containers -------------------------------------------------------------- */

.wrap {
  max-width: var(--wide);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.column {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Site header ------------------------------------------------------------- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 2rem;
  padding-block: 1.5rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: .625rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 1.1875rem;
  letter-spacing: -.01em;
}

.wordmark img {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  object-fit: cover;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: inline-block;
  padding-block: .25rem;
  color: var(--muted);
  font-weight: 600;
  font-size: .9375rem;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover { color: var(--ink); }

.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--lamp);
}

/* Home: hero ------------------------------------------------------------- */

.hero { padding-block: clamp(2.5rem, 8vw, 6rem) clamp(2rem, 5vw, 3.5rem); }

.hero-title {
  margin: 0;
  max-width: 15ch;
  font-size: clamp(2.5rem, 7.2vw, 5rem);
  font-weight: 800;
  line-height: 1.14;
  letter-spacing: -.03em;
  text-wrap: balance;
}

.hero-lede {
  max-width: 34rem;
  margin: 1.5rem 0 0;
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.7;
  color: var(--muted);
}

/* Home: career route ------------------------------------------------------ */

.route-block { padding-bottom: clamp(3rem, 8vw, 5.5rem); }

.route {
  --dot: .875rem;
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.5rem;
  margin: 0;
  padding: 2rem 0 0;
  list-style: none;
}

/* the road: runs past the last stop, because the trip is not over */
.route::before {
  content: "";
  position: absolute;
  top: calc(var(--dot) / 2 - 1px);
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(to right, var(--ink) 88%, transparent);
  transform-origin: left center;
  animation: route-draw 1.1s cubic-bezier(.3, .6, .2, 1) both;
}

.route li { position: relative; }

.route li::before {
  content: "";
  position: absolute;
  top: -2rem;
  left: 0;
  width: var(--dot);
  height: var(--dot);
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  animation: route-stop .35s ease-out both;
  animation-delay: calc(.2s + var(--i, 0) * .22s);
}

.route li.is-now::before {
  top: calc(-2rem - .1875rem);
  left: -.1875rem;
  width: calc(var(--dot) + .375rem);
  height: calc(var(--dot) + .375rem);
  border-color: var(--ink);
  background: var(--lamp);
}

.route-year {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.route-place {
  display: block;
  margin-top: .125rem;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.3;
}

.route-note {
  display: block;
  margin-top: .25rem;
  font-size: .875rem;
  line-height: 1.5;
  color: var(--muted);
}

.route-more {
  display: inline-block;
  margin-top: 1.75rem;
  font-weight: 600;
  font-size: .9375rem;
}

@keyframes route-draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes route-stop { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }

@media (max-width: 40rem) {
  .route {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 0 0 0 2rem;
  }
  .route::before {
    top: 0;
    bottom: 0;
    left: calc(var(--dot) / 2 - 1px);
    right: auto;
    width: 2px;
    height: auto;
    background: linear-gradient(to bottom, var(--ink) 88%, transparent);
    transform-origin: center top;
    animation-name: route-draw-down;
  }
  .route li::before { top: .3rem; left: -2rem; }
  .route li.is-now::before { top: calc(.3rem - .1875rem); left: calc(-2rem - .1875rem); }
}

@keyframes route-draw-down { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* Home: post list --------------------------------------------------------- */

.section-title {
  margin: 0 0 1.25rem;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.015em;
}

.entries { padding-bottom: 4rem; }
.entries > * { max-width: 52rem; }

.entry + .entry { margin-top: .5rem; }

.entry-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.5rem;
  align-items: start;
  padding-block: 1.25rem;
  color: inherit;
  text-decoration: none;
}

.entry-title {
  margin: 0;
  font-size: clamp(1.25rem, 2.6vw, 1.5625rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.01em;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 2px;
  text-underline-offset: .2em;
  transition: text-decoration-color .15s;
}

.entry-link:hover .entry-title,
.entry-link:focus-visible .entry-title { text-decoration-color: var(--lamp); }

.entry-excerpt {
  margin: .5rem 0 0;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-meta,
.post-meta {
  margin: .625rem 0 0;
  font-size: .875rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.entry-thumb {
  width: 9.5rem;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--paper-2);
}

@media (max-width: 34rem) {
  .entry-link { grid-template-columns: 1fr; }
  .entry-thumb { order: -1; width: 100%; aspect-ratio: 16 / 9; }
}

.empty-state { color: var(--muted); }

/* Post ------------------------------------------------------------------- */

.post-header { padding-block: clamp(2rem, 6vw, 4rem) 2rem; }

.post-category {
  display: inline-block;
  margin-bottom: .75rem;
  font-weight: 600;
  font-size: .9375rem;
  text-decoration: none;
}
.post-category:hover { text-decoration: underline; }

.post-title,
.page-title {
  margin: 0;
  font-size: clamp(2.125rem, 5.4vw, 3.375rem);
  font-weight: 800;
  line-height: 1.16;
  letter-spacing: -.025em;
  text-wrap: balance;
}

.post-lede {
  margin: 1rem 0 0;
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.6;
  color: var(--muted);
}

.post-cover { margin: 0 auto clamp(2rem, 5vw, 3.5rem); max-width: var(--wide); padding-inline: var(--gutter); }

.post-cover-frame {
  overflow: hidden;
  aspect-ratio: 2 / 1;
  border-radius: var(--radius);
  background: var(--paper-2);
}

.post-cover-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 78%;
  /* overscan so the parallax shift never shows an edge */
  transform: translate3d(0, var(--parallax, 0px), 0) scale(1.12);
  will-change: transform;
}

@media (max-width: 40rem) {
  .post-cover { padding-inline: 0; }
  .post-cover-frame { aspect-ratio: 16 / 10; border-radius: 0; }
}

/* Reading progress, post pages only */
.read-progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  z-index: 20;
  pointer-events: none;
}
.read-progress span {
  display: block;
  height: 100%;
  background: var(--lamp);
  transform: scaleX(0);
  transform-origin: left center;
}

.post-footer { padding-block: 3rem 1rem; }

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: .9375rem;
  font-weight: 600;
}
.post-tags a { text-decoration: none; }
.post-tags a:hover { text-decoration: underline; }

.share {
  margin: 1.25rem 0 0;
  font-size: .9375rem;
  color: var(--muted);
}
.share a { margin-left: .75rem; font-weight: 600; }

.author {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}

.author img {
  flex: none;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  object-fit: cover;
}

.author-name { margin: 0; font-weight: 700; font-size: 1.0625rem; }
.author-bio { margin: .125rem 0 0; font-size: .9375rem; color: var(--muted); line-height: 1.55; }
.author-bio a { font-weight: 600; }

.comments { padding-block: 2rem 4rem; }
.comments h2 { margin: 0 0 1rem; font-size: 1.375rem; font-weight: 800; }

/* Prose ------------------------------------------------------------------ */

.prose {
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.75;
  overflow-wrap: break-word;
}

.prose > * + * { margin-top: 1.4em; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose table, .prose figure { margin-bottom: 0; }
.prose > :first-child { margin-top: 0; }

.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  position: relative;
  margin: 2.4em 0 0;
  font-family: var(--sans);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.01em;
}
/* post sections are h2 (h1 is the post title); they keep the size the old h3 had */
.prose h1 { font-size: 1.625rem; font-weight: 800; }
.prose h2 { font-size: 1.375rem; }
.prose h3 { font-size: 1.1875rem; }
.prose h4 { font-size: 1.0625rem; }
.prose h5, .prose h6 { font-size: 1rem; }

.prose h1 + *, .prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: .75em; }

/* section stops: echoes the route on the home page */
@media (min-width: 60rem) {
  .prose h2::before, .prose h3::before {
    content: "";
    position: absolute;
    left: -1.875rem;
    top: .5em;
    width: .625rem;
    height: .625rem;
    border: 2px solid var(--ink);
    border-radius: 50%;
    background: var(--lamp);
  }
}

.prose a {
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
}
.prose a:hover { text-decoration-thickness: 2px; }

.prose strong { font-weight: 600; }

.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: .4em; }
.prose li::marker { color: var(--muted); }

.prose blockquote {
  margin-left: 0;
  margin-right: 0;
  padding-left: 1.25rem;
  border-left: 3px solid var(--lamp);
  font-style: italic;
  color: var(--muted);
}

.prose hr {
  width: 4rem;
  height: 2px;
  margin: 3em 0;
  border: 0;
  background: var(--rule);
}

.prose code, .prose kbd {
  font-family: var(--mono);
  font-size: .84em;
  padding: .12em .35em;
  border-radius: 4px;
  background: var(--paper-2);
}

.prose pre {
  padding: 1.125rem 1.25rem;
  overflow-x: auto;
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--code-ink);
  font-size: .875rem;
  line-height: 1.65;
}
.prose pre code { padding: 0; background: none; font-size: inherit; color: inherit; }
.prose .highlight, .prose div.highlighter-rouge { margin-top: 1.4em; }

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: .9375rem;
  display: block;
  overflow-x: auto;
}
.prose th, .prose td { padding: .625rem .75rem; text-align: left; border-bottom: 1px solid var(--rule); }
.prose th { font-weight: 700; }

/* Figures ----------------------------------------------------------------- */

.prose img { border-radius: 4px; }

.prose figure { margin-inline: 0; margin-top: 2em; }
.prose figure + * { margin-top: 2em; }

.prose figure img { margin-inline: auto; }

/* images fill the column and never exceed it; a percentage width (<img width="30%">) keeps its intended size */
.prose figure img:not([width$="%"]) { width: 100%; }

.prose figure.small img { max-width: min(100%, 34rem); }

.prose figure video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  background: var(--paper-2);
}

.prose figcaption {
  margin-top: .625rem;
  font-family: var(--sans);
  font-size: .875rem;
  line-height: 1.5;
  color: var(--muted);
}

.prose figure.small figcaption { max-width: 34rem; margin-inline: auto; }
.prose figure:has(> img[width]) figcaption { text-align: center; }

.prose figure.half,
.prose figure.third {
  display: grid;
  gap: .5rem;
}
.prose figure.half figcaption,
.prose figure.third figcaption { grid-column: 1 / -1; margin-top: .125rem; }
.prose figure.half img,
.prose figure.third img { height: 100%; aspect-ratio: 4 / 3; object-fit: cover; }

@media (min-width: 36rem) {
  .prose figure.half { grid-template-columns: repeat(2, 1fr); }
  .prose figure.third { grid-template-columns: repeat(3, 1fr); }
}

.prose figure a { display: block; }

/* Archive / taxonomy pages ------------------------------------------------- */

.page-header { padding-block: clamp(2rem, 6vw, 4rem) 2rem; }

.archive h2 {
  margin: 2.5rem 0 .5rem;
  font-size: 1.25rem;
  font-weight: 800;
  scroll-margin-top: 1.5rem;
}

.archive ul { margin: 0; padding: 0; list-style: none; }

.archive li {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  padding-block: .5rem;
}

.archive li time {
  flex: none;
  width: 5.75rem;
  font-size: .875rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.archive li a { font-weight: 600; text-decoration: none; color: var(--ink); }
.archive li a:hover { text-decoration: underline; text-decoration-color: var(--lamp); text-decoration-thickness: 2px; }

.term-list {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}
.term-list a { font-weight: 600; text-decoration: none; }
.term-list a:hover { text-decoration: underline; }
.term-list span { margin-left: .25rem; font-weight: 400; color: var(--muted); font-size: .875rem; }

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

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .75rem 2rem;
  margin-top: 3rem;
  padding-block: 2rem 2.5rem;
  /* rule stays inside the gutters, aligned with the content edge */
  background: linear-gradient(var(--rule), var(--rule)) no-repeat center top / calc(100% - 2 * var(--gutter)) 1px;
  font-size: .875rem;
  color: var(--muted);
}

.site-footer p { margin: 0; }
.site-footer ul { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin: 0; padding: 0; list-style: none; }
.site-footer a { color: var(--muted); font-weight: 600; text-decoration: none; }
.site-footer a:hover { color: var(--ink); text-decoration: underline; }

/* Syntax highlighting (rouge) --------------------------------------------- */

.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .cp { color: #7F9A95; font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kr, .highlight .kt, .highlight .kc { color: #F2B550; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sc, .highlight .sh, .highlight .sx, .highlight .sr { color: #A8D8A0; }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh, .highlight .il { color: #F0A58A; }
.highlight .nf, .highlight .fm, .highlight .nc, .highlight .nn { color: #82CCC3; }
.highlight .nt, .highlight .na, .highlight .nb, .highlight .bp { color: #9CC4F0; }
.highlight .o, .highlight .ow, .highlight .p { color: #C4D4CF; }
.highlight .nv, .highlight .vi, .highlight .vg { color: #E4ECE8; }
.highlight .gd { color: #F09A9A; }
.highlight .gi { color: #A8D8A0; }
.highlight .err { color: #F09A9A; }

/* Motion ----------------------------------------------------------------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(1.125rem); }
  to { opacity: 1; transform: none; }
}

@keyframes wipe {
  from { clip-path: inset(0 0 100% 0); }
  to { clip-path: inset(0 0 0 0); }
}

@media (prefers-reduced-motion: no-preference) {
  /* page intro: header pieces arrive in reading order */
  .hero > *,
  .post-header > *,
  .page-header > * {
    animation: rise .75s cubic-bezier(.2, .7, .2, 1) both;
  }
  .hero > :nth-child(2),
  .post-header > :nth-child(2) { animation-delay: .1s; }
  .post-header > :nth-child(3) { animation-delay: .2s; }
  .post-header > :nth-child(4) { animation-delay: .3s; }

  .post-cover-frame { animation: wipe 1.1s cubic-bezier(.65, 0, .35, 1) .3s both; }

  /* the route starts once the headline has landed */
  .route::before { animation-delay: .45s; }
  .route li::before { animation-delay: calc(.65s + var(--i, 0) * .22s); }

  /* scroll reveals; hidden only when JS is there to show them again */
  .js .prose figure,
  .js .entry {
    opacity: 0;
    transform: translateY(1.5rem);
    transition: opacity .7s ease, transform .8s cubic-bezier(.2, .7, .2, 1);
  }
  .js .prose figure.is-in,
  .js .entry.is-in {
    opacity: 1;
    transform: none;
  }
}

/* Motion preferences ------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
