/**
 * Copyright 2026 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://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.
 */

/* ===================================================================
   COMPONENTS — the reusable blocks pages are built from.

   Owns: card grids, model badges, figures, video embeds, model-card
         headers, step walkthroughs.
   Does NOT own: colours or scales (gemma.css), page grid (layout.css),
         code blocks (content.css), chat tokens (tokens.css),
         animation (motion.css).

   Every component is documented with live examples in
   docs/contributing/components.md — add examples there when you add one.
   =================================================================== */

/* -------------------------------------------------------------------
   Card grid
   `.card-grid` + `.card`. `.cookbook-grid`/`.cookbook-card` are kept as
   aliases because converter output and existing pages emit them.
   ------------------------------------------------------------------- */
.md-typeset .card-grid,
.md-typeset .cookbook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  gap: var(--gemma-space-4);
  margin: var(--gemma-space-5) 0 var(--gemma-space-6);
}

/* The shared box recipe: --gemma-surface, a --gemma-border hairline, --gemma-radius-md,
   and border-to-accent plus --gemma-shadow-sm on hover. Only padding varies by density.
   These used --md-default-fg-color--lighter, an 0.32-alpha black that drew a far heavier
   line than every other box on the site. */
.md-typeset .card,
.md-typeset .cookbook-card {
  display: flex;
  flex-direction: column;
  padding: var(--gemma-space-4) var(--gemma-space-5);
  border: 1px solid var(--gemma-border);
  border-radius: var(--gemma-radius-md);
  background: var(--gemma-box-surface);
  text-decoration: none !important;
  color: inherit;
}

.md-typeset .card:has(.card-icon) {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--gemma-space-3);
  align-content: start;
}

.md-typeset .card:has(.card-icon) .card-icon {
  grid-row: 1 / span 2;
}

.md-typeset a.card:hover,
.md-typeset a.cookbook-card:hover {
  border-color: var(--gemma-accent);
  box-shadow: var(--gemma-shadow-sm);
}

.md-typeset .card-title,
.md-typeset .cookbook-card-title {
  margin: 0 0 var(--gemma-space-1);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--gemma-text-secondary);
}

/* External-link arrow, inline with the title. */
.md-typeset .card-ext,
.md-typeset .cookbook-card-ext {
  margin-left: 0.3em;
  font-size: 0.85em;
  font-weight: 400;
  opacity: 0.5;
}

.md-typeset .card-desc,
.md-typeset .cookbook-card-desc {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--gemma-text-muted);
}

@media screen and (max-width: 37.5em) {
  .md-typeset .card-grid,
  .md-typeset .cookbook-grid {
    grid-template-columns: 1fr;
  }
}

/* -------------------------------------------------------------------
   Model badges
   Inline chips for size, modality and quantization. Content comes from
   data/models.yml so a badge can never disagree with the tables.
   ------------------------------------------------------------------- */
.md-typeset .badge {
  display: inline-block;
  padding: 0.1em 0.55em;
  border: 1px solid var(--md-default-fg-color--lighter);
  border-radius: var(--gemma-radius-pill);
  font-size: 0.75em;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  color: var(--md-default-fg-color--light);
}

.md-typeset .badge + .badge {
  margin-left: var(--gemma-space-1);
}

/* Emphasised badge — the current model, the recommended option. */
.md-typeset .badge--accent {
  border-color: var(--gemma-accent);
  color: var(--gemma-accent);
}

/* Signals a capability the selected model does *not* have. */
.md-typeset .badge--muted {
  opacity: 0.55;
  text-decoration: line-through;
}

/* -------------------------------------------------------------------
   Figure
   A framed image with a caption. Use for diagrams; plain screenshots
   can stay as bare images.
   ------------------------------------------------------------------- */
.md-typeset .figure {
  margin: var(--gemma-space-5) 0;
  text-align: center;
}

.md-typeset .figure img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: var(--gemma-radius-md);
}

.md-typeset .figure figcaption,
.md-typeset .figure .figure-caption {
  margin-top: var(--gemma-space-2);
  font-size: 0.8rem;
  color: var(--md-default-fg-color--light);
}

/* Dark-mode image swap: mark the pair and only one shows.
   (Phase 1 groundwork; variants are produced per-diagram as needed.) */
[data-md-color-scheme="default"] .md-typeset .only-dark,
[data-md-color-scheme="slate"] .md-typeset .only-light {
  display: none;
}

/* -------------------------------------------------------------------
   Steps
   A numbered walkthrough where each step is a titled block. Built on an
   ordered list so it degrades to a plain list without CSS.
   ------------------------------------------------------------------- */
.md-typeset .steps {
  counter-reset: gemma-step;
  padding-left: 0;
  list-style: none;
}

.md-typeset .steps > li {
  position: relative;
  margin-left: 0;
  padding-left: var(--gemma-space-7);
  padding-bottom: var(--gemma-space-4);
}

.md-typeset .steps > li::before {
  counter-increment: gemma-step;
  content: counter(gemma-step);
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--gemma-radius-pill);
  background: var(--gemma-accent-fill);
  color: var(--gemma-white);
  font-size: 0.8rem;
  font-weight: 700;
}

/* Connecting rail between steps. */
.md-typeset .steps > li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 0.875rem;
  top: 1.75rem;
  bottom: 0;
  width: 1px;
  background: var(--md-default-fg-color--lighter);
}

/* -------------------------------------------------------------------
   Video embeds
   Full content width, 16:9. Replaces the plain `[Video](youtube…)`
   links the upstream docs used.
   ------------------------------------------------------------------- */
.md-typeset .video-embed {
  position: relative;
  width: 100%;
  margin: var(--gemma-space-5) 0;
  aspect-ratio: 16 / 9;
}

.md-typeset .video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

@supports not (aspect-ratio: 16 / 9) {
  .md-typeset .video-embed {
    height: 0;
    padding-bottom: 56.25%;
  }
}

/* -------------------------------------------------------------------
   Model-card header
   Centres the resource links and the License/Authors line, matching the
   `<p align="center">` upstream uses. Alignment only.
   ------------------------------------------------------------------- */
.md-typeset .model-card-header {
  text-align: center;
}

@media screen and (max-width: 44.9375em) {
  .md-typeset .model-card-header {
    text-align: left;
  }
}
