/* ============================================================
   thedevilhunter — site theme
   Palette: sumi-ink black / paper white / rising-sun red
   ============================================================ */

:root {
  --bg: #0b0a0a;
  --bg-raised: #131111;
  --bg-card: #161313;
  --paper: #f6f3ea;
  --text: #e9e5db;
  --muted: #a09a8f;
  --faint: #6d675e;
  --red: #d41f30;
  --red-bright: #ef3347;
  --red-dim: #7e1420;
  --line: #282423;
  --line-soft: #1e1b1a;
  --code-bg: #141111;
  --mono: "Cascadia Code", Consolas, "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Segoe UI", Inter, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
  --maxw: 1100px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* faint paper-grain vignette */
  background-image: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(212, 31, 48, 0.05), transparent);
}

::selection { background: var(--red-dim); color: var(--paper); }

a { color: inherit; text-decoration: none; }

img { max-width: 100%; }

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 10, 10, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}

.site-header .inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--line);
}

.brand .tld { color: var(--muted); font-weight: 400; }
.brand .name { color: var(--text); }
.brand .cursor {
  display: inline-block;
  width: 9px;
  height: 19px;
  margin-left: 2px;
  background: var(--red);
  vertical-align: text-bottom;
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 14.5px;
}

.site-nav a {
  color: var(--muted);
  padding: 8px 13px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.site-nav a:hover { color: var(--text); background: var(--bg-raised); }

.site-nav a.active { color: var(--red-bright); }

.site-nav a.active::before { content: "./"; opacity: 0.7; }

/* mobile nav */
.nav-toggle { display: none; }

@media (max-width: 720px) {
  .nav-toggle {
    display: block;
    margin-left: auto;
    background: none;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 14px;
    padding: 7px 12px;
    cursor: pointer;
  }
  .site-nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    align-items: stretch;
    padding: 10px 16px 16px;
  }
  .site-nav.open { display: flex; }
}

/* ---------- layout ---------- */

main { flex: 1; }

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

.section { padding: 56px 0; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 28px;
}

.section-head h2 {
  font-size: 26px;
  letter-spacing: 0.01em;
}

.section-head .kanji {
  color: var(--faint);
  font-size: 15px;
  font-family: var(--mono);
}

.section-head .rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.section-head .more {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--muted);
}

.section-head .more:hover { color: var(--red-bright); }

/* ---------- hero ---------- */

.hero {
  position: relative;
  padding: 84px 0 64px;
  overflow: hidden;
}

.hero .kanji-bg {
  position: absolute;
  right: -30px;
  top: 8px;
  font-size: 300px;
  line-height: 0.9;
  color: var(--paper);
  opacity: 0.025;
  font-weight: 700;
  pointer-events: none;
  user-select: none;
  writing-mode: vertical-rl;
}

.hero .inner {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 48px;
  align-items: center;
}

@media (max-width: 860px) {
  .hero .inner { grid-template-columns: 1fr; }
  .hero .portrait { order: -1; justify-self: center; }
}

/* on phones, let the headline wrap naturally instead of honouring the
   desktop-crafted hard breaks, so no word can be clipped */
@media (max-width: 560px) {
  .hero h1 br { display: none; }
  .hero .kanji-bg { font-size: 200px; right: -10px; }
}

.hero h1 {
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 18px 0 14px;
}

.hero h1 .accent { color: var(--red-bright); }

.hero .tagline {
  color: var(--muted);
  font-size: 18px;
  max-width: 54ch;
}

.hero .eyebrow {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--red-bright);
  letter-spacing: 0.08em;
}

.hero .cta-row {
  display: flex;
  gap: 14px;
  margin-top: 30px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 15px;
  padding: 11px 22px;
  border-radius: 7px;
  border: 1px solid var(--line);
  color: var(--text);
  transition: all 0.15s;
}

.btn:hover { border-color: var(--faint); background: var(--bg-raised); }

.btn.primary {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.btn.primary:hover { background: var(--red-bright); border-color: var(--red-bright); }

/* portrait */
.portrait { position: relative; width: min(280px, 70vw); }

.portrait img {
  width: 100%;
  border-radius: 50%;
  border: 3px solid var(--line);
  box-shadow: 0 0 0 8px rgba(212, 31, 48, 0.06), 0 20px 60px rgba(0, 0, 0, 0.6);
  background: var(--paper);
}

.portrait::after {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 1px dashed var(--red-dim);
  opacity: 0.5;
  animation: spin 60s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* terminal card */
.terminal {
  margin-top: 34px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 14.5px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}

.terminal .bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line-soft);
}

