/*
 * TUT-01 (Issue #190, PO decisions D1-D5) - the public tutorial index only (loaded by its head_extra).
 *
 * Kept out of platform.css on purpose, the same pattern as storefront.css and my-services.css:
 * every rule is scoped to `body.tutorial-index-ui`, so the article index, the home page's cards,
 * the shared band and card partials and the tutorial page itself are untouched. Colours are the
 * platform's and the brand's own tokens, read and never redefined, so both themes follow and an
 * unbranded install draws plain panels. Nothing here moves, so reduced motion needs no rule.
 */

/* -- the band: compact, from the reading start (D1) -------------------------------------------- */

/* The height comes from what the editor wrote, not from a fixed minimum: a short title and
   introduction make a band of about 180-200px on a desktop, and a long introduction simply makes
   it taller. Nothing is clipped or shortened. The artwork, its veil and the eyebrow are the
   shared band's own. */
.tutorial-index-ui .content-hero__inner {
  min-block-size: 0;
  padding-block: clamp(1.2rem, 0.8rem + 1vw, 1.75rem);
  justify-content: flex-start;
  align-items: center;
}

.tutorial-index-ui .content-hero__copy {
  inline-size: min(100%, 46rem);
  margin-inline: 0;
}

/* The title and introduction carry their own direction (`editorial_dir`), so they are aligned
   to the page's reading start physically: right on the Persian page, left on the English one. */
html[dir="rtl"] .tutorial-index-ui .content-hero__copy,
html[dir="rtl"] .tutorial-index-ui .content-hero__copy > * {
  text-align: right;
}

html[dir="ltr"] .tutorial-index-ui .content-hero__copy,
html[dir="ltr"] .tutorial-index-ui .content-hero__copy > * {
  text-align: left;
}

.tutorial-index-ui .content-hero__eyebrow {
  margin-block-end: 0.35rem;
}

.tutorial-index-ui .content-hero__title {
  font-size: clamp(1.75rem, 1.25rem + 1.5vw, 2.4rem);
  margin-block-end: 0.45rem;
}

.tutorial-index-ui .content-hero__lede {
  margin: 0;
  max-inline-size: 62ch;
  line-height: 1.85;
}

/* Text now starts at the reading side rather than the middle, so that side of the picture is
   deepened with the band's own ground colour; the rest of the artwork shows as before. */
.tutorial-index-ui .content-hero::after {
  background:
    linear-gradient(var(--tutorial-band-towards, to left),
      color-mix(in srgb, var(--content-hero-ground) 82%, transparent) 0%,
      color-mix(in srgb, var(--content-hero-ground) 40%, transparent) 55%,
      transparent 85%),
    var(--content-hero-veil);
}

html[dir="ltr"] .tutorial-index-ui .content-hero::after {
  --tutorial-band-towards: to right;
}

/* A phone: no fixed minimum either; the copy sits at the band's foot over the mobile artwork,
   as it did before. */
@media (max-width: 900px) {
  .tutorial-index-ui .content-hero__inner {
    min-block-size: 0;
    align-items: flex-end;
    padding-block: 1.6rem 1.25rem;
  }

  /* The shared mobile veil deepens the band's foot. The band is shorter now, so the brightest
     part of the picture sits behind the eyebrow; the band's own ground deepens the top too. */
  .tutorial-index-ui .content-hero::after {
    background:
      linear-gradient(to bottom,
        color-mix(in srgb, var(--content-hero-ground) 62%, transparent) 0%,
        color-mix(in srgb, var(--content-hero-ground) 30%, transparent) 50%,
        transparent 80%),
      var(--content-hero-veil-mobile);
  }
}

/* -- the card: the title leads, the summary previews (D2) -------------------------------------- */

.tutorial-index-ui .content-card__title {
  font-size: 1.15rem;
  line-height: 1.6;
}

/* Three lines at most on the card, then an ellipsis. The whole summary is still in the HTML (for
   a screen reader and a search engine alike) and on the tutorial's own page; titles are never
   clamped. */
