/*
 * YouTube block on TOP (SPEC §2.13; §3.1 rows 5 and 7). Values from
 * tokens.css only. Three blocks: the OFFICIAL YOUTUBE pill, the intro
 * section (pill, title, catch, body, photo) and the video with its
 * 公式YouTubeチャンネル button.
 *
 * HTML contract
 *   <section class="youtube-intro" aria-labelledby="youtube-title">
 *     <div class="youtube-intro__media">
 *       <img class="youtube-intro__image" src alt width height loading="lazy">
 *     </div>
 *     <div class="youtube-intro__body">
 *       <hgroup class="youtube-intro__heading">
 *         <p class="youtube-badge">
 *           <img class="youtube-badge__mark" src="../../assets/icons/youtube-mark.svg" alt="">
 *           <span class="youtube-badge__label" lang="en">OFFICIAL YOUTUBE</span>
 *         </p>
 *         <h2 class="youtube-intro__title" id="youtube-title">
 *           <span class="youtube-intro__phrase">サンミュージック公式</span>
 *           <span class="youtube-intro__phrase">ゴルフチャンネル</span>
 *         </h2>
 *         <p class="youtube-intro__catch"> phrases … </p>
 *       </hgroup>
 *       <p class="youtube-intro__text">
 *         <span class="youtube-intro__phrase">…</span>…
 *         <br class="youtube-intro__break"> (PC line ends, shown from 1200)
 *       </p>
 *     </div>
 *   </section>
 *   The section is full bleed. The photo comes first in the source (it is
 *   on top on SP); from 1024 it fills the right half and the text column
 *   starts at the top-wide edge (SPEC §4.1 #7, §4.3: the photo stays 50%
 *   of the viewport above 1920). Phrases (`__phrase`, inline-block) keep
 *   the XD line breaks: SP breaks between every phrase where two do not fit,
 *   PC adds `__break` line ends from 1200. A phrase wider than the column
 *   wraps inside itself (320).
 *
 *   <div class="youtube-video">
 *     <div class="youtube-video__player" data-youtube-block
 *          data-youtube-block-id="<11-character video id>">
 *       <a class="youtube-video__link" href="https://www.youtube.com/watch?v=…"
 *          aria-label="動画を再生：<video title>">
 *         <img class="youtube-video__poster" src srcset sizes alt="" …>
 *         <img class="youtube-video__play" src="../../assets/icons/youtube-mark.svg" alt="">
 *       </a>
 *     </div>
 *     <p class="youtube-video__action">
 *       <a class="button button--main" href="<channel>">公式YouTubeチャンネル</a>
 *     </p>
 *   </div>
 *   A lite embed (ASSUMPTION, SPEC §2.13): without JS the poster is a link
 *   to the video on YouTube. With JS (js/components/youtube-block.js, only
 *   when data-youtube-block-id is a valid id) a click swaps it for a
 *   youtube-nocookie iframe (.youtube-video__frame) that autoplays, and
 *   focus moves into it. The video fills its column (content: 1000 on PC).
 *
 * States (ASSUMPTION, SPEC §2.13): video hover and press darken the poster
 * by 10% (the play mark is already red, as drawn); focus is the base ring
 * around the video. The pill and the intro are not interactive. The button
 * keeps the .button states.
 */

/* ---- OFFICIAL YOUTUBE pill ---- */

.youtube-badge {
  display: inline-flex;
  gap: var(--youtube-badge-gap);
  align-items: center;
  block-size: var(--youtube-badge-height);
  padding-inline: var(--youtube-badge-padding-inline);
  font-family: var(--font-en);
  font-size: var(--text-label-en-size);
  font-weight: var(--font-weight-bold);
  line-height: var(--text-label-en-lh);
  color: var(--color-green-700);
  white-space: nowrap;
  background-color: var(--color-green-50);
  border-radius: var(--youtube-badge-radius);
}

.youtube-badge__mark {
  flex: none;
  inline-size: var(--youtube-badge-mark-width);
}

/* ---- Intro ---- */

.youtube-intro {
  container-type: inline-size;
  display: grid;

  /* v2: #youtube is the header / footer anchor target; land below the
     sticky header (35 offset + 66 pill on PC; more than enough on SP). */
  scroll-margin-block-start: calc(var(--header-offset) + var(--header-height));
  gap: var(--youtube-intro-media-gap);
}

.youtube-intro__media {
  aspect-ratio: var(--youtube-intro-media-ratio);
  overflow: hidden;
}

.youtube-intro__image {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  object-position: var(--youtube-intro-image-position);
}

/* SP: the column of the top-wide container (the page gutter). */
.youtube-intro__body {
  display: flex;
  flex-direction: column;
  gap: var(--youtube-intro-text-gap);
  align-items: flex-start;
  inline-size: min(100% - 2 * var(--gutter-wide), var(--container-top-wide));
  margin-inline: auto;
}

.youtube-intro__heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.youtube-intro__title {
  inline-size: fit-content;
  max-inline-size: 100%;
  margin-block-start: var(--youtube-intro-title-gap);
  font-size: var(--text-h1-ja-size);
  line-height: var(--text-h1-ja-lh);
  color: var(--color-green-700);
}

.youtube-intro__catch {
  inline-size: fit-content;
  max-inline-size: 100%;
  margin-block-start: var(--youtube-intro-catch-gap);
  font-size: var(--text-h2-tight-size);
  font-weight: var(--font-weight-bold);
  line-height: var(--text-h2-tight-lh);
  color: var(--color-green-700);
}

.youtube-intro__text {
  inline-size: fit-content;
  max-inline-size: 100%;
  color: var(--color-ink-900);
}

.youtube-intro__phrase {
  display: inline-block;
  max-inline-size: 100%;
}

.youtube-intro__break {
  display: none;
}

@media (width >= 1024px) {
  .youtube-intro {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
  }

  .youtube-intro__media {
    grid-area: 1 / 2;
    align-self: start;
  }

  .youtube-intro__image {
    object-position: var(--youtube-intro-image-position-pc);
  }

  /* The text column starts at the top-wide container's edge. */
  .youtube-intro__body {
    grid-area: 1 / 1;
    inline-size: auto;
    margin-inline: 0;
    padding-block-start: var(--youtube-intro-padding-block-start-pc);
    padding-inline: max(
        var(--gutter-wide),
        (100cqi - var(--container-top-wide)) / 2
      )
      var(--youtube-intro-padding-inline-end-pc);
  }
}

@media (width >= 1200px) {
  .youtube-intro__break {
    display: inline;
  }
}

/* ---- Video ---- */

.youtube-video {
  display: flex;
  flex-direction: column;
  gap: var(--youtube-video-action-gap);
  align-items: center;
}

.youtube-video__player {
  position: relative;
  inline-size: 100%;
  aspect-ratio: var(--youtube-video-ratio);
  background-color: var(--color-ink-900);
}

.youtube-video__link,
.youtube-video__frame {
  position: absolute;
  inset: 0;
  display: block;
  inline-size: 100%;
  block-size: 100%;
  border: 0;
}

.youtube-video__poster {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  transition: filter var(--duration-hover);
}

.youtube-video__play {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  inline-size: var(--youtube-video-play-width);
  translate: -50% -50%;
}

/* ---- States ---- */

@media (hover: hover) {
  .youtube-video__link:hover .youtube-video__poster {
    filter: brightness(var(--youtube-video-dim));
  }
}

.youtube-video__link:active .youtube-video__poster {
  filter: brightness(var(--youtube-video-dim));
}

@media print {
  .youtube-video__play {
    display: none;
  }
}
