/* custom.css — Blog enrichment styles */
/* Uses PaperMod CSS variables for auto light/dark support */

/* === Light-Mode Code Blocks — GitHub Chroma tokens === */
/* Background override is in extend_head.html inline <style> */
html[data-theme="light"] .chroma .k,
html[data-theme="light"] .chroma .kc,
html[data-theme="light"] .chroma .kd,
html[data-theme="light"] .chroma .kn,
html[data-theme="light"] .chroma .kp,
html[data-theme="light"] .chroma .kr,
html[data-theme="light"] .chroma .kt { color: #cf222e; }
html[data-theme="light"] .chroma .na,
html[data-theme="light"] .chroma .nc,
html[data-theme="light"] .chroma .nx { color: #1f2328; }
html[data-theme="light"] .chroma .no,
html[data-theme="light"] .chroma .nd,
html[data-theme="light"] .chroma .nt,
html[data-theme="light"] .chroma .o,
html[data-theme="light"] .chroma .ow,
html[data-theme="light"] .chroma .m,
html[data-theme="light"] .chroma .mb,
html[data-theme="light"] .chroma .mf,
html[data-theme="light"] .chroma .mh,
html[data-theme="light"] .chroma .mi,
html[data-theme="light"] .chroma .il,
html[data-theme="light"] .chroma .mo { color: #0550ae; }
html[data-theme="light"] .chroma .nb,
html[data-theme="light"] .chroma .ni,
html[data-theme="light"] .chroma .nf,
html[data-theme="light"] .chroma .fm { color: #6639ba; }
html[data-theme="light"] .chroma .nv,
html[data-theme="light"] .chroma .vc,
html[data-theme="light"] .chroma .vg,
html[data-theme="light"] .chroma .vi,
html[data-theme="light"] .chroma .vm { color: #953800; }
html[data-theme="light"] .chroma .s,
html[data-theme="light"] .chroma .sa,
html[data-theme="light"] .chroma .sb,
html[data-theme="light"] .chroma .sc,
html[data-theme="light"] .chroma .dl,
html[data-theme="light"] .chroma .sd,
html[data-theme="light"] .chroma .s2,
html[data-theme="light"] .chroma .se,
html[data-theme="light"] .chroma .sh,
html[data-theme="light"] .chroma .si,
html[data-theme="light"] .chroma .sx,
html[data-theme="light"] .chroma .sr,
html[data-theme="light"] .chroma .s1 { color: #0a3069; }
html[data-theme="light"] .chroma .ss { color: #032f62; }
html[data-theme="light"] .chroma .c,
html[data-theme="light"] .chroma .ch,
html[data-theme="light"] .chroma .cm,
html[data-theme="light"] .chroma .c1,
html[data-theme="light"] .chroma .cs,
html[data-theme="light"] .chroma .cp,
html[data-theme="light"] .chroma .cpf { color: #57606a; }
html[data-theme="light"] .chroma .p { color: #1f2328; }
html[data-theme="light"] .chroma .nn { color: #24292e; }
html[data-theme="light"] .chroma .nl { color: #900; font-weight: bold; }
html[data-theme="light"] .chroma .bp { color: #6a737d; }
html[data-theme="light"] .chroma .gh,
html[data-theme="light"] .chroma .gu { color: #953800; font-weight: bold; }
html[data-theme="light"] .chroma .gd { color: #82071e; background-color: #ffebe9; }
html[data-theme="light"] .chroma .gi { color: #116329; background-color: #dafbe1; }
html[data-theme="light"] .chroma .err { color: #f6f8fa; background-color: #82071e; }
html[data-theme="light"] .chroma .hl { background-color: #e5e5e5; }
html[data-theme="light"] .chroma .lnt,
html[data-theme="light"] .chroma .ln { color: #7f7f7f; }
html[data-theme="light"] .chroma .w { color: #fff; }
/* Copy button — adjust for light background */
html[data-theme="light"] .copy-code {
  color: rgba(0, 0, 0, 0.75);
  background: rgba(200, 200, 200, 0.5);
}

/* === Blockquote Alerts === */
.alert {
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 16px 0;
  background: var(--code-bg);
}
.alert p { margin: 4px 0; }
.alert p:last-child { margin-bottom: 0; }
.alert-heading {
  font-weight: 700;
  font-size: 0.95em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.alert-icon svg { width: 100%; height: 100%; }
.alert-note { border-left-color: #3b82f6; }
.alert-note .alert-heading { color: #3b82f6; }
.alert-note .alert-icon svg { fill: #3b82f6; }
.alert-tip { border-left-color: #22c55e; }
.alert-tip .alert-heading { color: #22c55e; }
.alert-tip .alert-icon svg { fill: #22c55e; }
.alert-important { border-left-color: #a855f7; }
.alert-important .alert-heading { color: #a855f7; }
.alert-important .alert-icon svg { fill: #a855f7; }
.alert-warning { border-left-color: #f59e0b; }
.alert-warning .alert-heading { color: #f59e0b; }
.alert-warning .alert-icon svg { fill: #f59e0b; }
.alert-caution { border-left-color: #ef4444; }
.alert-caution .alert-heading { color: #ef4444; }
.alert-caution .alert-icon svg { fill: #ef4444; }
/* Light-mode WCAG AA contrast overrides (-700 shades) */
html[data-theme="light"] .alert-note .alert-heading { color: #1d4ed8; }
html[data-theme="light"] .alert-note .alert-icon svg { fill: #1d4ed8; }
html[data-theme="light"] .alert-tip .alert-heading { color: #15803d; }
html[data-theme="light"] .alert-tip .alert-icon svg { fill: #15803d; }
html[data-theme="light"] .alert-important .alert-heading { color: #7e22ce; }
html[data-theme="light"] .alert-important .alert-icon svg { fill: #7e22ce; }
html[data-theme="light"] .alert-warning .alert-heading { color: #b45309; }
html[data-theme="light"] .alert-warning .alert-icon svg { fill: #b45309; }
html[data-theme="light"] .alert-caution .alert-heading { color: #b91c1c; }
html[data-theme="light"] .alert-caution .alert-icon svg { fill: #b91c1c; }

/* === Post Content Links — WCAG 1.4.1 (color alone) ===
   PaperMod uses box-shadow: 0 1px as a faux underline. Lighthouse requires
   text-decoration for compliance, so we swap: remove box-shadow, add underline. */
.post-content a {
  box-shadow: none;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.post-content a:hover {
  text-decoration-thickness: 2px;
}
/* Exclude elements that have their own visual treatment */
.post-content .btn,
.post-content .card-link,
.post-content .anchor,
.post-content .heading-anchor a,
.post-content .toc a,
.post-content .footnote-backref,
.post-content sup a {
  text-decoration: none;
  box-shadow: none;
}

/* === Heading Anchors === */
.heading-anchor { position: relative; }
.heading-anchor .anchor {
  text-decoration: none;
  color: var(--secondary);
  font-weight: 400;
  margin-left: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}
.heading-anchor:hover .anchor { opacity: 1; }

/* === Tables === */
.table-wrapper {
  overflow-x: auto;
  margin: 16px 0;
}
.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
}
.table-wrapper th,
.table-wrapper td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}
.table-wrapper th {
  background: var(--code-bg);
  font-weight: 700;
}
.table-wrapper tr:nth-child(even) td {
  background: var(--code-bg);
}

/* === Figures === */
figure {
  margin: 24px 0;
  text-align: center;
}
figure img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}
figcaption {
  margin-top: 8px;
  color: var(--secondary);
  font-size: 0.9em;
  font-style: italic;
}

/* === Alert Shortcode === */
.shortcode-alert {
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 16px 0;
  background: var(--code-bg);
}
.shortcode-alert p { margin: 4px 0; }
.shortcode-alert p:last-child { margin-bottom: 0; }
.shortcode-alert .alert-heading {
  font-weight: 700;
  font-size: 0.95em;
  margin-bottom: 8px;
}
.shortcode-alert-note { border-left-color: #3b82f6; }
.shortcode-alert-note .alert-heading { color: #3b82f6; }
.shortcode-alert-tip { border-left-color: #22c55e; }
.shortcode-alert-tip .alert-heading { color: #22c55e; }
.shortcode-alert-important { border-left-color: #a855f7; }
.shortcode-alert-important .alert-heading { color: #a855f7; }
.shortcode-alert-warning { border-left-color: #f59e0b; }
.shortcode-alert-warning .alert-heading { color: #f59e0b; }
.shortcode-alert-caution { border-left-color: #ef4444; }
.shortcode-alert-caution .alert-heading { color: #ef4444; }
/* Light-mode WCAG AA contrast overrides */
html[data-theme="light"] .shortcode-alert-note .alert-heading { color: #1d4ed8; }
html[data-theme="light"] .shortcode-alert-tip .alert-heading { color: #15803d; }
html[data-theme="light"] .shortcode-alert-important .alert-heading { color: #7e22ce; }
html[data-theme="light"] .shortcode-alert-warning .alert-heading { color: #b45309; }
html[data-theme="light"] .shortcode-alert-caution .alert-heading { color: #b91c1c; }

/* === Tabs === */
.tabs {
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--code-bg);
}
.tab-button {
  background: var(--code-bg);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--secondary);
  font-size: 0.9em;
  font-family: inherit;
}
.tab-button:hover {
  color: var(--primary);
}
.tab-button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--theme);
}
.tab-panel {
  display: none;
  padding: 16px;
}
.tab-panel.active { display: block; }
.tab-panel pre { margin: 0; }

/* === Buttons === */
.btn {
  display: inline-block;
  padding: 8px 20px;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9em;
  margin: 4px 4px 4px 0;
  transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-primary {
  background: var(--primary);
  color: var(--theme);
}
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

/* === File List === */
.file-list {
  margin: 16px 0;
  background: var(--code-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
}
.file-list pre {
  margin: 0;
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85em;
  line-height: 1.6;
  color: var(--content);
}

/* === Video === */
.video-wrapper {
  margin: 24px 0;
  text-align: center;
}
.video-wrapper video {
  max-width: 100%;
  border-radius: var(--radius);
}
.video-caption {
  margin-top: 8px;
  color: var(--secondary);
  font-size: 0.9em;
  font-style: italic;
}

/* === Keyboard Shortcuts === */
kbd {
  display: inline-block;
  padding: 2px 6px;
  font-size: 0.85em;
  font-family: inherit;
  line-height: 1.4;
  color: var(--primary);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  white-space: nowrap;
}

/* === Footnotes === */
.footnotes {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.9em;
  color: var(--secondary);
}
.footnotes ol { padding-left: 20px; }
.footnotes li { margin-bottom: 8px; }
.footnotes li p { margin: 0; }
sup a {
  text-decoration: none;
  color: #3b82f6;
  font-weight: 600;
  padding: 0 2px;
}
html[data-theme="light"] sup a { color: #1d4ed8; }
.footnote-backref {
  text-decoration: none;
  color: #3b82f6;
}
html[data-theme="light"] .footnote-backref { color: #1d4ed8; }

/* === Badges === */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.75em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 12px;
  vertical-align: middle;
  line-height: 1.6;
}
.badge-new {
  background: #15803d;
  color: #fff;
}
.badge-beta {
  background: #1d4ed8;
  color: #fff;
}
.badge-deprecated {
  background: #b91c1c;
  color: #fff;
}
.badge-experimental {
  background: #b45309;
  color: #fff;
}
.badge-outline {
  background: transparent;
  border: 1px solid var(--secondary);
  color: var(--secondary);
}

/* === Card Links === */
.card-link {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--primary);
  background: var(--code-bg);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card-link:hover {
  border-color: var(--secondary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.card-link-icon {
  font-size: 1.5em;
  flex-shrink: 0;
}
.card-link-body { flex: 1; min-width: 0; }
.card-link-title {
  font-weight: 700;
  font-size: 1em;
  margin: 0;
}
.card-link-desc {
  font-size: 0.85em;
  color: var(--secondary);
  margin: 4px 0 0;
}
.card-link-arrow {
  color: var(--secondary);
  flex-shrink: 0;
}

/* === Author Follow === */
.author-follow {
  margin: 32px 0;
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--code-bg);
  text-align: center;
}
.author-follow-text {
  margin: 0 0 12px;
  font-weight: 700;
  font-size: 1em;
  color: var(--primary);
}
.author-follow-links {
  display: flex;
  justify-content: center;
  gap: 16px;
}
.author-follow-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--primary);
  font-size: 0.9em;
  font-weight: 600;
  transition: border-color 0.2s, background 0.2s;
}
.author-follow-link:hover {
  border-color: var(--secondary);
  background: var(--theme);
}
.author-follow-link svg {
  width: 18px;
  height: 18px;
}

/* === Post Share === */
.post-share {
  margin: 0 0 32px;
  text-align: center;
}
.post-share-text {
  margin: 0 0 10px;
  font-size: 0.85em;
  color: var(--secondary);
}
.post-share-links {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.post-share-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--secondary);
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
}
.post-share-link:hover {
  color: var(--primary);
  border-color: var(--primary);
}
.post-share-link svg {
  width: 16px;
  height: 16px;
}

/* ── Sticky Sidebar ToC ────────────────────────── */

.post-single-wrapper {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  min-width: 0;
}

.post-single-content {
  min-width: 0;
  overflow-x: auto;
}

@media (min-width: 1200px) {
  .post-single-wrapper:has(.toc-sidebar) {
    grid-template-columns: 180px minmax(0, var(--main-width));
    gap: 2rem;
  }

  /* Widen .main on post pages to fit sidebar */
  .main:has(.toc-sidebar) {
    max-width: calc(var(--main-width) + 180px + 2rem + var(--gap) * 2);
  }

  /* Hide inline ToC when sidebar is visible */
  .post-single-content > .toc {
    display: none;
  }
}

.toc-sidebar {
  display: none;
}

@media (min-width: 1200px) {
  .toc-sidebar {
    display: block;
    position: sticky;
    top: 5rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    padding-right: 1rem;
    border-right: 1px solid var(--border);
    font-size: 0.85rem;
    line-height: 1.6;
  }

  .toc-sidebar-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--secondary);
    margin: 0 0 0.75rem 0;
    padding: 0;
  }

  .toc-sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }

  .toc-sidebar-nav li {
    margin: 0;
    padding: 0;
  }

  .toc-sidebar-nav ul ul {
    padding-left: 0.75rem;
  }

  .toc-sidebar-nav a {
    display: block;
    padding: 0.2rem 0.75rem 0.2rem 0;
    color: var(--secondary);
    text-decoration: none;
    transition: color 0.2s;
  }

  .toc-sidebar-nav a:hover {
    color: var(--primary);
  }

  .toc-sidebar-nav a.active {
    color: var(--primary);
    font-weight: 600;
  }

  .toc-sidebar::-webkit-scrollbar {
    width: 4px;
  }

  .toc-sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
  }
}

/* ── Talks Card Grid ───────────────────────────── */

.talks-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-top: 1.5rem;
}

@media (max-width: 640px) {
  .talks-grid {
    grid-template-columns: 1fr;
  }
}

.talk-card,
.talk-card *,
a.talk-card,
a.talk-card:hover,
a.talk-card:visited {
  text-decoration: none !important;
}

.talk-card {
  display: block;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  color: var(--primary);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.talk-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.talk-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--code-bg);
}

.talk-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.talk-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: white;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.2s;
}

.talk-card:hover .talk-play {
  opacity: 1;
}

.talk-info {
  padding: 0.75rem 1rem;
}

.talk-info h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.35rem 0;
  line-height: 1.3;
  text-decoration: none;
}

.talk-info p {
  font-size: 0.8rem;
  color: var(--secondary);
  margin: 0 0 0.5rem 0;
  line-height: 1.4;
  text-decoration: none;
}

.talk-meta-line {
  font-size: 0.75rem;
  color: var(--secondary);
  opacity: 0.7;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.talk-channel {
  text-decoration: none;
}

.talk-meta-sep {
  opacity: 0.5;
}

.talk-meta {
  text-decoration: none;
}

/* ── follow.it Subscribe Form ────────────────── */

.followit--follow-form-container {
  margin: 2rem 0;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.followit--follow-form-container .form-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background-color: var(--entry);
}

.followit--follow-form-container .form-preview h5 {
  margin: 0 0 0.75rem 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary);
  text-align: center;
}

.followit--follow-form-container .preview-input-field {
  width: 100%;
  margin-bottom: 0.5rem;
}

.followit--follow-form-container .preview-input-field input {
  width: 100%;
  height: 40px;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--theme);
  color: var(--primary);
  font-size: 0.85rem;
  text-align: center;
  outline: none;
  box-sizing: border-box;
}

.followit--follow-form-container .preview-input-field input::placeholder {
  color: var(--secondary);
  opacity: 0.7;
}

.followit--follow-form-container .preview-input-field input:focus {
  border-color: var(--primary);
}

.followit--follow-form-container .preview-submit-button {
  width: 100%;
}

.followit--follow-form-container .preview-submit-button button {
  width: 100%;
  height: 40px;
  border: none;
  border-radius: var(--radius);
  background-color: var(--primary);
  color: var(--theme);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.followit--follow-form-container .preview-submit-button button:hover {
  opacity: 0.85;
}

.followit--follow-form-container .powered-by-line {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: var(--secondary);
  opacity: 0.5;
  text-decoration: none;
}

.followit--follow-form-container .powered-by-line img {
  height: 1em;
}

.followit-count {
  margin: 0.25rem 0 0 0;
  font-size: 0.75rem;
  color: var(--secondary);
  text-align: center;
  opacity: 0.7;
}