.terminal .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--line); }
.terminal .dot.r { background: #c94444; }
.terminal .dot.y { background: #b8862f; }
.terminal .dot.g { background: #3f7d4e; }

.terminal .bar span {
  margin-left: 8px;
  color: var(--faint);
  font-size: 12.5px;
}

.terminal .body { padding: 16px 18px; min-height: 132px; }

.terminal .line { white-space: pre-wrap; word-break: break-word; }

.terminal .prompt { color: var(--red-bright); }
.terminal .path { color: var(--muted); }
.terminal .out { color: var(--muted); }
.terminal .ok { color: #7dc383; }

/* ---------- stats strip ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

.stat {
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 18px 20px;
}

.stat .num {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--red-bright);
}

.stat .lbl { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* ---------- cards grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 18px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 22px;
  transition: transform 0.16s, border-color 0.16s;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--red), transparent 60%);
  opacity: 0;
  transition: opacity 0.16s;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--line);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
}

.card:hover::before { opacity: 1; }

.card .meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.badge {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 5px;
  border: 1px solid var(--red-dim);
  color: var(--red-bright);
}

.pill {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 5px;
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  color: var(--muted);
}

.pill.easy { color: #7dc383; }
.pill.medium { color: #d6a742; }
.pill.hard { color: #e0664a; }
.pill.insane { color: #c96bd6; }

.card h3 {
  font-size: 19.5px;
  line-height: 1.3;
  margin-bottom: 8px;
}

.card h3 a:hover { color: var(--red-bright); }

.card .excerpt {
  color: var(--muted);
  font-size: 14.8px;
  flex: 1;
}

.card .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.tag {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
}

.tag::before { content: "#"; color: var(--red-dim); }

.card .foot {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--faint);
}

/* ---------- writeups page controls ---------- */

.controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 26px;
}

.search-box {
  flex: 1;
  min-width: 240px;
  position: relative;
  font-family: var(--mono);
}

.search-box input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14.5px;
  padding: 11px 14px 11px 40px;
  outline: none;
  transition: border-color 0.15s;
}

.search-box input:focus { border-color: var(--red-dim); }

.search-box .icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  color: var(--muted);
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.14s;
}

.filter-btn:hover { border-color: var(--line); color: var(--text); }

.filter-btn.active {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--paper);
}

.result-count {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--faint);
  margin-bottom: 18px;
}

.empty-state {
  text-align: center;
  padding: 70px 0;
  color: var(--faint);
  font-family: var(--mono);
}

/* ---------- post page ---------- */

.post-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 48px;
  align-items: start;
  padding-top: 44px;
}

@media (max-width: 960px) {
  .post-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}

.post-header { margin-bottom: 8px; }

.post-header .crumbs {
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--faint);
  margin-bottom: 18px;
}

.post-header .crumbs a { color: var(--muted); }
.post-header .crumbs a:hover { color: var(--red-bright); }

.post-header h1 {
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.15;
  margin: 12px 0 16px;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--faint);
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 34px;
}

.toc {
  position: sticky;
  top: 96px;
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 18px 20px;
  font-size: 14px;
}

.toc .toc-title {
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
  margin-bottom: 12px;
}

.toc a {
  display: block;
  color: var(--muted);
  padding: 4px 0;
  border-left: 2px solid transparent;
  padding-left: 10px;
  margin-left: -10px;
  transition: color 0.12s, border-color 0.12s;
}

.toc a:hover { color: var(--text); }
.toc a.active { color: var(--red-bright); border-left-color: var(--red); }
.toc a.lvl-3 { padding-left: 24px; font-size: 13px; }

.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 100%;
  background: linear-gradient(90deg, var(--red-dim), var(--red-bright));
  z-index: 60;
  transform: scaleX(0);
  transform-origin: 0 50%;
  will-change: transform;
}

/* ---------- markdown content ---------- */

.md { max-width: 780px; }

.md h2, .md h3, .md h4 {
  margin: 2.2em 0 0.6em;
  line-height: 1.3;
  scroll-margin-top: 90px;
}

