/* ==========================================================================
   Gruvbox Terminal Theme
   ========================================================================== */

/* ---------- 1. Gruvbox Palette as CSS Variables ---------- */

:root {
  --bg: #282828;
  --bg-secondary: #3c3836;
  --bg-header: #1d2021;
  --color: #ebdbb2;
  --color-variant: #fbf1c7;
  --color-secondary: #a89984;
  --border-color: #504945;
  --link-color: #83a598;
  --link-hover: #8ec07c;
  --heading-color: #fabd2f;
  --heading-secondary: #fe8019;
  --accent: #fe8019;
  --code-bg: #1d2021;
  --code-text: #ebdbb2;
  --blockquote-border: #d65d0e;
  --tag-color: #b8bb26;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fbf1c7;
    --bg-secondary: #ebdbb2;
    --bg-header: #f9f5d7;
    --color: #3c3836;
    --color-variant: #282828;
    --color-secondary: #665c54;
    --border-color: #d5c4a1;
    --link-color: #458588;
    --link-hover: #689d6a;
    --heading-color: #b57614;
    --heading-secondary: #af3a03;
    --accent: #d65d0e;
    --code-bg: #ebdbb2;
    --code-text: #3c3836;
    --blockquote-border: #d65d0e;
    --tag-color: #98971a;
  }
}

[data-theme="dark"] {
  --bg: #282828;
  --bg-secondary: #3c3836;
  --bg-header: #1d2021;
  --color: #ebdbb2;
  --color-variant: #fbf1c7;
  --color-secondary: #a89984;
  --border-color: #504945;
  --link-color: #83a598;
  --link-hover: #8ec07c;
  --heading-color: #fabd2f;
  --heading-secondary: #fe8019;
  --accent: #fe8019;
  --code-bg: #1d2021;
  --code-text: #ebdbb2;
  --blockquote-border: #d65d0e;
  --tag-color: #b8bb26;
}

[data-theme="light"] {
  --bg: #fbf1c7;
  --bg-secondary: #ebdbb2;
  --bg-header: #f9f5d7;
  --color: #3c3836;
  --color-variant: #282828;
  --color-secondary: #665c54;
  --border-color: #d5c4a1;
  --link-color: #458588;
  --link-hover: #689d6a;
  --heading-color: #b57614;
  --heading-secondary: #af3a03;
  --accent: #d65d0e;
  --code-bg: #ebdbb2;
  --code-text: #3c3836;
  --blockquote-border: #d65d0e;
  --tag-color: #98971a;
}

/* ---------- Content Width ---------- */

.header__inner {
  width: 900px;
}

.posts,
.post {
  max-width: 900px;
}

.notes-layout {
  max-width: 900px;
}

/* ---------- 2. Global Font ---------- */

body {
  font-family: "JetBrains Mono", "IBM Plex Mono", "Fira Code", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  line-height: 1.7;
}

/* ---------- 3. Background & Text Color Overrides ---------- */

body {
  background-color: var(--bg);
  color: var(--color);
}

[data-theme="dark"] body {
  background-color: var(--bg);
  color: var(--color);
}

[data-theme="light"] body {
  background-color: var(--bg);
  color: var(--color);
}

@media (prefers-color-scheme: dark) {
  body {
    background-color: var(--bg);
    color: var(--color);
  }
}

@media (prefers-color-scheme: light) {
  body {
    background-color: var(--bg);
    color: var(--color);
  }
}

em, i, strong {
  color: var(--color-variant);
}

[data-theme="dark"] em, [data-theme="dark"] i, [data-theme="dark"] strong {
  color: var(--color-variant);
}

[data-theme="light"] em, [data-theme="light"] i, [data-theme="light"] strong {
  color: var(--color-variant);
}

/* ---------- 4. Header ---------- */

.header {
  background: var(--bg-header);
}

[data-theme="dark"] .header {
  background: var(--bg-header);
}

[data-theme="light"] .header {
  background: var(--bg-header);
}

/* ---------- 5. Menu ---------- */

.menu {
  background: var(--bg-header);
}

[data-theme="dark"] .menu {
  background: var(--bg-header);
}

[data-theme="light"] .menu {
  background: var(--bg-header);
}

.submenu {
  background: var(--bg-header);
}

[data-theme="dark"] .submenu {
  background: var(--bg-header);
}

[data-theme="light"] .submenu {
  background: var(--bg-header);
}

.dropdown-content {
  background: var(--bg-header);
}

[data-theme="dark"] .dropdown-content {
  background: var(--bg-header);
}

[data-theme="light"] .dropdown-content {
  background: var(--bg-header);
}

/* ---------- 6. Footer ---------- */

.footer {
  color: var(--color-secondary);
}

.footer__content {
  color: var(--color-secondary);
}

/* ---------- 7. Links ---------- */

a {
  color: inherit;
}

.post-content a,
.note-content a {
  color: var(--link-color);
  text-decoration: none;
}

