/* Page-level layout: wrapper, header, navigation, footer, hero, grids. */

.wrapper {
  inline-size: min(100% - 2 * var(--gutter), var(--content-max));
  margin-inline: auto;
}

.flow > * + * {
  margin-block-start: var(--flow-space, var(--space-s));
}

/* ---- Skip links: the first focusable elements on every page ------------------ */
/* Every link is positioned at the same spot of the full-width list, so whichever
 * one is focused appears in the same place; the list items have no size of
 * their own and play no part in the layout. */
.skip-links {
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  z-index: 100;
  margin: 0;
  padding: 0;
  list-style: none;
}

.skip-link {
  position: absolute;
  inset-block-start: var(--space-2xs);
  inset-inline-start: var(--space-2xs);
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link:focus {
  inline-size: auto;
  max-inline-size: calc(100% - 2 * var(--space-2xs));
  block-size: auto;
  clip-path: none;
  white-space: normal;
  padding: var(--space-2xs) var(--space-s);
  background: var(--bg-inverse);
  color: var(--text-inverse);
  font-weight: 650;
  text-decoration: none;
  border-radius: var(--radius-s);
}

/* ---- Header ------------------------------------------------------------------- */
.site-header {
  background: var(--bg-raised);
  border-block-end: 1px solid var(--border);
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-m);
  padding-block: var(--space-xs);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  min-block-size: var(--target-comfortable);
  color: var(--text);
  text-decoration: none;
  font-size: var(--text-1);
  font-weight: 750;
  font-stretch: 106%;
  letter-spacing: -0.02em;
  line-height: 1;
  border-radius: var(--radius-s);
}

.brand:hover {
  color: var(--accent-strong);
}

/* The name sits on two lines next to a larger mark. Each line is trimmed to
 * cap height and baseline (text-box-trim), so the block is centred on the
 * glyphs themselves rather than on font metrics, which Chrome and Firefox
 * read differently for Archivo. Browsers without text-box-trim get the
 * metric-based layout plus a small downward nudge that matches Firefox. */
.brand__name {
  display: flex;
  flex-direction: column;
  gap: 0.12em;
}

.brand__name > span {
  text-box-trim: trim-both;
  text-box-edge: cap alphabetic;
}

@supports (text-box-trim: trim-both) {
  .brand__name {
    gap: 0.38em;
  }
}

@supports not (text-box-trim: trim-both) {
  .brand__name {
    translate: 0 0.07em;
  }
}

.brand__mark {
  inline-size: 3rem;
  block-size: auto;
  color: var(--accent);
  flex: none;
}

/* The logo is two masks (the ring and the cross) over two fixed rectangles
 * that carry the paint, one per shape and sized to its box, so each shape runs
 * the whole gradient from the accent in the top-left corner to the amber mix
 * in the bottom-right, and the paint stays put while the shapes turn on hover.
 * The gradient is the one the card accents use, defined once in the header
 * (#brand-gradient); the colour after the url() is the fallback when the
 * reference is missing. Elsewhere (the footer watermark) the rectangles keep
 * currentColor. */
.brand__mark :is(.brand-logo__ring, .brand-logo__cross) {
  fill: url("#brand-gradient") var(--accent);
}

/* The hover turns the mask content, not the SVG, so the gradient does not turn
 * with it; the origin is the centre of the 800-unit view box. */
.brand-logo__shape {
  transform-origin: 400px 400px;
}

.brand-gradient-defs {
  position: absolute;
  inline-size: 0;
  block-size: 0;
  overflow: hidden;
}

#brand-gradient stop:first-child {
  stop-color: var(--accent);
}

#brand-gradient stop:last-child {
  stop-color: color-mix(in oklch, var(--accent) 40%, var(--amber));
}

/* The hover rotation is movement, so it runs only without a reduced-motion preference. */
@media (prefers-reduced-motion: no-preference) {
  .brand-logo__shape {
    transition: rotate var(--duration-slow) var(--ease-out);
  }

  .brand:hover .brand-logo__shape {
    rotate: 90deg;
  }
}

.brand__name-accent {
  color: var(--accent);
}

/* The tools row is a query container: the settings collapse to the gear and the
 * search shrinks according to the row's own width, not the viewport's, which
 * is what differs between the three languages. */
.site-header__tools {
  container: tools / inline-size;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2xs) var(--space-xs);
  margin-inline-start: auto;
}

/* ---- Primary navigation --------------------------------------------------------- */
.site-nav {
  display: contents;
}

.site-nav__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3xs) var(--space-2xs);
}

.site-nav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-block-size: var(--target-comfortable);
  padding-inline: var(--space-xs);
  border-radius: var(--radius-pill);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}

.site-nav__link:hover {
  background: var(--bg-tint);
  color: var(--accent-strong);
}

.site-nav__link[aria-current]::after {
  content: "";
  position: absolute;
  inset-inline: var(--space-xs);
  inset-block-end: 0.35rem;
  block-size: 3px;
  border-radius: var(--radius-pill);
  background: var(--accent);
}

