/* =========================================================
   Kanagawa — a Hugo blog theme recolored to Kanagawa Dragon
   Palette: Kanagawa Dragon (default) / Kanagawa Lotus (light toggle)
   https://github.com/rebelot/kanagawa.nvim (MIT, © Tommaso Laurenzi)
   Layout/structure: hugo-macchiato by Lawless (Catppuccin Macchiato).
   Variable names follow the original theme's CSS API; values are Kanagawa:
   keywords/accent = dragonViolet, strings = dragonGreen2, functions/links =
   dragonBlue2, constants = dragonOrange, numbers = dragonPink, types =
   dragonAqua, operators = dragonRed, identifiers = dragonYellow,
   grays = dragonGray→fujiGray, surfaces = dragonBlack1–6.
   ========================================================= */

:root,
html[data-theme="dragon"] {
  --pink:      #a292a3;  /* dragonPink  — numbers */
  --mauve:     #8992a7;  /* dragonViolet — keywords, primary accent */
  --red:       #c4746e;  /* dragonRed   — errors */
  --peach:     #b6927b;  /* dragonOrange — constants */
  --yellow:    #c4b28a;  /* dragonYellow — identifiers */
  --green:     #8a9a7b;  /* dragonGreen2 — strings */
  --teal:      #8ea4a2;  /* dragonAqua  — types */
  --sky:       #c4746e;  /* dragonRed   — operators */
  --sapphire:  #658594;  /* dragonBlue  — labels */
  --blue:      #8ba4b0;  /* dragonBlue2 — functions, links */
  --text:      #c5c9c5;  /* dragonWhite */
  --subtext1:  #a6a69c;  /* dragonGray */
  --subtext0:  #9e9b93;  /* dragonGray2 */
  --overlay2:  #7a8382;  /* dragonGray3 */
  --overlay1:  #737c73;  /* dragonAsh   — comments */
  --overlay0:  #727169;  /* fujiGray */
  --surface2:  #625e5a;  /* dragonBlack6 */
  --surface1:  #393836;  /* dragonBlack5 */
  --surface0:  #282727;  /* dragonBlack4 */
  --base:      #181616;  /* dragonBlack3 */
  --mantle:    #12120f;  /* dragonBlack1 */
  --crust:     #0d0c0c;  /* dragonBlack0 */

  --shadow: 0 8px 24px rgba(13, 12, 12, 0.5);
  color-scheme: dark;
}

/* Optional light flavor — Kanagawa Paper Lotus — toggled via the sun/moon button.
   Same structure, easier on the eyes in bright rooms; still unmistakably Kanagawa. */
html[data-theme="lotus"] {
  --pink:      #b35b79;  /* lotusPink    — numbers */
  --mauve:     #624c83;  /* lotusViolet4 — keywords, primary accent */
  --red:       #c84053;  /* lotusRed     — errors */
  --peach:     #cc6d00;  /* lotusOrange  — constants */
  --yellow:    #77713f;  /* lotusYellow  — identifiers */
  --green:     #6f894e;  /* lotusGreen   — strings */
  --teal:      #597b75;  /* lotusAqua    — types */
  --sky:       #836f4a;  /* lotusYellow2 — operators */
  --sapphire:  #6693bf;  /* lotusTeal2   — labels */
  --blue:      #4d699b;  /* lotusBlue4   — functions, links */
  --text:      #545464;  /* lotusInk1 */
  --subtext1:  #716e61;  /* lotusGray2 */
  --subtext0:  #8a8980;  /* lotusGray3 */
  --overlay2:  #8a8980;  /* lotusGray3 */
  --overlay1:  #8a8980;  /* lotusGray3  — comments */
  --overlay0:  #a09cac;  /* lotusViolet1 */
  --surface2:  #a09cac;  /* lotusViolet1 */
  --surface1:  #dcd5ac;  /* lotusWhite1 */
  --surface0:  #d5cea3;  /* lotusWhite0 */
  --base:      #f2ecbc;  /* lotusWhite3 */
  --mantle:    #e5ddb0;  /* lotusWhite2 */
  --crust:     #dcd5ac;  /* lotusWhite1 */

  --shadow: 0 8px 24px rgba(84, 84, 100, 0.12);
  color-scheme: light;
}

