/*
 * Copyright (c) 2026 Contributors to the Eclipse Foundation
 *
 * See the NOTICE file(s) distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Apache License, Version 2.0 which is available at
 * https://www.apache.org/licenses/LICENSE-2.0.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/* The tutorials home page: intro, search and filters, the cards. Everything
   sits under .tx-home, inside the shared theme (pages/theme), so the header,
   footer and light/dark switch are the same as on every tutorial site. */

.tx-home {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #5c5c5c;
  --line: #e3e3e3;
  --line-strong: #c9c9c9;
  --chip: #f1f1f1;
  --warn-bg: #fff1d6;
  --warn-fg: #8a4b00;
  --card: #ffffff;
  --soft: #fff6e8;
  --orange: #faa023;
  --orange-dark: #c37304;
  --green: #b3cb2d;
  color-scheme: light;
}

[data-md-color-scheme="slate"] .tx-home {
  --bg: #0b0b0b;
  --fg: #f2f2f2;
  --muted: #a8a8a8;
  --line: #2a2a2a;
  --line-strong: #444444;
  --chip: #1f1f1f;
  --warn-bg: #3a2600;
  --warn-fg: #ffc266;
  --card: #141414;
  --soft: #2a1f0d;
  --orange-dark: #fbb24d;
  color-scheme: dark;
}

.tx-home, .tx-home * { box-sizing: border-box; }

.tx-home {
  color: var(--fg);
  font-size: 0.8rem;
  line-height: 1.55;
  padding: 2.8rem 0.8rem 3.2rem;
}

.tx-home .intro { max-width: 35.2rem; }

.tx-home h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4.5vw, 2.4rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.01em;
}

.tx-home h1::after {
  content: "";
  display: block;
  width: 3.6rem;
  height: 0.24rem;
  margin-top: 0.8rem;
  border-radius: 0.16rem;
  background: linear-gradient(90deg, var(--orange), var(--green));
}

.tx-home .eyebrow {
  display: block;
  margin-bottom: 0.48rem;
  color: var(--orange-dark);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tx-home .intro p {
  margin: 0.96rem 0 0;
  color: var(--muted);
  font-size: 0.864rem;
}

.tx-home .grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: 0.96rem;
  margin-top: 2.4rem;
  padding: 0;
  list-style: none;
}

.tx-home .card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: var(--card);
  box-shadow: 0 1px 2px rgb(0 0 0 / 5%);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.tx-home .card:hover,
.tx-home .card:focus-within {
  border-color: var(--orange);
  box-shadow: 0 10px 28px rgb(250 160 35 / 16%);
  transform: translateY(-2px);
}

.tx-home .card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.48rem;
  padding: 0.96rem 1.12rem;
}

.tx-home .card--featured .card__body { background: linear-gradient(180deg, var(--soft), var(--card) 70%); border-radius: 0 0 0.4rem 0.4rem; }

/* The picture on top of each card: a screenshot, a logo or an icon. */
.tx-home .card__media {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  border-radius: 0.4rem 0.4rem 0 0;
  background: radial-gradient(circle at 30% 20%, var(--soft), var(--card) 75%);
}

.tx-home .card__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top left;
  transition: transform 0.4s;
}

.tx-home .card:hover .card__media img { transform: scale(1.03); }

.tx-home .card__media--logo { position: relative; }

.tx-home .card__media--logo picture { display: contents; }

.tx-home .card__media--logo img { position: absolute; inset: 6%; width: 88%; height: 88%; object-fit: contain; object-position: center; }

.tx-home .card__media--icon svg {
  width: 3.6rem;
  height: 3.6rem;
  fill: var(--orange-dark);
  transition: transform 0.4s;
}

.tx-home .card:hover .card__media--icon svg { transform: scale(1.06); }

.tx-home .tag {
  align-self: flex-start;
  padding: 0.12rem 0.48rem;
  border: 1px solid var(--line);
  border-radius: 0.16rem;
  color: var(--muted);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tx-home .tag--site { border-color: var(--orange); color: var(--orange-dark); }

/* The tag and the difficulty, on one line: one to three stars. */
.tx-home .card__kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.32rem 0.64rem;
}

.tx-home .card__kicker .tag { align-self: auto; }

.tx-home .level {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  color: var(--muted);
  font-size: 0.624rem;
  font-weight: 700;
}

.tx-home .level__stars { display: inline-flex; gap: 0.04rem; }

.tx-home .level svg { width: 0.8rem; height: 0.8rem; fill: var(--line-strong); }

