/* ==========================================================================
   Indylist Template — Clean Editorial & Visual Directory Theme
   Compatible with ddgv6serp.js & ddgv6-panel hybrid schemas
   ========================================================================== */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --text: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;
  --border: #e2e8f0;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-soft: #f0f7ff;
  --primary-border: #bae6fd;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 18px -4px rgba(15, 23, 42, 0.08);
  --max-w: 1120px;
  --post-w: 840px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background-color: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--primary-hover);
}

/* Skip Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--primary);
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  z-index: 999;
}
.skip-link:focus {
  top: 12px;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.brand:hover {
  color: var(--primary);
}
.brand-mark {
  width: 12px;
  height: 24px;
  border-radius: 4px;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  display: inline-block;
}

.cat-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cat-chip {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: capitalize;
  color: var(--text-muted);
  background: var(--surface-alt);
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.cat-chip:hover {
  background: var(--primary-soft);
  color: var(--primary-hover);
  border-color: var(--primary-border);
}

/* Main Container */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 28px 20px 56px;
  flex: 1;
}

.section-head {
  margin-bottom: 24px;
}
.page-title {
  font-size: clamp(1.5rem, 2.5vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0 0 6px;
  color: var(--text);
}
.page-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
}

/* Breadcrumbs */
.crumbs {
  font-size: 0.88rem;
  color: var(--text-light);
  margin-bottom: 18px;
  overflow-wrap: anywhere;
}
.crumbs a {
  color: var(--text-muted);
  font-weight: 500;
}
.crumbs a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* Homepage Feed Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 22px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.card-media {
  display: block;
  aspect-ratio: 16 / 10;
  background: var(--surface-alt);
  overflow: hidden;
  position: relative;
}
.card-media.no-img {
  display: none;
}
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.card:hover .card-media img {
  transform: scale(1.03);
}