/* =========================================================
   Reset & base
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  background: var(--base);
  color: var(--text);
  font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.2s ease, color 0.2s ease;
}

img { max-width: 100%; height: auto; border-radius: 8px; display: block; }
hr { border: none; border-top: 1px solid var(--surface0); margin: 2.5rem 0; }

a {
  color: var(--blue);
  text-decoration-color: var(--surface2);
  text-underline-offset: 3px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
a:hover { color: var(--mauve); text-decoration-color: var(--mauve); }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--mauve);
  outline-offset: 2px;
  border-radius: 3px;
}

::selection { background: var(--mauve); color: var(--crust); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--mantle); }
::-webkit-scrollbar-thumb { background: var(--surface1); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--surface2); }

/* =========================================================
   Layout shell
   ========================================================= */
.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.wrap--wide { max-width: 1080px; }

.site-main { min-height: 60vh; padding: 2.5rem 0 4rem; }

/* =========================================================
   Reading progress bar (signature element, single posts only)
   ========================================================= */
#reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--mauve), var(--blue), var(--teal));
  z-index: 100;
  transition: width 0.1s ease-out;
}

/* =========================================================
   Header — a terminal-prompt identity, kept quiet everywhere else
   ========================================================= */
.site-header {
  border-bottom: 1px solid var(--surface0);
  background: var(--mantle);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--mantle) 88%, transparent);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.15rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: var(--text); }
.brand__user { color: var(--green); }
.brand__at { color: var(--overlay0); }
.brand__host { color: var(--blue); }
.brand__sep { color: var(--overlay0); }
.brand__path { color: var(--mauve); }
.brand__cursor {
  display: inline-block;
  width: 0.55ch;
  margin-left: 0.15em;
  background: var(--peach);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.nav {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.92rem;
}
.nav a {
  color: var(--subtext0);
  text-decoration: none;
  position: relative;
  padding: 0.2rem 0;
}
.nav a::before { content: "./"; color: var(--overlay0); }
.nav a:hover, .nav a[aria-current="page"] { color: var(--peach); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--surface0);
  background: var(--surface0);
  color: var(--yellow);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--surface1); transform: rotate(12deg); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-moon { display: none; }
html[data-theme="lotus"] .theme-toggle .icon-sun { display: none; }
html[data-theme="lotus"] .theme-toggle .icon-moon { display: inline-block; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--surface0);
  color: var(--text);
  border-radius: 8px;
  width: 34px; height: 34px;
  cursor: pointer;
}

@media (max-width: 640px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .nav {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--mantle);
    border-bottom: 1px solid var(--surface0);
    flex-direction: column;
    align-items: flex-start;
    gap: 0.9rem;
    padding: 1rem 1.5rem 1.4rem;
  }
  .nav.is-open { display: flex; }
}

/* =========================================================
   Typography
   ========================================================= */
h1, h2, h3, h4, h5, h6 {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  margin: 2.2em 0 0.7em;
  scroll-margin-top: 5rem;
}
h1 { font-size: 1.9rem; letter-spacing: -0.01em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.22rem; }
h4 { font-size: 1.05rem; }

.content h2, .content h3, .content h4 { position: relative; }
.content h2::before, .content h3::before {
  content: "#";
  color: var(--mauve);
  margin-right: 0.5rem;
  opacity: 0.7;
}

p { margin: 0 0 1.1em; }

.content ul, .content ol { margin: 0 0 1.1em; padding-left: 1.4em; }
.content li { margin: 0.3em 0; }
.content li::marker { color: var(--peach); }

strong { color: var(--text); font-weight: 700; }
em { color: var(--subtext1); }

blockquote {
  margin: 1.6em 0;
  padding: 0.2em 1.2em;
  border-left: 3px solid var(--mauve);
  background: var(--mantle);
  border-radius: 0 8px 8px 0;
  color: var(--subtext1);
}
blockquote p:last-child { margin-bottom: 0.4em; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.6em 0;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
}
th, td {
  padding: 0.55em 0.9em;
  border: 1px solid var(--surface0);
  text-align: left;
}
th { background: var(--mantle); color: var(--peach); font-family: "IBM Plex Mono", monospace; font-weight: 600; }
tr:nth-child(even) td { background: color-mix(in srgb, var(--mantle) 55%, transparent); }

