/*
 * 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.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 * SPDX-License-Identifier: Apache-2.0
 */

/* Eclipse Tractus-X look: black, white and the Tractus-X orange. */

:root,
[data-md-color-scheme="default"] {
  --md-primary-fg-color: #000000;
  --md-primary-fg-color--light: #1e1e1e;
  --md-primary-fg-color--dark: #000000;
  --md-primary-bg-color: #ffffff;
  --md-accent-fg-color: #faa023;
  --md-typeset-a-color: #c37304;
  --tx-orange: #faa023;
  --tx-orange-dark: #c37304;
  --tx-green: #b3cb2d;
  --tx-soft: #fff6e8;
}

[data-md-color-scheme="slate"] {
  --md-primary-fg-color: #000000;
  --md-primary-bg-color: #ffffff;
  --md-accent-fg-color: #faa023;
  --md-typeset-a-color: #fbb24d;
  --md-default-bg-color: #0b0b0b;
  --tx-soft: #2a1f0d;
}

/* One orange line, under the header; a thin light one under the tabs. */
.md-header {
  border-bottom: 1px solid var(--tx-orange);
}

.md-tabs {
  border-bottom: 1px solid rgb(255 255 255 / 14%);
}

.md-tabs__link--active,
.md-nav__link--active {
  color: var(--tx-orange) !important;
}

.md-typeset h1 {
  font-weight: 800;
  color: var(--md-default-fg-color);
}

.md-typeset h1::after {
  content: "";
  display: block;
  width: 4.5rem;
  height: 0.3rem;
  margin-top: 0.6rem;
  border-radius: 0.2rem;
  background: linear-gradient(90deg, var(--tx-orange), var(--tx-green));
}

.md-typeset h2 {
  font-weight: 700;
}

/* The "Goal · Time" line under each tutorial title. */
.md-typeset .mission {
  padding: 0.7rem 1rem;
  border-left: 0.3rem solid var(--tx-orange);
  border-radius: 0.2rem;
  background: var(--tx-soft);
}

/* The route at the top of each tutorial page. */
.md-typeset .route {
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  color: var(--md-default-fg-color--light);
}

.md-typeset table:not([class]) th {
  background: var(--tx-soft);
}

.md-typeset img {
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.3rem;
}

.md-typeset .md-button--primary {
  background: var(--tx-orange);
  border-color: var(--tx-orange);
  color: #000000;
}

.md-typeset .md-button--primary:hover {
  background: var(--tx-orange-dark);
  border-color: var(--tx-orange-dark);
  color: #ffffff;
}

.md-footer-meta {
  border-top: 1px solid var(--tx-orange);
}

/* ── Diagrams ────────────────────────────────────────────────────────────
   assets/javascripts/diagrams.js wraps each Mermaid diagram and large image
   in a card with a zoom bar; the card scrolls when zoomed in. Taken from the
   Eclipse Tractus-X EDC documentation. */

/* Set where Material sets the scheme colours, so they follow light and dark. */
[data-md-color-scheme] {
  --tx-line: var(--md-default-fg-color--lightest);
  --tx-line-strong: var(--md-default-fg-color--lighter);
  --tx-card: var(--md-default-bg-color);
}

[data-md-color-scheme="slate"] {
  --tx-line: #2e2e2e;
  --tx-line-strong: #4a4a4a;
  --tx-card: #141414;
}

.md-typeset .tx-diagram {
  display: flex;
  flex-direction: column;
  margin: 1.2em 0;
  overflow: hidden;
  border: 1px solid var(--tx-line);
  border-radius: 0.4rem;
  background-color: var(--md-default-bg-color);
}

.tx-diagram__bar {
  display: flex;
  justify-content: flex-end;
  gap: 0.25rem;
  padding: 0.4rem 0.45rem 0;
  /* Controls, not text: quick clicks on + or − must not select the zoom level. */
  user-select: none;
  -webkit-user-select: none;
}

.tx-diagram__button {
  display: inline-grid;
  place-items: center;
  min-width: 1.8rem;
  height: 1.8rem;
  margin: 0;
  padding: 0 0.4rem;
  border: 1px solid var(--tx-line-strong);
  border-radius: 0.2rem;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color--light);
  font-family: var(--md-text-font-family);
  font-size: 0.62rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  /* Repeated taps zoom the diagram, not the page. */
  touch-action: manipulation;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.tx-diagram__button svg {
  width: 1rem;
  height: 1rem;
  fill: currentcolor;
}

.tx-diagram__level {
  min-width: 3rem;
}