.md h2 {
  font-size: 26px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.md h2 .hash, .md h3 .hash {
  color: var(--red-dim);
  margin-right: 8px;
  font-family: var(--mono);
  font-size: 0.85em;
}

.md h3 { font-size: 21px; }
.md h4 { font-size: 17.5px; }

.md p { margin: 1em 0; }

.md a {
  color: var(--red-bright);
  border-bottom: 1px solid var(--red-dim);
}

.md a:hover { border-bottom-color: var(--red-bright); }

.md ul, .md ol { margin: 1em 0; padding-left: 26px; }
.md li { margin: 0.35em 0; }
.md li::marker { color: var(--red-dim); }

.md blockquote {
  margin: 1.4em 0;
  padding: 12px 20px;
  border-left: 3px solid var(--red);
  background: var(--bg-raised);
  border-radius: 0 8px 8px 0;
  color: var(--muted);
}

.md blockquote p { margin: 0.4em 0; }

.md hr {
  border: none;
  height: 1px;
  background: var(--line);
  margin: 2.4em 0;
}

.md img {
  border-radius: 10px;
  border: 1px solid var(--line);
  margin: 1.2em 0;
  display: block;
}

/* ---------- rich media: figures, screenshots, video, embeds ---------- */

.md figure.media {
  margin: 1.8em 0;
}

.md figure.media img,
.md figure.media video {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: block;
  margin: 0;
  background: #000;
}

.md figure.media img.zoomable { cursor: zoom-in; transition: filter 0.15s var(--ease-out, ease); }
.md figure.media img.zoomable:hover { filter: brightness(1.06); }

.md figcaption {
  margin-top: 10px;
  text-align: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
}

.md figcaption::before { content: "▸ "; color: var(--red-dim); }

/* responsive 16:9 iframe (YouTube) */
.md .embed {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #000;
}
.md .embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---------- lightbox (click screenshot to enlarge) ---------- */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 5, 5, 0.94);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  cursor: zoom-out;
}
#lightbox.open { opacity: 1; pointer-events: auto; }
#lightbox img {
  max-width: 94vw;
  max-height: 92vh;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
  transform: scale(0.97);
  transition: transform 0.22s var(--ease-out, ease);
}
#lightbox.open img { transform: scale(1); }
#lightbox .lb-close {
  position: absolute;
  top: 18px;
  right: 22px;
  font-family: var(--mono);
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
}
#lightbox .lb-close:hover { color: var(--red-bright); }

.md table {
  border-collapse: collapse;
  margin: 1.4em 0;
  width: 100%;
  font-size: 14.5px;
  display: block;
  overflow-x: auto;
}

.md th, .md td {
  border: 1px solid var(--line);
  padding: 9px 14px;
  text-align: left;
}

.md th {
  background: var(--bg-raised);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

.md code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 2px 6px;
  color: #e8b4ba;
}

.md pre {
  margin: 1.4em 0;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.md pre .code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
}

.md pre .copy-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 3px 10px;
  cursor: pointer;
  transition: all 0.13s;
}

