/* ==========================================================================
   Margin — sidebar layout theme
   Two-column: fixed left sidebar + scrollable content column
   ========================================================================== */

/* --- Design tokens -------------------------------------------------------- */

:root,
html[data-theme="light"] {
  --bg: #faf9f7;
  --sidebar-bg: #f2ede6;
  --sidebar-border: #e0d8ce;
  --txt: #2d2823;
  --muted: #7a6f65;
  --line: #e8e2da;
  --accent: #b5451b;
  --accent-soft: rgba(181, 69, 27, 0.08);
  --link: #b5451b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1a17;
    --sidebar-bg: #141210;
    --sidebar-border: #2e2a25;
    --txt: #e8e0d5;
    --muted: #8a8078;
    --line: #2e2a25;
    --accent: #e06030;
    --accent-soft: rgba(224, 96, 48, 0.12);
    --link: #e06030;
  }
}

html[data-theme="dark"] {
  --bg: #1c1a17;
  --sidebar-bg: #141210;
  --sidebar-border: #2e2a25;
  --txt: #e8e0d5;
  --muted: #8a8078;
  --line: #2e2a25;
  --accent: #e06030;
  --accent-soft: rgba(224, 96, 48, 0.12);
  --link: #e06030;
}

/* --- Reset & base --------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: "Lora", Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4, h5, h6 {
  font-family: "Lora", Georgia, serif;
  font-weight: 600;
  line-height: 1.3;
  color: var(--txt);
}

::selection { background: var(--accent-soft); }

/* --- Page layout ---------------------------------------------------------- */

.page-wrap {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar -------------------------------------------------------------- */

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  padding: 2.5rem 1.75rem;
  height: 100%;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--txt);
  margin-bottom: 0.5rem;
}

.site-prompt {
  font-size: 1.4rem;
  color: var(--accent);
  line-height: 1;
}

.brand-text {
  font-family: "Lora", serif;
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}

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

.site-tagline {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 2rem;
  font-style: italic;
  line-height: 1.4;
}

/* Sidebar nav */

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: auto;
}

.sidebar nav a {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
  margin-left: -0.6rem;
}

.sidebar nav a:hover {
  color: var(--txt);
  background: var(--accent-soft);
}

.sidebar nav a[aria-current="true"] {
  color: var(--accent);
  font-weight: 600;
}

.sidebar nav a[aria-current="true"]::before { content: "→ "; }

/* Sidebar footer */

.sidebar-footer {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-socials {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.social-link {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

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

.sidebar-copy {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 1rem;
  opacity: 0.7;
}

/* Theme toggle */

.theme-toggle {
  background: transparent;
  border: 1px solid var(--sidebar-border);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
  align-self: flex-start;
}

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

.theme-icon { display: none; }
.theme-icon-dark { display: inline; }

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

html[data-theme="dark"] .theme-icon-dark { display: none; }
html[data-theme="dark"] .theme-icon-light { display: inline; }
html[data-theme="light"] .theme-icon-dark { display: inline; }
html[data-theme="light"] .theme-icon-light { display: none; }

/* --- Content column ------------------------------------------------------- */

.content-col {
  flex: 1;
  min-width: 0;
}

main {
  max-width: 680px;
  padding: 3.5rem 4rem 5rem 4rem;
}

/* --- Home: posts list ----------------------------------------------------- */

.all-posts {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.year-section { margin-bottom: 2.5rem; }

.year-heading {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.year-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

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

.post-row {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

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

.post-link {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--txt);
}

.post-arrow {
  color: var(--accent);
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
}

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

.post-title {
  font-family: "Lora", serif;
  font-weight: 400;
  font-size: 1.05rem;
  flex: 1;
  transition: color 0.15s ease;
}

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

.post-meta {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.post-description {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0.25rem 0 0;
  line-height: 1.55;
}

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

.post-back {
  display: inline-block;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 2.5rem;
  transition: color 0.15s ease;
}

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

.post-head {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.post-head h1 {
  margin: 0 0 0.75rem;
  font-size: 2rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.post-meta-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.82rem;
  color: var(--muted);
}

.post-meta-sep { opacity: 0.5; }

.post-tags { display: inline-flex; gap: 0.5rem; margin-left: 0.25rem; }

.post-tag { color: var(--accent); }

.draft-badge {
  display: inline-block;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15em 0.5em;
  border-radius: 4px;
  color: #b45309;
  border: 1px solid #b45309;
}

.post p, .post li { line-height: 1.8; }

.post h2, .post h3 { margin-top: 2.5rem; font-size: 1.3rem; }

.post img { border-radius: 6px; border: 1px solid var(--line); max-width: 100%; }

.post blockquote {
  border-left: 3px solid var(--accent);
  color: var(--muted);
  padding-left: 1.25rem;
  font-style: italic;
  margin-left: 0;
}

/* --- Code ----------------------------------------------------------------- */

pre {
  background: var(--sidebar-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
}

code {
  font-family: ui-monospace, "JetBrains Mono", Menlo, monospace;
  font-size: 0.875em;
}

:not(pre) > code {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 4px;
  padding: 0.12em 0.4em;
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 720px) {
  .page-wrap { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--sidebar-border);
  }

  .sidebar-inner {
    padding: 1.25rem;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
  }

  .site-tagline, .sidebar-footer, .theme-toggle { display: none; }

  .sidebar nav { flex-direction: row; margin-bottom: 0; }

  main { padding: 2rem 1.25rem 3rem; }
}
