/* =============================================================================
 * css/pins.css - pinned tools on the home grid
 * =============================================================================
 * Standalone (no build step). Loaded on every route of the shell, so the cost
 * is these rules only. Uses the house tokens from css/themes/tokens.css; no
 * new token invented, no per-skin override needed, and the win in contrast
 * comes from reusing pairs that already pass audits.
 * =========================================================================== */

/* The pin toggle. Absolute in the card's top-right corner, mirroring the
 * ".tc-new" badge but stacked above it and clickable. 30px on desktop,
 * 44px on coarse pointers (house touch-target rule). */
.pin-btn{
  position:absolute;
  top:8px;
  right:8px;
  z-index:3;
  width:30px;
  height:30px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0;
  margin:0;
  border:1px solid transparent;
  border-radius:9px;
  background:transparent;
  color:var(--muted);
  opacity:.5;
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
  transition:opacity .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
}
.pin-btn:hover{
  opacity:1;
  color:var(--fg);
  background:var(--surface-3);
  border-color:var(--line);
}
.pin-btn:focus-visible{
  outline:2px solid var(--focus);
  outline-offset:2px;
  opacity:1;
}
/* Pinned state: accent fill so it reads at a glance, without moving layout. */
.pin-btn[aria-pressed="true"]{
  opacity:1;
  color:var(--accent-ink);
  background:var(--accent);
  border-color:color-mix(in srgb,var(--accent) 55%,transparent);
  box-shadow:0 2px 8px -2px color-mix(in srgb,var(--accent) 55%,transparent);
}
.pin-btn[aria-pressed="true"] svg .pin-body{
  fill:currentColor;
}

/* The ".tc-new" pill shares the top-right corner (css/mobile-layer.css:
 * .tool-card .tc-new{top:10px;right:10px}). Pinning wins the corner; slide
 * the pill left by the pin's width so both survive side by side. Right shift
 * applies only when the pin actually exists on this card. */
.tool-card:has(.pin-btn) .tc-new{
  right:44px;
}

/* The Pinned section. Heading row matches the sibling .cat-label sections,
 * only quieter; the grid reuses the sibling grid classes so auto-fill and
 * gaps stay consistent with Study & AI / Utilities. */
#pinnedWrap{
  margin:0 0 2px;
}
#pinnedWrap[hidden]{
  display:none !important;
}
.pin-note{
  font-weight:400;
  text-transform:none;
  letter-spacing:0;
  color:var(--muted);
  margin-left:.35em;
  opacity:.85;
}

/* Grid entrance for freshly moved cards - same cadence as the home grid, no
 * keyframes redefined, one reused animation. */
@keyframes pinnedCardIn{
  from{ opacity:0; transform:translateY(6px); }
  to{ opacity:1; transform:none; }
}
#pinnedGrid > .tool-card{
  animation:pinnedCardIn var(--dur-slow, .35s) var(--ease-out, ease-out) both;
}
@media (prefers-reduced-motion:reduce){
  .pin-btn{ transition:none; }
  #pinnedGrid > .tool-card{ animation:none; }
}

/* Touch: always visible, never hover-gated, and a full 44px target. */
@media (pointer:coarse), (max-width:820px){
  .pin-btn{
    width:44px;
    height:44px;
    top:6px;
    right:6px;
    opacity:.85;
  }
}

/* Forced-colors: keep the pressed state legible without relying on fill. */
@media (forced-colors:active){
  .pin-btn[aria-pressed="true"]{
    outline:2px solid Highlight;
    outline-offset:1px;
  }
}

/* Print: tools are a list there; a pin affordance on paper is noise. */
@media print{
  .pin-btn{ display:none; }
}

/* ============================================================
   PINS FILTER CHIP - Pinned-only toggle (js/pins-filter.js)
   ============================================================ */
.pins-filter-row{
  display:flex;
  justify-content:center;
  margin:10px auto 0;
  max-width:600px;
}
.pins-filter-row[hidden]{ display:none !important; }
.pins-filter-btn{
  display:inline-flex;
  align-items:center;
  gap:7px;
  padding:7px 14px;
  border-radius:99px;
  border:1px solid var(--line);
  background:var(--surface-2);
  color:var(--muted);
  font:600 11px var(--mono, ui-monospace, monospace);
  letter-spacing:.08em;
  text-transform:uppercase;
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
  transition:color .15s ease, background .15s ease, border-color .15s ease;
}
.pins-filter-btn:hover{ color:var(--fg); border-color:var(--line); background:var(--surface-3); }
.pins-filter-btn:focus-visible{ outline:2px solid var(--focus); outline-offset:2px; }
.pins-filter-btn[aria-pressed="true"]{
  color:var(--accent-ink);
  background:var(--accent);
  border-color:color-mix(in srgb,var(--accent) 55%,transparent);
  box-shadow:0 2px 8px -2px color-mix(in srgb,var(--accent) 55%,transparent);
}
/* Hidden targets: the two sibling .fallback-grid grids and their
 * .cat-label rows. #pinnedGrid is ALSO a .fallback-grid, so it is excluded
 * by id; the pinned and recent sections are protected the same way, and
 * the Study Desk and the Recent row are untouched. The home search pill and
 * its chip stay interactive so the user can clear the filter quickly. */
#view-home.pins-only .fallback-grid:not(#pinnedGrid){
  display:none !important;
}
#view-home.pins-only .cat-label{
  display:none !important;
}
#view-home.pins-only #pinnedWrap .cat-label,
#view-home.pins-only #recentsWrap .cat-label{
  display:block !important;
}
@media print{ .pins-filter-row{ display:none !important; } }
@media (prefers-reduced-motion:reduce){ .pins-filter-btn{ transition:none; } }

/* ============================================================
   PIN REORDER - drag indicator + live region (js/pins.js)
   ============================================================ */
#pinnedGrid > .tool-card[draggable="true"]{
  cursor:grab;
}
#pinnedGrid > .tool-card.pin-dragging{
  opacity:.55;
  cursor:grabbing;
}
/* Drop indicator: an accent stripe on the card that would accept the drop
 * (left edge for before, right edge for after the last card). */
#pinnedGrid > .tool-card.pin-drop-before{
  box-shadow:-4px 0 0 0 var(--accent), var(--shadow-inset), 0 4px 16px -12px rgba(0,0,0,.6);
}
#pinnedGrid > .tool-card.pin-drop-after{
  box-shadow:4px 0 0 0 var(--accent), var(--shadow-inset), 0 4px 16px -12px rgba(0,0,0,.6);
}
/* Visually-hidden aria-live announcer for reorder announcements. */
.pins-reorder-live{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0 0 0 0);
  clip-path:inset(50%);
  white-space:nowrap;
  border:0;
}
@media print{ .pins-reorder-live{ display:none; } }
