/* "A few of my favourite things" (/things/). Colours come from the theme tokens, so they follow Admin > Theme colours. */
main.page.wide.things-page { max-width: 1100px; }
.tg-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Draft notice (only you see the page while it's in draft) */
.tg-draft { margin: 0 0 24px; padding: 10px 14px; border-radius: 12px; background: #ffd84d; color: #3d2f00; font-weight: 700; font-size: .9rem; }

/* Category filter */
.tg-filter { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.tg-chip { display: inline-block; padding: 6px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink); font-size: .85rem; font-weight: 600; text-decoration: none; transition: border-color .15s ease, background-color .15s ease; }
.tg-chip:hover { border-color: var(--accent); }
.tg-chip.is-on { background: var(--accent); border-color: var(--accent); color: #0f1626; }
.tg-chip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Tools row: categories on the left, sort on the right (stacked when there's no room) */
.tg-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin: 0 0 8px; }
.tg-tools .tg-filter { margin: 0; }
.tg-sort { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-left: auto; }
.tg-sort-label { margin-right: 2px; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.tg-chip-sort { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; font-size: .8rem; }
.tg-chip-sort svg { width: 14px; height: 14px; flex: none; }
@media (max-width: 640px) { .tg-sort { margin-left: 0; } }

/* Grid */
.tg-grid { list-style: none; margin: 32px 0 0; padding: 0; display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); grid-auto-flow: row dense; }
.tg-card {
  --glow-c: var(--glow, var(--accent));   /* the glow colour: the item's own, or the theme accent */
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.tg-card[hidden] { display: none; }
.tg-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--glow-c, var(--accent)) 45%, var(--line)); box-shadow: 0 18px 40px -26px rgba(20, 33, 61, .45); }

/* The stage: a square where any shape fits (an app icon, a bottle, a book, a box), with a soft glow behind it */
.tg-stage {
  position: relative; isolation: isolate; aspect-ratio: 1 / 1; display: grid; place-items: center; overflow: hidden;
}
.tg-stage::before {   /* the glow */
  /* a soft halo that fades out completely well before the edges of the image area */
  content: ""; position: absolute; z-index: -1; left: 50%; top: 50%; width: 82%; height: 82%; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle closest-side, color-mix(in srgb, var(--glow-c) 62%, transparent), color-mix(in srgb, var(--glow-c) 30%, transparent) 50%, color-mix(in srgb, var(--glow-c) 8%, transparent) 80%, transparent 100%);
  opacity: 1; transition: opacity .25s ease, transform .25s ease;
}
.tg-stage img {
  /* a fixed box inside the square: tall, wide and square images all fit whole */
  position: absolute; top: 13%; left: 14%; width: 72%; height: 72%; object-fit: contain;
  /* follows the shape of a transparent PNG, not its rectangle */
  filter: drop-shadow(0 14px 18px rgba(15, 22, 38, .22));
  transition: transform .25s ease;
}
.tg-card:hover .tg-stage img { transform: translateY(-4px) scale(1.04); }
.tg-card:hover .tg-stage::before { transform: translate(-50%, -50%) scale(1.06); }

.tg-body { display: flex; flex-direction: column; gap: 6px; padding: 4px 20px 20px; flex: 1; }
.tg-cat { color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.tg-title { margin: 0; font-size: 1.1rem; font-weight: 800; line-height: 1.25; letter-spacing: -.01em; }
.tg-text { margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.5; }
.tg-link {
  align-self: flex-start; margin-top: auto; padding-top: 8px;
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--ink); font-size: .9rem; font-weight: 600; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px;
}
.tg-link svg { width: 15px; height: 15px; flex: none; transition: transform .15s ease; }
.tg-link:hover svg { transform: translate(2px, -2px); }
.tg-link:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* Mosaic: some cards are bigger, taller or wider (data-size, given by position: tg_size() / things.js).
   Only from 640px, where the grid always has at least 2 columns. */
@media (min-width: 640px) {
  .tg-card[data-size="big"]  { grid-column: span 2; grid-row: span 2; }
  .tg-card[data-size="tall"] { grid-row: span 2; }
  .tg-card[data-size="wide"] { grid-column: span 2; flex-direction: row; }
  .tg-card[data-size="big"] .tg-stage,
  .tg-card[data-size="tall"] .tg-stage { aspect-ratio: auto; flex: 1 1 auto; min-height: 260px; }
  .tg-card[data-size="big"] .tg-body,
  .tg-card[data-size="tall"] .tg-body { flex: 0 0 auto; }   /* the image area takes the extra height, not the text */
  .tg-card[data-size="big"] .tg-stage::before { width: 70%; height: 70%; }
  .tg-card[data-size="big"] .tg-body { padding: 4px 28px 28px; }
  .tg-card[data-size="big"] .tg-title { font-size: 1.55rem; }
  .tg-card[data-size="big"] .tg-text { font-size: 1.02rem; max-width: 52ch; }
  .tg-card[data-size="wide"] .tg-stage { flex: 0 0 46%; aspect-ratio: auto; min-height: 220px; }
  .tg-card[data-size="wide"] .tg-body { justify-content: center; padding: 22px 26px 22px 4px; }
  .tg-card[data-size="wide"] .tg-title { font-size: 1.3rem; }
  .tg-card[data-size="wide"] .tg-link { margin-top: 6px; }
}

/* Phones: one column, so a less tall image area */
@media (max-width: 520px) {
  .tg-grid { gap: 16px; }
  .tg-stage { aspect-ratio: 4 / 3; }
}

.tg-empty { margin: 32px 0 0; color: var(--muted); }
.tg-note { max-width: 70ch; margin: 48px 0 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; line-height: 1.55; }

@media (prefers-color-scheme: dark) {
  .tg-stage::before { opacity: .85; }
  .tg-stage img { filter: drop-shadow(0 14px 22px rgba(0, 0, 0, .45)); }
}
@media (prefers-reduced-motion: reduce) {
  .tg-card, .tg-stage::before, .tg-stage img, .tg-link svg, .tg-chip { transition: none; }
  .tg-card:hover, .tg-card:hover .tg-stage img { transform: none; }
}
