/* ---------------------------------------------------------------------------
   Ralovely — minimal stylesheet with dark mode
   --------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------
   Theme tokens
   --------------------------------------------------------------------------- */
:root {
  --color-bg: #fff;
  --color-text: #111;
  --color-text-secondary: #555;
  --color-text-muted: #888;
  --color-text-faint: #999;
  --color-text-date: #aaa;
  --color-border: #111;
  --color-border-light: #eee;
  --color-code-bg: #f3f3f3;
  --color-notice-bg: #fafafa;
  --color-footer-link: #888;
  --color-footer-link-hover: #111;
  --color-toggle: #888;
  --color-toggle-hover: #111;
}

[data-theme="dark"] {
  --color-bg: #111;
  --color-text: #e0e0e0;
  --color-text-secondary: #aaa;
  --color-text-muted: #777;
  --color-text-faint: #666;
  --color-text-date: #666;
  --color-border: #e0e0e0;
  --color-border-light: #222;
  --color-code-bg: #1a1a1a;
  --color-notice-bg: #1a1a1a;
  --color-footer-link: #666;
  --color-footer-link-hover: #e0e0e0;
  --color-toggle: #666;
  --color-toggle-hover: #e0e0e0;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #111;
    --color-text: #e0e0e0;
    --color-text-secondary: #aaa;
    --color-text-muted: #777;
    --color-text-faint: #666;
    --color-text-date: #666;
    --color-border: #e0e0e0;
    --color-border-light: #222;
    --color-code-bg: #1a1a1a;
    --color-notice-bg: #1a1a1a;
    --color-footer-link: #666;
    --color-footer-link-hover: #e0e0e0;
    --color-toggle: #666;
    --color-toggle-hover: #e0e0e0;
  }
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Base */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "cv11", "ss01", "ss03";
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
  max-width: 46rem;
  margin: 0 auto;
  padding: 3rem 2rem;
}

/* ---------------------------------------------------------------------------
   Typography
   --------------------------------------------------------------------------- */
h1, h2, h3 {
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin-top: 1.8em;
  margin-bottom: 0.5em;
}

h1 {
  font-size: 2.5rem;
  font-weight: 800;
}

h2 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

h3 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: none;
}

p {
  margin-bottom: 1em;
}

em { font-style: italic; }
strong { font-weight: 700; }

blockquote {
  border-left: 4px solid var(--color-border);
  margin: 1.5em 0;
  padding: 0.25em 1.25em;
  color: var(--color-text-secondary);
  font-style: italic;
}

ul, ol {
  margin: 0 0 1em 1.5em;
}

li {
  margin-bottom: 0.3em;
}

hr {
  border: none;
  border-top: 2px solid var(--color-border);
  margin: 3em 0;
}

/* ---------------------------------------------------------------------------
   Links
   --------------------------------------------------------------------------- */
a {
  color: var(--color-text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-thickness: 2px;
}

/* ---------------------------------------------------------------------------
   Header / Nav
   --------------------------------------------------------------------------- */
body > header {
  margin-bottom: 3rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

body > header nav a {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--color-text);
  text-decoration: none;
}

body > header nav a:hover {
  text-decoration: none;
  opacity: 0.6;
}

/* ---------------------------------------------------------------------------
   Theme toggle
   --------------------------------------------------------------------------- */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--color-toggle);
  transition: color 0.15s ease;
  line-height: 0;
}

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

.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Show sun in dark mode, moon in light mode */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ---------------------------------------------------------------------------
   Footer
   --------------------------------------------------------------------------- */
footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

footer a {
  color: var(--color-footer-link);
}

footer a:hover {
  color: var(--color-footer-link-hover);
}

/* ---------------------------------------------------------------------------
   Homepage sections
   --------------------------------------------------------------------------- */
#about {
  margin-bottom: 3.5rem;
  font-size: 1.05rem;
  line-height: 1.7;
}

#pages {
  margin-bottom: 3.5rem;
}

#pages ul {
  list-style: none;
  margin-left: 0;
}

#pages li {
  margin-bottom: 0.4em;
}

#pages li a {
  font-weight: 600;
}

#posts ul {
  list-style: none;
  margin-left: 0;
}

#posts li {
  padding: 0.6em 0;
}

#posts li a {
  display: block;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.3;
}

#posts li a:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

#posts li time {
  display: block;
  color: var(--color-text-faint);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 0.15em;
  line-height: 1;
}

/* ---------------------------------------------------------------------------
   Article (blog post / static page)
   --------------------------------------------------------------------------- */
article header {
  margin-bottom: 2.5rem;
}

article header h1 {
  margin-top: 0;
  margin-bottom: 0.2em;
  font-size: 2.8rem;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

article header time {
  display: block;
  color: var(--color-text-date);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 0.75rem;
  line-height: 1;
}

article .content {
  font-size: 1.05rem;
  line-height: 1.75;
}

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

/* ---------------------------------------------------------------------------
   Archive notice
   --------------------------------------------------------------------------- */
.archive-notice {
  background: var(--color-notice-bg);
  border-left: 4px solid var(--color-border);
  padding: 0.75em 1.25em;
  margin-bottom: 2rem;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.archive-notice p {
  margin: 0;
}

/* ---------------------------------------------------------------------------
   Code
   --------------------------------------------------------------------------- */
code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88em;
}

:not(pre) > code {
  background: var(--color-code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

pre {
  overflow-x: auto;
  border-radius: 4px;
  margin: 1.5em 0;
  padding: 1.25em;
  font-size: 0.82rem;
  line-height: 1.55;
}

/* shiki generates <pre> with background color already set */
pre code {
  background: none;
  padding: 0;
}

/* ---------------------------------------------------------------------------
   Post navigation (j/k)
   --------------------------------------------------------------------------- */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border-light);
  font-size: 0.8rem;
}

.post-nav a {
  color: var(--color-text-muted);
  text-decoration: none;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-nav a:last-child {
  text-align: right;
}

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

/* ---------------------------------------------------------------------------
   Audio
   --------------------------------------------------------------------------- */
audio {
  display: block;
  width: 100%;
  margin: 1.5em 0;
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */
@media (max-width: 600px) {
  body {
    padding: 1.5rem 1rem;
  }

  h1 { font-size: 1.8rem; }

  article header h1 {
    font-size: 2rem;
    letter-spacing: -0.025em;
  }

  body > header nav a {
    font-size: 1.35rem;
  }
}
