/* =========================================================
   _styles.css — “Japanese Ghost Blog” (Kaidan / Yūrei) theme
   For prose.sh

   What this targets:
   - Global typography + paper/mist background
   - A restrained “scroll panel” content container
   - Header (title + nav + RSS) styling
   - Post typography (headings, links, hr, quotes, code, images)
   - Footer appended via _footer.md (commonly #post-footer)
   - Dark mode variant
   - Mobile tuning

   Notes:
   - prose.sh markup may vary slightly; selectors are intentionally broad.
   - If default prose styles fight this, set `with_styles: false` in _readme.md.
   ========================================================= */

:root {
  /* Palette */
  --ink: #101213;
  --ink-soft: #1c2022;
  --paper: #f4f0e8;
  --paper-deep: #efe7da;

  --mist: rgba(90, 100, 110, 0.08);
  --mist-2: rgba(20, 30, 40, 0.06);

  --accent: #8b1f2d;
  /* deep vermillion/blood */
  --accent-2: #c64c3a;
  /* warmer highlight */
  --rule: rgba(16, 18, 19, 0.14);
  --shadow: rgba(0, 0, 0, 0.08);

  /* Typography */
  --serif-jp: "Hiragino Mincho ProN", "Yu Mincho", "MS Mincho",
    "Noto Serif JP", "Source Han Serif JP", serif;
  --sans-jp: "Hiragino Sans", "Yu Gothic", "Meiryo",
    "Noto Sans JP", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  /* Layout */
  --content-max: 760px;
  --pad-x: 1.25rem;
  --radius: 12px;
}

/* --- Base --- */
html,
body {
  height: 100%;
}

body {
  color: var(--ink);
  font-family: var(--serif-jp);
  line-height: 1.75;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;

  /* Paper texture + mist + Background Image (toned down) */
  background-image:
    radial-gradient(1200px 800px at 15% 10%, var(--mist), transparent 60%),
    radial-gradient(900px 600px at 85% 20%, var(--mist-2), transparent 55%),
    linear-gradient(rgba(244, 240, 232, 0.92), rgba(244, 240, 232, 0.92)),
    url('/bg.jpg');

  background-size: auto, auto, auto, cover;
  background-attachment: fixed, fixed, fixed, fixed;
  background-position: center top;
  background-repeat: no-repeat;
}

/* Ensure common containers are centered and readable */
main,
article,
#blog,
#post {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--pad-x);
}

/* Give the site breathing room */
main,
#blog,
article {
  margin-top: 2.5rem;
  margin-bottom: 3rem;
}

/* "Scroll panel" boundary on key content wrappers */
main,
#blog,
article,
#post {
  position: relative;
}

/* The panel effect, applied broadly but safely */
main::before,
#blog::before,
article::before,
#post::before {
  content: "";
  position: absolute;
  inset: -1.25rem -0.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px var(--shadow);
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.0));
}

/* Avoid panel overlay issues when nested wrappers exist */
article article::before,
#post article::before {
  content: none;
}

/* --- Header (blog title + nav + RSS) --- */
/* prose.sh typically uses a <header> near the top; target it */
header {
  max-width: var(--content-max);
  margin: 2.25rem auto 1.25rem;
  padding: 0 var(--pad-x) 1rem;
  border-bottom: 1px solid var(--rule);
  position: relative;
}

/* keep header above any panel pseudo-elements */
header {
  z-index: 1;
}

/* Title link often is the first anchor in header; keep it strong */
header a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid rgba(139, 31, 45, 0.35);
}

header a:hover {
  color: var(--accent);
  border-bottom-color: rgba(139, 31, 45, 0.75);
}

/* Nav tends to be a list of links; make it tidy */
header nav,
header ul {
  margin: 0.75rem 0 0;
  padding: 0;
}

header ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
}

header li {
  margin: 0;
}

/* Make nav links slightly more modern and compact */
header nav a,
header li a {
  font-family: var(--sans-jp);
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  padding: 0.1rem 0;
}

/* Soften RSS if present (common pattern: link ends with rss or /rss) */
header a[href$="rss"],
header a[href$="/rss"],
header a[href*="rss.xml"] {
  opacity: 0.78;
  border-bottom-color: transparent;
}