.site-nav__link[aria-current] {
  color: var(--accent-strong);
}

/* Forced colours replace every background with Canvas, which erased the
 * underline (and the dot of the mobile menu, which shares this pseudo-element).
 * Opting the marker out and painting it in the link's own forced colour keeps
 * the current item visible in Windows high-contrast themes. */
@media (forced-colors: active) {
  .site-nav__link[aria-current]::after {
    background: currentColor;
    forced-color-adjust: none;
  }
}

/* From 42em the header is a grid: the brand in the first column, the menu and
 * the tools row stacked in the second, so the search field starts under the
 * first menu item and stretches to the settings. The definite second column
 * also stops Firefox from shrinking the menu onto two lines, which it did when
 * the menu was a flex item sized from its own wrapping content. (This block
 * follows the .site-header__tools rule on purpose: it overrides its auto margin.) */
@media (width >= 42em) {
  .site-header__inner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "brand nav"
      ". tools";
    column-gap: var(--space-m);
    row-gap: var(--space-xs);
  }

  .site-header .brand {
    grid-area: brand;
  }

  /* A query container only here: in the narrow flex layout inline-size
   * containment would collapse the nav when JavaScript is off. */
  .site-nav__nav {
    grid-area: nav;
    container: nav / inline-size;
  }

  .site-header__tools {
    grid-area: tools;
    margin-inline-start: 0;
  }
}

/* When the menu no longer fits on one line it becomes a balanced 3 + 3 grid
 * instead of a greedy 5 + 1 wrap. The thresholds are the measured one-line
 * widths in the menu's own em (20 px at full size): Slovak 31.3em, Czech
 * 31.9em, English 34.3em, plus a margin. The widest three-item row is 18.7em,
 * which still fits at 42em, where the disclosure menu takes over; a third
 * line never happens. */
@container nav (width < 32.5em) {
  .site-nav__list {
    display: grid;
    grid-template-columns: repeat(3, max-content);
  }
}

@container nav (width < 35em) {
  .site-nav__list:lang(en) {
    display: grid;
    grid-template-columns: repeat(3, max-content);
  }
}

@media (width < 42em) {
  .brand {
    font-size: var(--text-0);
  }

  .brand__mark {
    inline-size: 2.5rem;
  }

  .site-header__tools {
    inline-size: 100%;
    margin-inline-start: 0;
    order: 10;
    justify-content: space-between;
  }
}

/* ---- Page structure ----------------------------------------------------------------- */
.site-main {
  padding-block: var(--space-xl) var(--space-3xl);
}

.page-header {
  --flow-space: var(--space-s);
  padding-block-end: var(--space-l);
  margin-block-end: var(--space-l);
  border-block-end: 1px solid var(--border);
  position: relative;
}

.page-header::after {
  content: "";
  position: absolute;
  inset-block-end: -1px;
  inset-inline-start: 0;
  inline-size: 5rem;
  block-size: 3px;
  background: var(--accent);
  border-radius: var(--radius-pill);
}

.page-title {
  max-inline-size: min(22ch, var(--measure));
}

/* ---- Breadcrumb bar ------------------------------------------------------------------ */
/* Full width under the header, it sticks to the top of the viewport. The bar is
 * the scroll-state container and the styling sits on its surface, as the query
 * applies to descendants. At rest the surface is plain, on the page background;
 * once stuck it turns to frosted glass over the content. Engines without
 * scroll-state queries keep the plain bar, which stays readable. The z-index
 * sits below the search popup (50), so the popup wins while both are visible. */
.breadcrumb-bar {
  position: sticky;
  inset-block-start: 0;
  z-index: 40;
  container-type: scroll-state;
}

.breadcrumb-bar__surface {
  background: var(--bg);
  border-block-end: 1px solid transparent;
  transition:
    background-color var(--duration-base) var(--ease-out),
    border-color var(--duration-base) var(--ease-out);
}

@container scroll-state(stuck: top) {
  .breadcrumb-bar__surface {
    background: color-mix(in oklch, var(--bg) 72%, transparent);
    backdrop-filter: blur(10px) saturate(1.4);
    border-color: color-mix(in oklch, var(--border) 60%, transparent);
  }
}

/* Engines without scroll-state queries (Firefox, 2026-09) cannot tell when the
 * bar is stuck, so the plain bar keeps its hairline all the time. */
@supports not (container-type: scroll-state) {
  .breadcrumb-bar__surface {
    border-color: color-mix(in oklch, var(--border) 60%, transparent);
  }
}

/* Less transparency on request: the plain bar even when stuck. Forced colours:
 * the system canvas with a system border. */
@media (prefers-reduced-transparency: reduce) {
  @container scroll-state(stuck: top) {
    .breadcrumb-bar__surface {
      background: var(--bg);
      backdrop-filter: none;
    }
  }
}

