/* indexcard.css — title in picture + hover digest/#age, non-breaking with your existing layout */
/* Index styles - Light Theme */
:root{
  --bg:#ffffff;
  --card:#ffffff;
  --fg:#111827;
  --muted:#6b7280;
  --accent:#111827;
  --shadow: 0 8px 24px rgba(17, 24, 39, 0.06);
  --card-gradient-start:#ffffff;
  --card-gradient-end:#f7f7f7;
  --card-border:#e5e7eb;
  --card-strong-shadow:0 18px 44px rgba(17, 24, 39, 0.08);
}
*{box-sizing:border-box} 
html,body{height:100%}
body{
  margin:0;
  background: var(--bg);
  color:var(--fg);
  font:16px/1.6 system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,Noto Sans,sans-serif;
}

/* Search + pagination */
.indexcard-block{ display:block; }


.indexcard-controls{
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:12px;
  padding:20px clamp(16px,4vw,40px) 0;
}

.indexcard-controls .indexcard-search{
  width:100%;
  max-width:340px;
  flex:1 1 280px;
}

.indexcard-sort-form{
  margin:0;
  margin-left:auto;
  display:flex;
  gap:8px;
  align-items:center;
}

.indexcard-sort__btn{
  width:40px;
  height:40px;
  min-width:40px;
  border-radius:12px;
  border:1px solid #e5e7eb;
  background:linear-gradient(145deg, #ffffff 0%, #f5f5f5 70%);
  color:#111827;
  font-size:1.05rem;
  font-weight:800;
  cursor:pointer;
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.04), 0 4px 10px rgba(0,0,0,0.04);
  transition: box-shadow .15s ease, border-color .15s ease, transform .1s ease, background .15s ease, color .15s ease;
}

.indexcard-sort__btn:hover{
  border-color:#d1d5db;
  box-shadow:0 0 0 3px rgba(17,24,39,.06);
  background:#fff;
  transform:translateY(-1px);
}

.indexcard-sort__btn--active{
  background:linear-gradient(145deg, #f3f4f6 0%, #ffffff 70%);
  border-color:#d1d5db;
  box-shadow:0 0 0 3px rgba(17,24,39,.08);
  color:#111827;
}

.indexcard-controls .indexcard-search input{
  width:100%;
  padding:10px 14px;
  border-radius:10px;
  border:1px solid #e5e7eb;
  background:#fff;
  color:var(--fg);
  outline:none;
  box-shadow: var(--shadow);
  transition: border-color .2s ease, box-shadow .2s ease;
}

.indexcard-controls .indexcard-search input:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(17,24,39,.12);
}

.searchbar input{
  width:100%;
  max-width:320px;
  padding:10px 14px;
  border-radius:10px;
  border:1px solid #e5e7eb;
  background:#fff;
  color:var(--fg);
  outline:none;
  box-shadow: var(--shadow);
  transition: border-color .2s ease, box-shadow .2s ease;
}

.searchbar input:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(17,24,39,.12);
}

.indexcard-controls .indexcard-search input::placeholder,
.searchbar input::placeholder{
  color:#888;
}

.indexcard-pagination{
  padding:16px clamp(16px,4vw,40px) 40px;
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:8px;
}

.indexcard-pagination .page-info{
  font-weight:600;
  color:var(--muted);
  margin-right:auto;
}

.indexcard-pagination button{
  border:none;
  background:#fff;
  color:var(--muted);
  border-radius:999px;
  padding:8px 14px;
  font-weight:600;
  box-shadow: var(--shadow);
  cursor:pointer;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}

.indexcard-pagination button:hover:not(:disabled){
  background:var(--accent);
  color:#fff;
  transform:translateY(-1px);
}

.indexcard-pagination button:disabled{
  opacity:.45;
  cursor:not-allowed;
}

.indexcard-pagination button.is-active{
  background:var(--accent);
  color:#fff;
}

.indexcard-pagination .ellipsis{
  color:var(--muted);
  font-weight:700;
  padding:0 4px;
}

/* Grid layout */
.indexcard-groups{
  display:block;
}

.indexcard-group{
  margin-bottom:32px;
}

.indexcard-group[hidden]{
  display:none !important;
}

.indexcard-group:last-child{
  margin-bottom:0;
}

.indexcard-headings{
  padding:0 clamp(16px,4vw,40px);
  margin-bottom:12px;
  display:flex;
  flex-direction:column;
  gap:4px;
}

.indexcard-headings[hidden]{
  display:none !important;
}