header a[href$="rss"]:hover,
header a[href$="/rss"]:hover,
header a[href*="rss.xml"]:hover {
  opacity: 1;
  border-bottom-color: rgba(198, 76, 58, 0.8);
  color: var(--accent-2);
}

/* --- Typography --- */
h1,
h2,
h3,
h4 {
  font-family: var(--serif-jp);
  letter-spacing: 0.02em;
  line-height: 1.25;
  color: var(--ink);
}

/* Primary title (index or post title) */
h1 {
  font-size: clamp(2.0rem, 3.2vw, 2.65rem);
  margin: 0.25rem 0 1.25rem;
  position: relative;
}

/* "Red seal" underline accent */
h1::after {
  content: "";
  display: block;
  width: 64px;
  height: 3px;
  margin-top: 0.7rem;
  background: linear-gradient(90deg, var(--accent), transparent);
  border-radius: 99px;
  opacity: 0.9;
}

h2 {
  margin-top: 2.25rem;
  border-left: 3px solid var(--accent);
  padding-left: 0.85rem;
}

h3 {
  margin-top: 1.75rem;
  color: var(--ink-soft);
}

p {
  margin: 1rem 0;
}

/* Subtle small text handling */
small,
.muted {
  color: rgba(16, 18, 19, 0.75);
}

/* --- Links --- */
a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid rgba(139, 31, 45, 0.35);
}

a:hover {
  color: var(--accent);
  border-bottom-color: rgba(139, 31, 45, 0.75);
}

/* Make link focus visible */
a:focus-visible {
  outline: 2px solid rgba(139, 31, 45, 0.55);
  outline-offset: 3px;
  border-bottom-color: transparent;
}

/* --- Rules / separators --- */
hr {
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--rule), transparent);
  margin: 2.25rem 0;
}

/* --- Quotes: “lantern light” --- */
blockquote {
  margin: 1.75rem 0;
  padding: 1rem 1.15rem;
  border-left: 4px solid var(--accent);
  background: rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
}

blockquote p {
  margin: 0.6rem 0;
}

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

code {
  background: rgba(16, 18, 19, 0.06);
  padding: 0.15em 0.35em;
  border-radius: 6px;
}

pre {
  background: rgba(16, 18, 19, 0.08);
  padding: 1rem 1.1rem;
  border-radius: 12px;
  overflow-x: auto;
  border: 1px solid rgba(16, 18, 19, 0.10);
}

pre code {
  background: transparent;
  padding: 0;
}

/* --- Lists --- */
ul,
ol {
  padding-left: 1.25rem;
  margin: 1rem 0;
}

li {
  margin: 0.35rem 0;
}

/* --- Tables (in case you use them) --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-family: var(--sans-jp);
  font-size: 0.95rem;
}

th,
td {
  border-bottom: 1px solid var(--rule);
  padding: 0.65rem 0.5rem;
  vertical-align: top;
}

th {
  text-align: left;
  letter-spacing: 0.01em;
}

/* --- Images: like old prints --- */
img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.10);
  border: 1px solid rgba(16, 18, 19, 0.10);
}

/* If images are inside links, avoid double underline weirdness */
a img {
  border-bottom: none;
}

/* --- Post metadata (dates, bylines) --- */
/* Try to catch typical “meta” wrappers without relying on exact markup */
time,
.date,
.meta,
.byline {
  font-family: var(--sans-jp);
  color: rgba(16, 18, 19, 0.70);
  font-size: 0.95rem;
}

/* --- Footer appended via _footer.md --- */
/* prose.sh commonly uses #post-footer; also handle class fallback */
#post-footer,
.post-footer,
footer.post-footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  opacity: 0.92;
  font-family: var(--sans-jp);
  font-size: 0.95rem;
}

/* Decorative “seal” / sigil element if you add one in _footer.md */
#post-footer .sigil,
.post-footer .sigil {
  margin-top: 0.75rem;
  font-size: 1.6rem;
  letter-spacing: 0.15em;
  color: var(--accent);
}