@media (forced-colors: active) {
  .breadcrumb-bar__surface {
    background: Canvas;
    border-color: CanvasText;
  }
}

/* Focus and in-page anchors land below the bar (2.4.11 Focus Not Obscured). */
:root:has(.breadcrumb-bar) {
  scroll-padding-block-start: calc(var(--target-comfortable) + var(--space-2xs));
}

.breadcrumb {
  display: flex;
  align-items: center;
  min-block-size: var(--target-comfortable);
  font-size: var(--text--1);
}

.breadcrumb__list {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumb__item {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  min-inline-size: 0;
}

/* Everything but the current page keeps its width; the current page gives way. */
.breadcrumb__item:not(:last-child) {
  flex: none;
}

/* The separator is decoration: CSS alt text keeps it out of the accessible name. */
.breadcrumb__item + .breadcrumb__item::before {
  content: "›" / "";
  color: var(--text-muted);
}

.breadcrumb__link {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--target-min);
  color: var(--text-muted);
  text-decoration-color: transparent;
  text-underline-offset: 0.2em;
  transition:
    color var(--duration-fast) var(--ease-out),
    text-decoration-color var(--duration-fast) var(--ease-out);
}

.breadcrumb__link:hover {
  color: var(--accent-strong);
  text-decoration-color: currentColor;
}

/* Home is the mark in the link colour, no gradient; its name is hidden text. */
.breadcrumb__logo {
  block-size: 1.5em;
  inline-size: auto;
}

/* The current page is the last crumb, plain text; on a short line it is cut with
 * an ellipsis, the heading below carries the full title. */
.breadcrumb__current {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text);
}

/* ---- Hero (home) --------------------------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  margin-block-start: calc(-1 * var(--space-xl));
  padding-block: var(--space-2xl) var(--space-xl);
  background:
    radial-gradient(60rem 30rem at 0% 0%, color-mix(in oklch, var(--bg-tint) 80%, transparent), transparent 70%),
    linear-gradient(to bottom, var(--bg-raised), var(--bg));
  border-block-end: 1px solid color-mix(in oklch, var(--border) 55%, transparent);
}

/* Whatever follows the hero keeps a clear distance from its divider. */
.hero + * {
  margin-block-start: var(--space-2xl);
}

.hero__inner {
  --flow-space: var(--space-m);
  position: relative;
}

.hero__title {
  font-size: var(--text-4);
  max-inline-size: var(--measure);
}

.hero__lede {
  font-size: var(--text-1);
  color: var(--text-muted);
  max-inline-size: var(--measure);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.home > .wrapper + .wrapper {
  margin-block-start: var(--space-2xl);
}

/* ---- Grids ---------------------------------------------------------------------------- */
/* Three columns at most: the minimum column width never drops below a third of
 * the row, so wide screens get three, narrower ones two, then one. */
.card-grid {
  --card-min: 15rem;
  display: grid;
  gap: var(--space-m);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, max(var(--card-min), calc((100% - 2 * var(--space-m)) / 3))), 1fr));
}

/* ---- Footer ---------------------------------------------------------------------------- */
.site-footer {
  position: relative;
  overflow: hidden;
  background: var(--bg-sunken);
  border-block-start: 1px solid var(--border);
  padding-block: var(--space-xl) var(--space-l);
  font-size: var(--text--1);
  color: var(--text-muted);
}

.site-footer__inner {
  display: grid;
  gap: var(--space-l) var(--space-xl);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  position: relative;
}

.site-footer .brand {
  font-size: var(--text-0);
}

.site-footer__tagline {
  font-weight: 550;
  color: var(--text);
}

.site-footer__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
}

.site-footer__list a {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--target-min);
  color: var(--text);
}

.site-footer__copyright {
  color: var(--text);
}

.site-footer__mark {
  position: absolute;
  inset-inline-end: -4rem;
  inset-block-end: -6rem;
  inline-size: 22rem;
  color: var(--accent);
  opacity: 0.06;
  pointer-events: none;
}

/* ---- View transitions between pages (Chromium; gated by reduced motion) ----------------- */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }

  /* The overlay is opaque in the page colour and the two pages fade through it,
   * the old one out, then the new one in: in dark mode the change passes through
   * the dark background and never through a white canvas (the default cross-fade
   * let the canvas show while the new page was still painting). */
  ::view-transition {
    background-color: var(--bg);
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    mix-blend-mode: normal;
    animation-duration: var(--duration-fast);
  }

  ::view-transition-old(root) {
    animation-name: view-fade-out;
    animation-timing-function: ease-in;
  }

  ::view-transition-new(root) {
    animation-name: view-fade-in;
    animation-delay: var(--duration-fast);
    animation-timing-function: ease-out;
  }

  @keyframes view-fade-out {
    to {
      opacity: 0;
    }
  }

  @keyframes view-fade-in {
    from {
      opacity: 0;
    }
  }

  .page-title,
  .hero__title {
    view-transition-name: page-title;
  }
}
