/* ==========================================================================
   Harrasteblogi Related Posts v2.2
   Pääväri:  #d6111e   Korostus: #ddc76d   Tumma: #000   Vaalea: #fff
   ========================================================================== */

:root {
  --hb-primary:       #d6111e;
  --hb-primary-dark:  #a30c17;
  --hb-accent:        #ddc76d;
  --hb-black:         #000000;
  --hb-white:         #ffffff;

  --hb-text:          #1a1a1a;
  --hb-text-muted:    #5a5a5a;
  --hb-bg-card:       #ffffff;
  --hb-bg-wrapper:    #faf9f6;
  --hb-border:        rgba(0, 0, 0, 0.08);
  --hb-shadow:        0 4px 14px rgba(0, 0, 0, 0.08);
  --hb-shadow-hover:  0 14px 32px rgba(214, 17, 30, 0.18);
  --hb-radius-lg:      20px;
  --hb-radius-md:      14px;
  --hb-radius-full:    999px;
  --hb-transition:     0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Tumma tila: kunnioittaa käyttäjän järjestelmäasetusta */
@media (prefers-color-scheme: dark) {
  :root {
    --hb-text:        #f2f2f2;
    --hb-text-muted:  #b7b7b7;
    --hb-bg-card:     #161616;
    --hb-bg-wrapper:  #0c0c0c;
    --hb-border:      rgba(255, 255, 255, 0.08);
    --hb-shadow:      0 4px 14px rgba(0, 0, 0, 0.35);
    --hb-shadow-hover: 0 14px 32px rgba(214, 17, 30, 0.32);
  }
}

/* --------------------------------------------------------------------------
   Wrapper
   -------------------------------------------------------------------------- */

.hb-related-wrapper {
  --local-fade: 1;
  margin: 56px 0 24px;
  padding: 32px;
  border-radius: var(--hb-radius-lg);
  background: var(--hb-bg-wrapper);
  border: 1px solid var(--hb-border);
  box-shadow: var(--hb-shadow);
  position: relative;
  overflow: hidden;
}

/* Hieno korostusviiva ylälaidassa pääväreillä */
.hb-related-wrapper::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--hb-primary), var(--hb-accent), var(--hb-primary));
  background-size: 200% 100%;
  animation: hbGradientShift 6s ease infinite;
}

@keyframes hbGradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* --------------------------------------------------------------------------
   Otsikkorivi
   -------------------------------------------------------------------------- */

.hb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
}

.hb-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.6rem);
  font-weight: 800;
  color: var(--hb-black);
  line-height: 1.2;
}

.hb-icon {
  font-size: 1.1em;
}

.hb-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2em;
  padding: 6px 14px;
  border-radius: var(--hb-radius-full);
  background: var(--hb-primary);
  color: var(--hb-white);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
}

/* --------------------------------------------------------------------------
   Grid & kortit
   -------------------------------------------------------------------------- */

.hb-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.hb-card {
  background: var(--hb-bg-card);
  border: 1px solid var(--hb-border);
  border-radius: var(--hb-radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--hb-transition), box-shadow var(--hb-transition), border-color var(--hb-transition);
}

.hb-card:hover,
.hb-card:focus-within {
  transform: translateY(-6px);
  box-shadow: var(--hb-shadow-hover);
  border-color: var(--hb-primary);
}

/* Kuvat */
.hb-thumb-link {
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--hb-border);
}

.hb-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}

.hb-card:hover .hb-thumb {
  transform: scale(1.06);
}

.hb-thumb--placeholder {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: linear-gradient(135deg, var(--hb-accent) 0%, var(--hb-primary) 120%);
  opacity: 0.85;
}

/* Sisältö */
.hb-content {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.hb-title {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
}

.hb-title a {
  color: var(--hb-black);
  text-decoration: none;
  background-image: linear-gradient(var(--hb-primary), var(--hb-primary));
  background-position: 0 100%;
  background-repeat: no-repeat;
  background-size: 0% 2px;
  transition: background-size var(--hb-transition);
}

.hb-title a:hover,
.hb-title a:focus-visible {
  background-size: 100% 2px;
  color: var(--hb-primary);
}

.hb-excerpt {
  margin: 0 0 16px;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--hb-black);
  flex: 1;
}

/* Lue lisää -painike */
.hb-readmore {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 10px 18px;
  border-radius: var(--hb-radius-full);
  text-decoration: none;
  color: var(--hb-white) !important;
  font-weight: 700;
  font-size: 0.9rem;
  background: var(--hb-primary);
  border: 2px solid var(--hb-primary);
  transition: background var(--hb-transition), color var(--hb-transition), transform var(--hb-transition);
}

.hb-readmore:hover,
.hb-readmore:focus-visible {
  background: var(--hb-black);
  border-color: var(--hb-black);
  transform: translateX(2px);
}

.hb-arrow {
  transition: transform var(--hb-transition);
}

.hb-readmore:hover .hb-arrow,
.hb-readmore:focus-visible .hb-arrow {
  transform: translateX(4px);
}

/* --------------------------------------------------------------------------
   Saavutettavuus
   -------------------------------------------------------------------------- */

/* Selkeä, näkyvä fokusrengas kaikille interaktiivisille elementeille */
.hb-related-wrapper a:focus-visible {
  outline: 3px solid var(--hb-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Kunnioita käyttäjän liikkeenvähennysasetusta */
@media (prefers-reduced-motion: reduce) {
  .hb-related-wrapper::before,
  .hb-card,
  .hb-thumb,
  .hb-title a,
  .hb-readmore,
  .hb-arrow {
    animation: none !important;
    transition: none !important;
  }
}

/* --------------------------------------------------------------------------
   Responsiivisuus
   -------------------------------------------------------------------------- */

@media (max-width: 480px) {
  .hb-related-wrapper {
    padding: 22px 18px;
    margin: 40px 0 16px;
    border-radius: var(--hb-radius-md);
  }

  .hb-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .hb-heading {
    font-size: 1.15rem;
  }
}

@media (min-width: 481px) and (max-width: 640px) {
  .hb-related-wrapper {
    padding: 22px 18px;
    margin: 40px 0 16px;
    border-radius: var(--hb-radius-md);
  }

  .hb-grid {
    gap: 14px;
  }

  .hb-heading {
    font-size: 1.15rem;
  }
}

/* Pidetään ruudukko kahdessa sarakkeessa myös suurilla näytöillä */

/* Tulostus: pidetään yksinkertaisena */
@media print {
  .hb-related-wrapper {
    display: none;
  }
}