/* --- Subtle mist animation (respects reduced motion) --- */
@media (prefers-reduced-motion: no-preference) {
  body::before {
    content: "";
    position: fixed;
    inset: -20%;
    background:
      radial-gradient(800px 500px at 20% 30%, rgba(20, 30, 40, 0.07), transparent 55%),
      radial-gradient(700px 450px at 80% 60%, rgba(90, 100, 110, 0.06), transparent 60%);
    pointer-events: none;
    filter: blur(6px);
    opacity: 0.75;
    animation: mist-drift 18s ease-in-out infinite alternate;
  }

  @keyframes mist-drift {
    from {
      transform: translate3d(-1.5%, -1%, 0);
    }

    to {
      transform: translate3d(1.5%, 1%, 0);
    }
  }
}

/* --- Dark mode: “midnight shrine” --- */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e9ecef;
    --ink-soft: #cfd6db;
    --paper: #0f1214;
    --paper-deep: #0b0d0f;
    --mist: rgba(230, 240, 255, 0.06);
    --mist-2: rgba(120, 140, 160, 0.05);
    --rule: rgba(233, 236, 239, 0.14);
    --shadow: rgba(0, 0, 0, 0.35);
  }

  body {
    background-image:
      radial-gradient(1200px 800px at 15% 10%, var(--mist), transparent 60%),
      radial-gradient(900px 600px at 85% 20%, var(--mist-2), transparent 55%),
      linear-gradient(rgba(15, 18, 20, 0.88), rgba(15, 18, 20, 0.88)),
      url('/bg.jpg');
    background-attachment: fixed, fixed, fixed, fixed;
  }

  /* Panel highlight should be darker in dark mode */
  main::before,
  #blog::before,
  article::before,
  #post::before {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.0));
  }

  a {
    color: var(--ink);
    border-bottom-color: rgba(198, 76, 58, 0.45);
  }

  a:hover {
    color: var(--accent-2);
    border-bottom-color: rgba(198, 76, 58, 0.9);
  }

  header {
    border-bottom-color: var(--rule);
  }

  code {
    background: rgba(233, 236, 239, 0.08);
  }

  pre {
    background: rgba(233, 236, 239, 0.08);
    border-color: rgba(233, 236, 239, 0.12);
  }

  blockquote {
    background: rgba(233, 236, 239, 0.06);
  }

  time,
  .date,
  .meta,
  .byline,
  small,
  .muted {
    color: rgba(233, 236, 239, 0.74);
  }
}

/* --- Mobile tuning --- */
@media (max-width: 640px) {
  header {
    margin-top: 1.75rem;
  }

  main,
  #blog,
  article {
    margin-top: 2rem;
    margin-bottom: 2.5rem;
  }

  main::before,
  #blog::before,
  article::before,
  #post::before {
    inset: -0.9rem -0.5rem;
    border-radius: 10px;
  }
}

/* --- Overrides --- */

/* 1. Target the global footer container */
footer {
  /* Keep it in flow so it sits at the bottom */
  display: block !important;

  /* Styling to match custom footer (#post-footer) */
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  text-align: center;

  /* Hide the default "published with" text node */
  color: transparent;
  font-size: 0;
}

/* 2. Hide specific default children */
footer a,
footer hr {
  display: none !important;
}

/* 3. Inject "myriadleaves.eu 2026" via ::before */
footer::before {
  content: "myriadleaves.eu 2026";
  visibility: visible;
  display: block;

  /* Restore text props */
  color: var(--ink);
  font-family: var(--sans-jp);
  font-size: 0.95rem;
  font-weight: bold;
  opacity: 0.92;

  margin-bottom: 0.5rem;
  /* Space between text and sigil */
}

/* 4. Inject Sigil "朱" via ::after */
footer::after {
  content: "朱";
  visibility: visible;
  display: block;

  /* Sigil styling */
  font-family: var(--serif-jp);
  /* Sigil looks serif-y */
  font-size: 1.6rem;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-top: 0.25rem;
}

/* Ensure our custom footer remains visible even if it renders as a footer tag */
#post-footer,
.post-footer,
footer.post-footer {
  display: block !important;
}