/*! ciantic-blog */

:root {
    /* This also controls shiki's `light-dark()` code colors and native forms. */
    color-scheme: light dark;

  --font-sans: 'Fira Sans', Verdana, Geneva, 'DejaVu Sans', sans-serif;
  --font-mono: 'Fira Code', ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;

  --font-weight-light: 300;
  --font-weight-base: 400; 
  --font-weight-semibold: 500; 
  --font-weight-bold: 700; 

  --font-size-xs: 0.8rem; 
  --font-size-sm: 0.9rem; 
  --font-size-base: 1rem; 
  --font-size-lg: 1.125rem; 

  --prose-h1: 1.9rem;
  --prose-h2: 1.35rem;
  --prose-h3: 1.15rem;
  --prose-h4: 1rem;
  --prose-code: 0.85rem;
  --prose-footnote: var(--font-size-xs);

  /* Surfaces — light mode is a warm cream "paper" palette. */
  --bg: light-dark(#faf6eb, #1e2129);
  --surface: light-dark(#f1ecdd, #171a21);
  --surface-hover: light-dark(#e7e0ca, #20242d);

  --btn-bg: light-dark(#fffcf2, #171a21);
  --btn-bg-hover: light-dark(#e7e0ca, #20242d);
  --btn-text: light-dark(#2e2a20, #d2d9e8);
  --btn-box-shadow: 0 2px 5px light-dark(#00000010, #00000012);
  --btn-text-hover: light-dark(#2e2a20, #d2d9e8);
  --btn-border: light-dark(#dcd6c9, #2c2f3a);
  --btn-border-hover: light-dark(#cfc9b8, #3a3d4a);

  /* Text */
  --text: light-dark(#2e2a20, #d2d9e8);
  --text-muted: light-dark(#6b6350, #a6adba);
  --text-faint: light-dark(#a89c80, #5d6470);

  /* Lines / hairlines */
  --line: light-dark(rgba(74, 58, 30, 0.17), rgba(255, 255, 255, 0.13));

  /* Accent */
  --accent: light-dark(#882d22, #9bb5f1);
  --accent-strong: light-dark(#b91c0b, #6f93e8);
  --accent-contrast: light-dark(#ffffff, #0a1224);

  /* Warning (Draft chips) */
  --warn: light-dark(#92400e, #f2b53d);
  --warn-bg: light-dark(rgba(146, 64, 14, 0.12), rgba(242, 181, 61, 0.12));
}

/* daisyUI-style CSS-only theme toggle: checking the checkbox (value any)
   forces the dark scheme. */
:root:has(.theme-controller:checked) {
  color-scheme: dark;
}

/* --- Base ----------------------------------------------------------------- */

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-base);
  line-height: 1.6;
}

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

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

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

/* --- Layout shell --------------------------------------------------------- */

.layout {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

/* The column-padding-less full-width bar sits on the header/footer; content
   inside is capped to the reading width (.container). */
.container {
  width: 100%;
  max-width: 48rem; /* ~3xl */
  margin-inline: auto;
  padding-inline: 1rem;
}

.page {
  padding-block: 3rem; /* py-12 */
  flex: 1; /* grow so the footer is pinned to the bottom on short pages */
}

/* --- Header --------------------------------------------------------------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.5rem;
}

.brand {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  text-decoration: none;
}

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

.nav ul {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
}

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

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

.site-footer {
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.site-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding-block: 1rem;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.site-footer__right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-footer__credit {
  margin: 0;
  color: var(--text-faint);
}

/* --- Theme toggle (CSS-only, no JS) -------------------------------------- */

.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  color: var(--text-muted);
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* Invisible but still focusable checkbox that drives the whole toggle. */
.theme-toggle input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.theme-toggle__icon {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
  pointer-events: none;
}

/* Swap sun (light, default) / moon (dark, checked) like daisyUI's .swap. */
.theme-toggle__icon--moon {
  display: none;
}

:root:has(.theme-controller:checked) .theme-toggle__icon--moon {
  display: block;
}

:root:has(.theme-controller:checked) .theme-toggle__icon--sun {
  display: none;
}

/* --- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: var(--font-size-sm);
  line-height: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  background: var(--btn-bg);
  color: var(--btn-text);
  border-color: var(--btn-border);
  box-shadow: var(--btn-box-shadow);
}

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

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover {
  background: var(--accent-strong);
  color: var(--accent-contrast);
}

.btn-link,
.btn-link:hover {
  background: none;
  border-color: transparent;
  text-decoration: underline;
  box-shadow: none;
}

/* --- Home (post index) ---------------------------------------------------- */

.home-head {
  margin-bottom: 2.5rem;
}

.home-tagline {
  margin: 0.75rem 0 0;
  font-size: var(--font-size-lg);
  color: var(--text-muted);
}

.year {
  margin-bottom: 2rem;
}

.year__title {
  margin: 0 0 0.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  position: sticky;
  top: 0;
  background: var(--bg);
}

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

.post-list__item {
  border-bottom: 1px solid var(--line);
}

.post-list__item:last-child {
  border-bottom: none;
}

.post-link {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  padding: 1.1rem 0;
  color: inherit;
  text-decoration: none;
}

.post-link:hover {
  color: inherit;
}

.post-link__date {
  flex-shrink: 0;
  min-width: 3rem;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  font-variant-numeric: tabular-nums;
}

.post-link__body {
  min-width: 0;
}

.post-link__title {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  line-height: 1.35;
}

.post-link:hover .post-link__title {
  color: var(--accent);
}

.post-link__arrow {
  display: inline-block;
  margin-left: 0.35rem;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.post-link:hover .post-link__arrow {
  opacity: 1;
  transform: translateX(2px);
}

.post-link__excerpt {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  line-height: 1.55;
}

/* --- Draft chip ----------------------------------------------------------- */

.chip {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.05rem 0.55rem;
  border: 1px solid;
  border-radius: 9999px;
  vertical-align: middle;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.4;
}

.chip--warn {
  color: var(--warn);
  border-color: var(--warn);
  background: var(--warn-bg);
}

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

.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.post-back {
  margin-top: 4rem;
}

/* --- Prose (markdown body) — deliberately light --------------------------- */

.prose {
  max-width: none;
  line-height: 1.75;
  overflow-wrap: break-word;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  line-height: 1.3;
  margin: 1.6em 0 0.6em;
  font-weight: var(--font-weight-semibold);
}

.prose h1:first-child,
.prose h2:first-child,
.prose h3:first-child,
.prose h4:first-child,
.prose h5:first-child,
.prose h6:first-child,
.prose p:first-child {
  margin-top: 0;
}

.prose h1 {
  font-size: var(--prose-h1);
}

.prose h2 {
  font-size: var(--prose-h2);
  padding-bottom: 0.25em;
  border-bottom: 1px solid var(--line);
}

.prose h3 {
  font-size: var(--prose-h3);
}

.prose h4 {
  font-size: var(--prose-h4);
}

.prose p {
  margin: 0.85em 0;
}

.prose a {
  text-underline-offset: 2px;
}

.prose a:hover {
  text-decoration: none;
}

.prose strong {
  font-weight: var(--font-weight-bold);
}

.prose ul,
.prose ol {
  margin: 0.85em 0;
  padding-left: 1.5em;
}

.prose li {
  margin: 0.3em 0;
}

.prose blockquote {
  margin: 1em 0;
  padding: 0.05em 1em;
  border-left: 3px solid var(--line);
}

.prose blockquote p:first-of-type::before,
.prose blockquote p:first-of-type::after {
  content: none;
}

.prose img {
  max-width: 100%;
  height: auto;
}

.prose hr {
  margin: 2em auto;
  width: 60%;
  border: 0;
  border-top: 1px solid var(--line);
}

/* Inline code (not inside a shiki <pre>). */
.prose :not(pre) > code {
  padding: 0.1em 0.35em;
  border-radius: 0.25em;
  background: var(--surface-hover);
  font-family: var(--font-mono);
  font-size: var(--prose-code);
}

/* Shiki code blocks */
.prose pre.shiki {
  margin: 1em 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface) !important;
  font-family: var(--font-mono);
  font-size: var(--prose-code);
  line-height: 1.6;
}

.prose pre.shiki,
.prose pre.shiki span {
  background: var(--surface) !important;
}

/* --- marked-alert callouts (GitHub `> [!NOTE]` blocks) -------------------- */

.markdown-alert {
  --alert: var(--accent);
  margin: 1em 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--alert);
  border-radius: 0.5rem;
  background: var(--surface);
}

.markdown-alert-note {
  --alert: light-dark(#1d4ed8, #7aa2ff);
}
.markdown-alert-tip {
  --alert: light-dark(#166534, #4ade80);
}
.markdown-alert-warning {
  --alert: light-dark(#92400e, #f2b53d);
}
.markdown-alert-caution {
  --alert: light-dark(#b91c1c, #f87171);
}
.markdown-alert-important {
  --alert: light-dark(#7e22ce, #c084fc);
}

.markdown-alert .markdown-alert-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.25rem;
  color: var(--alert);
  font-weight: var(--font-weight-semibold);
}

.markdown-alert .octicon {
  flex-shrink: 0;
  width: 1em;
  height: 1em;
  fill: currentColor;
}

.markdown-alert p {
  margin: 0.35em 0 0;
}

/* --- Footnotes (GFM `[^1]`, see render.ts) -------------------------------- */

.prose .footnotes {
  margin-top: 2.5em;
  padding-top: 0.75em;
  border-top: 1px solid var(--line);
}

.prose .footnotes ol {
  margin: 0;
  padding-left: 1.2em;
  color: var(--text-muted);
  font-size: var(--prose-footnote);
}

.prose .footnotes [data-footnote-backref] {
  margin-left: 0.35em;
  color: inherit;
  text-decoration: none;
}

/* --- Tables --------------------------------------------------------------- */

table {
  text-align: left;
  border-collapse: collapse;
}

table th, table td {
  padding: 0.15em 0.45em;
  border: 1px solid var(--line);
}

/* --- Page-not-found (404) ------------------------------------------------- */

.not-found {
  text-align: center;
}

.not-found h1 {
  margin: 0 0 0.5em;
  font-size: var(--font-size-lg);
}

/* --- Utilities ------------------------------------------------------------ */

/* Visually hidden but available to screen readers (Tailwind's sr-only). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
