/*
 * nd-article-index.css — ニコルデジマ Article Index Template (v2)
 * ================================================================
 * Restyles GP's default archive output to match the design.
 * Does NOT replace GP's loop — works with GP's existing markup.
 *
 * GP's per-post markup on archives:
 *   article.post > .inside-article
 *     > header.entry-header > h2.entry-title > a
 *                           > .entry-meta (date, author)
 *     > .post-image > a > img
 *     > .entry-summary > p (excerpt)
 *     > footer.entry-meta (categories, tags, comments)
 *
 * DEPENDS ON: nd-tokens.css, nd-base.css, nd-global.css
 */


/* ═══════════════════════════════════════════════
   1. PAGE HEADER
   ═══════════════════════════════════════════════ */

.nd-page-head {
  padding: var(--s-6) 0 var(--s-8);
}

.nd-page-h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 42px;
  letter-spacing: 0.5px;
  margin: 0 0 var(--s-4_5);
  color: var(--ink);
}

.nd-page-dek {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.95;
  margin: 0 0 var(--s-5_5);
}

.nd-page-stats {
  display: flex;
  align-items: center;
  gap: var(--s-5_5);
  font-size: 11px;
  color: var(--ink-3);
  flex-wrap: wrap;
}

.nd-page-stats .item {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1_5);
  white-space: nowrap;
}

.nd-page-stats svg { color: var(--ink-3); }

.nd-page-stats strong {
  color: var(--ink-2);
  font-weight: 500;
  font-family: var(--serif);
  font-size: 13px;
  margin: 0 2px;
}


/* ═══════════════════════════════════════════════
   2. HIDE GP's DEFAULT PAGE HEADER
   ═══════════════════════════════════════════════ */

.archive .page-header,
.blog .page-header {
  display: none;
}


/* ═══════════════════════════════════════════════
   3. LAYOUT (2-column with sidebar)
   ═══════════════════════════════════════════════ */

.index-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--s-14);
  align-items: start;
  padding-bottom: var(--s-16);
}


/* ═══════════════════════════════════════════════
   4. TABS
   ═══════════════════════════════════════════════ */

.tabs {
  display: flex;
  align-items: center;
  gap: var(--s-8);
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 0;
  margin-bottom: var(--s-2);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  font-size: 13px;
  color: var(--ink-3);
  padding: var(--s-3_5) 0;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
  display: inline-block;
}

.tab:hover { color: var(--ink-2); }

.tab.active {
  color: var(--ink);
  font-weight: 500;
  border-bottom-color: var(--kaki);
}


/* ═══════════════════════════════════════════════
   5. RESTYLE GP's ARTICLE CARDS
   ═══════════════════════════════════════════════
   Transform GP's default <article> markup into
   our horizontal card layout with thumbnail.
   ═══════════════════════════════════════════════ */

/* Each article becomes a horizontal grid row */
.archive .site-main > article,
.blog .site-main > article {
  /* Remove GP's separate container styling */
  padding: 0;
  margin: 0;
  background: none;
  border: none;
  box-shadow: none;
}

.archive .inside-article,
.blog .inside-article {
  display: grid;
  grid-template-columns: 200px 1fr;
  grid-template-rows: auto;
  gap: 0 var(--s-7);
  padding: var(--s-7) 0;
  border-bottom: 1px solid var(--hairline-2);
  align-items: start;
  background: none;
}

/* Featured image → thumbnail in left column */
.archive .post-image,
.blog .post-image {
  grid-column: 1;
  grid-row: 1 / -1;
  margin: 0;
}

.archive .post-image a,
.blog .post-image a {
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-ctrl);
  overflow: hidden;
}

.archive .post-image img,
.blog .post-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Entry header → right column, top */
.archive .entry-header,
.blog .entry-header {
  grid-column: 2;
  padding: 0;
  margin: 0;
}

.archive .entry-title,
.blog .entry-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 20px;
  line-height: 1.55;
  margin: 0 0 var(--s-2);
  letter-spacing: 0.3px;
}

.archive .entry-title a,
.blog .entry-title a {
  color: var(--ink);
  text-decoration: none;
  transition: color var(--hover-dur) var(--ease-soft);
}

.archive .entry-title a:hover,
.blog .entry-title a:hover {
  color: var(--kaki);
}

/* Header entry meta (date, author) — restyle as subtle meta row */
.archive .entry-header .entry-meta,
.blog .entry-header .entry-meta {
  font-size: 11px;
  color: var(--ink-3);
  margin: 0 0 var(--s-2);
  display: flex;
  gap: var(--s-2_5);
  flex-wrap: wrap;
  order: -1;
}

/* Hide "by" prefix and author link styling */
.archive .entry-header .byline,
.blog .entry-header .byline {
  display: none;
}

.archive .entry-header .updated,
.blog .entry-header .updated {
  display: none;
}

/* Excerpt → right column */
.archive .entry-summary,
.blog .entry-summary {
  grid-column: 2;
  padding: 0;
  margin: 0;
}

.archive .entry-summary p,
.blog .entry-summary p {
  font-size: 13px;
  line-height: 1.85;
  color: var(--ink-2);
  margin: 0;
  /* Clamp to 3 lines */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Hide "Read more" link in excerpt */
.archive .entry-summary .read-more,
.blog .entry-summary .read-more {
  display: none;
}

/* Footer meta (categories, tags) — hide on archive cards */
.archive footer.entry-meta,
.blog footer.entry-meta {
  display: none;
}

/* Articles without featured images */
.archive .inside-article:not(:has(.post-image)),
.blog .inside-article:not(:has(.post-image)) {
  grid-template-columns: 1fr;
}


/* ═══════════════════════════════════════════════
   6. SIDEBAR (index-specific)
   ═══════════════════════════════════════════════ */

.index-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--s-9);
  position: sticky;
  top: 24px;
}