.tx-diagram__button:hover:not(:disabled),
.tx-diagram__button:focus-visible {
  border-color: var(--tx-orange);
  background: var(--tx-orange);
  color: #000000;
}

.tx-diagram__button:disabled {
  opacity: 0.4;
  cursor: default;
}

.tx-diagram__viewport {
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0.6rem 0.8rem 0.8rem;
  text-align: center;
  cursor: default;
}

.md-typeset .tx-diagram__viewport > .mermaid {
  margin: 0;
  overflow: visible;
}

.md-typeset .tx-diagram__viewport > img {
  vertical-align: top;
  border: 0;
}

.tx-diagram--zoomed .tx-diagram__viewport {
  max-height: 80vh;
  cursor: grab;
}

.tx-diagram__viewport--dragging {
  cursor: grabbing;
  user-select: none;
}

/* Full screen: the figure covers the page, the bar stays on top. */
.md-typeset .tx-diagram--full {
  position: fixed;
  inset: 0;
  z-index: 10;
  margin: 0;
  border: 0;
  border-radius: 0;
}

.tx-diagram--full .tx-diagram__bar {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--tx-line);
}

.tx-diagram--full .tx-diagram__viewport {
  display: flex;
  flex: 1;
  max-height: none;
}

/* Full width and centred vertically; auto margins still let a zoomed diagram
   scroll to every edge (the script sets an inline width while zoomed). */
.md-typeset .tx-diagram--full .tx-diagram__viewport > * {
  flex: none;
  width: 100%;
  margin: auto;
}

.tx-diagram-open,
.tx-diagram-open body {
  overflow: hidden;
}

/* ── Page navigation ─────────────────────────────────────────────────────
   hooks/page_nav.py turns the "← previous · Home · next →" line at the end
   of each page into Previous on the left, Home in the middle, Next on the
   right. */

.md-typeset .tx-pager {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 0.8rem;
  margin: 2.5rem 0 2rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--tx-line);
}

.md-typeset .tx-pager__link {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--tx-line);
  border-radius: 0.25rem;
  background: var(--tx-card);
  color: var(--md-default-fg-color);
  box-shadow: 0 1px 2px rgb(0 0 0 / 6%);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.md-typeset .tx-pager__link--prev {
  justify-self: start;
}

.md-typeset .tx-pager__link--next {
  grid-column: 3;
  justify-self: end;
  flex-direction: row-reverse;
  text-align: right;
}

.md-typeset .tx-pager__link:hover,
.md-typeset .tx-pager__link:focus-visible {
  border-color: var(--tx-orange);
  color: var(--md-default-fg-color);
  box-shadow: 0 6px 18px rgb(250 160 35 / 18%);
  transform: translateY(-1px);
}

.tx-pager__arrow {
  flex: none;
  width: 2rem;
  height: 2rem;
  padding: 0.4rem;
  border-radius: 0.2rem;
  background: var(--tx-soft);
  fill: var(--tx-orange-dark);
  transition: background-color 0.2s, fill 0.2s, transform 0.2s;
}

[data-md-color-scheme="slate"] .tx-pager__arrow {
  fill: var(--tx-orange);
}

.md-typeset .tx-pager__link:hover .tx-pager__arrow {
  background: var(--tx-orange);
  fill: #000000;
}

.md-typeset .tx-pager__link--prev:hover .tx-pager__arrow {
  transform: translateX(-3px);
}

.md-typeset .tx-pager__link--next:hover .tx-pager__arrow {
  transform: translateX(3px);
}

.tx-pager__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tx-pager__dir {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--md-default-fg-color--light);
}

.tx-pager__title {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35;
}

.tx-pager__middle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  grid-column: 2;
  grid-row: 1;
}

.md-typeset .tx-pager__home {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--tx-line);
  border-radius: 0.25rem;
  color: var(--md-default-fg-color--light);
  font-size: 0.68rem;
  font-weight: 700;
  transition: border-color 0.2s, color 0.2s;
}

.tx-pager__home svg {
  width: 0.9rem;
  height: 0.9rem;
  fill: currentcolor;
}

.md-typeset .tx-pager__home:hover,
.md-typeset .tx-pager__home:focus-visible {
  border-color: var(--tx-orange);
  color: var(--md-default-fg-color);
}

