/* ==========================================================================
   AFTERHOURS — Jazz Guitar Theme
   Blue Note Records-inspired. Warm club night by default.
   "afternoon rehearsal" light mode via html[data-theme="light"].
   ========================================================================== */

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

/* Dark default — warm club night */
:root,
html[data-theme="dark"] {
  --bg: #130d08;
  --bg-soft: #1e1510;
  --txt: #f0e0c8;
  --muted: #8a7060;
  --line: rgba(210, 160, 60, 0.2);
  --accent: #d4a843;
  --accent-soft: rgba(212, 168, 67, 0.12);
  --accent-2: #e87040;
  --code-2: #d4a843;
}

/* Light — afternoon rehearsal */
html[data-theme="light"] {
  --bg: #fdf6ec;
  --bg-soft: #f5ead8;
  --txt: #2a1a08;
  --muted: #7a6040;
  --line: rgba(140, 90, 20, 0.2);
  --accent: #8b5e10;
  --accent-soft: rgba(139, 94, 16, 0.1);
  --accent-2: #c04020;
  --code-2: #8b5e10;
}

/* System dark preference (when no explicit theme set) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #130d08;
    --bg-soft: #1e1510;
    --txt: #f0e0c8;
    --muted: #8a7060;
    --line: rgba(210, 160, 60, 0.2);
    --accent: #d4a843;
    --accent-soft: rgba(212, 168, 67, 0.12);
    --accent-2: #e87040;
    --code-2: #d4a843;
  }
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #fdf6ec;
    --bg-soft: #f5ead8;
    --txt: #2a1a08;
    --muted: #7a6040;
    --line: rgba(140, 90, 20, 0.2);
    --accent: #8b5e10;
    --accent-soft: rgba(139, 94, 16, 0.1);
    --accent-2: #c04020;
    --code-2: #8b5e10;
  }
}

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

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0 auto;
  max-width: 65ch;
  padding: 3.5rem 1.5rem 6rem;
  background: var(--bg);
  color: var(--txt);
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 18px;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

h1, h2, h3, h4, h5, h6 {
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  color: var(--txt);
  line-height: 1.25;
}

p {
  margin: 0 0 1.25rem;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

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

img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--line);
}

hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 2.5rem 0;
}

ul, ol {
  padding-left: 1.5em;
}

li {
  margin-bottom: 0.4em;
}

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

.site-header {
  margin-bottom: 3.5rem;
}

.site-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid rgba(212, 168, 67, 0.35);
}

html[data-theme="light"] .site-bar {
  border-bottom-color: rgba(139, 94, 16, 0.35);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .site-bar {
    border-bottom-color: rgba(139, 94, 16, 0.35);
  }
}

.site-brand {
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.15s ease;
}

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

.site-prompt {
  font-size: 1.4rem;
}

.site-tagline {
  font-family: "Source Serif 4", Georgia, serif;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}

/* Theme toggle */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

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

.theme-icon {
  display: none;
  line-height: 1;
}

/* Default (dark): show "go light" icon; light: show "go dark" icon */
.theme-icon-dark { display: inline; }
.theme-icon-light { display: none; }

@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; }

/* --- Navigation ----------------------------------------------------------- */

.site-header nav {
  display: flex;
  gap: 2rem;
  margin-top: 1.25rem;
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-variant: small-caps;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

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

.site-header nav a[aria-current="true"] {
  color: var(--accent);
  text-decoration: none;
}

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

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

.year-section {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.year-heading {
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
  font-weight: 400;
  font-style: italic;
  color: var(--muted);
  margin: 0 0 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.6em;
  border: 0;
  padding: 0;
}

.year-heading::before {
  content: "—";
  color: var(--accent);
  opacity: 0.7;
}

.year-heading::after {
  content: "—";
  color: var(--accent);
  opacity: 0.7;
}

.posts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

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

.post-row:first-child {
  border-top: 1px solid var(--line);
}

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

.post-arrow {
  color: var(--accent-2);
  font-size: 1rem;
  flex-shrink: 0;
  line-height: 1;
}

.post-title {
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 400;
  flex: 1;
  transition: color 0.15s ease;
}

.post-meta {
  font-family: "Source Serif 4", Georgia, serif;
  font-style: italic;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
}

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

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

.post-description {
  margin: 0.2rem 0 0 1.65rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
  line-height: 1.6;
}

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

.post-back {
  display: inline-block;
  font-family: "Source Serif 4", Georgia, serif;
  font-style: italic;
  font-size: 0.88rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 2rem;
  transition: color 0.15s ease;
}

.post-back::before {
  content: "← ";
}

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

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

.post-head h1 {
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  line-height: 1.2;
  color: var(--txt);
}

.post-meta-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-family: "Source Serif 4", Georgia, serif;
  font-style: italic;
  font-size: 0.88rem;
  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: "Source Serif 4", Georgia, serif;
  font-style: normal;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1;
  padding: 0.2em 0.55em;
  border-radius: 3px;
  color: var(--accent-2);
  border: 1px solid var(--accent-2);
}

/* Post body */
.post {
  font-family: "Source Serif 4", Georgia, serif;
}

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

.post h2,
.post h3 {
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  margin-top: 2.5rem;
  color: var(--txt);
}

.post h2 {
  font-size: 1.4rem;
}

.post h3 {
  font-size: 1.15rem;
  font-style: italic;
}

.post img {
  border-radius: 4px;
  border: 1px solid var(--line);
}

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

.post blockquote p {
  margin: 0;
}

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

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

code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

:not(pre) > code {
  background: var(--accent-soft);
  color: var(--code-2);
  border-radius: 3px;
  padding: 0.12em 0.4em;
  font-size: 0.875em;
}

/* Syntax highlighting */
.hljs-keyword,
.hljs-selector-tag,
.hljs-section,
.hljs-link { color: var(--accent-2); }

.hljs-string,
.hljs-attribute,
.hljs-symbol,
.hljs-bullet,
.hljs-addition,
.hljs-template-tag { color: #a8c060; }

.hljs-title,
.hljs-name,
.hljs-function .hljs-title,
.hljs-type { color: var(--accent); }

.hljs-variable,
.hljs-template-variable,
.hljs-attr,
.hljs-property { color: #80b8c8; }

.hljs-number,
.hljs-regexp,
.hljs-literal { color: #c8a060; }

.hljs-built_in,
.hljs-class .hljs-title,
.hljs-params { color: var(--accent-2); }

.hljs-comment,
.hljs-quote,
.hljs-deletion,
.hljs-meta { color: var(--muted); font-style: italic; }

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

.site-footer {
  margin-top: 5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-family: "Source Serif 4", Georgia, serif;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--muted);
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  font-style: italic;
  transition: color 0.15s ease;
}

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

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

@media (max-width: 540px) {
  body {
    padding: 2rem 1.1rem 4rem;
    font-size: 17px;
  }

  .post-head h1 {
    font-size: 1.65rem;
  }

  .post-link {
    flex-wrap: wrap;
  }

  .post-meta {
    margin-left: 1.65rem;
    text-align: left;
  }
}
