/* ==========================================================================
   Noxysoft Blog theme, built on the "Night Launch" design system tokens
   ========================================================================== */

/* ----- Fonts (self-hosted, served from /fonts via extraStaticDirs) ----- */
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/space-grotesk-700.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/inter-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/inter-500.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/inter-600.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-400.woff2") format("woff2");
}

/* ----- Design tokens (mirrors css/style.css on the main site) ----- */
:root {
  --bg-deep: #070d1d;
  --bg: #0a1124;
  --surface: #101b36;
  --surface-2: #16243d;
  --border: #233456;
  --border-subtle: #1d2a47;
  --accent: #5fb4e6;
  --accent-hi: #8ed0f9;
  --accent-dim: rgba(95, 180, 230, 0.16);
  --text: #f2f6fc;
  --text-2: #9fb3d1;
  --text-muted: #71819e;
  /* --text-muted is tuned for 4.5:1 on --bg only (4.77:1); on the lighter
     --surface it drops to 4.331:1 and fails WCAG AA. Use this on surfaces. */
  --text-muted-surface: #7b8ba8;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --radius: 14px;
  --radius-sm: 9px;
  --container-w: 1100px;
  --prose-w: 760px;
  --nav-h: 64px;
  /* code token colors, tuned for AA on --surface */
  --code-keyword: #8ed0f9;
  --code-string: #a3d9a5;
  --code-comment: #8494b3;
  --code-number: #e6c15f;
  /* callout hues */
  --tip: #6fd08c;
  --warning: #e6c15f;
}

/* ----- Reset & base ----- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--font-body);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hi);
}

::selection {
  background: var(--accent);
  color: var(--bg-deep);
}

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

[hidden] {
  display: none !important;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: var(--bg-deep);
  padding: 10px 18px;
  border-radius: 0 0 8px 0;
  font-weight: 600;
}

.skip-link:focus {
  left: 0;
}

.container {
  max-width: var(--container-w);
  margin-inline: auto;
  padding-inline: 24px;
}

/* ----- Header / nav ----- */
.site-header {
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(7, 13, 29, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: var(--nav-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--text);
}

.brand:hover {
  color: var(--accent-hi);
}

.brand-blog {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--accent);
  border-left: 1px solid var(--border);
  padding-left: 18px;
}

/* ----- Search ----- */
.search {
  margin-left: auto;
  position: relative;
}

.search input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 8px 16px;
  width: min(240px, 50vw);
}

.search input::placeholder {
  color: var(--text-muted-surface);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(340px, 80vw);
  list-style: none;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  max-height: 60vh;
  overflow-y: auto;
}

.search-results a,
.search-results .none {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text);
}

.search-results a:hover,
.search-results a:focus {
  background: var(--accent-dim);
  color: var(--accent-hi);
}

.search-results .none {
  color: var(--text-muted-surface);
}

/* ----- Post list (index, tags) ----- */
.post-list-header {
  padding-block: 56px 8px;
  max-width: var(--prose-w);
}

.post-list-header h1 {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
}

.lede {
  margin-top: 10px;
  color: var(--text-muted);
}

.post-list {
  list-style: none;
  padding: 0;
  max-width: var(--prose-w);
  margin-block: 24px 72px;
}

.post-list li {
  border-bottom: 1px solid var(--border-subtle);
  padding-block: 26px;
}

.post-list h2 {
  font-size: 1.35rem;
}

.post-list h2 a {
  color: var(--text);
}

.post-list h2 a:hover {
  color: var(--accent-hi);
}

.post-meta {
  margin-top: 6px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.tag {
  display: inline-block;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 999px;
  padding: 1px 10px;
  margin-inline: 2px;
  font-size: 0.8rem;
}

/* ----- Post page ----- */
.post {
  max-width: var(--prose-w);
  margin-inline: auto;
  padding-block: 56px 48px;
}

.post-cover {
  margin-bottom: 32px;
}

.post-cover img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
}

.post-header h1 {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
}

.post-header .post-meta {
  margin-top: 12px;
}

.post-body {
  margin-top: 28px;
}

.post-body h2 {
  font-size: 1.5rem;
  margin-top: 2.2em;
  margin-bottom: 0.6em;
}

