:root {
  --bg: #f3f4f7;
  --card: #ffffff;
  --text: #1c1f26;
  --muted: #5b6270;
  --nav: #2b4c8c;
  --accent: #2b6fd6;
  --line: #dfe2e8;
  --cream: #fbf1dc;
  --cream-line: #e8cf9c;
  --hex-w: 104px;
  --radius: 22px;
  --shadow: 0 10px 40px rgba(20, 30, 60, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  overflow-x: hidden;
}
a { color: inherit; }

/* ---------- NAV ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; font-size: 1.25rem; text-decoration: none; }
.nav-links { display: flex; gap: clamp(16px, 3vw, 32px); }
.nav-links a {
  text-decoration: none; color: var(--nav); font-weight: 500; letter-spacing: .02em;
}
.nav-links a:hover { text-decoration: underline; text-underline-offset: 6px; }
.nav-toggle { display: none; background: none; border: 0; font-size: 1.5rem; color: var(--nav); cursor: pointer; }

/* ---------- HERO ---------- */
.hero { padding: clamp(16px, 4vw, 40px); }
.hero-card {
  max-width: 1100px; margin: 0 auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(24px, 5vw, 64px);
}
.hello { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 500; margin: 0; }
.aka { font-style: italic; color: var(--muted); margin: 2px 0 12px; font-size: .95rem; }
h1 {
  font-size: clamp(2.1rem, 6vw, 4rem);
  line-height: 1.08; margin: 0 0 20px; max-width: 14ch; font-weight: 600;
}
.accent { color: var(--accent); }
.bio { max-width: 60ch; color: #333a46; margin: 0 0 24px; }

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-actions.center { justify-content: center; }
.btn {
  display: inline-block; padding: 10px 20px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff;
  text-decoration: none; font-weight: 500; transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.btn-primary { background: var(--cream); border-color: var(--cream-line); }

.stats {
  list-style: none; padding: 0; margin: 36px 0 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.stats li {
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
  display: flex; flex-direction: column;
}
.stats strong { font-size: 1.7rem; color: var(--nav); line-height: 1.1; }
.stats span { color: var(--muted); font-size: .88rem; }

.certs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 24px; }
.certs-label {
  font-family: "IBM Plex Mono", monospace; font-size: .75rem; text-transform: uppercase;
  letter-spacing: .1em; color: var(--muted); margin-right: 4px;
}
.cert {
  font-size: .82rem; padding: 4px 10px; border-radius: 999px;
  background: #eef3fc; color: var(--nav); border: 1px solid #d5e1f6;
}

/* ---------- SECTIONS ---------- */
.section-head { text-align: center; max-width: 700px; margin: 0 auto 24px; padding: 0 16px; }
.section-head h2 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0 0 6px; }
.section-head p { margin: 0; color: var(--muted); }
.skills, .projects { padding: 64px clamp(16px, 4vw, 40px); }

/* ---------- SKILL MAP ---------- */
.skill-tools {
  display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 28px;
}
#skill-search {
  width: min(440px, 100%); padding: 10px 18px; border-radius: 999px;
  border: 1.5px solid #333; background: #fff; font: inherit; font-size: .95rem;
}
#skill-search:focus { outline: 3px solid #c9dbf8; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip {
  font: inherit; font-size: .8rem; font-family: "IBM Plex Mono", monospace;
  text-transform: uppercase; letter-spacing: .08em;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
}
.chip.active { background: var(--nav); border-color: var(--nav); color: #fff; }

.hex-map {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 40px 48px; max-width: 1300px; margin: 0 auto;
}
.hex-group { display: flex; flex-direction: column; align-items: center; }
.hex-group.hidden { display: none; }
.group-label {
  font-family: "IBM Plex Mono", monospace; text-transform: uppercase;
  letter-spacing: .12em; font-size: .8rem; margin: 0 0 10px;
  color: var(--g);
}
.hex-cluster { position: relative; }

.hex {
  position: absolute;
  width: var(--hex-w); height: calc(var(--hex-w) * 1.1547);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: var(--g);
  border: 0; padding: 0; cursor: pointer;
  transition: transform .2s, opacity .25s, filter .25s;
}
.hex::before {
  content: ""; position: absolute; inset: 3px;
  clip-path: inherit;
  background: radial-gradient(circle at 50% 35%, var(--g-in2), var(--g-in) 70%);
}
.hex span {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center; text-align: center;
  height: 100%; padding: 0 12px;
  color: #fff; font: 500 0.78rem/1.2 "IBM Plex Sans", sans-serif;
}
.hex:hover, .hex:focus-visible, .hex.selected { transform: scale(1.08); z-index: 2; outline: none; }
.hex.selected::before { background: var(--g); }
.hex-map.searching .hex { opacity: .18; filter: grayscale(.7); }
.hex-map.searching .hex.match { opacity: 1; filter: none; transform: scale(1.06); }

.skill-detail {
  text-align: center; max-width: 640px; margin: 28px auto 0; min-height: 3em;
  color: var(--muted); padding: 0 16px;
}
.skill-detail strong { color: var(--text); }

/* ---------- PROJECTS ---------- */
.project-grid {
  max-width: 1100px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;
}
.project {
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
  padding: 24px; display: flex; flex-direction: column; gap: 10px;
  border-top: 5px solid var(--g);
  transition: transform .2s;
}
.project:hover { transform: translateY(-4px); }
.project-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.project h3 { margin: 0; font-size: 1.15rem; line-height: 1.3; }
.metric {
  flex-shrink: 0; font-weight: 700; color: var(--g); font-size: 1.05rem; text-align: right;
}
.metric small { display: block; font-weight: 500; font-size: .7rem; color: var(--muted); }
.where { margin: 0; font-size: .85rem; color: var(--muted); }
.project p.desc { margin: 0; color: #333a46; font-size: .95rem; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
.tag { font-size: .75rem; padding: 3px 9px; border-radius: 999px; background: #f1f2f5; color: #444b58; }

/* ---------- CONTACT ---------- */
.contact {
  text-align: center; padding: 64px 16px 80px;
  max-width: 700px; margin: 0 auto;
}
.contact h2 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0 0 8px; }
.contact p { color: var(--muted); margin: 0 0 24px; }
.footer { text-align: center; padding: 24px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; gap: 0; background: #fff; border-bottom: 1px solid var(--line);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 14px 20px; border-top: 1px solid var(--line); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  :root { --hex-w: 92px; }
  .hex span { font-size: .7rem; padding: 0 8px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

/* =========================================================
   PORTFOLIO GRID (portfolio.html)
   ========================================================= */
.nav-links a[aria-current="page"] { text-decoration: underline; text-underline-offset: 6px; }
.portfolio-page { padding: 48px clamp(16px, 4vw, 40px) 72px; }
.portfolio-grid {
  max-width: 1200px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 22px;
}
.tile {
  position: relative; display: block; aspect-ratio: 16 / 10;
  border-radius: 16px; overflow: hidden; text-decoration: none;
  background: #0f1724; box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,.06);
}
.tile-preview { position: absolute; inset: 0; transition: transform .5s ease; }
.tile:hover .tile-preview, .tile:focus-visible .tile-preview { transform: scale(1.04); }
.tile-shade {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(8,12,20,.92) 0%, rgba(8,12,20,.55) 30%, rgba(8,12,20,0) 58%);
}
.tile-info { position: absolute; left: 20px; right: 70px; bottom: 16px; color: #fff; }
.tile-info h2 { margin: 0; font-size: 1.2rem; font-weight: 600; line-height: 1.25; }
.tile-info p { margin: 4px 0 0; font-size: .8rem; color: rgba(255,255,255,.72); font-family: "IBM Plex Mono", monospace; }
.tile-arrow {
  position: absolute; right: 16px; bottom: 16px; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-size: 1.05rem;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.35);
  transition: background .2s, transform .2s;
}
.tile:hover .tile-arrow { background: var(--g); border-color: var(--g); transform: rotate(45deg); }
.tile::after { content: ""; position: absolute; left: 0; top: 0; right: 0; height: 4px; background: var(--g); }

/* ---------- Previews ---------- */
.pv {
  position: absolute; inset: 0; padding: 18px 20px; overflow: hidden;
  font-family: "IBM Plex Mono", monospace; font-size: 12px; color: #c9d4e5;
  background: #0f1724;
}
.pv-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; color: #8a97ab; font-size: 11px; }
.pv-bar span:first-child { color: #e6edf7; font-weight: 500; }
.pv-branch { padding: 1px 8px; border-radius: 99px; background: #1d2a3e; color: #9fb7dc; }
.pv-ok { margin-left: auto; color: #4fd18b; }

/* pipeline */
.pv-pipeline { background: radial-gradient(circle at 80% 0%, #1b2b45, #0f1724 60%); }
.pl-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 0; }
.pl-stage {
  display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 8px;
  background: #16233a; border: 1px solid #263a5a; color: #dbe6f5; white-space: nowrap;
}
.pl-stage i { font-style: normal; color: #4fd18b; font-weight: 700; }
.pl-stage.run { border-color: var(--g); box-shadow: 0 0 0 3px color-mix(in srgb, var(--g) 25%, transparent); }
.pl-stage.run i { color: var(--g); animation: pulse 1.4s infinite; }
.pl-link { width: 14px; height: 2px; background: #2f4568; }
.pl-log { margin-top: 20px; display: grid; gap: 7px; }
.pl-log span { height: 7px; border-radius: 4px; background: #1c2a40; }
.pl-log span:nth-child(1) { width: 80%; } .pl-log span:nth-child(2) { width: 62%; } .pl-log span:nth-child(3) { width: 72%; }
@keyframes pulse { 50% { opacity: .3; } }

/* terminal */
.pv-term { background: #0c111a; line-height: 1.75; }
.pv-dots { display: flex; gap: 6px; margin-bottom: 12px; }
.pv-dots i { width: 10px; height: 10px; border-radius: 50%; background: #ff5f57; }
.pv-dots i:nth-child(2) { background: #febc2e; } .pv-dots i:nth-child(3) { background: #28c840; }
.pv-term div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-cmd { color: #e6edf7; } .t-cmd span { color: var(--g); }
.t-add, .t-ok { color: #4fd18b; } .t-chg { color: #f0c05a; }
.t-add b, .t-ok b, .t-chg b { font-weight: 500; }
.t-sum { color: #fff; font-weight: 500; margin-top: 4px; }

/* flow diagram */
.pv-flow { background: #0f1724; display: flex; align-items: flex-start; padding-top: 28px; }
.fl-grid {
  position: absolute; inset: 0; opacity: .5;
  background-image: linear-gradient(#1a263a 1px, transparent 1px), linear-gradient(90deg, #1a263a 1px, transparent 1px);
  background-size: 22px 22px;
}
.fl-row { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 0; }
.fl-node {
  padding: 10px 12px; border-radius: 10px; background: #16233a; color: #e6edf7;
  border: 1px solid color-mix(in srgb, var(--g) 60%, #263a5a); white-space: nowrap;
}
.fl-arrow { width: 22px; height: 2px; background: var(--g); position: relative; }
.fl-arrow::after {
  content: ""; position: absolute; right: -1px; top: -4px;
  border-left: 6px solid var(--g); border-top: 5px solid transparent; border-bottom: 5px solid transparent;
}

/* dashboard */
.pv-dash { background: #111217; }
.d-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.d-stats div { background: #181b22; border: 1px solid #23262e; border-radius: 6px; padding: 8px 10px; }
.d-stats small { display: block; color: #8a8f9c; font-size: 10px; }
.d-stats b { font-size: 20px; color: #73bf69; font-weight: 500; }
.d-stats b.warn { color: #f2cc0c; }
.d-line { width: 100%; height: 60px; margin-top: 10px; }
.d-line polyline { fill: none; stroke: var(--g); stroke-width: 2; vector-effect: non-scaling-stroke; }
.d-bars { display: flex; align-items: flex-end; gap: 4px; height: 50px; margin-top: 6px; }
.d-bars i { flex: 1; background: color-mix(in srgb, #5794f2 70%, transparent); border-radius: 2px 2px 0 0; }

/* =========================================================
   PROJECT DETAIL (project.html)
   ========================================================= */
.project-detail { max-width: 1100px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 72px; }
.pd-back { display: inline-block; color: var(--nav); text-decoration: none; font-weight: 500; margin-bottom: 18px; }
.pd-back:hover { text-decoration: underline; }
.pd-hero {
  display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: center;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: clamp(22px, 4vw, 44px); border-top: 6px solid var(--g);
}
.pd-hero h1 { font-size: clamp(1.9rem, 4.5vw, 2.9rem); line-height: 1.1; margin: 0 0 12px; max-width: none; }
.pd-tagline { color: #333a46; font-size: 1.08rem; margin: 0 0 18px; }
.pd-hero .tags { margin-bottom: 20px; }
.pd-hero-preview { position: relative; aspect-ratio: 16 / 10; border-radius: 14px; overflow: hidden; }
.pd-body { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.pd-card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 26px; min-width: 0; }
.pd-card h2 { margin: 0 0 12px; font-size: 1.2rem; }
.pd-card p { margin: 0; color: #333a46; }
.pd-code-card { grid-column: 1 / -1; }
.pd-list { margin: 0; padding-left: 20px; color: #333a46; display: grid; gap: 8px; }
.pd-checks { list-style: none; padding: 0; }
.pd-checks li { padding-left: 28px; position: relative; }
.pd-checks li::before { content: "✓"; position: absolute; left: 0; color: var(--g); font-weight: 700; }
.pd-flow { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.pd-flow li { display: flex; align-items: center; gap: 12px; position: relative; padding: 8px 0; font-weight: 500; }
.pd-flow li span {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--g); color: #fff; font-size: .8rem; position: relative; z-index: 1;
}
.pd-flow li:not(:last-child)::after {
  content: ""; position: absolute; left: 13px; top: 36px; bottom: -8px; width: 2px;
  background: color-mix(in srgb, var(--g) 35%, transparent);
}
.pd-code-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.pd-code-head h2 { margin: 0; }
.pd-lang {
  font-family: "IBM Plex Mono", monospace; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  padding: 2px 8px; border-radius: 99px; background: #f1f2f5; color: var(--muted);
}
.pd-copy {
  margin-left: auto; font: inherit; font-size: .85rem; padding: 6px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
}
.pd-copy:hover { background: #f5f6f8; }
.pd-code {
  margin: 0; padding: 20px; border-radius: 12px; background: #0f1724; color: #dbe6f5;
  font: 13px/1.6 "IBM Plex Mono", monospace; overflow-x: auto; tab-size: 2;
}
.c-com { color: #7d8ba1; font-style: italic; }
.c-str { color: #9ad48a; }
.pd-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 28px; }
.pd-nav a {
  background: var(--card); border-radius: 14px; padding: 16px 20px; text-decoration: none;
  border: 1px solid var(--line); font-weight: 600;
}
.pd-nav a:hover { border-color: var(--nav); }
.pd-nav a.right { text-align: right; }
.pd-nav small { display: block; color: var(--muted); font-weight: 400; font-size: .8rem; }
.pd-missing { text-align: center; padding: 80px 0; }

@media (max-width: 860px) {
  .pd-hero, .pd-body { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .pv { font-size: 10.5px; padding: 14px; }
  .pv-bar { margin-bottom: 12px; }
  .pl-stage { padding: 5px 7px; }
  .fl-node { padding: 7px 9px; }
  .tile-info h2 { font-size: 1.05rem; }
  .pd-nav { grid-template-columns: 1fr; }
  .pd-nav a.right { text-align: left; }
}