code {
  font-family: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
  font-size: 0.87em;
  background: var(--surface0);
  color: var(--peach);
  padding: 0.15em 0.4em;
  border-radius: 5px;
}

/* footnotes */
.footnotes { color: var(--subtext0); font-size: 0.9rem; }
.footnotes hr { margin: 2.5rem 0 1rem; }
.footnote-ref { color: var(--peach); text-decoration: none; padding: 0 0.1em; }
.footnote-return { color: var(--overlay0); text-decoration: none; }

/* =========================================================
   Code blocks — filename tab, language chip, copy button
   ========================================================= */
.highlight {
  position: relative;
  margin: 1.6em 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--surface0);
  box-shadow: var(--shadow);
}
.highlight pre {
  margin: 0;
  padding: 1.1rem 1.2rem;
  overflow-x: auto;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.87rem;
  line-height: 1.6;
  background: var(--mantle) !important;
}
code { }
.highlight pre code { background: transparent; color: var(--text); padding: 0; }

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.9rem;
  background: var(--crust);
  border-bottom: 1px solid var(--surface0);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.76rem;
  color: var(--overlay1);
}
.code-block-header .dots { display: inline-flex; gap: 5px; }
.code-block-header .dots span { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.code-block-header .dots span:nth-child(1) { background: var(--red); }
.code-block-header .dots span:nth-child(2) { background: var(--yellow); }
.code-block-header .dots span:nth-child(3) { background: var(--green); }
.code-block-header .lang { text-transform: uppercase; letter-spacing: 0.06em; }

.copy-btn {
  border: 1px solid var(--surface1);
  background: var(--surface0);
  color: var(--subtext0);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.copy-btn:hover { background: var(--surface1); color: var(--text); }
.copy-btn.copied { color: var(--green); border-color: var(--green); }

/* =========================================================
   Admonition shortcode {{< note >}}
   ========================================================= */
.admonition {
  margin: 1.6em 0;
  padding: 0.9rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--surface0);
  border-left: 4px solid var(--blue);
  background: var(--mantle);
}
.admonition-title {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.admonition p:last-child { margin-bottom: 0; }
.admonition--note { border-left-color: var(--blue); }
.admonition--note .admonition-title { color: var(--blue); }
.admonition--tip { border-left-color: var(--green); }
.admonition--tip .admonition-title { color: var(--green); }
.admonition--warning { border-left-color: var(--yellow); }
.admonition--warning .admonition-title { color: var(--yellow); }
.admonition--danger { border-left-color: var(--red); }
.admonition--danger .admonition-title { color: var(--red); }

/* =========================================================
   Home / list — intro + post cards
   ========================================================= */
.intro {
  padding: 1.2rem 0 0.4rem;
  border-bottom: 1px solid var(--surface0);
  margin-bottom: 2.2rem;
}
.intro__eyebrow {
  font-family: "IBM Plex Mono", monospace;
  color: var(--overlay1);
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}
.intro__eyebrow .cursor {
  display: inline-block;
  width: 0.55ch;
  background: var(--peach);
  animation: blink 1.1s steps(1) infinite;
  margin-left: 2px;
}
.intro h1 { margin-top: 0; font-size: 1.7rem; }
.intro p { color: var(--subtext1); max-width: 60ch; margin-bottom: 1.6rem; }

.section-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  color: var(--overlay1);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 1rem;
}

.post-list { list-style: none; margin: 0 0 2rem; padding: 0; display: flex; flex-direction: column; gap: 1rem; }

.post-card {
  position: relative;
  display: block;
  padding: 1.15rem 1.3rem 1.15rem 1.5rem;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.post-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0.6rem; bottom: 0.6rem;
  width: 3px;
  border-radius: 3px;
  background: var(--accent, var(--mauve));
}
.post-card:hover {
  transform: translateX(3px);
  border-color: var(--surface1);
  box-shadow: var(--shadow);
}
.post-card__title {
  margin: 0 0 0.35rem;
  font-size: 1.12rem;
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
}
.post-card:hover .post-card__title { color: var(--accent, var(--mauve)); }
.post-card__meta {
  font-size: 0.82rem;
  color: var(--overlay1);
  font-family: "IBM Plex Mono", monospace;
  margin-bottom: 0.5rem;
}
.post-card__meta span:not(:last-child)::after { content: "  ·  "; color: var(--surface2); }
.post-card__excerpt { color: var(--subtext0); font-size: 0.95rem; margin: 0; }

.tag-list { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0; margin: 0.6rem 0 0; }
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.76rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--surface0);
  color: var(--subtext1);
  text-decoration: none;
  border: 1px solid var(--surface1);
}
.tag-pill:hover { color: var(--text); border-color: var(--overlay0); }
.tag-pill::before { content: "#"; color: var(--overlay0); }