.post-body h3 {
  font-size: 1.2rem;
  margin-top: 1.8em;
  margin-bottom: 0.5em;
}

.post-body p,
.post-body ul,
.post-body ol {
  margin-block: 1em;
}

.post-body li + li {
  margin-top: 0.35em;
}

.post-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 18px;
  color: var(--text-muted);
  margin-block: 1.4em;
}

.post-body hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin-block: 2.2em;
}

.post-body table {
  border-collapse: collapse;
  width: 100%;
  display: block;
  overflow-x: auto;
  margin-block: 1.4em;
}

.post-body th,
.post-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.post-body th {
  background: var(--surface);
  color: var(--text);
}

.post-body img {
  border-radius: var(--radius-sm);
}

.post-body figure {
  margin-block: 1.6em;
}

.post-body figcaption {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.footnotes {
  margin-top: 3em;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ----- Code ----- */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

p code,
li code,
td code {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 1px 6px;
}

pre {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  overflow-x: auto;
  margin-block: 1.4em;
  line-height: 1.55;
}

pre code {
  color: var(--text-2);
}

/* ColorCode token classes */
pre .keyword { color: var(--code-keyword); }
pre .string { color: var(--code-string); }
pre .comment { color: var(--code-comment); font-style: italic; }
pre .number { color: var(--code-number); }
pre .xmlDocTag,
pre .preprocessorKeyword { color: var(--code-comment); }
pre .className,
pre .typeName { color: var(--text); }

/* ----- Callouts ----- */
.callout {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-block: 1.4em;
}

.callout > p {
  margin-block: 0.35em;
}

.callout-title {
  font-weight: 600;
  color: var(--text);
}

.callout-tip {
  border-left-color: var(--tip);
}

.callout-warning {
  border-left-color: var(--warning);
}

/* ----- Mermaid -----
   Diagrams are rendered to inline SVG at build time (mermaid: "cli"), so they
   arrive as a bare <svg> in the post body and need no JavaScript. The pre
   rule is the local-preview fallback when mmdc is not installed: the diagram
   source shows as plain text instead. */
.post-body > svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin-block: 1.6em;
  margin-inline: auto;
}

pre.mermaid {
  background: var(--surface);
  border: 1px dashed var(--border);
  color: var(--text-muted-surface);
  text-align: left;
}

/* ----- YouTube lite embed ----- */
.lite-yt {
  position: relative;
  aspect-ratio: 16 / 9;
  margin-block: 1.6em;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-deep);
}

/* Locally drawn poster: no thumbnail is fetched from YouTube before the
   reader clicks, so nothing contacts a Google host on page load. */
.lite-yt a {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background:
    repeating-linear-gradient(
      45deg,
      var(--surface) 0 14px,
      var(--surface-2) 14px 28px
    );
}

.lite-yt-label {
  color: var(--text-2);
  font-size: 0.9rem;
  font-weight: 500;
}

.lite-yt a:hover .lite-yt-label {
  color: var(--accent-hi);
}

.lite-yt iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Stays in the flex flow so the label sits below it rather than on top of it;
   relative only to position the triangle in ::after. */
.lite-yt-play {
  position: relative;
  flex: none;
  width: 68px;
  height: 48px;
  border-radius: 12px;
  background: rgba(7, 13, 29, 0.8);
  border: 1px solid var(--border);
}

.lite-yt-play::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 10px 0 10px 17px;
  border-color: transparent transparent transparent var(--accent-hi);
}

.lite-yt a:hover .lite-yt-play {
  background-color: rgba(7, 13, 29, 0.95);
}

/* ----- Post prev/next ----- */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
}

.post-nav a {
  display: flex;
  flex-direction: column;
  max-width: 46%;
}

.post-nav a span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.post-nav a[rel="next"] {
  text-align: right;
  margin-left: auto;
}

/* ----- Footer ----- */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding-block: 28px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ----- Small screens ----- */
@media (max-width: 560px) {
  .brand span {
    display: none;
  }

  .post,
  .post-list,
  .post-list-header {
    padding-block: 32px 24px;
  }
}
