/* Skip link — hidden until keyboard focus (sr-only not in compiled Tailwind) */
.skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus-visible {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 9999;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0.625rem 1rem;
  overflow: visible;
  clip: auto;
  white-space: normal;
  border-radius: 0.75rem;
  background: var(--color-primary);
  color: var(--color-primary-foreground);
  font-weight: 500;
  font-size: 0.875rem;
  outline: none;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.25);
}

/* Suppress focus ring / tint flash on mouse and touch clicks */
:focus:not(:focus-visible) {
  outline: none;
  --tw-ring-shadow: 0 0 #0000;
  --tw-ring-offset-shadow: 0 0 #0000;
}

/* Keep keyboard focus visible */
:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--color-primary) 45%, transparent);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
[role="button"]:focus:not(:focus-visible) {
  box-shadow: none;
}

/* Card links: avoid primary background flash while pressed */
article.group > a,
.post-list article > a {
  -webkit-tap-highlight-color: transparent;
  color: inherit;
}

article.group > a:link,
article.group > a:visited,
.post-list article > a:link,
.post-list article > a:visited {
  color: inherit;
}

article.group > a:active > div,
article.group > a:active .post-card,
.post-list article > a:active > div,
.post-list article > a:active .post-card {
  background-color: var(--color-card) !important;
  border-color: var(--color-border) !important;
  transform: none !important;
  box-shadow: none !important;
}

/* Newsletter — centered stack + form layout */
.newsletter-form {
  width: 100%;
  max-width: 28rem;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.newsletter-msg {
  margin-top: 1rem;
  width: 100%;
  max-width: 28rem;
}

.newsletter-form input {
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  padding: 0.625rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--color-border);
  background: var(--color-muted);
  color: var(--color-foreground);
  font-size: 0.875rem;
}

.newsletter-form input::placeholder {
  color: var(--color-muted-foreground);
}

.newsletter-form input:focus-visible {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.newsletter-form button[type="submit"] {
  width: 100%;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 0.5rem;
  background: var(--color-primary);
  color: var(--color-primary-foreground);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.newsletter-form button[type="submit"]:hover {
  background: color-mix(in oklab, var(--color-primary) 90%, transparent);
}

@media (min-width: 640px) {
  .newsletter-form {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: center;
    gap: 0.5rem;
  }

  .newsletter-form input {
    flex: 1 1 8rem;
    width: auto;
  }

  .newsletter-form button[type="submit"] {
    width: auto;
    flex: 0 0 auto;
  }
}

/* Code blocks inside prose — Hugo render-codeblock parity */
.prose .code-block-container {
  margin: 1.5rem 0;
}

.prose .code-block-container pre,
.prose .code-block-container code {
  background: transparent;
  padding: 0;
  margin: 0;
  font-weight: normal;
  border-radius: 0;
}

.prose .code-block-container pre::before,
.prose .code-block-container code::before,
.prose .code-block-container code::after {
  content: none;
}

.copy-code-btn.text-green-600 {
  color: var(--color-green-600, #16a34a);
}

/* Post cards — Hugo w-80 / md:pr-[21rem] fallbacks */
@media (min-width: 768px) {
  .post-card-cover,
  .post-card-cover-gradient {
    width: 20rem;
  }

  .post-card-content {
    padding-right: 21rem;
  }
}

.youtube-embed {
  aspect-ratio: 16 / 9;
  height: 16rem;
  border: 0;
}

@media (min-width: 768px) {
  .youtube-embed {
    height: 18rem;
  }
}

.search-result-selected {
  background-color: color-mix(in oklab, var(--color-primary) 10%, transparent);
  color: var(--color-primary);
}

/* Hero — centered avatar + name stack */
.hero-avatar {
  width: 7rem;
  height: 7rem;
}

.author-section h1 {
  line-height: 1.2;
}

/* Cookie consent — centered banner + button row */
#cookie-consent {
  position: fixed;
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  left: 50%;
  z-index: 100;
  width: min(calc(100vw - 2rem), 32rem);
  max-width: 32rem;
  margin: 0;
  opacity: 0;
  transform: translateX(-50%) translateY(1rem);
  pointer-events: none;
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

#cookie-consent.cookie-consent--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.cookie-consent-body {
  text-align: center;
}

.cookie-consent-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.cookie-consent-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  margin-inline: auto;
}

.cookie-consent-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 7.5rem;
  padding: 0.625rem 1.5rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.cookie-consent-btn:active {
  transform: scale(0.98);
}

.cookie-consent-btn--accept {
  background-color: var(--color-primary);
  color: var(--color-primary-foreground);
}

.cookie-consent-btn--accept:hover {
  filter: brightness(1.08);
}

.cookie-consent-btn--reject {
  background-color: var(--color-muted);
  color: var(--color-foreground);
  border-color: var(--color-border);
}

.cookie-consent-btn--reject:hover {
  filter: brightness(1.06);
}

.cookie-consent-close {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Post meta card — author row spacing (Tailwind pt-* not in compiled bundle) */
.post-meta-author {
  margin-top: 0.75rem;
  padding-top: 1rem;
}

/* Prose links: override compiled.css pseudo underlines (AdSense google-anno + inline links) */
.prose a:not(.footnote-ref):not(.footnote-backref)::before,
.prose a::after {
  content: none !important;
}

.prose a:not(.block):not(.google-anno):not(.google-anno-oc) {
  position: static;
  padding: 0;
  margin: 0;
}

.prose a.google-anno,
.prose a.google-anno-oc {
  text-decoration: none !important;
}

/* YouTube embeds — aspect-video is not in compiled Tailwind bundle */
.prose .aspect-video,
.prose .youtube-embed {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  margin-block: 1.5rem;
  overflow: hidden;
  border-radius: var(--radius-lg, 0.75rem);
  background: var(--color-muted);
}

.prose .aspect-video > a,
.prose .youtube-embed > a {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none !important;
}

.prose .aspect-video img,
.prose .youtube-embed img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.prose .aspect-video .absolute,
.prose .youtube-embed .absolute {
  position: absolute;
  inset: 0;
}

/* Mobile — touch targets & layout (h-11 / min-h-[44px] missing from compiled Tailwind) */
@media (max-width: 767px) {
  #mobile-menu-toggle,
  header .md\:hidden > a[aria-label] {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
  }

  header .md\:hidden .dropdown-toggle,
  header .md\:hidden #theme-switch-btn {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
  }

  .mobile-nav-link {
    min-height: 3rem;
    padding-top: 1rem;
    padding-bottom: 1rem;
  }

  .cookie-consent-actions {
    flex-direction: column;
    align-items: center;
  }

  .cookie-consent-btn {
    width: 100%;
    max-width: 16rem;
    margin-inline: auto;
  }

  .newsletter-form button[type="submit"] {
    min-height: 44px;
  }

  /* Prevent horizontal scroll from wide embeds/tables */
  .prose pre,
  .code-block-container,
  .prose table,
  .youtube-embed,
  iframe {
    max-width: 100%;
  }

  .prose table {
    display: block;
    overflow-x: auto;
  }
}