/* =========================================================
   Single post
   ========================================================= */
.post-header { margin-bottom: 2rem; }
.post-header__meta {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
  color: var(--overlay1);
  margin-bottom: 0.6rem;
}
.post-header__meta span:not(:last-child)::after { content: "  ·  "; color: var(--surface2); }
.post-header h1 { margin-top: 0.2em; font-size: 2rem; }
.post-header__desc { color: var(--subtext1); font-size: 1.05rem; margin-top: 0.6rem; }

.post-layout { display: grid; grid-template-columns: 1fr; gap: 2rem; }

@media (min-width: 1000px) {
  .post-layout--with-toc {
    grid-template-columns: minmax(0, 1fr) 220px;
    max-width: 100%;
  }
}

.toc {
  position: sticky;
  top: 5.2rem;
  align-self: start;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
}
.toc__title { color: var(--overlay1); text-transform: uppercase; letter-spacing: 0.07em; font-size: 0.75rem; margin-bottom: 0.6rem; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--surface0); }
.toc li { margin: 0; }
.toc ul ul { padding-left: 0.9rem; border-left: none; }
.toc a {
  display: block;
  padding: 0.28rem 0 0.28rem 0.9rem;
  color: var(--subtext0);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -1px;
}
.toc a:hover { color: var(--text); border-left-color: var(--mauve); }

.post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--surface0);
}

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 2rem;
}
.post-nav__link {
  display: block;
  padding: 1rem 1.1rem;
  border: 1px solid var(--surface0);
  border-radius: 10px;
  text-decoration: none;
  color: var(--subtext0);
  background: var(--mantle);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.post-nav__link:hover { border-color: var(--overlay0); transform: translateY(-2px); }
.post-nav__label { font-family: "IBM Plex Mono", monospace; font-size: 0.74rem; color: var(--overlay1); text-transform: uppercase; letter-spacing: 0.06em; }
.post-nav__title { color: var(--text); font-weight: 600; margin-top: 0.3rem; }
.post-nav--next { text-align: right; }

@media (max-width: 640px) {
  .post-nav { grid-template-columns: 1fr; }
  .post-nav--next { text-align: left; }
}

/* =========================================================
   Pagination
   ========================================================= */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
}
.pagination a {
  color: var(--subtext0);
  text-decoration: none;
  border: 1px solid var(--surface0);
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
}
.pagination a:hover { color: var(--text); border-color: var(--overlay0); }
.pagination .disabled { color: var(--surface2); }

/* =========================================================
   Footer
   ========================================================= */
.site-footer {
  border-top: 1px solid var(--surface0);
  padding: 2rem 0;
  color: var(--overlay1);
  font-size: 0.85rem;
}
.site-footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: center; }
.site-footer a { color: var(--overlay1); }
.site-footer a:hover { color: var(--mauve); }
.footer-links { display: flex; gap: 1rem; list-style: none; padding: 0; margin: 0; }

/* =========================================================
   404
   ========================================================= */
.error-page { text-align: center; padding: 4rem 0; }
.error-page__code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 4rem;
  color: var(--surface2);
  margin: 0;
}
.error-page__code span { color: var(--red); }

/* =========================================================
   Utility
   ========================================================= */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
