/* ABOUTME: Content blocks used inside tutorial and news bodies: figures, puzzle/solution pairs and worked-example steps. */
/* ABOUTME: Also the click-to-play video poster, download buttons and the image zoom dialog. */

/* Figures and puzzle/solution pairs */

.figure {
  margin: 2rem auto;
  text-align: center;
}

.figure img {
  margin-inline: auto;
  max-height: 420px;
  width: auto;
  border-radius: var(--radius-sm);
}

.figure figcaption,
.figure-pair figcaption {
  margin-top: 0.6rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.figure-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.75rem, 0.25rem + 2vw, 2rem);
  margin: 2rem 0;
  padding: clamp(1rem, 0.5rem + 2vw, 2rem);
  background: var(--cream);
  border-radius: var(--radius);
}

.figure-pair__item {
  margin: 0;
  text-align: center;
  flex: 0 1 240px;
}

.figure-pair__item img {
  background: var(--white);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.figure-pair figcaption {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--plum-600);
}

.figure-pair__arrow {
  font-size: 1.6rem;
  color: var(--rose);
  margin-bottom: 1.8rem;
}

/* Image beside text (news posts) */

.media-text {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: clamp(1rem, 0.5rem + 2vw, 2rem);
  align-items: center;
  margin: 2rem 0;
}

.media-text__image img {
  width: 100%;
  border-radius: var(--radius-sm);
}

.media-text__text > :last-child {
  margin-bottom: 0;
}

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

.button-wrap {
  margin: 1.5rem 0;
}

.prose .button,
.prose .button:hover {
  color: var(--white);
  text-decoration: none;
}

/* Worked example steps */

.step {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: clamp(1rem, 0.5rem + 2vw, 2rem);
  align-items: start;
  margin: 0 0 1.75rem;
  padding: clamp(1rem, 0.6rem + 1.5vw, 1.5rem);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font-size: 1.02rem;
  line-height: 1.65;
}

.step + .step::before {
  content: "";
  position: absolute;
  top: calc(-1.75rem - 1px);
  left: calc(clamp(1rem, 0.6rem + 1.5vw, 1.5rem) + 1.25rem);
  width: 2px;
  height: 1.75rem;
  background: repeating-linear-gradient(to bottom, var(--rose-300) 0 4px, transparent 4px 8px);
}

.step__image {
  position: relative;
  display: block;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--cream);
  cursor: zoom-in;
}

.step__image img {
  width: 100%;
  transition: transform 0.5s var(--ease);
}

.step__image::after {
  content: "";
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.92) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%234e194a' stroke-width='1.7' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='m10.4 10.4 3.1 3.1M7 5v4M5 7h4'/%3E%3C/svg%3E") no-repeat center / 16px;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transition: opacity 0.2s;
}

.step__image:hover::after,
.step__image:focus-visible::after {
  opacity: 1;
}

.step__image:hover img {
  transform: scale(1.02);
}

.step__number {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin: 0 0 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--plum);
}

.step__number span:first-child {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--plum);
  color: var(--white);
}

.step__total {
  color: var(--ink-soft);
  font-weight: 600;
}

.step__text p:last-child {
  margin-bottom: 0;
}

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

  .step__text {
    order: -1;
  }

  .step__text p:last-child {
    margin-bottom: 0;
  }
}

/* Video poster */

.video {
  margin: 1.5rem 0 2rem;
}

.video__poster,
.video iframe {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--plum-900);
  box-shadow: var(--shadow-md);
}

.video__poster picture {
  position: absolute;
  inset: 0;
}

.video__poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.85;
  transition: opacity 0.3s, transform 0.6s var(--ease);
}

.video__poster::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgb(34 10 32 / 0.85), rgb(34 10 32 / 0) 55%);
}

.video__play {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: 76px;
  height: 76px;
  margin: -38px 0 0 -38px;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.95) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5.5v13l10.5-6.5Z' fill='%234e194a'/%3E%3C/svg%3E") no-repeat 55% center / 30px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.3);
  transition: transform 0.3s var(--ease);
}

.video__title {
  position: absolute;
  left: 1.25rem;
  right: 1.25rem;
  bottom: 1rem;
  z-index: 1;
  color: var(--white);
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
}

.video__poster:hover img {
  opacity: 1;
  transform: scale(1.03);
}

.video__poster:hover .video__play {
  transform: scale(1.08);
}

/* Download button */

.download-wrap {
  margin: 1.5rem 0 2rem;
}

.download {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem 1rem 1rem;
  border-radius: var(--radius);
  background: var(--blue);
  color: var(--white);
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transition: background-color 0.25s, transform 0.25s var(--ease);
}

.download:hover {
  background: var(--blue-700);
  color: var(--white);
  transform: translateY(-2px);
}

.download__icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: rgb(255 255 255 / 0.16) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12M7 10l5 5 5-5M4 20h16'/%3E%3C/svg%3E") no-repeat center / 24px;
  flex: none;
}

.download__text {
  display: grid;
  line-height: 1.3;
}

.download__label {
  font-weight: 700;
  font-size: 1.05rem;
}

.download__meta {
  font-size: 0.85rem;
  opacity: 0.8;
}

/* Image zoom dialog */

.lightbox {
  max-width: min(94vw, 1100px);
  max-height: 92vh;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: 0 30px 80px rgb(0 0 0 / 0.4);
}

.lightbox::backdrop {
  background: rgb(34 10 32 / 0.75);
  backdrop-filter: blur(4px);
}

.lightbox img {
  max-height: 88vh;
  width: auto;
  margin: auto;
  padding: 1rem;
}

.lightbox__close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--cream);
  color: var(--plum);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox[open] {
  animation: lightbox-in 0.25s var(--ease);
}

@keyframes lightbox-in {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
}

/* Killer Sudoku cage combination tables */

.combos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0 2.5rem;
}

.combos__group {
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

.combos__group h3 {
  margin: 0 0 0.75rem;
  font-size: var(--step-1);
  color: var(--plum);
}

.combos__list {
  margin: 0;
}

.combos__row {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.35rem 0;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.combos__row dt {
  font-weight: 700;
  color: var(--plum);
}

.combos__row dd {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin: 0;
  letter-spacing: 0.04em;
}

.combos__row.is-unique dd span {
  padding: 0 0.4rem;
  border-radius: 4px;
  background: var(--rose-100);
  font-weight: 700;
}

.combos--required .combos__row dd {
  gap: 0.35rem;
}

.combos--required .combos__row dd span {
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--plum-100);
  font-weight: 700;
  color: var(--plum);
}