.post-content a:hover,
.note-content a:hover {
  color: var(--link-hover);
}

.post-info a {
  color: var(--link-color);
}

.post-info a:hover {
  color: var(--link-hover);
}

/* ---------- 8. Headings ---------- */

h1, h2, .post-title, .posts h1 {
  color: var(--heading-color);
}

h3, h4, h5, h6 {
  color: var(--heading-secondary);
}

.post-title a {
  color: var(--heading-color);
}

.post-title a:hover {
  color: var(--heading-color);
}

/* ---------- 9. HR ---------- */

hr {
  background: var(--border-color);
}

[data-theme="dark"] hr {
  background: var(--border-color);
}

[data-theme="light"] hr {
  background: var(--border-color);
}

/* ---------- 10. Inline Code ---------- */

code {
  font-family: inherit;
  font-size: 0.9em;
  background: var(--bg-secondary);
  color: var(--code-text);
  padding: 2px 6px;
  border-radius: 3px;
}

[data-theme="dark"] code {
  background: var(--bg-secondary);
}

[data-theme="light"] code {
  background: var(--bg-secondary);
}

.post-content code,
.note-content code {
  background: none;
  padding: 0;
  font-size: 0.9em;
  color: inherit;
  opacity: 0.85;
}

/* ---------- 11. Code Blocks (Prism Override) ---------- */

code[class*="language-"],
pre[class*="language-"] {
  color: var(--code-text);
  background: none;
  font-family: inherit;
  text-shadow: none;
  line-height: 1.6;
}

pre[class*="language-"],
:not(pre) > code[class*="language-"] {
  background: var(--code-bg);
}

pre[class*="language-"] {
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: none;
  padding: 1em;
}

:not(pre) > code[class*="language-"] {
  border: none;
  box-shadow: none;
}

pre code {
  background: none !important;
  color: var(--code-text);
}

/* Gruvbox syntax tokens (dark) */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #928374;
}

.token.punctuation {
  color: #a89984;
  opacity: 1;
}

.token.namespace {
  opacity: 1;
}

.token.keyword,
.token.property,
.token.selector,
.token.constant,
.token.symbol,
.token.builtin {
  color: #fb4934;
}

.token.tag,
.token.boolean,
.token.number,
.token.deleted {
  color: #d3869b;
}

.token.string,
.token.char,
.token.attr-value,
.token.inserted {
  color: #b8bb26;
}

.token.operator,
.token.entity,
.token.url,
.token.variable,
.language-css .token.string,
.style .token.string {
  color: #fe8019;
}

.token.atrule {
  color: #83a598;
}

.token.attr-name {
  color: #fabd2f;
}

.token.function {
  color: #8ec07c;
}

.token.class-name {
  color: #fabd2f;
}

.token.regex,
.token.important {
  color: #fabd2f;
}

.language-markup .token.tag,
.language-markup .token.attr-name,
.language-markup .token.punctuation {
  color: #83a598;
}

/* Gruvbox syntax tokens (light) */
[data-theme="light"] .token.comment,
[data-theme="light"] .token.prolog,
[data-theme="light"] .token.doctype,
[data-theme="light"] .token.cdata {
  color: #928374;
}

[data-theme="light"] .token.keyword,
[data-theme="light"] .token.property,
[data-theme="light"] .token.selector,
[data-theme="light"] .token.constant,
[data-theme="light"] .token.symbol,
[data-theme="light"] .token.builtin {
  color: #9d0006;
}

[data-theme="light"] .token.tag,
[data-theme="light"] .token.boolean,
[data-theme="light"] .token.number,
[data-theme="light"] .token.deleted {
  color: #8f3f71;
}

[data-theme="light"] .token.string,
[data-theme="light"] .token.char,
[data-theme="light"] .token.attr-value,
[data-theme="light"] .token.inserted {
  color: #79740e;
}

[data-theme="light"] .token.operator,
[data-theme="light"] .token.entity,
[data-theme="light"] .token.url,
[data-theme="light"] .token.variable,
[data-theme="light"] .language-css .token.string,
[data-theme="light"] .style .token.string {
  color: #af3a03;
}

[data-theme="light"] .token.atrule {
  color: #427b58;
}

[data-theme="light"] .token.attr-name {
  color: #b57614;
}

[data-theme="light"] .token.function {
  color: #689d6a;
}

[data-theme="light"] .token.class-name {
  color: #b57614;
}

[data-theme="light"] code[class*="language-"],
[data-theme="light"] pre[class*="language-"] {
  color: var(--code-text);
}

/* Code toolbar */
div.code-toolbar > .toolbar a,
div.code-toolbar > .toolbar button,
div.code-toolbar > .toolbar span {
  background: var(--bg-secondary);
  color: var(--color-secondary);
  box-shadow: none;
}

/* ---------- 12. Blockquotes ---------- */