/* Welcome card */
.welcome {
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: var(--s-5_5);
  background: var(--paper);
}

.welcome .icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--matcha-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--matcha-ink);
  margin-bottom: var(--s-3_5);
}

.welcome h3 {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 500;
  margin: 0 0 var(--s-2_5);
  color: var(--ink);
}

.welcome p {
  font-size: 12px;
  line-height: 1.85;
  color: var(--ink-2);
  margin: 0 0 var(--s-3_5);
}

.welcome a {
  font-size: 12px;
  color: var(--kaki);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: var(--s-1_5);
}

/* Sidebar block headings */
.sb-block {}

.sb-h {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--ink);
  padding-bottom: var(--s-3_5);
  margin: 0 0 var(--s-1_5);
  border-bottom: 1px solid var(--hairline);
}

/* Category list */
.cat-list { display: flex; flex-direction: column; }

.cat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px dashed var(--hairline-2);
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  transition: color 0.15s;
  text-decoration: none;
}

.cat-item:last-of-type { border-bottom: none; }
.cat-item:hover { color: var(--ink); }
.cat-item .count { font-size: 11px; color: var(--ink-3); }

/* Popular posts */
.pop-list { display: flex; flex-direction: column; }

.pop-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: var(--s-3);
  padding: var(--s-3) 0;
  border-bottom: 1px dashed var(--hairline-2);
  font-size: 12px;
  line-height: 1.65;
  color: var(--ink-2);
  align-items: start;
  cursor: pointer;
  transition: color 0.15s;
  text-decoration: none;
}

.pop-item:last-of-type { border-bottom: none; }
.pop-item:hover { color: var(--ink); }

.pop-item .num {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--kaki);
  font-weight: 500;
  line-height: 1.4;
}


/* ═══════════════════════════════════════════════
   7. PAGINATION OVERRIDE
   ═══════════════════════════════════════════════ */

.archive .nav-links,
.blog .nav-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--s-1);
  margin-top: var(--s-12);
  padding-top: var(--s-8);
}

.archive .nav-links a,
.archive .nav-links span,
.blog .nav-links a,
.blog .nav-links span {
  min-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--ink-2);
  border: 1px solid transparent;
  border-radius: var(--r-thumb);
  padding: 0 var(--s-2);
  text-decoration: none;
}

.archive .nav-links .current,
.blog .nav-links .current {
  border-color: var(--kaki);
  color: var(--kaki);
  font-weight: 500;
  background: var(--kaki-soft);
}

.archive .nav-links a:hover,
.blog .nav-links a:hover {
  background: var(--paper-2);
}


/* ═══════════════════════════════════════════════
   8. RESPONSIVE
   ═══════════════════════════════════════════════ */

@media (max-width: 1000px) {
  .index-layout {
    grid-template-columns: 1fr;
    gap: var(--s-12);
  }

  .index-sidebar {
    position: static;
  }
}

@media (max-width: 880px) {
  .nd-page-h1 {
    font-size: 32px;
  }

  .archive .inside-article,
  .blog .inside-article {
    grid-template-columns: 140px 1fr;
    gap: 0 var(--s-4_5);
  }

  .archive .entry-title,
  .blog .entry-title {
    font-size: 16px;
  }

  .index-sidebar {
    display: none;
  }
}

@media (max-width: 640px) {
  .archive .inside-article,
  .blog .inside-article {
    grid-template-columns: 1fr;
  }

  .archive .post-image,
  .blog .post-image {
    grid-row: auto;
    margin-bottom: var(--s-3);
  }

  .archive .post-image a,
  .blog .post-image a {
    aspect-ratio: 16 / 9;
  }
}

/* ═══════════════════════════════════════════════
   9. REVEAL ANIMATIONS
   ═══════════════════════════════════════════════ */

@media (prefers-reduced-motion: no-preference) {
  .nd-page-head .nd-page-h1,
  .nd-page-head .nd-page-dek,
  .nd-page-head .nd-page-stats {
    opacity: 0;
    transform: translateY(6px);
    animation: ndRevealUp var(--rev-dur) var(--ease-soft) forwards;
  }
  .nd-page-head .nd-page-h1   { animation-delay: 80ms; }
  .nd-page-head .nd-page-dek  { animation-delay: 220ms; }
  .nd-page-head .nd-page-stats { animation-delay: 380ms; }

  .tabs {
    opacity: 0;
    animation: ndFadeIn 700ms var(--ease-soft) 480ms forwards;
  }

  [data-reveal] {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity var(--rev-dur) var(--ease-soft),
                transform var(--rev-dur) var(--ease-soft);
  }
  [data-reveal].is-in { opacity: 1; transform: translateY(0); }

  .archive .inside-article[data-reveal].is-in:nth-child(1),
  .blog    .inside-article[data-reveal].is-in:nth-child(1) { transition-delay: 0ms; }
  .archive .inside-article[data-reveal].is-in:nth-child(2),
  .blog    .inside-article[data-reveal].is-in:nth-child(2) { transition-delay: 60ms; }
  .archive .inside-article[data-reveal].is-in:nth-child(3),
  .blog    .inside-article[data-reveal].is-in:nth-child(3) { transition-delay: 120ms; }
  .archive .inside-article[data-reveal].is-in:nth-child(4),
  .blog    .inside-article[data-reveal].is-in:nth-child(4) { transition-delay: 180ms; }
}

@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1 !important; transform: none !important; }
}

@keyframes ndRevealUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes ndFadeIn {
  from { opacity: 0; } to { opacity: 1; }
}