.tutorial-index-ui .content-card__summary {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

/* -- the classifications: one compact row (D3) ------------------------------------------------- */

.tutorial-index-ui .content-card__taxonomy {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.tutorial-index-ui .content-tag {
  padding: 0.05rem 0.55rem;
  font-size: 0.74rem;
}

/* Subjects get their own quiet tint, so the three dimensions are not told apart by two colours
   and a missing one; each group is also named for assistive technology. */
.tutorial-index-ui .content-tags--subjects .content-tag {
  border-color: color-mix(in srgb, var(--accent-2) 35%, var(--line));
  background: color-mix(in srgb, var(--accent-2) 7%, var(--surface-raised));
  color: var(--ink);
}

/* "+N": the number of the tutorial's classifications not shown here. Plain words in the soft ink,
   with no border or fill, so it never looks like a control. */
.tutorial-index-ui .content-tags__more {
  display: inline-flex;
  align-items: center;
  padding-inline: 0.2rem;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.75;
  white-space: nowrap;
}

/* -- a tutorial with no lead image (D4) -------------------------------------------------------- */

/* The same 16:9 frame, so a row of cards stays even, on a quiet ground of the theme's own colours
   with a plain guide mark in the middle. The mark is decoration on a frame already hidden from
   assistive technology: no picture, no file and no alternative text is invented. */
.tutorial-index-ui .content-card__media--empty {
  background:
    radial-gradient(120% 90% at 50% 115%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 62%),
    linear-gradient(180deg, var(--surface-sunken), color-mix(in srgb, var(--accent) 6%, var(--surface-sunken)));
}

.tutorial-index-ui .content-card__media--empty::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  inline-size: 3rem;
  block-size: 3rem;
  background-color: color-mix(in srgb, var(--accent) 50%, var(--ink-soft));
  opacity: 0.75;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5.5A2.5 2.5 0 0 1 6.5 3H20v15H6.5A2.5 2.5 0 0 0 4 20.5z'/%3E%3Cpath d='M4 20.5A2.5 2.5 0 0 0 6.5 23H20v-5'/%3E%3Cpath d='M9 8h7M9 12h5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5.5A2.5 2.5 0 0 1 6.5 3H20v15H6.5A2.5 2.5 0 0 0 4 20.5z'/%3E%3Cpath d='M4 20.5A2.5 2.5 0 0 0 6.5 23H20v-5'/%3E%3Cpath d='M9 8h7M9 12h5'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* -- a phone (D5) ------------------------------------------------------------------------------ */

@media (max-width: 640px) {
  .tutorial-index-ui .content-index__head {
    margin-block-end: 0.8rem;
  }

  .tutorial-index-ui .content-card__title {
    font-size: 1.08rem;
  }
}

/* -- search and three filters (CONTENT-DISCOVERY-01 PR2) --------------------------------------- */

/* Above the cards, never in the band. The search field is the platform's own `discovery-search`
   (the games catalog's and the article index's), so it shrinks below 375 px and shows its focus
   on the whole field. Filters are links that wrap onto as many lines as they need. */
.tutorial-index-ui .tutorial-discovery {
  display: grid;
  gap: 0.85rem;
  margin-block-end: 1.5rem;
}

.tutorial-index-ui .tutorial-discovery__search {
  max-inline-size: 40rem;
}

/* On a phone the three filters fold into a native <details>, closed, so the results stay on the
   first screen; its summary is a 44 px target that says how many filters are in force. */
.tutorial-index-ui .tutorial-discovery__filters {
  min-inline-size: 0;
  padding-inline: 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-sunken);
}

.tutorial-index-ui .tutorial-discovery__toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-block-size: 2.75rem;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.tutorial-index-ui .tutorial-discovery__count {
  color: var(--ink-soft);
}

/* The summary is a flex row, which drops the native disclosure triangle; this chevron replaces it
   at the row's end and turns over when the filters are open. */
.tutorial-index-ui .tutorial-discovery__chevron {
  flex: 0 0 auto;
  inline-size: 1.1rem;
  block-size: 1.1rem;
  margin-inline-start: auto;
  color: var(--ink-soft);
}

.tutorial-index-ui .tutorial-discovery__filters[open] .tutorial-discovery__chevron {
  transform: rotate(180deg);
}

.tutorial-index-ui .tutorial-discovery__groups {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 2rem;
  align-items: flex-start;
  padding-block: 0.35rem 0.9rem;
}

.tutorial-index-ui .tutorial-discovery__group {
  min-inline-size: 0;
}

.tutorial-index-ui .tutorial-discovery__label {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: var(--tracking-eyebrow);
  color: var(--ink-soft);
}

.tutorial-index-ui .tutorial-discovery__choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A 44 px target. The chosen term is marked by more than colour: a heavier weight, an inset rule
   along its foot and a tick, as the article index and the games catalog mark theirs. */
.tutorial-index-ui .tutorial-discovery__choice {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-block-size: 2.75rem;
  max-inline-size: 100%;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.tutorial-index-ui .tutorial-discovery__choice:hover {
  border-color: var(--accent-edge);
  color: var(--ink);
}

.tutorial-index-ui .tutorial-discovery__choice--selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--surface-sunken));
  color: var(--ink);
  font-weight: 800;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.tutorial-index-ui .tutorial-discovery__check {
  flex: 0 0 auto;
  inline-size: 1rem;
  block-size: 1rem;
  color: var(--accent);
}

/* What is shown, in words, and the one way back to every tutorial. */
.tutorial-index-ui .tutorial-discovery__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  margin: 0;
  color: var(--ink-soft);
}

.tutorial-index-ui .tutorial-discovery__summary bdi {
  color: var(--ink);
  font-weight: 700;
}

.tutorial-index-ui .tutorial-discovery__clear {
  font-weight: 700;
  white-space: nowrap;
}

/* A wide screen has room for the filters, so they are simply shown: no summary to open, no box.
   Only where the browser can show a closed <details>'s content (`::details-content`); anywhere
   else the filters stay one click away behind the same summary, as on a phone. */
@media (min-width: 900px) {
  @supports selector(::details-content) {
    .tutorial-index-ui .tutorial-discovery__filters {
      padding-inline: 0;
      border: 0;
      background: none;
    }

    .tutorial-index-ui .tutorial-discovery__toggle {
      display: none;
    }

    .tutorial-index-ui .tutorial-discovery__filters::details-content {
      content-visibility: visible;
    }

    .tutorial-index-ui .tutorial-discovery__groups {
      padding-block: 0;
    }
  }
}