blockquote {
  border-left: 3px solid var(--blockquote-border);
  background: var(--bg-secondary);
  border-radius: 0 4px 4px 0;
  color: var(--color-secondary);
  padding: 10px 20px;
  margin: 30px 0;
}

blockquote::before {
  content: none;
}

blockquote p:first-of-type {
  margin-top: 0;
}

blockquote p:last-of-type {
  margin-bottom: 0;
}

/* ---------- 13. Post List ---------- */

.posts .post-item {
  border-bottom: 1px dashed var(--border-color);
}

.posts:not(:last-of-type) {
  border-bottom-color: var(--border-color);
}

[data-theme="dark"] .posts:not(:last-of-type) {
  border-bottom-color: var(--border-color);
}

[data-theme="light"] .posts:not(:last-of-type) {
  border-bottom-color: var(--border-color);
}

.posts .post-title {
  color: var(--color);
}

.post-item-inner {
  color: var(--color);
}

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

/* ---------- 14. Tags ---------- */

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

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

/* ---------- 15. Pagination ---------- */

.button {
  background: var(--bg-secondary);
  border-radius: 4px;
}

[data-theme="dark"] .button {
  background: var(--bg-secondary);
}

[data-theme="light"] .button {
  background: var(--bg-secondary);
}

.pagination__title-h {
  background: var(--bg);
  color: var(--color-secondary);
}

[data-theme="dark"] .pagination__title-h {
  background: var(--bg);
  color: var(--color-secondary);
}

[data-theme="light"] .pagination__title-h {
  background: var(--bg);
  color: var(--color-secondary);
}

/* ---------- 16. Tables ---------- */

.post-content table th,
.post-content table td {
  border-color: var(--border-color);
}

.post-content table thead tr {
  background-color: var(--bg-secondary);
}

/* ---------- 17. Selection ---------- */

::selection {
  background: #458588;
  color: #ebdbb2;
}

[data-theme="light"] ::selection {
  background: #83a598;
  color: #282828;
}

/* ---------- 18. Scrollbar ---------- */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-secondary);
}

/* ---------- 19. Logo Cursor ---------- */

@keyframes cursor {
  50% { opacity: 0; }
}

.logo__cursor {
  opacity: 1;
  animation: cursor 1s step-end infinite;
  background-color: var(--accent) !important;
}

/* ---------- 20. Post Content ---------- */

.post-content {
  line-height: 1.75;
}

.post-content h2 {
  margin-top: 1.5em;
}

.post-content p {
  margin: 1em 0;
}

/* ---------- 21. Notes Layout ---------- */

.notes-layout {
  position: relative;
  max-width: 800px;
  margin: 20px auto;
  padding: 20px;
}

.notes, .note-single {
  text-align: left;
}

.notes-sidebar {
  position: absolute;
  left: calc(100% + 3rem);
  top: 20px;
  width: 200px;
  padding-top: 0.5rem;
  text-align: left;
}

.notes-sidebar h3 {
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-secondary);
}

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

.tag-list li {
  margin-bottom: 0.4rem;
}

.tag-list a {
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--color);
}

.tag-list a:hover {
  text-decoration: underline;
  color: var(--link-color);
}

.tag-count {
  color: var(--color-secondary);
  font-size: 0.75rem;
}

@media (max-width: 768px) {
  .notes-sidebar {
    position: static;
    width: 100%;
    margin-top: 2rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
  }
}

.notes h1 {
  margin-bottom: 0;
}

.notes-feed {
  max-width: 100%;
}

.note {
  padding: 2.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

.note:last-child {
  border-bottom: none;
}

.note-content {
  text-align: left;
  line-height: 1.7;
  font-size: 1rem;
}

.note-content p {
  margin: 1em 0;
}

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

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

.note-title {
  font-size: 1.35rem;
  margin: 0 0 0.5rem 0;
}

.note-title a {
  text-decoration: none;
  color: inherit;
}

.note-title a:hover {
  text-decoration: none;
}

.note-meta {
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  color: var(--color-secondary);
}

.note-tags {
  margin-left: 0.5rem;
}

/* ---------- 22. Webmentions ---------- */

.webmentions {
  margin-top: 2rem;
}

.webmentions h3 {
  margin-bottom: 1rem;
}

.webmentions-empty,
.webmentions-loading {
  color: var(--color-secondary);
  font-size: 0.9rem;
}

.wm-likes,
.wm-reposts {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--color-secondary);
}

.wm-replies h4,
.wm-mentions h4 {
  margin-bottom: 0.5rem;
}

.wm-reply {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}

.wm-reply:last-child {
  border-bottom: none;
}

.wm-author {
  font-weight: bold;
}

.wm-date {
  font-size: 0.85rem;
  color: var(--color-secondary);
  margin-left: 0.5rem;
}

.wm-content {
  margin-top: 0.25rem;
  line-height: 1.6;
}

.wm-mentions ul {
  list-style: none;
  padding: 0;
}

.wm-mentions li {
  padding: 0.25rem 0;
}
