/*
 * Pistachio palette override for hugo-theme-terminal.
 * Generated from panr.github.io/terminal-css (Pistachio preset).
 * Source palette:
 *   background #1d2021
 *   foreground #ebdbb2
 *   accent     #8ec07c
 */

:root {
  --background: #1d2021;
  --foreground: #ebdbb2;
  --accent: #8ec07c;
  --radius: 4px;
}

/* ──────────────────────────────────────────────────────────────────────────
 * Global image border — terminal theme ships with `img { border: 8px solid
 * var(--accent); padding: 8px; }` which puts a thick green frame around
 * every image. Slim it down across the board.
 * ────────────────────────────────────────────────────────────────────────── */
img {
  border: 6px solid var(--accent) !important;
  padding: 6px !important;
  border-radius: var(--radius);
}

/* ──────────────────────────────────────────────────────────────────────────
 * Mobile responsiveness for the homepage `$ whoami` console — the theme
 * uses `white-space: pre` which causes horizontal overflow on phones. Allow
 * it to wrap on narrow viewports while preserving spacing on desktop.
 * ────────────────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .index-content pre,
  .index-content .highlight pre,
  .index-content code {
    white-space: pre-wrap !important;
    word-break: break-word;
  }
  .index-content .chroma {
    overflow-x: visible !important;
  }
}

/* ──────────────────────────────────────────────────────────────────────────
 * Author byline visibility:
 *   - Listing pages (home, /posts/, tags, categories): hide the byline
 *     (single-author blog — date + reading-time is enough)
 *   - Single post page: keep the byline
 * Terminal theme wraps listings in `.index-content`; single posts are
 * direct children of `.content` without that wrapper.
 * ────────────────────────────────────────────────────────────────────────── */
.index-content .post-author {
  display: none !important;
}
/* Bookmark thumbnails — opt out of the global 6px accent frame entirely.
 * `border: none !important` (not just transparent color) so the 6px-wide
 * invisible ring doesn't eat layout space inside the card. */
.bookmark img.bookmark-thumb {
  border: none !important;
  padding: 0 !important;
}

/* Selection highlight using the accent color */
::selection {
  background: var(--accent);
  color: var(--background);
}
::-moz-selection {
  background: var(--accent);
  color: var(--background);
}

/* Inline code: subtle accent background */
:not(pre) > code {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--foreground);
  padding: 0.1em 0.35em;
  border-radius: var(--radius);
}

