/* /repositorio (demo index): hero stage, animated mosaic and the information sections below it.
   Scoped to .repo-*, uses the site's own colour variables.
   Rules (same as the site's _motion.scss):
   - everything is visible and usable with no JS and with reduced motion; motion lives under
     `@media (prefers-reduced-motion: no-preference)` and, when it needs the script, under `html.js`;
   - every motion is finite and starts from the visitor's action or from the page entering the viewport;
   - only transform / opacity / clip-path are animated (plus one grid-row track inside a tile's own plate);
   - CSS owns a property OR the script does, never both on the same element (cell = reveal, tile = tilt,
     par = scroll, img = zoom/pointer, plus the individual `scale` property for the reveal settle). */

/* ---------- hero ---------- */
.repo-hero .page-title { font-size: clamp(2.5rem, 1.1rem + 4.6vw, 4.75rem); }
.repo-lead { max-width: 30rem; }
.repo-hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.75rem; margin-top: 2rem; }
.repo-quiet-link { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 2.75rem; color: var(--bs-body-color); font-weight: 500; text-decoration: underline; text-decoration-color: var(--bs-primary); text-decoration-thickness: 2px; text-underline-offset: 0.3em; }
.repo-quiet-link:hover { color: var(--bs-primary-text, #9e4a29); }
.repo-quiet-link:focus-visible, .repo-chip:focus-visible, .repo-tile:focus-visible { outline: 3px solid var(--bs-secondary); outline-offset: 3px; border-radius: 0.375rem; }
.repo-proof { display: grid; gap: 0.5rem; margin: 1.75rem 0 0; padding: 0; color: #4a3428; font-size: 0.9375rem; }
.repo-proof li { display: flex; align-items: baseline; gap: 0.5rem; }
.repo-proof i { flex: none; color: var(--bs-primary-text, #9e4a29); font-size: 1.05em; vertical-align: -0.12em; }

/* hero stage: two columns of real demo screenshots, decorative */
.repo-stage { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; align-items: start; }
.repo-stage-col { display: grid; gap: 0.75rem; }
.repo-stage-col:nth-child(2) { margin-top: 2.5rem; }
.repo-piece { position: relative; height: var(--h); margin: 0; overflow: hidden; border-radius: 1.125rem; background: var(--t-bg); transform: rotate(var(--r, 0deg)); box-shadow: 0 1px 2px rgb(74 52 40 / 0.1), 0 22px 40px -26px rgb(74 52 40 / 0.65); }
.repo-piece img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: left top; }
.repo-piece-chip { position: absolute; left: 0.6rem; bottom: 0.6rem; max-width: calc(100% - 1.2rem); padding: 0.3rem 0.7rem; border-radius: 50rem; background: var(--t-bg); color: var(--t-ink); font-size: 0.75rem; font-weight: 600; line-height: 1.3; box-shadow: 0 0 0 1px rgb(255 255 255 / 0.12); }
@media (max-width: 991.98px) {
  .repo-stage-col .repo-piece:nth-child(3) { display: none; }
  .repo-piece { height: calc(var(--h) * 0.72); }
}
@media (max-width: 575.98px) { .repo-stage-col:nth-child(2) { margin-top: 1.5rem; } }

/* ---------- section headings ---------- */
.repo-head { max-width: 40rem; margin-bottom: 2.25rem; }
.repo-head .lead { color: #6e5a4b; }

/* ---------- filter ---------- */
.repo-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1.5rem; margin-bottom: 1.5rem; }
.repo-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.repo-filters[hidden] { display: none; }
.repo-chip { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 2.75rem; padding: 0.4rem 1rem; border: 1px solid var(--bs-border-color); border-radius: 50rem; background: #fff; color: var(--bs-body-color); font: inherit; font-size: 0.9375rem; font-weight: 500; line-height: 1.2; cursor: pointer; }
.repo-chip:hover { border-color: var(--bs-secondary); }
.repo-chip[aria-pressed="true"] { background: var(--bs-secondary); border-color: var(--bs-secondary); color: #fff; }
.repo-chip-n { display: inline-grid; place-items: center; min-width: 1.5rem; height: 1.5rem; padding: 0 0.35rem; border-radius: 50rem; background: var(--bs-light); color: #6e5a4b; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.repo-chip[aria-pressed="true"] .repo-chip-n { background: rgb(255 255 255 / 0.18); color: #fff; }
.repo-count { color: #6e5a4b; font-variant-numeric: tabular-nums; }
.repo-caption { display: flex; align-items: flex-start; gap: 0.6rem; max-width: 52rem; margin: 1.75rem 0 0; color: #6e5a4b; font-size: 0.875rem; }
.repo-caption i { flex: none; margin-top: 0.1rem; font-size: 1.125rem; color: var(--bs-primary-text, #9e4a29); }
.repo-caption strong { color: var(--bs-body-color); }

/* ---------- mosaic: grid and slots ----------
   <640px: one column, every tile is its screenshot with the demo's own colours and all its information below.
   640-1023px: two columns of the same stacked tiles (an odd last tile spans both).
   >=1024px: 12 columns; with exactly 8 demos a hand-placed bento (two large tiles on a diagonal), with any
   other number of demos (filter active, "soon" demos) a 7/5/5/7 rhythm. Slots come from data-i / data-pos /
   data-last, written by the server and re-written by the script when the filter changes. */
.repo-mosaic { display: grid; gap: 1rem; padding: 0; margin: 0; }
.repo-cell { position: relative; min-width: 0; border-radius: 1.375rem; }
.repo-cell[hidden] { display: none; }
.repo-cell:hover, .repo-cell:focus-within { z-index: 2; }

.repo-tile { position: relative; display: block; height: 100%; overflow: hidden; border-radius: inherit; background: var(--t-bg); color: var(--t-ink); text-decoration: none; isolation: isolate; box-shadow: 0 1px 2px rgb(74 52 40 / 0.1), 0 18px 36px -26px rgb(74 52 40 / 0.55); container-type: inline-size; }
.repo-tile:hover { color: var(--t-ink); }
.repo-tile-media { position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden; background: var(--t-bg); }
.repo-tile-par { position: absolute; inset: -6% 0; }
.repo-tile-par img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: left top; }
.repo-tile-icon { position: absolute; inset: 0; margin: auto; width: 4rem; height: 4rem; fill: none; stroke: var(--t-mute); stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round; }
.repo-tile.is-soon .repo-tile-media::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(135deg, transparent 0 14px, rgb(74 52 40 / 0.06) 14px 15px); }

/* The plate: the demo's own colours and, on mobile, simply the text block under the screenshot */
.repo-tile-plate { position: relative; display: flex; flex-direction: column; gap: 0.4rem; padding: 1.1rem 1.1rem 1.25rem; background: var(--t-bg); color: var(--t-ink); }
.repo-tile-plate > * { flex: none; }
.repo-tile-eyebrow { display: block; padding-right: 3rem; color: var(--t-mute); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; line-height: 1.3; }
.repo-tile-pages::before { content: "·"; margin: 0 0.45rem; }
.repo-tile-name { display: block; padding-right: 3rem; font-size: 1.25rem; font-weight: 600; line-height: 1.2; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.repo-tile-line { display: block; color: var(--t-ink); font-size: 0.875rem; line-height: 1.45; }
.repo-tile-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.2rem; }
.repo-tile-chip { padding: 0.2rem 0.6rem; border: 1px solid color-mix(in srgb, var(--t-ink) 34%, transparent); border-radius: 50rem; font-size: 0.75rem; line-height: 1.35; white-space: nowrap; }
.repo-tile-go { position: absolute; top: 1rem; right: 1rem; display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 50%; background: var(--t-ac); color: var(--t-ac-ink); font-size: 1.25rem; }
.repo-tile-soon { align-self: flex-start; margin-top: 0.3rem; padding: 0.3rem 0.7rem; border-radius: 50rem; border: 1px solid currentColor; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }

/* "more": pages included, typography, colours and the call to action. Closed on hover-capable large screens
   until hover/focus; always open on touch and on mobile (nothing important hides behind a hover). */
.repo-tile-more { display: grid; grid-template-rows: 1fr; }
.repo-tile-more-in { min-height: 0; overflow: hidden; display: block; }
.repo-tile-facts { display: grid; gap: 0.35rem; margin-top: 0.35rem; padding-top: 0.8rem; border-top: 1px solid color-mix(in srgb, var(--t-ink) 22%, transparent); font-size: 0.8125rem; line-height: 1.4; color: var(--t-mute); }
.repo-tile-fact b { color: var(--t-ink); font-weight: 600; margin-right: 0.25rem; }
.repo-tile-swatches { display: inline-flex; gap: 0.3rem; vertical-align: -0.2em; }
.repo-tile-swatches i { width: 1.1rem; height: 1.1rem; border-radius: 50%; box-shadow: 0 0 0 1px color-mix(in srgb, var(--t-ink) 40%, transparent); }
.repo-tile-cta-label { display: block; margin-top: 0.85rem; font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--t-ink); }
.repo-tile-cta-label::after { content: " →"; }
.repo-tile:hover .repo-tile-go, .repo-tile:focus-visible .repo-tile-go { transform: translate(1px, -1px); }
.repo-tile:hover { box-shadow: 0 1px 2px rgb(74 52 40 / 0.1), 0 34px 60px -28px rgb(74 52 40 / 0.7); }

/* mobile: alternate the screenshot crop a little so the column has a rhythm */
@media (max-width: 639.98px) {
  .repo-cell[data-pos="2"] .repo-tile-media, .repo-cell[data-pos="4"] .repo-tile-media { aspect-ratio: 4 / 3; }
}

/* tablet: two columns, same stacked tiles (screenshot, then all the information) */
@media (min-width: 640px) {
  .repo-mosaic { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .repo-cell[data-last][data-pos="1"], .repo-cell[data-last][data-pos="3"] { grid-column: 1 / -1; }
}

/* desktop: 12 columns */
@media (min-width: 1024px) {
  .repo-mosaic { grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: clamp(5.5rem, 7vw, 7.25rem); }
  /* the screenshot fills the tile, the plate floats over its lower part */
  .repo-tile-media { position: absolute; inset: 0; aspect-ratio: auto; border-radius: inherit; }
  .repo-tile-plate { position: absolute; left: 0.75rem; right: 0.75rem; bottom: 0.75rem; max-height: calc(100% - 1.5rem); overflow: hidden; border-radius: 1rem; padding: 0.95rem 1rem 1.05rem; box-shadow: 0 0 0 1px rgb(255 255 255 / 0.1), 0 10px 24px -12px rgb(0 0 0 / 0.5); }
  .repo-tile-go { top: 0.85rem; right: 0.85rem; }
  /* any number of demos except 8: 7 / 5 / 5 / 7 */
  .repo-cell[data-pos="1"], .repo-cell[data-pos="4"] { grid-column: span 7; grid-row: span 5; }
  .repo-cell[data-pos="2"], .repo-cell[data-pos="3"] { grid-column: span 5; grid-row: span 5; }
  /* a lone last tile (odd number of demos) takes the middle 8 columns instead of leaving a hole */
  .repo-cell[data-last][data-pos="1"], .repo-cell[data-last][data-pos="3"] { grid-column: 3 / span 8; }
  /* exactly 8 demos: the bento */
  .repo-mosaic[data-count="8"] .repo-cell[data-i="1"] { grid-column: 1 / span 6; grid-row: 1 / span 7; }
  .repo-mosaic[data-count="8"] .repo-cell[data-i="2"] { grid-column: 7 / span 6; grid-row: 1 / span 3; }
  .repo-mosaic[data-count="8"] .repo-cell[data-i="3"] { grid-column: 7 / span 3; grid-row: 4 / span 4; }
  .repo-mosaic[data-count="8"] .repo-cell[data-i="4"] { grid-column: 10 / span 3; grid-row: 4 / span 4; }
  .repo-mosaic[data-count="8"] .repo-cell[data-i="5"] { grid-column: 1 / span 6; grid-row: 8 / span 3; }
  .repo-mosaic[data-count="8"] .repo-cell[data-i="6"] { grid-column: 1 / span 3; grid-row: 11 / span 4; }
  .repo-mosaic[data-count="8"] .repo-cell[data-i="7"] { grid-column: 4 / span 3; grid-row: 11 / span 4; }
  .repo-mosaic[data-count="8"] .repo-cell[data-i="8"] { grid-column: 7 / span 6; grid-row: 8 / span 7; }
  /* hover-capable screens: the plate shows the essentials and opens up for the rest */
  @media (hover: hover) {
    .repo-tile-more { grid-template-rows: 0fr; }
    .repo-tile:hover .repo-tile-more, .repo-tile:focus-visible .repo-tile-more { grid-template-rows: 1fr; }
  }
}
/* narrow tiles (the small squares of the bento): keep the plate compact until it opens */
@media (min-width: 1024px) { @container (max-width: 340px) {
  .repo-tile-name { font-size: 1.0625rem; }
  .repo-tile-line { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .repo-tile-chip:nth-child(n+3) { display: none; }
  .repo-tile:hover .repo-tile-chip:nth-child(n+3), .repo-tile:focus-visible .repo-tile-chip:nth-child(n+3) { display: inline-block; }
} }
@container (min-width: 520px) {
  .repo-tile-name { font-size: 1.5rem; }
  .repo-tile-line { font-size: 0.9375rem; }
}
/* ---------- what every demo includes ---------- */
.repo-incl { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.repo-incl li { padding: 1.5rem; border-radius: 1.125rem; background: #fff; border: 1px solid var(--bs-border-color); }
.repo-incl li p { color: #6e5a4b; }
.repo-incl-icon { display: grid; place-items: center; width: 3rem; height: 3rem; margin-bottom: 1rem; border-radius: 0.875rem; background: var(--bs-light); color: var(--bs-primary-text, #9e4a29); font-size: 1.5rem; }
@media (min-width: 640px) { .repo-incl { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .repo-incl { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; } }

/* ---------- how it works ---------- */
.repo-steps { display: grid; gap: 2rem 3rem; grid-template-columns: 1fr; counter-reset: none; }
.repo-steps li { position: relative; padding-top: 1.25rem; border-top: 2px solid var(--bs-secondary); }
.repo-steps p { color: #6e5a4b; max-width: 24rem; }
.repo-step-n { display: block; margin-bottom: 0.75rem; font-size: clamp(2.5rem, 2rem + 2vw, 3.5rem); line-height: 1; font-weight: 600; letter-spacing: -0.04em; color: var(--bs-primary-text, #9e4a29); font-variant-numeric: tabular-nums; }
@media (min-width: 768px) { .repo-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- call to action ---------- */
.repo-cta-text { max-width: 36rem; color: rgb(255 255 255 / 0.86); }
.repo-cta-direct { color: rgb(255 255 255 / 0.78); font-size: 0.875rem; }
.repo-cta-links { display: grid; gap: 0.25rem; }
.repo-cta-links a { display: inline-flex; align-items: center; gap: 0.6rem; min-height: 2.75rem; color: #fff; text-decoration: underline; text-underline-offset: 0.25em; text-decoration-color: rgb(255 255 255 / 0.5); overflow-wrap: anywhere; }
.repo-cta-links a:hover { text-decoration-color: #fff; color: #fff; }
.repo-cta-links a:focus-visible { outline: 3px solid #fff; outline-offset: 3px; border-radius: 0.375rem; }
.repo-cta-links i { font-size: 1.25rem; }

@media (forced-colors: active) {
  .repo-tile, .repo-tile-plate, .repo-chip, .repo-piece { border: 1px solid CanvasText; }
  .repo-tile-go { border: 1px solid ButtonText; }
}

/* ---------- motion (only when the visitor allows it) ---------- */
@media (prefers-reduced-motion: no-preference) {
  /* hero stage: the pieces fly in from the right and settle, pure CSS, transform only (they can be the LCP) */
  html.js .repo-piece { animation: repo-fly 1s cubic-bezier(0.16, 1, 0.3, 1) both; animation-delay: calc(var(--d0, 0s) + 0.25s + var(--i) * 90ms); }
  @keyframes repo-fly { from { transform: translate(2.5rem, 2rem) rotate(calc(var(--r, 0deg) * 4 + 4deg)) scale(0.94); } }

  .repo-chip { transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease; }

  /* Reveal. The cell (observed by the script) owns a small rise; the tile inside owns the clip-path wipe.
     The observed element must not be clipped itself: Chrome's IntersectionObserver counts a clipped target as
     not visible, so the wipe lives on the child. Transform and clip-path only, never opacity. The failsafes
     show everything after 3 s if the script never runs. */
  html.js .repo-cell:not(.is-in) { transform: translateY(1.75rem); animation: repo-failsafe-cell 0s 3s forwards; }
  html.js .repo-cell:not(.is-in) .repo-tile { clip-path: inset(100% 0 0 0 round 1.375rem); animation: repo-failsafe-tile 0s 3s forwards; }
  html.js .repo-cell:not(.is-in) .repo-tile-par img { scale: 1.12; transition: none; }
  html.js .repo-cell.is-in { transition: transform 0.75s cubic-bezier(0.16, 1, 0.3, 1) var(--d, 0ms); }
  html.js .repo-cell.is-in .repo-tile { clip-path: inset(0 0 0 0 round 1.375rem); transition: clip-path 0.75s cubic-bezier(0.16, 1, 0.3, 1) var(--d, 0ms), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.45s cubic-bezier(0.16, 1, 0.3, 1); }
  html.js .repo-cell.is-in .repo-tile-par img { transition: scale 1.1s cubic-bezier(0.16, 1, 0.3, 1) var(--d, 0ms), transform 0.9s cubic-bezier(0.16, 1, 0.3, 1); }
  /* once settled the clip is released, so the hover shadow and lift are not cut off */
  html.js .repo-cell.is-done { transition: none; }
  html.js .repo-cell.is-done .repo-tile { clip-path: none; transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.45s cubic-bezier(0.16, 1, 0.3, 1); }
  @keyframes repo-failsafe-cell { to { transform: none; } }
  @keyframes repo-failsafe-tile { to { clip-path: none; } }

  /* hover and focus: lift + zoom; the tilt (fine pointer only) is driven by --mx / --my from the script */
  .repo-tile { transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.45s cubic-bezier(0.16, 1, 0.3, 1); }
  .repo-tile-par img { transition: transform 0.9s cubic-bezier(0.16, 1, 0.3, 1); }
  .repo-tile-go { transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1); }
  .repo-tile-more { transition: grid-template-rows 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
  .repo-tile:hover .repo-tile-par img, .repo-tile:focus-visible .repo-tile-par img { transform: scale(1.06); }
  .repo-tile:not(.is-soon):active { transform: scale(0.985); }
}
@media (prefers-reduced-motion: no-preference) and (hover: hover) and (pointer: fine) {
  .repo-tile:not(.is-soon):hover { transform: perspective(1100px) rotateX(calc(var(--my, 0) * -2deg)) rotateY(calc(var(--mx, 0) * 2.6deg)) scale(1.018); }
  .repo-tile:not(.is-soon):hover .repo-tile-par img { transform: translate3d(calc(var(--mx, 0) * -10px), calc(var(--my, 0) * -7px), 0) scale(1.07); }
}

/* Scroll-linked motion (Chromium for now; elsewhere everything is simply static): the screenshot drifts inside
   its tile, and the two hero columns drift apart a little as the hero scrolls away. */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    html.js .repo-tile-par { animation: repo-par linear both; animation-timeline: view(); animation-range: cover; }
    @keyframes repo-par { from { transform: translateY(-4.5%); } to { transform: translateY(4.5%); } }
    @media (min-width: 992px) {
      html.js .repo-stage-col:nth-child(1) { animation: repo-drift-a linear both; animation-timeline: scroll(root block); animation-range: 0 60vh; }
      html.js .repo-stage-col:nth-child(2) { animation: repo-drift-b linear both; animation-timeline: scroll(root block); animation-range: 0 60vh; }
      @keyframes repo-drift-a { to { transform: translateY(-1.5rem); } }
      @keyframes repo-drift-b { to { transform: translateY(1.5rem); } }
    }
  }
}