/* Phones: Previous and Next share the row, Home goes below them. */
@media screen and (max-width: 44.9375em) {
  .md-typeset .tx-pager {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .md-typeset .tx-pager__link--next {
    grid-column: 2;
  }

  .tx-pager__middle {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: center;
  }

  .md-typeset .tx-pager__link {
    padding: 0.6rem 0.7rem;
    gap: 0.5rem;
  }
}

/* ── Buttons ─────────────────────────────────────────────────────────────
   Material draws the plain button in the primary colour, which is black here:
   invisible on the dark scheme. Outline it in the text colour instead. */

.md-typeset .md-button {
  border-radius: 0.25rem;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
}

.md-typeset .md-button:not(.md-button--primary) {
  border-color: var(--tx-line-strong);
  color: var(--md-default-fg-color);
}

.md-typeset .md-button:not(.md-button--primary):hover,
.md-typeset .md-button:not(.md-button--primary):focus-visible {
  border-color: var(--tx-orange);
  background: transparent;
  color: var(--md-typeset-a-color);
}

.md-typeset .md-button:hover {
  transform: translateY(-1px);
}

/* ── Header ──────────────────────────────────────────────────────────────
   Logo and title together on the left, search in the middle, the repository
   and the light/dark switch on the right. */

/* Material shows the logo in the header only on wide screens (in the menu
   drawer otherwise); keep that, and centre it with the title. */
@media screen and (min-width: 76.25em) {
  .md-header__button.md-logo {
    display: flex;
    align-items: center;
    margin: 0.2rem 0 0.2rem 0.2rem;
    padding: 0.3rem;
  }

  /* The title close to the logo. [dir] outweighs Material's own
     [dir=ltr] .md-header__title margin of 1rem. */
  [dir] .md-header__title {
    margin-left: 0.2rem;
  }
}

.md-header__button.md-logo img,
.md-header__button.md-logo svg {
  height: 1.6rem;
  width: auto;
}

.md-header__title {
  margin-left: 0.5rem;
}

/* The header's controls: "About this tutorial" and the light/dark switch sit
   together, last in the header, after the repository. Every icon button is
   the same 1.8rem target, centred, with a soft hover. */
.md-header__option[data-md-component="palette"] {
  order: 1;
  align-items: center;
  align-self: center;
  gap: 0.4rem;
  margin: 0 0.2rem 0 0.6rem;
}

.md-header__option[data-md-component="palette"] .md-header__button {
  box-sizing: border-box;
  width: 1.8rem;
  height: 1.8rem;
  margin: 0;
  padding: 0.3rem;
  border-radius: 0.2rem;
  transition: background-color 150ms ease, color 150ms ease;
}

.md-header__option[data-md-component="palette"] .md-header__button svg {
  width: 1.2rem;
  height: 1.2rem;
}

.md-header__option[data-md-component="palette"] .md-header__button:hover,
.md-header__option[data-md-component="palette"] .md-header__button:focus-visible {
  background: rgb(255 255 255 / 12%);
  color: var(--tx-orange);
  opacity: 1;
}

.tx-about-button:popover-open,
.tx-about-button[aria-expanded="true"] {
  color: var(--tx-orange);
}

@media screen and (min-width: 60em) {
  /* Title and repository take equal room on each side, so the search sits
     in the middle. */
  .md-header__title {
    flex: 1 1 0;
  }

  .md-header__source {
    display: flex;
    flex: 1 1 0;
    justify-content: flex-end;
    width: auto;
    max-width: none;
    margin-left: 1rem;
  }

  /* The full repository name, not "eclipse-tractusx/tutorial-r…". */
  .md-source__repository {
    max-width: none;
  }
}

/* ── Home: the intro next to the TestLab logo ──────────────────────────── */

.md-typeset .tx-hero {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.md-typeset .tx-hero__text {
  flex: 1 1 0;
  min-width: 0;
}

.md-typeset .tx-hero__logo {
  flex: none;
  width: 9rem;
  height: auto;
  border: 0;
  border-radius: 0;
}

/* Phones: the logo above the text, smaller. */
@media screen and (max-width: 44.9375em) {
  .md-typeset .tx-hero {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .md-typeset .tx-hero__logo {
    width: 7rem;
  }
}

/* The search field in the header gets a border, orange while it is in use. */
@media screen and (min-width: 60em) {
  .md-search__form {
    border: 1px solid rgb(255 255 255 / 35%);
    border-radius: 0.25rem;
    transition: border-color 0.2s, background-color 0.2s;
  }

  .md-search__form:hover {
    border-color: rgb(255 255 255 / 60%);
  }

  [data-md-toggle="search"]:checked ~ .md-header .md-search__form {
    border-color: var(--tx-orange);
    border-radius: 0.25rem 0.25rem 0 0;
  }
}

/* "About this tutorial": the info button in the header, left of the theme
   switch, and the panel it opens (pages/theme/hooks/about.py). */
.tx-about {
  position: fixed;
  inset: 3.2rem 0.8rem auto auto;
  width: min(22rem, calc(100vw - 1.6rem));
  max-height: calc(100vh - 4.4rem);
  margin: 0;
  padding: 1rem 1.2rem 1.1rem;
  overflow: auto;
  border: 1px solid var(--tx-line-strong);
  border-radius: 0.4rem;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  box-shadow: 0 0.8rem 2rem rgb(0 0 0 / 25%);
  font-size: 0.7rem;
  line-height: 1.5;
}

.tx-about::backdrop {
  background: transparent;
}

.tx-about__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.tx-about h2 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 800;
}

.tx-about__close {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0.2rem;
  color: var(--md-default-fg-color--light);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.tx-about__close:hover,
.tx-about__close:focus-visible {
  background: var(--md-default-fg-color--lightest);
  color: var(--md-default-fg-color);
}

.tx-about__facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin: 0.9rem 0 0;
}

.tx-about dt,
.tx-about h3 {
  margin: 0;
  color: var(--md-default-fg-color--light);
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tx-about h3 {
  margin: 1rem 0 0.45rem;
}

.tx-about dd {
  margin: 0.1rem 0 0;
  font-weight: 600;
}

.tx-about__authors,
.tx-about__history {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tx-about__authors {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem 0.8rem;
}

.tx-about__authors a {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  overflow: hidden;
  color: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-about__authors a:hover {
  color: var(--md-accent-fg-color);
}

.tx-about__authors img {
  flex: none;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: var(--md-default-fg-color--lightest);
}

.tx-about__more {
  color: var(--md-default-fg-color--light);
}

.tx-about__history li + li {
  margin-top: 0.3rem;
}

.tx-about__history span {
  color: var(--md-default-fg-color--light);
}

.tx-about__links {
  margin: 1rem 0 0;
  padding-top: 0.7rem;
  border-top: 1px solid var(--tx-line);
  color: var(--md-default-fg-color--light);
}

/* The menu and search icons get the same 1.8rem target. */
.md-header__inner > label.md-header__button.md-icon {
  box-sizing: border-box;
  width: 1.8rem;
  height: 1.8rem;
  margin: 0.2rem;
  padding: 0.3rem;
  border-radius: 0.2rem;
  transition: background-color 150ms ease;
}

.md-header__inner > label.md-header__button.md-icon svg {
  width: 1.2rem;
  height: 1.2rem;
}

.md-header__inner > label.md-header__button.md-icon:hover {
  background: rgb(255 255 255 / 12%);
}

/* Phones: a smaller title that fits, and breathing room at the right edge. */
@media screen and (max-width: 44.9375em) {
  .md-header {
    height: 3rem;
  }

  .md-header__inner {
    align-items: center;
    height: 3rem;
    padding: 0 0.4rem;
  }

  .md-header__title {
    margin-left: 0.3rem;
    font-size: 0.8rem;
  }

  /* The site name may take two lines rather than end in "…". */
  .md-header__topic .md-ellipsis {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-height: 1.15;
    white-space: normal;
  }

  .md-header__option[data-md-component="palette"] {
    margin: 0 0.2rem;
  }
}

/* The About button is a text label: a thin outline, a low radius, no pill. */
.md-header__option[data-md-component="palette"] .md-header__button.tx-about-button {
  width: auto;
  padding: 0 0.6rem;
  border: 1px solid rgb(255 255 255 / 45%);
  border-radius: 0.15rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  height: 1.6rem;
}
.md-header__option[data-md-component="palette"] .md-header__button.tx-about-button:hover,
.md-header__option[data-md-component="palette"] .md-header__button.tx-about-button:focus-visible,
.tx-about-button:popover-open {
  border-color: var(--tx-orange);
}

/* Glossary tables: a term opened by a link (#term) is marked, and the term
   column stays narrow enough for the meaning to get the room. */
.md-typeset td > span[id]:first-child { scroll-margin-top: 7rem; }
.md-typeset tr:has(> td > span[id]:target) > td { background: color-mix(in srgb, var(--tx-orange) 14%, transparent); }
.md-typeset tr:has(> td > span[id]:first-child) > td:first-child { width: 28%; }

/* The banner of a pull request preview (hooks/preview.py, main.html). */
.md-banner:has(.tx-preview) {
  background: var(--tx-orange);
  color: #000;
}
.md-banner .tx-preview a {
  color: inherit;
  text-decoration: underline;
}