.md pre .copy-btn:hover { color: var(--text); border-color: var(--faint); }
.md pre .copy-btn.done { color: #7dc383; border-color: #3f7d4e; }

.md pre code {
  display: block;
  padding: 16px 18px;
  background: none;
  border: none;
  overflow-x: auto;
  line-height: 1.6;
  font-size: 13.8px;
  color: #ddd8cd;
}

.md .math-block {
  margin: 1.5em 0;
  padding: 8px 4px;
  overflow-x: auto;
  overflow-y: hidden;
  color: var(--text);
}

.md .math-inline {
  white-space: nowrap;
}

.md mjx-container {
  color: var(--text);
}

/* light syntax highlight tokens */
.tok-c { color: #6d675e; font-style: italic; }   /* comment */
.tok-k { color: #ef6c7d; }                        /* keyword */
.tok-s { color: #a8c48b; }                        /* string */
.tok-n { color: #d6a742; }                        /* number */
.tok-f { color: #8fb8d8; }                        /* function/cmd */
.tok-p { color: #c9899a; }                        /* prompt marker */

/* ---------- about page ---------- */

.about-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
  padding-top: 44px;
}

@media (max-width: 860px) {
  .about-grid { grid-template-columns: 1fr; }
  .about-side { display: flex; flex-direction: column; align-items: center; text-align: center; }
}

.about-side .portrait { margin-bottom: 22px; }

.about-side h1 { font-size: 26px; font-family: var(--mono); }

.about-side .role { color: var(--muted); margin: 6px 0 18px; }

.social-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.social-links a {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 10px 16px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--muted);
  transition: all 0.14s;
}

.social-links a:hover { border-color: var(--red-dim); color: var(--text); }

.social-links svg { flex-shrink: 0; }

.skill-rows { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }

.skill-row {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 14px;
  align-items: center;
}

@media (max-width: 560px) { .skill-row { grid-template-columns: 1fr; gap: 4px; } }

.skill-row .lbl { font-family: var(--mono); font-size: 14px; color: var(--muted); }

.skill-row .chips { display: flex; flex-wrap: wrap; gap: 7px; }

.chip {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 4px 11px;
  color: var(--text);
}

/* timeline */
.timeline { margin-top: 8px; border-left: 2px solid var(--line); padding-left: 26px; }

.tl-item { position: relative; padding-bottom: 26px; }

.tl-item::before {
  content: "";
  position: absolute;
  left: -33px;
  top: 6px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--red);
}

.tl-item .when {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--red-bright);
  letter-spacing: 0.04em;
}

.tl-item h4 { margin: 4px 0 4px; font-size: 16.5px; }

.tl-item p { color: var(--muted); font-size: 14.5px; }

/* ---------- box info card (writeups) ---------- */

.box-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  overflow: hidden;
  margin: 6px 0 34px;
}

.bi-row {
  background: var(--bg-card);
  padding: 13px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bi-k {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}

.bi-v { font-size: 15px; color: var(--text); }

#related { margin-top: 60px; }

/* ---------- tags index ---------- */

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.tag-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 9px 14px;
  font-family: var(--mono);
  font-size: 14px;
  transition: all 0.14s;
}

.tag-link:hover { border-color: var(--red-dim); transform: translateY(-2px); }
.tag-link .t { color: var(--text); }
.tag-link .c {
  color: var(--faint);
  background: var(--bg-raised);
  border-radius: 20px;
  padding: 1px 9px;
  font-size: 12px;
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line-soft);
  margin-top: 40px;
  padding: 34px 0;
  color: var(--faint);
  font-size: 14px;
}

.site-footer .inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.site-footer .kanji { font-size: 18px; color: var(--red-dim); }

.site-footer .links {
  margin-left: auto;
  display: flex;
  gap: 18px;
  font-family: var(--mono);
  font-size: 13px;
}

.site-footer a:hover { color: var(--red-bright); }

/* ---------- misc ---------- */

.page-title { padding-top: 52px; }

.page-title .eyebrow {
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--red-bright);
  letter-spacing: 0.08em;
}

.page-title h1 { font-size: clamp(30px, 4.5vw, 42px); margin: 10px 0 10px; }

.page-title .sub { color: var(--muted); max-width: 62ch; }

.loading {
  font-family: var(--mono);
  color: var(--faint);
  text-align: center;
  padding: 80px 0;
}

.loading::after {
  content: "";
  animation: dots 1.2s steps(4) infinite;
}

@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* ============================================================
   MOTION LAYER — 60fps, transform/opacity only (compositor-safe)
   All scroll-reveal is gated behind the `.js` class so no-JS users
   always see content. Reduced-motion users get everything instantly.
   ============================================================ */

