/* Responsive and interaction corrections */

/* Fully clickable reflection cards */
.reflection-item {
  min-width: 0;
}

.reflection-item .article-card {
  position: relative;
  display: grid;
  align-content: start;
  width: 100%;
  min-width: 0;
  min-height: 100%;
  color: inherit;
  text-decoration: none;
}

.reflection-item .article-card:hover,
.reflection-item .article-card:focus-visible,
.reflection-item .article-card:active {
  text-decoration: none;
}

.reflection-item .article-card:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 5px;
}

.reflection-item .article-card h2 {
  position: relative;
  z-index: 2;
  margin: 0;
  padding-right: 2.75rem;
}

.reflection-item .article-card__arrow {
  position: absolute !important;
  inset: 1rem 1rem auto auto !important;
  z-index: 4;
  margin: 0;
  font-size: 1.4rem;
  line-height: 1;
  pointer-events: none;
}

/* Selected themes: no rotating outline */
.theme-filter::before,
.theme-filter::after {
  content: none !important;
}

.theme-filter {
  isolation: auto;
  overflow: visible;
}

.theme-filter[aria-pressed="true"] {
  position: relative;
  border-color: var(--ink);
  background: var(--primary-light);
  color: var(--ink);
  box-shadow: 0.28rem 0.28rem var(--primary);
}

.theme-filter[aria-pressed="true"] span {
  position: relative;
  z-index: 1;
}

.theme-filter[aria-pressed="true"] span::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -0.42rem;
  width: 0.34rem;
  height: 0.34rem;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--accent-pink);
  transform: translateX(-50%);
}

.theme-list .theme-filter:nth-child(4n + 1)[aria-pressed="true"] span::after {
  animation: theme-bounce 1.1s ease-in-out infinite;
}

.theme-list .theme-filter:nth-child(4n + 2)[aria-pressed="true"] span::after {
  border-radius: var(--radius-sm);
  background: var(--accent-blue);
  animation: theme-wiggle 1.4s ease-in-out infinite;
}

.theme-list .theme-filter:nth-child(4n + 3)[aria-pressed="true"] span::after {
  background: var(--accent-orange);
  animation: theme-orbit 1.7s linear infinite;
}

.theme-list .theme-filter:nth-child(4n + 4)[aria-pressed="true"] span::after {
  background: var(--primary);
  animation: theme-pulse 1.2s ease-in-out infinite;
}

@keyframes theme-bounce {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -0.32rem); }
}

@keyframes theme-wiggle {
  0%, 100% { transform: translateX(-50%) rotate(-8deg); }
  50% { transform: translateX(-50%) rotate(8deg); }
}

@keyframes theme-orbit {
  from { transform: translateX(-50%) rotate(0deg) translateX(0.25rem) rotate(0deg); }
  to { transform: translateX(-50%) rotate(360deg) translateX(0.25rem) rotate(-360deg); }
}

@keyframes theme-pulse {
  0%, 100% { transform: translateX(-50%) scale(0.75); }
  50% { transform: translateX(-50%) scale(1.2); }
}

/* Article end aligned with the wide sections above */
.article-footer {
  width: 100%;
  max-width: 72rem;
  margin: 4rem auto 0;
}

/* General responsive safeguards */
img,
svg,
canvas,
video,
iframe {
  max-width: 100%;
}

.page-inner,
.article-page,
.article-layout,
.article-body,
.support-block,
.article-recommendations {
  min-width: 0;
}

@media (max-width: 64rem) {
  .article-layout {
    grid-template-columns: minmax(11rem, 14rem) minmax(0, 1fr);
    gap: 2rem;
  }
}

@media (max-width: 58rem) {
  .article-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .article-toc {
    position: static;
    width: 100%;
    max-width: none;
  }

  .article-recommendations,
  .support-block,
  .article-footer {
    width: 100%;
    max-width: none;
  }
}

@media (max-width: 48rem) {
  .articles-list,
  .article-recommendations__grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .reflection-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .reflection-search {
    grid-column: 1 / -1;
    width: 100%;
    max-width: none;
  }

  .support-block {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 40rem) {
  .page-inner {
    padding-inline: 1rem;
  }

  .header {
    gap: 1rem;
  }

  .logo {
    width: 104px;
    height: 104px;
  }

  .nav {
    align-items: flex-end;
    font-size: 0.82rem;
  }

  .theme-list {
    gap: 0.55rem;
  }

  .theme-filter {
    min-height: 2.35rem;
    padding: 0.4rem 0.7rem;
    border-width: 2px;
    font-size: 0.85rem;
  }

  .reflection-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .reset-filters {
    width: 100%;
  }

  .article-card {
    padding: 1rem;
    border-width: 2px;
    box-shadow: 0.3rem 0.3rem var(--primary);
  }

  .reflection-item .article-card__arrow {
    top: 0.8rem !important;
    right: 0.8rem !important;
  }

  .article-header {
    margin-bottom: 2rem;
  }

  .article-header h1 {
    overflow-wrap: anywhere;
  }

  .article-body {
    font-size: 1rem;
  }

  .article-body blockquote {
    padding: 1.25rem 1rem 1.15rem 3.15rem;
    border-width: 2px;
    box-shadow: 0.3rem 0.3rem var(--accent-blue);
  }

  .article-body blockquote::before {
    left: 0.65rem;
    font-size: 4rem;
  }

  .support-block,
  .article-recommendations,
  .article-footer {
    margin-top: 3rem;
  }

  .footer {
    align-items: flex-start;
    gap: 0.75rem;
  }

  .footer nav {
    width: 100%;
    justify-content: flex-start;
    gap: 0.75rem 1.5rem;
  }
}

@media (hover: none) and (pointer: coarse) {
  .article-card:active .article-card__visual {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .theme-filter[aria-pressed="true"] span::after {
    animation: none !important;
  }
}
