/* Books on the portfolio: affectUI's shapes over the site's own palette and type.
   For side to load after the site's stylesheet, on the book routes only (/libro/*, /en/book/*).
   Shapes adapted from affectUI's free MIT items: Card (a tray around a card with a 1px ring and a soft shadow),
   Badge (pills with a dot), Code Block (a radius-12 frame with a header strip), Grid Background (a fine grid that
   fades out at the edges). Colors are only the site's tokens; no text is added or changed.
   Motion is short and stops under prefers-reduced-motion. */

.book-layout, .book-header, .book-cards, .book-entry, .book-pager {
  --aff-r: 12px;                       /* inner controls */
  --aff-r-lg: 16px;                    /* cards */
  --aff-r-tray: 20px;                  /* the tray around a card */
  --aff-tray: color-mix(in oklab, var(--surface-sunken) 55%, var(--paper));
  --aff-ring: 0 0 0 1px var(--line), 0 1px 2px rgba(14, 14, 14, .04);
  --aff-ring-hover: 0 0 0 1px var(--line-strong), 0 2px 6px -1px rgba(14, 14, 14, .08);
  --aff-ease: cubic-bezier(.22, 1, .36, 1);
  --aff-grid: color-mix(in srgb, var(--line) 70%, transparent);
}

/* ----- Diagrams and images: a card on a tray ----- */
.book-article .prose img {
  padding: 4px;
  border: 0;
  border-radius: var(--aff-r-tray);
  background: var(--aff-tray);
  box-shadow: 0 0 0 1px var(--line);
}

/* ----- «Actualización 2026» and «Extensión»: a card inside a tray, a fading grid in its corner ----- */
.prose .book-update {
  isolation: isolate;
  overflow: hidden;
  padding: clamp(1.15rem, 3vw, 1.6rem) clamp(1.1rem, 3vw, 1.75rem);
  border: 0;
  border-radius: var(--aff-r-lg);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), 0 0 0 5px var(--aff-tray), 0 0 0 6px var(--line), 0 10px 24px -18px rgba(14, 14, 14, .18);
}
.prose .book-update::before {
  content: "";
  position: absolute;
  inset: 0 0 auto auto;
  z-index: -1;
  width: min(60%, 22rem);
  height: 11rem;
  background-image:
    linear-gradient(to right, var(--aff-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--aff-grid) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(ellipse at 100% 0%, #000 10%, transparent 70%);
  mask-image: radial-gradient(ellipse at 100% 0%, #000 10%, transparent 70%);
  pointer-events: none;
}
.prose .book-update + .book-update { margin-top: 2.2em; }
.book-update-kicker {
  gap: .45rem;
  padding: .22rem .62rem .22rem .5rem;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line-strong);
  font-size: .66rem;
  line-height: 1.2;
}
.book-update-kicker::before { width: 6px; height: 6px; }
.prose .book-update--extension { background: var(--paper); }
.prose .book-update--extension .book-update-kicker { background: var(--paper); box-shadow: 0 0 0 1px var(--line); }

/* ----- Quotes and examples: a card with a rounded bar ----- */
.prose blockquote {
  position: relative;
  padding: 1rem 1.15rem 1rem 1.6rem;
  border: 0;
  border-radius: var(--aff-r-lg);
  background: var(--surface);
  box-shadow: var(--aff-ring);
}
.prose blockquote::before {
  content: "";
  position: absolute;
  inset: .85rem auto .85rem .7rem;
  width: 3px;
  border-radius: 999px;
  background: var(--accent);
}

/* ----- Tables: a card, a quiet header band, rows that light up under the pointer ----- */
.prose table {
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--aff-r-lg);
  background: var(--surface);
  box-shadow: var(--aff-ring);
}
.prose thead th {
  background: var(--aff-tray);
  border-bottom: 0;
}
.prose tbody tr:first-child td { border-top: 1px solid var(--line); }
.prose thead th:first-child { border-top-left-radius: var(--aff-r-lg); }
.prose thead th:last-child { border-top-right-radius: var(--aff-r-lg); }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody tr { transition: background-color 160ms ease; }
.prose tbody tr:hover { background: color-mix(in oklab, var(--surface-sunken) 30%, var(--surface)); }

/* ----- Code: a radius-12 frame with a header strip ----- */
.prose pre {
  position: relative;
  padding: 2.35rem 1.15rem 1rem;
  border-radius: var(--aff-r);
  box-shadow: 0 0 0 1px var(--night-line), 0 10px 24px -18px rgba(14, 14, 14, .35);
}
.prose pre::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1.6rem;
  border-bottom: 1px solid var(--night-line);
  background:
    radial-gradient(circle at 1rem 50%, var(--night-faint) 3px, transparent 3.5px),
    radial-gradient(circle at 1.6rem 50%, var(--night-faint) 3px, transparent 3.5px),
    radial-gradient(circle at 2.2rem 50%, var(--night-faint) 3px, transparent 3.5px);
}
.prose :not(pre) > code {
  border: 0;
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--line);
}

/* ----- The book's index (left) and this chapter's sections (right) ----- */
.book-toc-link { border-radius: var(--aff-r); transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease; }
.book-toc-link.is-current { box-shadow: var(--aff-ring); }
.book-toc-link.is-current .book-toc-n {
  display: inline-grid;
  place-items: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding-inline: .3rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: .72rem;
}
.book-toc-part-label span {
  padding: .05rem .45rem;
  border-radius: 999px;
  box-shadow: 0 0 0 1px var(--line);
}
.book-rail-toc a { border-left-width: 2px; transition: color 160ms ease, border-color 160ms ease; }
.book-rail-toc a.is-active { border-left-color: var(--accent); }

/* ----- Previous and next: cards that lift a little ----- */
.book-pager-link {
  border: 0;
  border-radius: var(--aff-r-tray);
  box-shadow: var(--aff-ring);
  transition: box-shadow 160ms ease, transform 260ms var(--aff-ease);
}
.book-pager-link:hover { border: 0; box-shadow: var(--aff-ring-hover); transform: translateY(-1px); }
.book-pager-dir {
  width: fit-content;
  padding: .18rem .55rem;
  border-radius: 999px;
  box-shadow: 0 0 0 1px var(--line);
}

/* ----- The books' page and each book's list of chapters ----- */
.book-card {
  border: 0;
  border-radius: var(--aff-r-tray);
  box-shadow: var(--aff-ring);
  transition: box-shadow 160ms ease, transform 260ms var(--aff-ease);
}
.book-card:hover, .book-card:focus-visible { border: 0; box-shadow: var(--aff-ring-hover); transform: translateY(-1px); }
.book-entry {
  padding-inline: .6rem;
  border-radius: var(--aff-r);
  transition: background-color 160ms ease;
}
.book-entry:hover { background: var(--surface); }

/* ----- Chips: pills with a ring instead of a border ----- */
.book-header .chip { border: 0; box-shadow: 0 0 0 1px var(--line); }
.book-header .chip--warn { box-shadow: 0 0 0 1px var(--accent-line); }

@media (prefers-reduced-motion: reduce) {
  .book-toc-link, .book-rail-toc a, .book-pager-link, .book-card, .book-entry, .prose tbody tr { transition: none; }
  .book-pager-link:hover, .book-card:hover, .book-card:focus-visible { transform: none; }
}
@media (forced-colors: active) {
  .prose .book-update, .prose blockquote, .prose table, .book-pager-link, .book-card { border: 1px solid CanvasText; }
}
