:root {
  --bg: #faf9f6;
  --ink: #22221f;
  --muted: #8c887f;
  --accent: #935f35; /* crust brown */
  --line: #e4e1d9;
  --code-bg: #f0efe9;

  --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1b18;      /* Deep warm charcoal */
    --ink: #f4f3ef;     /* Soft off-white text */
    --muted: #a19d93;   /* Lifted mid-tone grey for dark background contrast */
    --accent: #d49460;  /* Brightened crust brown for high readability */
    --line: #2e2c27;    /* Subtle dark border */
    --code-bg: #242320; /* Elevated surface tone for code blocks */

    --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', serif;
    --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  }
}

[data-theme="dark"] {
  --bg: #1c1b18;
  --ink: #f4f3ef;
  --muted: #a19d93;
  --accent: #d49460;
  --line: #2e2c27;
  --code-bg: #242320;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 4rem 1.5rem 6rem;
}

/* Header Layout */
.site-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  margin-bottom: 3.5rem;
}

.site-header-content {
  grid-column: 1;
}

.site-title {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  display: inline-block;
}

.site-tagline {
  margin: 0.35rem 0 1.1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.site-nav a {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink);
  text-decoration: none;
  margin-right: 1.25rem;
  border-bottom: 1px solid transparent;
}

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

#theme-toggle {
  grid-column: 2;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: color 0.15s ease;
}

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

/* Icon switching logic */
.sun-icon,
.moon-icon {
  display: none;
}

/* Light mode defaults (or system light mode): show Moon */
.moon-icon {
  display: block;
}

/* Dark mode (explicit data-theme or system preference): show Sun */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .moon-icon { display: none; }
  html:not([data-theme="light"]) .sun-icon { display: block; }
}

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

/* Post list (home / tag archive) */
.post-list { list-style: none; margin: 0; padding: 0; }

.post-item {
  padding: 1.25rem 0;
  border-top: 1px solid var(--line);
}

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

.post-date {
  display: block;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-bottom: 0.3rem;
}

.post-item .post-title {
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
}

.post-item .post-title:hover,
.post-content a:hover { color: var(--accent); }

.post-summary {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.post-tags {
  margin: 0.5rem 0 0;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.post-tags a { color: var(--accent); text-decoration: none; }
.post-tags a:hover { text-decoration: underline; }

/* Single post */
article.post .post-title {
  display: block;
  font-family: var(--serif);
  font-size: 2rem;
  margin: 0.3rem 0 0.6rem;
  text-decoration: none;
}

article.post .post-date { margin-bottom: 0; }

.post-content { margin-top: 2rem; font-size: 1.02rem; }
.post-content p { margin: 1.1em 0; }

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 3px;
  margin: 1.5rem 0;
}

.post-content h2 {
  font-family: var(--serif);
  font-size: 1.35rem;
  margin: 2.2em 0 0.6em;
}

.post-content h3 {
  font-family: var(--serif);
  font-size: 1.1rem;
  margin: 1.8em 0 0.5em;
}

.post-content a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

.post-content code {
  font-family: var(--mono);
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-size: 0.9em;
}

.post-content pre {
  background: var(--code-bg);
  padding: 1rem;
  overflow-x: auto;
  border-radius: 4px;
}

.post-content pre code { background: none; padding: 0; }

.post-content blockquote {
  margin: 1.5em 0;
  padding-left: 1rem;
  border-left: 2px solid var(--accent);
  color: var(--muted);
}

/* Archive / tags */
.archive-title {
  font-family: var(--serif);
  font-size: 1.4rem;
  margin-bottom: 1.5rem;
}

.tag-list { list-style: none; padding: 0; }

.tag-list li {
  padding: 0.5rem 0;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.95rem;
}

.tag-list a { color: var(--ink); text-decoration: none; }
.tag-list a:hover { color: var(--accent); }
.tag-count { color: var(--muted); font-size: 0.85em; }

.back-link { margin-top: 3rem; font-family: var(--mono); font-size: 0.85rem; }
.back-link a { color: var(--muted); text-decoration: none; }
.back-link a:hover { color: var(--accent); }

/* Footer */
.site-footer {
  margin-top: 5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
}

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

@media (max-width: 480px) {
  .wrap { padding: 2.5rem 1.25rem 4rem; }
  article.post .post-title { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}


/* ==========================================================================
   Songbook & Accordion Components
   ========================================================================== */

/* Download Actions Container */
.download-group {
  margin: 2rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Base Button Style */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.8rem 1.2rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none !important; /* Prevents link underlining */
  border-radius: 5px;
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  box-sizing: border-box;
  line-height: 1.2;
}

/* Ensure post-content generic link styling doesn't override button text */
.post-content a.btn {
  text-decoration: none !important;
}

/* Primary Button (Main Songbook) */
.btn-primary {
  background-color: var(--accent);
  color: #ffffff !important; /* Force crisp white text in both light/dark mode */
  border: 1px solid var(--accent);
  font-size: 1.05rem;
  width: 100%;
  padding: 0.95rem 1.25rem;
}

/* Hover state: slight opacity drop keeps text perfectly legible */
.btn-primary:hover {
  opacity: 0.9;
  color: #ffffff !important;
  background-color: var(--accent);
  border-color: var(--accent);
}

/* Secondary Button Grid (Lidovky & Koledy) */
.download-secondary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* Secondary Buttons */
.btn-secondary {
  background-color: transparent;
  color: var(--ink) !important;
  border: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 500;
}

.btn-secondary:hover {
  background-color: var(--code-bg);
  border-color: var(--muted);
  color: var(--ink) !important;
}

/* Responsive Secondary Buttons */
@media (max-width: 480px) {
  .download-secondary-grid {
    grid-template-columns: 1fr;
  }
}

/* Accordion Component (<details> / <summary>) */
details.accordion {
  border: 1px solid var(--line);
  border-radius: 5px;
  margin-bottom: 1rem;
  background: var(--bg);
  overflow: hidden;
}

details.accordion summary {
  padding: 0.85rem 1.1rem;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  list-style: none; /* Hide default browser marker */
  display: flex;
  justify-content: space-between;
  align-items: center;
}

details.accordion summary::-webkit-details-marker {
  display: none;
}

details.accordion summary::after {
  content: "+";
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--muted);
}

details.accordion[open] summary::after {
  content: "−";
}

details.accordion summary:hover::after {
  color: var(--accent);
}

details.accordion[open] summary {
  border-bottom: 1px solid var(--line);
  background-color: var(--code-bg);
}

.accordion-content {
  padding: 1.2rem 1.1rem;
  font-size: 1rem;
}

.accordion-content p:first-child {
  margin-top: 0;
}

.accordion-content p:last-child {
  margin-bottom: 0;
}