/* smooth, hardware-friendly easing tokens */
:root {
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* scroll-in targets: hidden until the observer marks them .is-in */
.js .reveal,
.js .card,
.js .stat,
.js .section-head,
.js .tl-item,
.js .skill-row,
.js .box-info,
.js .tag-link,
.js .social-links a,
.js .hero .eyebrow,
.js .hero h1,
.js .hero .tagline,
.js .hero .cta-row,
.js .hero .terminal,
.js .hero .portrait,
.js .page-title .eyebrow,
.js .page-title h1,
.js .page-title .sub {
  opacity: 0;
  transform: translate3d(0, 24px, 0);
  transition: opacity 0.62s var(--ease-out), transform 0.62s var(--ease-out);
  transition-delay: var(--d, 0ms);
}

/* the portrait rises with a touch of scale for a premium feel */
.js .hero .portrait { transform: translate3d(0, 24px, 0) scale(0.96); }

.js .is-in {
  opacity: 1 !important;
  transform: none !important;
}

/* FAIL-OPEN: if anim.js never signals liveness, a <head> timer adds
   .no-anim and everything becomes visible (content is never trapped hidden) */
.no-anim .reveal, .no-anim .card, .no-anim .stat, .no-anim .section-head,
.no-anim .tl-item, .no-anim .skill-row, .no-anim .box-info, .no-anim .tag-link,
.no-anim .social-links a, .no-anim .hero .eyebrow, .no-anim .hero h1,
.no-anim .hero .tagline, .no-anim .hero .cta-row, .no-anim .hero .terminal,
.no-anim .hero .portrait, .no-anim .page-title .eyebrow, .no-anim .page-title h1,
.no-anim .page-title .sub {
  opacity: 1 !important;
  transform: none !important;
}

/* clear will-change once settled (set/removed by JS) */
.anim-active { will-change: opacity, transform; }

/* ---------- hero terminal caret / typed line already animate ---------- */

/* ---------- portrait: gentle float + parallax container ---------- */
.portrait { transition: transform 0.25s var(--ease-out); }
.portrait-inner { display: block; }
.portrait img { animation: float 6s ease-in-out infinite; }
/* pause continuous motion while the portrait is scrolled off-screen */
.portrait.motion-idle img,
.portrait.motion-idle::after { animation-play-state: paused; }

@keyframes float {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50%      { transform: translate3d(0, -10px, 0); }
}

/* ---------- card hover: buttery lift + red sweep (compositor only) ---------- */
.card {
  transition: transform 0.28s var(--ease-out), border-color 0.28s var(--ease-out);
}
.card:hover {
  transform: translate3d(0, -6px, 0);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}
.card h3 a { transition: color 0.18s var(--ease-out); }

/* ---------- buttons: lift + primary shine sweep ---------- */
.btn { transition: transform 0.2s var(--ease-out), background 0.18s, border-color 0.18s; position: relative; overflow: hidden; }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn.primary:hover { box-shadow: 0 10px 26px rgba(212, 31, 48, 0.35); }
.btn.primary::after {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: skewX(-20deg);
  opacity: 0;
}
.btn.primary:hover::after { animation: shine 0.9s var(--ease-out); }

@keyframes shine {
  0%   { left: -60%; opacity: 0; }
  20%  { opacity: 1; }
  100% { left: 130%; opacity: 0; }
}

/* ---------- nav: underline grows from left ---------- */
.site-nav a { position: relative; }
.site-nav a::after {
  content: "";
  position: absolute;
  left: 13px;
  right: 13px;
  bottom: 4px;
  height: 2px;
  background: var(--red);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.24s var(--ease-out);
}
.site-nav a:hover::after,
.site-nav a:focus-visible::after,
.site-nav a.active::after { transform: scaleX(1); }

/* ---------- brand logo subtle spin-up on hover ---------- */
.brand img { transition: transform 0.5s var(--ease-spring); }
.brand:hover img { transform: rotate(8deg) scale(1.06); }

/* ---------- filter / tag / pill micro-interactions ---------- */
.filter-btn { transition: transform 0.16s var(--ease-out), background 0.16s, border-color 0.16s, color 0.16s; }
.filter-btn:active { transform: scale(0.95); }
.tag-link { transition: transform 0.2s var(--ease-out), border-color 0.2s; }
.tag-link:hover { transform: translate3d(0, -3px, 0); box-shadow: 0 10px 22px rgba(0, 0, 0, 0.4); }
.social-links a { transition: transform 0.18s var(--ease-out), border-color 0.18s, color 0.18s; }
.social-links a:hover { transform: translateX(4px); }

/* ---------- stat cards lift ---------- */
.stat { transition: transform 0.24s var(--ease-out), border-color 0.24s; }
.stat:hover { transform: translate3d(0, -4px, 0); border-color: var(--line); }

/* ---------- copy button feedback ---------- */
.copy-btn { transition: color 0.14s, border-color 0.14s, transform 0.14s; }
.copy-btn:active { transform: scale(0.92); }

/* ---------- cursor spotlight (one fixed element, transform-driven) ---------- */
#cursor-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 420px;
  height: 420px;
  margin: -210px 0 0 -210px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(circle, rgba(212, 31, 48, 0.10), transparent 60%);
  opacity: 0;
  transition: opacity 0.4s ease;
}
/* promote to its own layer only while actually visible/animating */
.js #cursor-glow.on { opacity: 1; will-change: transform; }

@media (hover: none) { #cursor-glow { display: none; } }

/* keep content above the glow */
.site-header, main, .site-footer { position: relative; z-index: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  html { scroll-behavior: auto; }
  /* never leave reveal targets stuck hidden when motion is off */
  .js .reveal, .js .card, .js .stat, .js .section-head, .js .tl-item,
  .js .skill-row, .js .box-info, .js .tag-link, .js .social-links a,
  .js .hero .eyebrow, .js .hero h1, .js .hero .tagline, .js .hero .cta-row,
  .js .hero .terminal, .js .hero .portrait, .js .page-title .eyebrow,
  .js .page-title h1, .js .page-title .sub {
    opacity: 1 !important;
    transform: none !important;
  }
  #cursor-glow { display: none !important; }
}