.tx-home .level svg.on { fill: var(--orange); }

.tx-home .card h2 {
  margin: 0.16rem 0 0;
  font-size: 0.96rem;
  font-weight: 800;
  line-height: 1.3;
}

/* The whole card is the link; the title carries it. */
.tx-home .card h2 a { color: inherit; text-decoration: none; }

.tx-home .card h2 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }

.tx-home .card h2 a:focus-visible { outline: none; }

.tx-home .card:has(a:focus-visible) { outline: 2px solid var(--orange); outline-offset: 2px; }

.tx-home .card p { margin: 0; color: var(--muted); font-size: 0.76rem; }

/* The card's button: the full width of the card, at the bottom. The whole
   card is the link, so it lights up when the card is hovered or focused. */
.tx-home .go {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.48rem;
  margin-top: auto;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--orange);
  border-radius: 0.2rem;
  background: transparent;
  color: var(--orange-dark);
  font-size: 0.736rem;
  font-weight: 700;
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.tx-home .go svg { width: 0.92rem; height: 0.92rem; fill: currentcolor; transition: transform 0.2s; }

.tx-home .card:hover .go,
.tx-home .card:focus-within .go {
  background: var(--orange);
  color: #000000;
  box-shadow: 0 6px 16px rgb(250 160 35 / 30%);
}

/* Only the card's own button moves its arrow; a second button's icon stays put. */
.tx-home .card:hover .go:not(.go--secondary) svg,
.tx-home .card:focus-within .go:not(.go--secondary) svg { transform: translateX(4px); }