.indexcard-headings .indexcard-heading{
  margin:0;
  font-weight:700;
  color:var(--fg);
}

.indexcard-headings .indexcard-heading.level-1{
  font-size:1.35rem;
}

.indexcard-headings .indexcard-heading.level-2{
  font-size:1.15rem;
  color:var(--muted);
}

.indexcard-headings .indexcard-heading.level-3,
.indexcard-headings .indexcard-heading.level-4,
.indexcard-headings .indexcard-heading.level-5{
  font-size:1rem;
  color:var(--muted);
}

.grid{
  padding:8px clamp(18px,4vw,44px) 44px;
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  align-items:start;
  gap:22px;
}

.indexcard-block .card.indexcard{
  margin:0;
}

/* Reset global stacked card spacing so every indexcard aligns to the grid */
.indexcard-block .grid .card{
  margin-top:0 !important;
}

/* Card */
.card{
  position:relative;
  display:block;
  background:var(--card);
  border:1px solid var(--card-border);
  border-radius:16px;
  text-decoration:none;
  color:inherit;
  box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .2s ease, box-shadow .2s ease;
}
.card.indexcard{
  display:flex;
  flex-direction:column;
  gap:12px;
  padding:12px 12px 14px;
  background:radial-gradient(circle at 18% 12%, rgba(17,24,39,.03) 0, rgba(17,24,39,0) 32%),
    linear-gradient(180deg, var(--card-gradient-start) 0%, var(--card-gradient-end) 100%);
  border:1px solid var(--card-border);
  box-shadow: var(--shadow), var(--card-strong-shadow);
  border-radius:18px;
  overflow:hidden;
}
.card.indexcard:link,
.card.indexcard:visited{
  color:inherit;
  text-decoration:none;
}
.card.indexcard:focus-visible{
  outline:none;
  box-shadow:
    var(--shadow),
    0 22px 46px rgba(17,24,39,.12),
    0 0 0 3px rgba(17,24,39,.18);
}
.card.indexcard:hover{ border-color:#d1d5db; }
.indexcard-fav{
  position:absolute;
  top:10px;
  right:10px;
  z-index:2;
  border:none;
  background:rgba(255,255,255,.95);
  border-radius:50%;
  width:34px;
  height:34px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:19px;
  color:#0f172a;
  cursor:pointer;
  box-shadow:0 10px 22px rgba(0,0,0,.12);
  transition:transform .15s ease, box-shadow .15s ease, color .2s ease, background .2s ease;
}
.indexcard-fav:hover{
  transform:translateY(-1px);
  background:rgba(255,255,255,1);
  box-shadow:0 14px 28px rgba(0,0,0,.14);
}
.indexcard-fav.is-favorite{
  color:#f59e0b;
}
.card:hover{ transform: translateY(-2px); border-color:var(--accent); }

/* Thumbnail */
.card .thumb{
  aspect-ratio: 3 / 4;
  display:flex;align-items:center;justify-content:center;
  overflow:hidden;
  border-radius:14px;
  background:#f5f5f5;
  position: relative;
  isolation:isolate;
}
.indexcard-grid.layout-landscape .card.indexcard .thumb,
.card.indexcard.layout-landscape .thumb{
  aspect-ratio: 16 / 9;
}
.indexcard-grid.layout-square .card.indexcard .thumb,
.card.indexcard.layout-square .thumb{
  aspect-ratio: 1 / 1;
}
.card .thumb img{ width:100%; height:100%; object-fit:cover; display:block }
.thumb-missing{ color:#666; opacity:.7 }

/* Title + details */
.card .title{ font-size:1.05rem; margin:.1rem 0 .25rem; font-weight:700 }
.details{ color:var(--muted); font-size:.9rem }


/* Empty block */
.empty{
  grid-column:1/-1;
  opacity:.7;
  padding:24px;
  border:1px dashed #ccc;
  border-radius:12px;
  background:#f9fafc;
}

.indexcard-empty{
  padding:24px clamp(16px,4vw,40px) 0;
  color:var(--muted);
  font-weight:600;
}

/* Footer */
.footer{ padding:20px clamp(16px,4vw,40px) 60px; color:#555; opacity:.8 }
.footer code{ background:#f1f5f9; padding:2px 6px; border-radius:6px; border:1px solid #e2e8f0 }

/* Overlay inside thumbnail */
.thumb-overlay{
  position:absolute;
  left:0; right:0; bottom:0;
  padding:12px 14px;
  color:#0f172a;
  background:linear-gradient(180deg, rgba(255,255,255,.9) 0%, rgba(255,255,255,.82) 60%, rgba(255,255,255,.6) 100%);
  pointer-events:none;
  transition:max-height .28s ease, transform .28s ease, opacity .28s ease;
  max-height:72px;
  opacity:.88;
  overflow:hidden;
  transform:translateY(10%);
}
.thumb-overlay .title-row{
  display:flex; align-items:center; gap:8px;
  font-weight: 800; letter-spacing:.2px;
  font-size: 1rem; line-height:1.2;
  text-shadow:none;
  word-break: break-word;
}
.thumb-overlay .age-tag{
  font-size:.8rem; font-weight:700;
  padding: 3px 6px; border-radius: 8px;
  backdrop-filter: blur(2px);
  background: rgba(15,23,42,.06);
  border: 1px solid rgba(15,23,42,.12);
  white-space: nowrap;
}
.thumb-overlay .digest{
  margin-top:0;
  font-size:.9rem; line-height:1.3;
  color:#1f2937;
  text-shadow:none;
  max-height:0;
  overflow:hidden;
  opacity:0;
  transition: max-height .25s ease, opacity .2s ease, margin-top .2s ease;
}
.thumb-overlay .digest-html p{
  margin:0 0 .45em;
}
.thumb-overlay .digest-html p:last-child{
  margin-bottom:0;
}
.thumb-overlay .tags{
  margin-top:0;
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  max-height:0;
  overflow:hidden;
  opacity:0;
  transition: max-height .25s ease, opacity .2s ease, margin-top .2s ease;
}
.thumb-overlay .age-tag{
  font-size:.85rem;
  font-weight:700;
  background:rgba(255,255,255,.9);
  border:1px solid rgba(15,23,42,.12);
  color:#0f172a;
  padding:4px 8px;
  border-radius:999px;
  letter-spacing:.2px;
}
.card.indexcard.is-hover .thumb-overlay,
.card.indexcard:hover .thumb-overlay,
.card.indexcard:focus-within .thumb-overlay{
  max-height: clamp(120px, 70%, 320px);
  transform:translateY(0);
  opacity:1;
}
.card.indexcard.is-hover .thumb-overlay .digest,
.card.indexcard:hover .thumb-overlay .digest,
.card.indexcard:focus-within .thumb-overlay .digest{
  margin-top:6px;
  max-height:240px;
  opacity:1;
}
.card.indexcard.is-hover .thumb-overlay .tags,
.card.indexcard:hover .thumb-overlay .tags,
.card.indexcard:focus-within .thumb-overlay .tags{
  margin-top:6px;
  max-height:260px;
  opacity:1;
}
.card.indexcard.tag-layout .thumb-overlay .digest{
  max-height:0;
  opacity:0;
  margin-top:0;
}

/* Meta (outside text container) */
.card .meta{ padding:12px 14px 14px; }   /* default */
.card.indexcard .meta{ padding:0 2px 2px; }

.card.indexcard.no-image{
  padding:18px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  min-height:180px;
}
.card.indexcard.no-image .meta{
  padding:0;
}
.card.indexcard.no-image .title{
  margin:0 0 8px;
  font-size:1.1rem;
}
.card.indexcard.no-image .details{
  font-size:.95rem;
  line-height:1.4;
}
.card.indexcard.no-image .details-html p{
  margin:0 0 .5em;
}
.card.indexcard.no-image .details-html p:last-child{
  margin-bottom:0;
}
.card.indexcard.no-image .tags{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}
.card.indexcard.no-image .age-tag{
  display:inline-flex;
  align-items:center;
  gap:4px;
  padding:4px 10px;
  border-radius:999px;
  background:#f3f4f6;
  color:#111827;
  font-weight:600;
  font-size:.85rem;
  border:1px solid #e5e7eb;
}

.card.indexcard.is-hidden{
  display:none;
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce){
  .thumb-overlay{ transition:none; }
}

/* Mobile tweaks */
@media (max-width: 720px){
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap:8px;
    padding:0 10px 12px;
  }
  .card .thumb{ aspect-ratio: 2 / 3; border-radius:12px; }
  .card .meta{ padding:8px 10px; }   /* compact on phones */
  .card.indexcard .meta{ padding:2px 2px 4px; }
}

/* Smallest screens */
@media (max-width: 480px){
  .thumb-overlay{ max-height:64px; }
  .thumb-overlay .title-row{ font-size:.95rem; }
}
