/* WordPress + mobile adaptations for NOIR */

.custom-logo-link {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}

.custom-logo-link img,
.custom-logo {
  display: block;
  max-height: 28px;
  width: auto;
  height: auto;
}

.screen-reader-text {
  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;
}

.skip-link:focus {
  clip: auto !important;
  clip-path: none;
  display: block;
  height: auto;
  left: 1rem;
  top: 1rem;
  width: auto;
  z-index: 100000;
  padding: 0.75rem 1rem;
  background: var(--elev, #141414);
  color: var(--text, #f4f4f4);
  border: 1px solid var(--line, #2a2a2a);
  border-radius: 10px;
}

/* Search form in header */
.header-c .search-field {
  position: relative;
}

.header-c .search-field input[type="search"] {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text, #f4f4f4);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  outline: none;
  min-width: 0;
}

.header-c .search-field input[type="search"]::placeholder {
  color: var(--muted, #8a8a8a);
  opacity: 0.7;
}

.header-c .search-field input[type="search"]::-webkit-search-decoration,
.header-c .search-field input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* Menu toggle */
.menu-toggle {
  display: none;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line, #2a2a2a);
  border-radius: 12px;
  background: var(--elev, #141414);
  color: var(--text, #f4f4f4);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.menu-toggle span,
.menu-toggle span::before,
.menu-toggle span::after {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  position: relative;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.menu-toggle span::before,
.menu-toggle span::after {
  content: "";
  position: absolute;
  left: 0;
}

.menu-toggle span::before { top: -6px; }
.menu-toggle span::after { top: 6px; }

.menu-toggle[aria-expanded="true"] span {
  background: transparent;
}

.menu-toggle[aria-expanded="true"] span::before {
  top: 0;
  transform: rotate(45deg);
}

.menu-toggle[aria-expanded="true"] span::after {
  top: 0;
  transform: rotate(-45deg);
}

.site-header.is-scrolled {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* Images — do NOT force height:100% on .card (breaks aspect-ratio on mobile) */
.cover-strip img,
.genre-card img,
.aside-covers img,
.comic-cover img,
.gallery-stack img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  max-width: none;
}

.card img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  max-width: 100%;
}

.entry-content a {
  color: var(--accent, #5ef2d0);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

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

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

.desc-block .desc.entry-content > *:last-child {
  margin-bottom: 0;
}

.page-full {
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
}

.page-full__head {
  margin-bottom: 1.5rem;
  max-width: none;
}

.page-full__head h1 {
  margin: 0.25rem 0 0;
  font-size: clamp(1.75rem, 3vw, 2.4rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.page-content {
  margin-top: 1rem;
  color: var(--muted, #b5b5b5);
  line-height: 1.65;
}

.page-content--full {
  max-width: none;
  width: 100%;
  color: var(--ink, #f2f4f7);
  font-size: 1.02rem;
  line-height: 1.7;
}

.page-content--full > *:first-child {
  margin-top: 0;
}

.page-content--full img,
.page-content--full .wp-block-image img,
.page-content--full figure {
  max-width: 100%;
  height: auto;
}

.page-content--full .alignwide,
.page-content--full .alignfull {
  width: 100%;
  max-width: 100%;
}

.page-content--full .alignfull {
  margin-left: 0;
  margin-right: 0;
}

.genres-hero__panel {
  padding: 1.5rem;
}

.comic-meta .eyebrow a {
  color: inherit;
  text-decoration: none;
}

.comic-meta .eyebrow a:hover {
  color: var(--accent, #5ef2d0);
}

.alignwide,
.alignfull {
  max-width: 100%;
}

.wp-caption,
.wp-caption-text,
.gallery-caption {
  color: var(--muted, #8a8a8a);
  font-size: 0.85rem;
}

/* Mobile header: logo + menu on top, search full width below */
@media (max-width: 900px) {
  .menu-toggle {
    display: inline-flex;
  }

  .header-c .header-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.65rem 0.75rem;
    padding-block: 0.65rem;
    min-height: 0;
  }

  .header-c .logo,
  .header-c .custom-logo-link.logo {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    min-width: 0;
  }

  .header-c .menu-toggle {
    grid-column: 2;
    grid-row: 1;
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }

  .header-c .search-field {
    grid-column: 1 / -1;
    grid-row: 2;
    flex: none;
    width: 100%;
    min-height: 42px;
    padding: 0 0.85rem;
    border-radius: 10px;
  }

  .header-c .search-field input[type="search"] {
    font-size: 0.88rem;
  }

  .header-c .nav {
    display: none;
    grid-column: 1 / -1;
    grid-row: 3;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    padding: 0.15rem 0 0;
    margin: 0;
  }

  .header-c .nav.is-open {
    display: flex;
  }

  .header-c .nav a {
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    background: var(--elev, #141821);
    border: 1px solid var(--line, rgba(242, 244, 247, 0.08));
    opacity: 1;
  }

  .header-c .nav a.is-active {
    border-color: rgba(94, 242, 208, 0.35);
    color: var(--accent, #5ef2d0);
  }
}

@media (max-width: 640px) {
  .home-stats {
    width: 100%;
  }

  .discover-panel__top {
    gap: 1.25rem;
  }

  .footer-inner {
    gap: 1.75rem;
  }

  .footer-links {
    gap: 0.4rem;
  }

  .footer-links a {
    font-size: 0.82rem;
    padding: 0.4rem 0.7rem;
  }

  .cover-strip span {
    font-size: 0.72rem;
  }

  .grid {
    gap: 0.85rem 0.65rem;
  }

  .card {
    gap: 0.35rem;
  }

  .card b {
    font-size: 0.8rem;
    -webkit-line-clamp: 2;
  }

  .card__meta {
    font-size: 0.7rem;
    gap: 0.25rem 0.4rem;
  }

  .card__views .icon-eye {
    width: 0.85rem;
    height: 0.85rem;
  }

  .rank {
    width: 1.4rem;
    height: 1.4rem;
    font-size: 0.68rem;
    top: 0.35rem;
    left: 0.35rem;
  }

  .rail {
    gap: 0.65rem;
  }
}

/* PageSpeed: defer paint of below-fold sections */
.section,
.strip,
.seo-block,
.section--genres,
.genre-cards,
.category-hero + .section {
  content-visibility: auto;
  contain-intrinsic-size: auto 480px;
}

.discover {
  content-visibility: visible;
}

/* Extra space for related/random under comic */
.noir-comic #similar,
.noir-comic #random {
  padding-top: 0.5rem;
}

@media (max-width: 640px) {
  body {
    background-image:
      radial-gradient(640px 280px at 50% -8%, rgba(94, 242, 208, 0.07), transparent 55%),
      radial-gradient(480px 320px at 100% 40%, rgba(88, 120, 200, 0.04), transparent 60%);
  }
}

/* Reduce paint cost of glass / sticky header on mid & small screens */
@media (max-width: 900px) {
  .site-header {
    backdrop-filter: none;
    background: rgba(11, 13, 18, 0.97);
  }

  .glass-panel__veil {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(11, 13, 18, 0.72);
  }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
