/* =====================================================================
   Cards: neater shape, theme hover, optional animated glow border.
   Loaded on index.html and explore.html after the theme files.
   - Shape applies to Small cards only (Large keeps the original look).
   - Glow is switched on/off in Dashboard > Appearance > 5. Card border light
     (html[data-card-glow=off] turns it off). Colours come from the theme.
   ===================================================================== */
:root{--cg:var(--c-glow)}
:root[data-mode="light"]{--cg:var(--c-accent)}
@property --cg-a{syntax:"<angle>";inherits:false;initial-value:0deg}

/* 1. Smaller, neater rectangles: tighter corners, balanced picture box */
html:not([data-cards=large]) :is(.tool-card,.svc,.quiz-card,.res-card,.project-card){border-radius:12px}
html:not([data-cards=large]) :is(.tool-card,.svc,.quiz-card) .card-media,
html:not([data-cards=large]) #projectsGrid .card-media-container{border-radius:8px}
@media (min-width:521px){
  html:not([data-cards=large]) :is(.tools-grid,.quiz-grid,.svc-grid){grid-template-columns:repeat(auto-fill,minmax(200px,260px));justify-content:start}
}
@media (min-width:768px){
  html:not([data-cards=large]) #projectsGrid{grid-template-columns:repeat(auto-fill,minmax(200px,260px));justify-content:start}
}

/* 2. Hover: the same border + glow the theme already uses on glass panels */
@media (hover:hover){
  :is(.tool-card,.svc,.quiz-card,.res-card):hover{border-color:var(--t-line-hi) !important;box-shadow:var(--t-hover-glow) !important}
  .landing .project-card.glass-frame:hover{border-color:var(--t-line-hi) !important;box-shadow:var(--t-hover-glow) !important}
}

/* 3. Animated light that travels once around the border and loops */
html:not([data-card-glow=off]) :is(.tool-card,.svc,.quiz-card,.res-card,.project-card){position:relative}
html:not([data-card-glow=off]) :is(.tool-card,.svc,.quiz-card,.res-card,.project-card)::before,
html:not([data-card-glow=off]) :is(.tool-card,.svc,.quiz-card,.res-card,.project-card)::after{
  content:"";position:absolute;inset:-1px;border-radius:inherit;padding:1.5px;pointer-events:none;
  background:conic-gradient(from var(--cg-a),transparent 0 90%,color-mix(in srgb,var(--cg) 45%,transparent) 96%,var(--cg) 100%);
  -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);
  animation:cgSpin 7s linear infinite;opacity:.85}
html:not([data-card-glow=off]) :is(.tool-card,.svc,.quiz-card,.res-card,.project-card)::before{filter:blur(5px);opacity:.55;padding:3px}
@keyframes cgSpin{to{--cg-a:360deg}}
@media (prefers-reduced-motion:reduce){
  :is(.tool-card,.svc,.quiz-card,.res-card,.project-card)::before,
  :is(.tool-card,.svc,.quiz-card,.res-card,.project-card)::after{animation:none;display:none}
}

/* 4. Picture-first cards (Small size): narrower card, big image, less text.
      Badges sit on the picture, description is 2 lines, buttons are compact. */
html:not([data-cards=large]) :is(.tools-grid,.quiz-grid,.svc-grid){grid-template-columns:repeat(auto-fill,minmax(min(100%,180px),1fr));gap:16px;justify-content:stretch}
html:not([data-cards=large]) :is(.tool-card,.quiz-card,.svc){position:relative;padding:8px 8px 10px;gap:6px}
html:not([data-cards=large]) :is(.tool-card,.quiz-card,.svc,.res-card) .card-media{height:auto;aspect-ratio:4/3;margin:0;border-radius:9px}
html:not([data-cards=large]) :is(.tool-card,.quiz-card) > header{position:absolute;top:14px;left:14px;right:14px;z-index:2;pointer-events:none}
html:not([data-cards=large]) :is(.tool-card,.quiz-card) > header .badge{font-size:.6rem;padding:3px 7px;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}
html:not([data-cards=large]) :is(.tool-card,.quiz-card,.svc) h3{font-size:.9rem;line-height:1.25;margin:2px 4px 0}
html:not([data-cards=large]) .tool-card .cat{font-size:.58rem;margin:0 4px}
html:not([data-cards=large]) :is(.tool-card,.quiz-card,.svc) p{font-size:.76rem;line-height:1.4;margin:0 4px;-webkit-line-clamp:2;line-clamp:2;display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden}
html:not([data-cards=large]) :is(.tool-card,.quiz-card) .actions{margin:auto 4px 0;gap:5px}
html:not([data-cards=large]) :is(.tool-card,.quiz-card,.svc) .btn{padding:6px 10px;font-size:.7rem;min-height:30px}
/* the whole tool card opens the tool, so "Learn more" only shows when there is no Open button */
html:not([data-cards=large]) .tool-card .actions .btn-primary ~ a[href^="#/tool/"]{display:none}
html:not([data-cards=large]) .svc .svc-foot{margin:auto 4px 0}
@media (max-width:520px){
  html:not([data-cards=large]) :is(.tools-grid,.quiz-grid,.svc-grid){grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  html:not([data-cards=large]) :is(.tool-card,.quiz-card,.svc,.res-card) .card-media{height:auto}
}
/* home page cards: same idea */
html:not([data-cards=large]) #projectsGrid{grid-template-columns:repeat(auto-fill,minmax(min(100%,180px),1fr)) !important;gap:16px !important;justify-content:stretch}
html:not([data-cards=large]) #projectsGrid .project-card{padding:8px 8px 10px !important}
html:not([data-cards=large]) #projectsGrid .card-media-container{height:auto !important;aspect-ratio:4/3;margin-bottom:8px !important}
html:not([data-cards=large]) #projectsGrid .project-card h3{font-size:.9rem !important;margin-top:6px !important}
html:not([data-cards=large]) #projectsGrid .project-card p{font-size:.76rem !important;margin-top:4px !important;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
html:not([data-cards=large]) #projectsGrid .project-card > div:last-child{margin-top:8px !important;padding-top:6px !important}

/* 5. Resources and blog cards follow the same picture-first small size */
html:not([data-cards=large]) .res-grid{grid-template-columns:repeat(auto-fill,minmax(min(100%,180px),1fr));gap:16px;justify-content:stretch}
html:not([data-cards=large]) .res-card{padding:8px 8px 10px;gap:6px}
html:not([data-cards=large]) .res-card h3{font-size:.9rem;margin:2px 4px 0}
html:not([data-cards=large]) .res-card p{font-size:.76rem;line-height:1.4;margin:0 4px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
html:not([data-cards=large]) .res-card .tags{margin:0 4px}
@media (max-width:520px){html:not([data-cards=large]) .res-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}}