.tx-home .card--featured .go:not(.go--secondary) { background: var(--orange); color: #000000; }

.tx-home .card--featured:hover .go:not(.go--secondary) { background: var(--orange-dark); color: #000000; }

/* Search and filters. Shown only with JavaScript; without it every card shows. */
.tx-home .controls {
  display: grid;
  gap: 0.8rem;
  margin-top: 2rem;
}

.tx-home .search {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.tx-home .search svg {
  position: absolute;
  left: 0.72rem;
  width: 0.96rem;
  height: 0.96rem;
  fill: var(--muted);
  pointer-events: none;
}

.tx-home .search input {
  width: 100%;
  padding: 0.64rem 2.24rem 0.64rem 2.24rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.2rem;
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-size: 0.8rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.tx-home .search input::placeholder { color: var(--muted); }

.tx-home .search input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgb(250 160 35 / 25%);
}

.tx-home .search kbd {
  position: absolute;
  right: 0.64rem;
  padding: 0.04rem 0.36rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.28rem;
  color: var(--muted);
  font: inherit;
  font-size: 0.6rem;
}

.tx-home .search input:focus ~ kbd,
.tx-home .search input:not(:placeholder-shown) ~ kbd { display: none; }

.tx-home .filters { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.tx-home .filter {
  padding: 0.36rem 0.76rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.2rem;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.704rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.tx-home .filter:hover { border-color: var(--orange); }

.tx-home .filter:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

.tx-home .filter[aria-pressed="true"] {
  border-color: var(--orange);
  background: var(--orange);
  color: #000000;
}

.tx-home .count { margin: 0; color: var(--muted); font-size: 0.704rem; }

.tx-home .controls + .grid { margin-top: 1.2rem; }

.tx-home .grid > li[hidden] { display: none; }

.tx-home .empty {
  display: grid;
  justify-items: start;
  gap: 0.64rem;
  margin-top: 1.2rem;
  padding: 1.6rem;
  border: 1px dashed var(--line-strong);
  border-radius: 0.4rem;
  color: var(--muted);
}

.tx-home .empty[hidden] { display: none; }

.tx-home .empty p { margin: 0; }

/* Who a tutorial is for, on each card. */
.tx-home .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  margin: 0.16rem 0 0;
  padding: 0;
  list-style: none;
}

.tx-home .chips li {
  padding: 0.08rem 0.44rem;
  border-radius: 0.16rem;
  background: var(--chip);
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 600;
}

.tx-home .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.48rem;
}

/* When a tutorial was added and last changed, and its version. */
.tx-home .facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.56rem 0.8rem;
  margin: auto 0 0;
  padding-top: 0.72rem;
  border-top: 1px solid var(--line);
  font-size: 0.68rem;
}

.tx-home .facts div { display: grid; align-content: start; gap: 0.12rem; }

.tx-home .facts dt {
  color: var(--muted);
  font-size: 0.544rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tx-home .facts dd { margin: 0; font-weight: 600; }

.tx-home .facts + .go,
.tx-home .facts + .actions { margin-top: 0.8rem; }

/* Two buttons: the card's own, and a second one with a link of its own
   (the app), above the card's link. */
.tx-home .actions { display: flex; flex-wrap: wrap; gap: 0.48rem; margin-top: auto; }

.tx-home .actions .go { flex: 1 1 auto; margin-top: 0; padding-inline: 0.68rem; font-size: 0.704rem; white-space: nowrap; }

.tx-home .go--secondary {
  position: relative;
  z-index: 2;
  justify-content: center;
  gap: 0.32rem;
  border-color: var(--line-strong);
  color: var(--fg);
  text-decoration: none;
}

.tx-home .card:hover .go--secondary,
.tx-home .card:focus-within .go--secondary { background: transparent; color: var(--fg); box-shadow: none; }

.tx-home .card .go--secondary:hover,
.tx-home .card .go--secondary:focus-visible {
  border-color: var(--orange);
  background: var(--soft);
  color: var(--fg);
  outline: none;
}

/* Over the second button, only it lights up. */
.tx-home .card:has(.go--secondary:hover) .go:not(.go--secondary) { background: transparent; color: var(--orange-dark); box-shadow: none; }

.tx-home .card--featured:has(.go--secondary:hover) .go:not(.go--secondary) { background: var(--orange); color: #000000; }

.tx-home .card:has(.go--secondary:hover) .go svg { transform: none; }

/* Authors: GitHub avatars, overlapping a little, most commits first. */
.tx-home .facts__authors { grid-column: 1 / -1; }

.tx-home .authors ul { display: flex; margin: 0; padding: 0 0 0 0.24rem; list-style: none; }

.tx-home .authors li { margin-left: -0.3rem; }

.tx-home .authors a { position: relative; z-index: 1; display: block; border-radius: 50%; }

.tx-home .authors a:hover,
.tx-home .authors a:focus-visible { z-index: 2; outline: 2px solid var(--orange); outline-offset: 1px; }

.tx-home .authors img {
  display: block;
  width: 1.4rem;
  height: 1.4rem;
  border: 2px solid var(--card);
  border-radius: 50%;
  background: var(--chip);
}

.tx-home .authors .more a {
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border: 2px solid var(--card);
  background: var(--chip);
  color: var(--muted);
  font-size: 0.544rem;
  font-weight: 700;
  text-decoration: none;
}

.tx-home .sort {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  color: var(--muted);
  font-size: 0.656rem;
  font-weight: 600;
}

.tx-home .sort select {
  padding: 0.24rem 1.44rem 0.24rem 0.48rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.2rem;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23999' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 0.32rem center / 0.88rem;
  color: var(--fg);
  font: inherit;
  appearance: none;
  cursor: pointer;
}

.tx-home .sort select:hover { border-color: var(--orange); }

.tx-home .sort select:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

.tx-home .meta__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.48rem; }

.tx-home .toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.24rem 0.56rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.2rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.656rem;
  font-weight: 600;
  cursor: pointer;
}

.tx-home .toggle::before {
  content: "";
  width: 0.64rem;
  height: 0.64rem;
  border: 1.5px solid currentcolor;
  border-radius: 0.16rem;
}

.tx-home .toggle[aria-pressed="true"] { border-color: var(--orange); color: var(--fg); }

.tx-home .toggle[aria-pressed="true"]::before { border-color: var(--orange); background: var(--orange); box-shadow: inset 0 0 0 2px var(--card); }

.tx-home .toggle:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

/* Deprecated tutorials: a badge on the picture, the picture in grey. */
.tx-home .card__media { position: relative; }

.tx-home .badge {
  position: absolute;
  top: 0.56rem;
  left: 0.56rem;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.2rem 0.48rem 0.2rem 0.4rem;
  border-radius: 0.2rem;
  background: var(--warn-bg);
  color: var(--warn-fg);
  font-size: 0.6rem;
  font-weight: 700;
  box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
}

.tx-home .badge svg { width: 0.76rem; height: 0.76rem; fill: currentcolor; }

.tx-home .card--deprecated .card__media img { filter: grayscale(0.85); opacity: 0.75; }

.tx-home .card--deprecated:hover .card__media img { filter: none; opacity: 1; }

.tx-home .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* A card with two logos shows the one for the colour scheme of the switch. */
.tx-home .card__media img.tx-only-dark { display: none; }
[data-md-color-scheme="slate"] .tx-home .card__media img.tx-only-dark { display: block; }
[data-md-color-scheme="slate"] .tx-home .card__media img.tx-only-light { display: none; }
