/* ==========================================================================
   wdenniss Hugo Theme
   ========================================================================== */

/* ---------- Fonts ---------- */
@font-face {
  font-family: "Berkeley Mono";
  src: url("/fonts/BerkeleyMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Berkeley Mono";
  src: url("/fonts/BerkeleyMono-Oblique.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Berkeley Mono";
  src: url("/fonts/BerkeleyMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Berkeley Mono";
  src: url("/fonts/BerkeleyMono-Bold-Oblique.woff2") format("woff2");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/fonts/Inter-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  /* Inter has a tall x-height; scale down to match the system-font metrics. */
  size-adjust: 94%;
}
@font-face {
  font-family: "Inter";
  src: url("/fonts/Inter-Variable-Italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
  size-adjust: 94%;
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --color-bg: #ede8e1;
  --color-text: #000;
  --color-text-secondary: #555;
  --color-link: #333;
  --color-link-hover: #000;
  --color-border: #ddd;
  --color-code-bg: #f5f2ed;
  --color-header-bg: #ede8e1;
  /* Fluid reading scale: 20px on phones/tablets, growing to 25px on large
     monitors. Holds at 20px to ~640px viewport, climbs, caps at 25px. */
  --font-size-base: clamp(1.25rem, 1.0rem + 0.6vw, 1.5625rem);
  /* Prose column in em (not px) so it scales with --font-size-base; the wider
     measure keeps it from feeling cramped on big screens.
     ~840px at 20px → ~1050px at 25px. */
  --max-width: 42em;
  --max-width-wide: 1320px;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  --font-mono: "Berkeley Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --transition-speed: 0.2s;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1a1a1a;
    --color-text: #e0ddd8;
    --color-text-secondary: #a0a0a0;
    --color-link: #c8c4be;
    --color-link-hover: #fff;
    --color-border: #333;
    --color-code-bg: #2a2724;
    --color-header-bg: #1a1a1a;
  }
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: 1.7;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Links ---------- */
a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
  transition: color var(--transition-speed) ease;
}

a:hover,
a:focus {
  color: var(--color-link-hover);
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

/* Headings in em so they track the fluid body size and keep their proportion. */
h1 { font-size: 1.6em; }
h2 { font-size: 1.2em; }
h3 { font-size: 1em; }

p {
  margin: 0 0 1.5em;
}

blockquote {
  border-left: 3px solid var(--color-text);
  margin: 1.5em 0;
  padding: 0.5em 1.5em;
  font-style: italic;
}

/* ---------- Code ---------- */
code {
  font-family: var(--font-mono);
  font-size: 1em;
  background: var(--color-code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

pre {
  font-family: var(--font-mono);
  font-size: var(--font-size-base);
  background: var(--color-code-bg);
  padding: 1.25em 1.5em;
  border-radius: 4px;
  overflow-x: auto;
  line-height: 1.5;
  margin: 0 0 1.5em;
  /* No wrapping by default — long lines scroll horizontally. */
  white-space: pre;
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

/* Plain text in a code block (a fence with no language hint → bare <pre> with
   no inline style) wraps instead of scrolling. */
pre:not([style]) {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Opt-in wrapping via the `wrap` shortcode — e.g. a short bash command that
   reads better wrapped than scrolled. Wins over the no-wrap default for both
   plain and highlighted blocks. */
.wrap pre {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Line numbers (`{linenos=table}`): Chroma emits a two-column table (numbers |
   code) inside .highlight. Strip the per-cell <pre> margins/radius the theme
   adds so the block reads as one panel with a number gutter; keep horizontal
   scroll on the code column only. */
.highlight > div {
  border-radius: 4px;
  overflow: hidden;
}
.highlight table {
  margin: 0;
  width: 100%;
  border-spacing: 0;
}
.highlight table td {
  padding: 0;
}
.highlight table pre {
  margin: 0;
  border-radius: 0;
  white-space: pre;
}
.highlight table td:first-child pre {
  padding-right: 0.5em;
}
.highlight table td:last-child {
  width: 100%;
}
.highlight table td:last-child pre {
  padding-left: 0.75em;
  overflow-x: auto;
}

.code-block {
  position: relative;
}

.code-block pre {
  margin: 0;
}

.code-block {
  margin: 0 0 1.5em;
}

.copy-button {
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  padding: 0.3em 0.7em;
  font-family: inherit;
  font-size: 0.75rem;
  line-height: 1;
  color: #f8f8f2;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.copy-button:hover,
.copy-button:focus {
  opacity: 1;
  background: rgba(255, 255, 255, 0.22);
}

.copy-button.copied {
  color: #fff;
  background: rgba(76, 175, 80, 0.85);
  border-color: rgba(76, 175, 80, 0.85);
  opacity: 1;
}

/* Plain (non-highlighted) code blocks use the theme background, so the
   button needs contrasting colors against the light surface. */
.code-block > pre:not([style]) ~ .copy-button {
  color: var(--color-text);
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.15);
}

.code-block > pre:not([style]) ~ .copy-button:hover,
.code-block > pre:not([style]) ~ .copy-button:focus {
  background: rgba(0, 0, 0, 0.12);
}

/* ---------- Copy as Markdown button ---------- */
/* Sits under the post header meta; an <a> to the post's .md output that JS
   upgrades to copy-to-clipboard. rem (not em) so it stays chrome-sized like the
   meta and does not scale with the fluid reading body. */
.copy-md-button {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.3em 0.7em;
  font-size: 0.8rem;
  line-height: 1;
  color: var(--color-text-secondary);
  background: var(--color-code-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.copy-md-button:hover,
.copy-md-button:focus {
  color: var(--color-link-hover);
  border-color: var(--color-text-secondary);
}

.copy-md-button.copied {
  color: #fff;
  background: rgba(76, 175, 80, 0.85);
  border-color: rgba(76, 175, 80, 0.85);
}

/* ---------- Admonitions (Note / Tip / Warning / Caution) ---------- */
.admonition {
  margin: 1.5em 0;
  padding: 0.8em 1.1em;
  border-left: 4px solid var(--admonition-accent);
  border-radius: 4px;
  background: var(--admonition-bg);
}

.admonition > p {
  margin: 0;
}

/* Icon is prepended to the existing "Note:"/"Tip:"/etc. label text. */
.admonition > p::before {
  content: var(--admonition-icon) "\00a0";
}

.admonition-note {
  --admonition-accent: #4a90d9;
  --admonition-bg: rgba(74, 144, 217, 0.10);
  --admonition-icon: "📄";
}

.admonition-tip {
  --admonition-accent: #3fa45b;
  --admonition-bg: rgba(63, 164, 91, 0.10);
  --admonition-icon: "💡";
}

.admonition-warning {
  --admonition-accent: #e0a030;
  --admonition-bg: rgba(224, 160, 48, 0.12);
  --admonition-icon: "⚠️";
}

.admonition-caution {
  --admonition-accent: #d9534f;
  --admonition-bg: rgba(217, 83, 79, 0.10);
  --admonition-icon: "🛑";
}

/* ---------- Expander (details/summary) ---------- */
.expander {
  margin: 1.5em 0;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-code-bg);
}

.expander-summary {
  cursor: pointer;
  padding: 0.6em 1.1em;
  font-weight: 600;
  list-style: none;
  user-select: none;
}

/* Replace the default disclosure triangle with our own rotating marker. */
.expander-summary::-webkit-details-marker {
  display: none;
}

.expander-summary::before {
  content: "▶";
  display: inline-block;
  margin-right: 0.6em;
  font-size: 0.75em;
  color: var(--color-text-secondary);
  transition: transform var(--transition-speed);
}

.expander[open] > .expander-summary::before {
  transform: rotate(90deg);
}

.expander-content {
  border-top: 1px solid var(--color-border);
}

/* Code blocks carry their own background; let them fill the box edge-to-edge. */
.expander-content > .highlight,
.expander-content > pre {
  margin: 0;
}

/* ---------- Images ---------- */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

figure {
  margin: 1.5em 0;
}

figcaption {
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  text-align: center;
  margin-top: 0.5em;
}

/* ---------- Bonus material callout ---------- */
/* Two columns: book cover left, note right (the {{< bonus >}} shortcode). */
.bonus-material {
  display: flex;
  align-items: center;
  gap: 1.5em;
  margin: 2em 0;
  padding: 1.25em 1.5em;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-code-bg);
}

.bonus-cover {
  flex: 0 0 auto;
  width: 33%;
  max-width: 160px;
  margin: 0;
}

.bonus-cover img {
  border: 1px solid var(--color-border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.bonus-note {
  flex: 1;
}

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

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

@media (max-width: 600px) {
  .bonus-material {
    flex-direction: column;
    text-align: center;
  }

  .bonus-cover {
    width: auto;
  }
}

/* ---------- Tables ---------- */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5em 0;
}

th, td {
  border: 1px solid var(--color-border);
  padding: 0.5em 0.75em;
  text-align: left;
}

th {
  font-weight: 700;
}

/* ---------- Layout ---------- */
.site {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Shared centered wrapper: header inner, content, footer inner all use it. */
.container {
  width: 100%;
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* The content wrapper is the flex child that grows to keep the footer down. */
#content {
  flex: 1;
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--color-header-bg);
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--color-border);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.site-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

.site-title a {
  color: var(--color-text);
  text-decoration: none;
}

.site-title a:hover {
  color: var(--color-link-hover);
}

/* ---------- Navigation ---------- */
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.site-nav a {
  color: var(--color-text);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 400;
  transition: color var(--transition-speed) ease;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--color-link-hover);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25em 0;
}

@media (max-width: 600px) {
  .menu-toggle {
    display: block;
  }

  .site-nav ul {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
    padding-top: 0.75rem;
  }

  .site-nav.toggled ul {
    display: flex;
  }
}

/* ---------- Post ---------- */
.post {
  margin-bottom: 3rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--color-border);
}

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

.post-header {
  margin-bottom: 0.75rem;
}

.post-title {
  font-size: 1.2em;
  font-weight: 700;
  margin: 0 0 0.25rem;
  line-height: 1.3;
}

.post-title a {
  color: var(--color-text);
  text-decoration: none;
}

.post-title a:hover {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.prose {
  font-size: var(--font-size-base);
  line-height: 1.7;
}

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

.read-more {
  font-style: italic;
}

/* ---------- Post Meta ---------- */
.post-meta {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

.post-meta a {
  color: var(--color-text-secondary);
}

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

.post-date,
.post-categories,
.post-tags {
  display: inline;
}

.post-categories::before {
  content: " · ";
}

.post-tags::before {
  content: " · ";
}

/* ---------- Post Image ---------- */
.post-image {
  margin: 0.75rem 0 1rem;
}

.post-image img {
  width: 100%;
  height: auto;
  border-radius: 4px;
}

/* List cards show a smaller image; the single post's banner stays full width. */
.post:not(.post--single) .post-image img {
  max-width: 500px;
}

/* ---------- Single Post ---------- */
.post--single .post-header {
  margin-bottom: 1.5rem;
}

.post--single .post-title {
  font-size: 1.6em;
}

/* Tighten only the header meta; the footer meta (tags) keeps the base spacing. */
.post--single .post-header .post-meta {
  margin-top: 0.5rem;
}

/* ---------- Section / Taxonomy Header ---------- */
.section-header {
  margin-bottom: 2rem;
}

.section-title {
  font-size: 1.6em;
  font-weight: 700;
  margin: 0 0 0.25rem;
}

.section-description {
  color: var(--color-text-secondary);
  font-size: 1rem;
  margin: 0;
}

/* ---------- Post Index (titles-only listing, e.g. home page k8s feed) ---------- */
.post-index {
  margin-top: 1rem;
}

.post-index-title {
  font-size: 1.2em;
  font-weight: 700;
  margin: 0 0 1rem;
}

.post-index-title a {
  color: var(--color-text);
  text-decoration: none;
}

.post-index-title a:hover {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.post-index-list {
  margin: 0;
  padding-left: 1.25em;
}

.post-index-list li {
  margin-bottom: 0.4em;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 1.5rem 0;
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

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

.site-footer a:hover {
  color: var(--color-link-hover);
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--color-text);
  color: var(--color-bg);
  padding: 0.5em 1em;
  z-index: 100;
  text-decoration: none;
  font-size: 0.875rem;
}

.skip-link:focus {
  top: 0;
}

/* ---------- Visually hidden (screen-reader only) ---------- */
.visually-hidden {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}

/* ---------- Print ---------- */
@media print {
  .site-header,
  .site-footer,
  .site-nav {
    display: none;
  }

  body {
    font-size: 12pt;
    color: #000;
    background: #fff;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  .post {
    border-bottom: none;
    page-break-inside: avoid;
  }
}