/* Blockquote: leftside accent bar */
blockquote {
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

/* Footer separator */
.footer {
  border-top: 1px dashed color-mix(in srgb, var(--accent) 40%, transparent);
}

/* Hide the auto-generated FALLBACK title bar for code blocks with no language.
   Tag your blocks with ```lang to get a proper title. */
.highlight:has(code[data-lang="fallback"]) .code-title {
  display: none;
}

/* ──────────────────────────────────────────────────────────────────────────
 * Block editor shortcodes — Pistachio-native styling.
 * Each block authored via the CMS slash menu (or toolbar) maps to a Hugo
 * shortcode under layouts/shortcodes/<id>.html.
 * ────────────────────────────────────────────────────────────────────────── */

/* Callout — info | warn | success | danger
   Uses CSS variable inheritance: each variant overrides --accent locally so
   the existing accent-tinted border/background work without new utilities. */
.callout {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-left: 4px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: var(--radius);
}
.callout-warn    { --accent: #fabd2f; } /* gruvbox yellow */
.callout-success { --accent: #b8bb26; } /* gruvbox green  */
.callout-danger  { --accent: #fb4934; } /* gruvbox red    */

.callout-title {
  font-weight: 700;
}
.callout-body > :first-child { margin-top: 0; }
.callout-body > :last-child  { margin-bottom: 0; }

/* Gallery — square-cropped images in a CSS grid. cols 2..5 supported. */
.gallery {
  display: grid;
  gap: 0.5rem;
  margin: 1.5rem 0;
  grid-template-columns: repeat(3, 1fr); /* default */
}
.gallery.cols-2 { grid-template-columns: repeat(2, 1fr); }
.gallery.cols-3 { grid-template-columns: repeat(3, 1fr); }
.gallery.cols-4 { grid-template-columns: repeat(4, 1fr); }
.gallery.cols-5 { grid-template-columns: repeat(5, 1fr); }

.gallery-item {
  display: block;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--radius);
  overflow: hidden;
}
.gallery-item img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}
@media (max-width: 600px) {
  .gallery.cols-3, .gallery.cols-4, .gallery.cols-5 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Audio + video — full-width with subtle accent border */
.audio-block {
  margin: 1.5rem 0;
}
.audio-block audio {
  width: 100%;
}
.audio-block figcaption {
  margin-bottom: 0.5rem;
  opacity: 0.75;
}
.video-block {
  display: block;
  width: 100%;
  margin: 1.5rem 0;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}

/* Attachment download card — icon + filename + optional size */
.attachment-card {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--foreground);
  background: color-mix(in srgb, var(--accent) 4%, transparent);
  transition: background-color 0.15s ease;
}
.attachment-card:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.attachment-card .material-symbols-outlined {
  color: var(--accent);
  font-size: 1.5em;
  line-height: 1;
}
.attachment-name {
  flex: 1;
  font-weight: 500;
}
.attachment-size {
  opacity: 0.6;
  font-size: 0.85em;
}

/* Embed iframe */
.embed-block {
  display: block;
  margin: 1.5rem 0;
  border-radius: var(--radius);
}

/* Bookmark — URL preview card */
.bookmark {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
  padding: 1rem;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--foreground);
  background: color-mix(in srgb, var(--accent) 3%, transparent);
  transition: background-color 0.15s ease;
}
.bookmark:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.bookmark:not(:has(.bookmark-thumb)) {
  grid-template-columns: 1fr;
}
.bookmark-thumb {
  width: 120px;
  height: auto;
  max-height: 90px;
  object-fit: contain;
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 3px;
  align-self: start;
  padding: 4px;
}
.bookmark-meta { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.bookmark-title { display: block; }
.bookmark-desc {
  margin: 0;
  opacity: 0.85;
  font-size: 0.9em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.bookmark-host {
  opacity: 0.6;
  font-size: 0.85em;
}
@media (max-width: 500px) {
  .bookmark { grid-template-columns: 1fr; }
  /* Override base max-height too — otherwise the image gets clamped at
   * 90px tall on mobile (where the bookmark stacks vertically and the
   * thumbnail acts as a hero image). */
  .bookmark-thumb {
    width: 100% !important;
    max-height: 200px !important;
    height: auto !important;
  }
}

/* Product card — Ghost shopping/affiliate card → Hugo */
.product-card {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.25rem;
  margin: 1.5rem 0;
  padding: 1rem;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}
.product-card .product-image img {
  width: 100%;
  height: auto;
  max-height: 240px;
  object-fit: contain;
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 3px;
  padding: 6px;
}
.product-card .product-title { margin: 0 0 0.5rem; }
.product-card .product-rating { color: var(--accent); margin-bottom: 0.5rem; }
.product-card .product-description p { margin: 0.5rem 0; }
.product-card .product-button {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--background);
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 600;
}
.product-card .product-button:hover { opacity: 0.85; }
@media (max-width: 600px) {
  .product-card { grid-template-columns: 1fr; }
}

/* ──────────────────────────────────────────────────────────────────────────
 * Search page — Pagefind UI polish (terminal palette + clean spacing)
 * ────────────────────────────────────────────────────────────────────────── */
.search-intro {
  opacity: 0.75;
  margin-bottom: 1.25rem;
  font-size: 0.95em;
}
.search-intro kbd {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--foreground);
  padding: 0 0.4em;
  border-radius: 3px;
  font-family: inherit;
}
#search {
  --pagefind-ui-scale: 0.85;
  --pagefind-ui-primary: var(--accent);
  --pagefind-ui-text: var(--foreground);
  --pagefind-ui-background: var(--background);
  --pagefind-ui-border: color-mix(in srgb, var(--accent) 35%, transparent);
  --pagefind-ui-tag: color-mix(in srgb, var(--accent) 15%, transparent);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: var(--radius);
  --pagefind-ui-font: inherit;
}
#search .pagefind-ui__result-image,
#search .pagefind-ui__result-thumb { display: none !important; }
#search .pagefind-ui__search-input {
  font-family: inherit !important;
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
#search .pagefind-ui__search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
#search .pagefind-ui__result-title a {
  color: var(--accent);
  text-decoration: none;
}
#search .pagefind-ui__result-title a:hover { text-decoration: underline; }
#search .pagefind-ui__result-excerpt mark {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--foreground);
  padding: 0 0.15em;
}
/* Hide Pagefind's "Clear" button entirely — the input itself is enough; you
 * can clear with backspace / Ctrl-A. Removes the visual clutter. */
#search .pagefind-ui__search-clear {
  display: none !important;
}

/* ──────────────────────────────────────────────────────────────────────────
 * Mobile menu polish — terminal theme drops mobile menu items into a
 * tap-to-open dropdown. Make the trigger more inviting + the dropdown
 * easier to read on small screens.
 * ────────────────────────────────────────────────────────────────────────── */
@media (max-width: 684px) {
  .menu--mobile .menu__trigger {
    padding: 4px 10px;
    border-radius: var(--radius);
  }
  .menu--mobile .menu__dropdown {
    min-width: 200px;
    padding: 14px 18px !important;
    white-space: nowrap;
  }
  .menu--mobile .menu__dropdown > li:not(:last-of-type) {
    margin-bottom: 14px !important;
  }
  .menu--mobile .menu__dropdown > li a {
    font-size: 1.05em;
    padding: 4px 0 !important;
    white-space: nowrap;
  }
  /* Make sure container has padding so nothing clips edge */
  .container.center { padding-left: 16px; padding-right: 16px; }
}

/* Toggle / details block */
details.toggle-block {
  margin: 1.5rem 0;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  background: color-mix(in srgb, var(--accent) 3%, transparent);
}
details.toggle-block > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.25rem 0;
}
details.toggle-block[open] > summary { margin-bottom: 0.5rem; }
