/*
 * Tactile surfaces for the home pages: the bento grid of "Today's tools" and "Top starred on GitHub",
 * the pointer spotlight and tilt, and the mini-terminal of the tool of the day.
 * Works with public/assets/visual-engine.js. Rules kept here:
 *  - nothing is hidden when JavaScript is off: without the script the lists are a plain grid with the first card wide;
 *  - only logical properties (inline-size, margin-inline, padding-inline, inset-inline), so Arabic (right to left) and English mirror each other;
 *  - monospace is used only for commands and GitHub numbers.
 * The colours come from the page's own variables (--panel, --line, --accent, --gold), so light and dark themes both work.
 */
.bento { grid-auto-flow: dense; container-type: inline-size; }
.bento > .card { position: relative; isolation: isolate; --mouse-x: 50%; --mouse-y: 50%; --tilt-x: 0deg; --tilt-y: 0deg; }
/* a container query: the featured card reacts to the width of its own list. The media query after it is for browsers without container queries. */
@container (min-width: 620px) {
  .bento > .card:first-child { grid-column: span 2; padding-block: 26px; padding-inline: 28px; background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 13%, var(--panel)), var(--panel) 62%); }
  .bento > .card:first-child h3 { font-size: 1.5rem; line-height: 1.45; }
  .bento > .card:first-child > p { max-inline-size: 46em; }
}
@supports not (container-type: inline-size) {
  @media (min-width: 680px) {
    .bento > .card:first-child { grid-column: span 2; padding-block: 26px; padding-inline: 28px; background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 13%, var(--panel)), var(--panel) 62%); }
    .bento > .card:first-child h3 { font-size: 1.5rem; line-height: 1.45; }
    .bento > .card:first-child > p { max-inline-size: 46em; }
  }
}
/* GitHub numbers are the one place besides commands where monospace is used */
.bento .bd.st { font-family: ui-monospace, Consolas, monospace; font-variant-numeric: tabular-nums; }

/* ---------- pointer spotlight and tilt (the script adds .bento-card and sets --mouse-x / --mouse-y) ---------- */
.bento > .card.bento-card { transform: perspective(900px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y)); transition: transform .28s ease, border-color .2s ease, box-shadow .28s ease; will-change: transform; }
.bento-card::before, .bento-card::after { content: ""; position: absolute; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .28s ease; }
/* a ring of light on the border that follows the pointer */
.bento-card::before { inset: -1px; padding: 1.5px; z-index: 1; background: radial-gradient(260px circle at var(--mouse-x) var(--mouse-y), var(--accent), transparent 68%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); }
/* a soft glow under the content */
.bento-card::after { inset: 0; z-index: -1; background: radial-gradient(340px circle at var(--mouse-x) var(--mouse-y), color-mix(in srgb, var(--accent) 16%, transparent), transparent 62%); }
.bento-card.is-lit::before, .bento-card.is-lit::after { opacity: 1; }
.bento-card.is-lit { box-shadow: 0 22px 44px -28px rgb(0 0 0 / .7); }

/* ---------- mini-terminal: the command of the tool of the day, typed out ---------- */
.mini-term { margin-block: 10px 6px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #031026; direction: ltr; text-align: start; }
html[data-theme=light] .mini-term { background: #0B1B3B; }
.mini-term-bar { display: flex; align-items: center; gap: 6px; padding-block: 7px; padding-inline: 12px; border-block-end: 1px solid rgb(255 255 255 / .09); }
.mini-term-bar i { inline-size: 10px; block-size: 10px; border-radius: 50%; background: #FF6B7A; }
.mini-term-bar i:nth-child(2) { background: #FFC857; } .mini-term-bar i:nth-child(3) { background: #59D39B; }
.mini-term-bar span { margin-inline-start: 6px; color: #9FB0D6; font: 400 13px/1.4 Cairo, Tahoma, system-ui, sans-serif; }
.mini-term-bar button { margin-inline-start: auto; background: none; border: 1px solid rgb(255 255 255 / .22); color: #F2F6FF; border-radius: 8px; padding-block: 2px; padding-inline: 10px; font: 700 12px/1.5 Cairo, sans-serif; cursor: pointer; }
.mini-term-bar button:hover { border-color: #3FB8FF; }
.mini-term-body { min-block-size: 4.6em; padding-block: 12px; padding-inline: 14px; color: #F2F6FF; font: 14px/1.65 ui-monospace, Consolas, monospace; overflow-wrap: anywhere; white-space: pre-wrap; }
.mini-term-body .mt-prompt { color: #59D39B; } .mini-term-body .mt-note { color: #9FB0D6; }
.mini-term-body .mt-caret { display: inline-block; inline-size: .55em; block-size: 1.05em; margin-inline-start: 1px; vertical-align: text-bottom; background: #3FB8FF; animation: mt-blink 1s steps(2, start) infinite; }
@keyframes mt-blink { to { visibility: hidden; } }
/* the card's ordinary command row stays for the Copy button; its text is already shown in the terminal above */
.bento-card.has-term > .cmd code { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.bento-card.has-term > .cmd { justify-content: flex-end; background: none; border: 0; padding: 0; margin-block: 0; }

@media (prefers-reduced-motion: reduce) {
  .bento > .card.bento-card { transform: none; transition: none; }
  .mini-term-body .mt-caret { animation: none; }
}
@media (hover: none) { .bento > .card.bento-card { transform: none; } }