.card-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-badge {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 3px 9px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.card-title {
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 8px;
}
.card-title a {
  color: var(--text);
}
.card-title a:hover {
  color: var(--primary);
}

.card-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-date {
  margin-top: auto;
  font-size: 0.8rem;
  color: var(--text-light);
}

/* Single Post & Attachment Container */
.post, .attachment {
  max-width: var(--post-w);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(20px, 4vw, 40px);
  box-shadow: var(--shadow-sm);
}

.post h1, .attachment h1 {
  font-size: clamp(1.65rem, 3.2vw, 2.35rem);
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0 0 12px;
  color: var(--text);
}

.post-meta {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.post-meta a {
  color: var(--text-muted);
  font-weight: 600;
}

.hero {
  width: 100%;
  max-height: 520px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin: 0 0 22px;
  background: var(--surface-alt);
}

/* Soft Sky-Blue Collapsible Table of Contents */
.toc-box {
  margin: 22px 0;
  background: #f0f7ff;
  border: 1px solid #bae6fd;
  border-left: 4px solid #0284c7;
  border-radius: 10px;
  overflow: hidden;
}
.toc-toggle {
  width: 100%;
  background: transparent;
  border: 0;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0c4a6e;
  cursor: pointer;
  text-align: left;
}
.toc-toggle:hover {
  background: #e0f2fe;
}
.toc-icon {
  width: 18px;
  height: 18px;
  color: #0284c7;
  transition: transform 0.2s ease;
}
.toc-toggle[aria-expanded="true"] .toc-icon {
  transform: rotate(180deg);
}
.toc-body {
  display: none;
  padding: 12px 16px 14px;
  border-top: 1px solid #bae6fd;
  background: #f8fbff;
}
.toc-body.open {
  display: block;
}
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.toc-list li {
  margin: 0 0 8px;
  line-height: 1.4;
}
.toc-list li:last-child {
  margin-bottom: 0;
}
.toc-list a {
  text-decoration: none;
  color: #0369a1;
  font-size: 0.9rem;
  font-weight: 600;
}
.toc-list a:hover {
  color: #0c4a6e;
  text-decoration: underline;
}
.toc-list .toc-sub {
  padding-left: 16px;
}
.toc-list .toc-sub a {
  font-size: 0.85rem;
  font-weight: 500;
  color: #334155;
}

.post-lead {
  font-size: 1.08rem;
  color: var(--text-muted);
  background: var(--surface-alt);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin: 0 0 24px;
}

/* Article Body Content + Legacy Figure Blocks */
.content {
  font-size: 1.04rem;
  line-height: 1.75;
  color: #1e293b;
  overflow-wrap: anywhere;
}
.content h2 {
  font-size: 1.45rem;
  font-weight: 800;
  margin: 32px 0 12px;
  color: var(--text);
  letter-spacing: -0.015em;
}
.content h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 24px 0 10px;
  color: var(--text);
}
.content p {
  margin: 0 0 16px;
}
.content ul, .content ol {
  margin: 0 0 18px;
  padding-left: 24px;
}
.content li {
  margin-bottom: 6px;
}
.content hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

/* Hybrid Figure Block Support (for trigger/legacy content_html) */
.figure-block {
  margin: 26px 0;
  padding: 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.figure-title {
  font-size: 1.15rem !important;
  margin: 0 0 12px !important;
}
.figure-img-wrap img {
  border-radius: 6px;
  margin: 0 auto;
}
.figure-desc {
  margin: 10px 0 0 !important;
  font-size: 0.92rem;
  color: var(--text-muted);
}

/* Gallery Section (article_images) */
.gallery {
  margin-top: 38px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.gallery h2 {
  font-size: 1.45rem;
  font-weight: 800;
  margin: 0 0 18px;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}
.gallery-card {
  margin: 0;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.gallery-img-link {
  display: block;
  aspect-ratio: 4 / 3;
  background: #e2e8f0;
  overflow: hidden;
}
.gallery-img-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}
.gallery-card:hover .gallery-img-link img {
  transform: scale(1.04);
}
.gallery-card figcaption {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.88rem;
}
.gallery-card figcaption strong a {
  color: var(--text);
  line-height: 1.35;
  display: block;
}
.gallery-card figcaption strong a:hover {
  color: var(--primary);
}
.gallery-caption {
  margin: 4px 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gallery-card .meta {
  font-size: 0.76rem;
  color: var(--text-light);
}

/* Related Posts */
.related-section {
  margin-top: 38px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}
.related-section h2 {
  font-size: 1.3rem;
  margin: 0 0 16px;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.related-card {
  display: flex;
  flex-direction: column;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
}
.related-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}
.related-card span {
  padding: 10px 12px;
  line-height: 1.35;
}
.related-card:hover {
  border-color: var(--primary-border);
  color: var(--primary);
}

/* Attachment Page */
.attachment-summary {
  color: var(--text-muted);
  margin: 0 0 20px;
}
.attachment-image {
  margin: 0 0 22px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.attachment-image img {
  margin: 0 auto;
  border-radius: 6px;
  max-height: 75vh;
  width: auto;
}
.attachment-image figcaption {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-light);
}

.specs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 0 0 20px;
}
.specs dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  font-weight: 700;
}
.specs dd {
  margin: 2px 0 0;
  font-weight: 600;
  color: var(--text);
}

.attachment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary);
  transition: background 0.15s ease;
}
.btn:hover {
  background: var(--primary-hover);
  color: #ffffff;
}
.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover {
  background: var(--surface-alt);
  color: var(--primary);
}

.notice {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 24px;
}
.notice p {
  margin: 0 0 8px;
}
.notice p:last-child {
  margin-bottom: 0;
}

/* Pagination / Pager */
.pager {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.pager-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}
.pager-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.pager-info {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* 404 Page */
.not-found-box {
  max-width: 540px;
  margin: 48px auto;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 28px;
  box-shadow: var(--shadow-sm);
}
.not-found-code {
  display: inline-block;
  font-size: 3.2rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 8px;
}

/* Footer */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  font-size: 0.9rem;
}
.footer-nav a {
  color: var(--text-muted);
  font-weight: 500;
}
.footer-nav a:hover {
  color: var(--primary);
}
.copyright {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-light);
}

@media (max-width: 640px) {
  .post, .attachment {
    padding: 18px 16px;
  }
  .grid {
    grid-template-columns: 1fr;
  }
}
