/* Tools page (tools/index.qmd). Cards sit in a grid; tools.js opens one into a
   full-width row (name | icon | details) and animates the reflow. */

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  grid-auto-flow: row dense; /* later cards fill the gap an opened card leaves */
  gap: 1.5rem;
  align-items: start;
}

.tool-card {
  position: relative;
  border: 1px solid #dee2e6;
  border-radius: 12px;
  padding: 1.25rem 1rem 1rem;
  text-align: center;
  background: #fff;
}
.tool-card > p { margin-bottom: 0.75rem; }

.tool-name { font-size: 1.25rem; font-weight: 600; overflow-wrap: anywhere; }
.tool-name a { text-decoration: none; color: inherit; }
.tool-name a:hover { text-decoration: underline; }

img.tool-icon {
  width: 96px;
  height: 96px;
  object-fit: contain;
  border-radius: 20px;
}
.tool-icon-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  font-size: 64px;
  color: #276dc3;
  text-decoration: none;
}

.tool-card details { text-align: left; }
.tool-card summary {
  text-align: center;
  cursor: pointer;
  color: #6c757d;
  font-size: 0.85rem;
}

/* ---- opened card: one full row, name | icon | details ---- */
.tool-card.open {
  grid-column: 1 / -1;
  display: grid;
  /* name | icon | details; the icon column is sized by the icon's fixed width */
  grid-template-columns: minmax(9rem, 1fr) auto minmax(0, 60%);
  grid-template-rows: auto 1fr;
  column-gap: 2rem;
  padding: 1.5rem 3rem 1.5rem 1.5rem;
  text-align: left;
}
.tool-card.open > p:has(.tool-name)  { grid-area: 1 / 1; }
.tool-card.open > p:has(.tool-icon)  { grid-area: 1 / 2 / 3 / 3; }
.tool-card.open > p:not(:has(.tool-name, .tool-icon)) { grid-area: 2 / 1; color: #6c757d; }
.tool-card.open > details { grid-area: 1 / 3 / 3 / 4; }
.tool-card.open summary { display: none; }
.tool-card.open img.tool-icon,
.tool-card.open .tool-icon-glyph { width: 128px; height: 128px; }
.tool-card.open .tool-icon-glyph { font-size: 88px; }
.tool-card.open details > :last-child { margin-bottom: 0; }
/* Bullets hang in the margin so list text lines up with paragraph text. */
.tool-card details ul { padding-left: 0; }

.tool-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  border: 0;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #6c757d;
  cursor: pointer;
}
.tool-close:hover { color: #212529; }
.tool-card:not(.open) .tool-close { display: none; }

/* Narrow screens: stack the opened card instead of three columns. */
@media (max-width: 700px) {
  .tool-card.open {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    padding: 1.25rem 2.5rem 1.25rem 1.25rem;
  }
  .tool-card.open > p:has(.tool-icon)  { grid-area: 1 / 1 / 3 / 2; }
  .tool-card.open > p:has(.tool-name)  { grid-area: 1 / 2; }
  .tool-card.open > p:not(:has(.tool-name, .tool-icon)) { grid-area: 2 / 2; }
  .tool-card.open > details { grid-area: 3 / 1 / 4 / 3; margin-top: 0.75rem; }
  .tool-card.open img.tool-icon,
  .tool-card.open .tool-icon-glyph { width: 72px; height: 72px; }
  .tool-card.open .tool-icon-glyph { font-size: 48px; }
}

/* Reflow animation (View Transitions; browsers without it just snap). */
::view-transition-group(*) { animation-duration: 0.3s; animation-timing-function: ease; }
/* Let card snapshots keep their aspect while the box resizes, instead of stretching. */
::view-transition-old(*),
::view-transition-new(*) { height: 100%; width: auto; object-fit: none; object-position: top left; }

/* A screenshot in place of a square icon: keep its aspect. */
img.tool-icon.tool-shot,
.tool-card.open img.tool-icon.tool-shot {
  width: auto;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid #dee2e6;
}
img.tool-icon.tool-shot { height: 96px; }
.tool-card.open img.tool-icon.tool-shot { width: 220px; height: auto; }
@media (max-width: 700px) {
  .tool-card.open img.tool-icon.tool-shot { width: 120px; }
}
