
/* ===== ISNAD Page ===== */
.isnad-page {
  --isnad-bg: #0B0F0E;
  --isnad-surface: #121917;
  --isnad-green: #2FBF71;
  --isnad-text: #E8EDEB;
  --isnad-muted: #96A39D;
  --isnad-amber: #E8B93E;
  --isnad-red: #E4574D;
  --isnad-grey: #8B8F93;
  --isnad-border: rgba(150, 163, 157, 0.15);
  background: var(--isnad-bg);
  color: var(--isnad-text);
  min-height: 100vh;
}

.isnad-hero {
  padding: 10rem 2rem 5rem;
  position: relative;
  overflow: hidden;
}

.isnad-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cdefs%3E%3Cpattern id='star8' width='80' height='80' patternUnits='userSpaceOnUse'%3E%3Cpath d='M40 0 L50 20 L70 30 L50 40 L40 60 L30 40 L10 30 L30 20 Z' fill='none' stroke='%232FBF71' stroke-width='0.5' opacity='0.12'/%3E%3Ccircle cx='40' cy='40' r='2' fill='%232FBF71' opacity='0.05'/%3E%3C/pattern%3E%3C/defs%3E%3Crect width='200' height='200' fill='url(%23star8)'/%3E%3C/svg%3E");
  opacity: 0.4;
  pointer-events: none;
}

.isnad-hero-inner {
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
  position: relative;
  z-index: 1;
}

.isnad-arabic {
  font-size: clamp(3.5rem, 8vw, 6rem);
  color: var(--isnad-green);
  margin-bottom: 0.5rem;
  line-height: 1.2;
  font-weight: 400;
}

.isnad-title {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
  color: var(--isnad-text);
}

.isnad-tagline {
  font-size: clamp(1.05rem, 1.8vw, 1.25rem);
  color: var(--isnad-muted);
  line-height: 1.6;
  max-width: 600px;
  margin: 0 auto 1rem;
}

.isnad-sub {
  font-size: 0.95rem;
  color: var(--isnad-muted);
  line-height: 1.7;
  max-width: 650px;
  margin: 0 auto 2rem;
  opacity: 0.8;
}

.isnad-hero-btns {
  display: flex;
  gap: 0.85rem;
  justify-content: center;
  flex-wrap: wrap;
}

.isnad-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.5rem;
  min-height: 46px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: all 0.2s ease;
  cursor: pointer;
}

.isnad-btn-primary {
  background: var(--isnad-green);
  color: #0B0F0E;
  border: 1px solid var(--isnad-green);
}
.isnad-btn-primary:hover {
  background: #3bd47c;
  transform: translateY(-2px);
}

.isnad-btn-secondary {
  background: transparent;
  color: var(--isnad-text);
  border: 1px solid var(--isnad-border);
}
.isnad-btn-secondary:hover {
  border-color: var(--isnad-green);
  background: rgba(47, 191, 113, 0.06);
  transform: translateY(-2px);
}

/* ===== Chain Animation ===== */
.chain-section {
  padding: 2rem 0 4rem;
}

.chain-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 2rem;
}

.chain-svg-wrap {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.chain-svg-wrap svg {
  width: 100%;
  min-width: 600px;
  height: auto;
}

.chain-caption {
  text-align: center;
  font-size: 0.95rem;
  color: var(--isnad-muted);
  margin-top: 1rem;
  font-style: italic;
  min-height: 1.5em;
  transition: opacity 0.4s ease;
}

/* Node colors */
.node-reliable { fill: var(--isnad-green); }
.node-ungraded { fill: var(--isnad-amber); }
.node-weak { fill: var(--isnad-red); }

/* Grade chip colors */
.grade-sahih { fill: var(--isnad-green); color: var(--isnad-green); }
.grade-hasan { fill: var(--isnad-amber); color: var(--isnad-amber); }
.grade-daif { fill: var(--isnad-red); color: var(--isnad-red); }

/* ISNAD sections */
.isnad-section {
  padding: 4rem 2rem;
  border-top: 1px solid var(--isnad-border);
}

.isnad-section-inner {
  max-width: 800px;
  margin: 0 auto;
}

.isnad-section h2 {
  font-size: clamp(1.4rem, 2.5vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  color: var(--isnad-text);
}

.isnad-section p {
  font-size: 1rem;
  color: var(--isnad-muted);
  line-height: 1.75;
  margin-bottom: 1rem;
}

/* Principle cards for ISNAD */
.isnad-principles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-top: 1.5rem;
}

.isnad-principle {
  background: var(--isnad-surface);
  border: 1px solid var(--isnad-border);
  border-radius: 8px;
  padding: 1.2rem;
}

.isnad-principle .num {
  font-size: 0.7rem;
  color: var(--isnad-green);
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}

.isnad-principle p {
  font-size: 0.9rem;
  color: var(--isnad-muted);
  line-height: 1.6;
  margin: 0;
}

/* Decision Matrix */
.isnad-matrix-wrap {
  overflow-x: auto;
  margin-top: 1.5rem;
}

.isnad-matrix {
  width: 100%;
  min-width: 600px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.isnad-matrix th,
.isnad-matrix td {
  padding: 0.85rem 1rem;
  text-align: left;
  border: 1px solid var(--isnad-border);
}

.isnad-matrix th {
  background: var(--isnad-surface);
  font-weight: 600;
  color: var(--isnad-text);
  font-size: 0.85rem;
}

.isnad-matrix td {
  color: var(--isnad-muted);
  line-height: 1.5;
}

.isnad-matrix .row-sahih { border-left: 3px solid var(--isnad-green); }
.isnad-matrix .row-hasan { border-left: 3px solid var(--isnad-amber); }
.isnad-matrix .row-daif { border-left: 3px solid var(--isnad-red); }
.isnad-matrix .row-mawdu { border-left: 3px solid var(--isnad-grey); }

.matrix-caption {
  font-size: 0.85rem;
  color: var(--isnad-muted);
  margin-top: 0.75rem;
  font-style: italic;
  line-height: 1.6;
}

/* Code Block */
.isnad-code {
  background: #0a0f0d;
  border: 1px solid var(--isnad-border);
  border-radius: 8px;
  padding: 1.2rem;
  margin-top: 1rem;
  position: relative;
  overflow-x: auto;
}

.isnad-code pre {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--isnad-muted);
  font-family: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
}

.copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: var(--isnad-surface);
  border: 1px solid var(--isnad-border);
  color: var(--isnad-muted);
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.copy-btn:hover {
  border-color: var(--isnad-green);
  color: var(--isnad-green);
}

/* Honest Status Panel */
.isnad-honest {
  background: var(--isnad-surface);
  border: 1px solid var(--isnad-border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 1rem;
  border-left: 3px solid var(--isnad-green);
}

.isnad-honest h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--isnad-text);
  margin-bottom: 0.75rem;
}

.isnad-honest p {
  font-size: 0.9rem;
  color: var(--isnad-muted);
  line-height: 1.7;
  margin-bottom: 0.5rem;
}

.isnad-honest p:last-child {
  margin-bottom: 0;
}

/* Links grid */
.isnad-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.isnad-link-card {
  background: var(--isnad-surface);
  border: 1px solid var(--isnad-border);
  border-radius: 8px;
  padding: 1rem;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.isnad-link-card:hover {
  border-color: var(--isnad-green);
  transform: translateY(-2px);
}
.isnad-link-card a {
  color: var(--isnad-green);
  font-weight: 600;
  font-size: 0.9rem;
}
.isnad-link-card .link-desc {
  font-size: 0.8rem;
  color: var(--isnad-muted);
  margin-top: 0.2rem;
}

.isnad-link-card.muted {
  opacity: 0.5;
  pointer-events: none;
}

/* BibTeX */
.isnad-bibtex {
  background: #0a0f0d;
  border: 1px solid var(--isnad-border);
  border-radius: 8px;
  padding: 1.2rem;
  margin-top: 1rem;
  position: relative;
  overflow-x: auto;
}

.isnad-bibtex pre {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--isnad-muted);
  font-family: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
}

/* ISNAD Footer */
.isnad-footer-note {
  font-size: 0.85rem;
  color: var(--isnad-muted);
  line-height: 1.7;
  margin-top: 0.5rem;
  font-style: italic;
}

/* ISNAD responsive */
@media (max-width: 768px) {
  .isnad-hero {
    padding: 7rem 1.2rem 3.5rem;
  }
  .isnad-section {
    padding: 3rem 1.2rem;
  }
  .isnad-hero-btns {
    flex-direction: column;
    align-items: center;
  }
  .isnad-btn {
    width: 100%;
    max-width: 280px;
  }
}

/* ===== Print / Misc ===== */
@media print {
  .nav, .footer { display: none; }
  body { background: #fff; color: #000; }
  .section { border: none; padding: 1rem 0; }
}

/* ===== ISNAD Expanded Styles ===== */

/* TOC / Section Rail */
.isnad-toc {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding: 1rem 0;
  font-size: 0.85rem;
}
.isnad-toc a {
  display: block;
  color: var(--isnad-muted);
  text-decoration: none;
  padding: 0.3rem 0;
  border-left: 2px solid transparent;
  padding-left: 0.75rem;
  transition: color 0.2s, border-color 0.2s;
  line-height: 1.5;
}
.isnad-toc a:hover,
.isnad-toc a.active { color: var(--isnad-green); border-left-color: var(--isnad-green); }

/* Section anchor links */
.isnad-anchor {
  opacity: 0;
  font-size: 0.8em;
  color: var(--isnad-green);
  text-decoration: none;
  margin-left: 0.5rem;
  transition: opacity 0.2s;
}
h2:hover .isnad-anchor,
.isnad-sect h2:hover .isnad-anchor { opacity: 1; }

/* Metadata strip */
.isnad-meta-strip {
  text-align: center;
  font-size: 0.85rem;
  color: var(--isnad-muted);
  margin: 0.5rem 0 0;
  opacity: 0.7;
}
.isnad-meta-strip span { margin: 0 0.4rem; }
.isnad-meta-strip .sep { opacity: 0.3; }

/* Status chips */
.status-chip {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
}
.status-validated { background: rgba(47,191,113,0.15); color: #2FBF71; }
.status-partial { background: rgba(232,185,62,0.15); color: #E8B93E; }
.status-failed { background: rgba(228,87,77,0.15); color: #E4574D; }
.status-open { background: rgba(150,163,157,0.1); color: #96A39D; }
.status-inconclusive { background: rgba(150,163,157,0.1); color: #96A39D; border: 1px solid rgba(150,163,157,0.2); }

/* Data tables (ISNAD) */
.isnad-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
  margin: 1rem 0;
}
.isnad-table th,
.isnad-table td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  border: 1px solid rgba(150,163,157,0.12);
  line-height: 1.5;
}
.isnad-table th {
  background: var(--isnad-surface);
  font-weight: 600;
  color: var(--isnad-text);
  font-size: 0.85rem;
}
.isnad-table td { color: var(--isnad-muted); }

/* Table scroll wrapper */
.isnad-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
  scrollbar-width: thin;
}
.isnad-table-wrap::-webkit-scrollbar { height: 4px; }
.isnad-table-wrap::-webkit-scrollbar-thumb { background: rgba(150,163,157,0.2); border-radius: 2px; }

/* Callout boxes */
.isnad-callout {
  background: var(--isnad-surface);
  border-left: 3px solid var(--isnad-green);
  padding: 1rem 1.2rem;
  margin: 1rem 0;
  border-radius: 0 6px 6px 0;
  font-size: 0.9rem;
  color: var(--isnad-muted);
  line-height: 1.65;
}
.isnad-callout strong { color: var(--isnad-text); }
.isnad-callout.warn { border-left-color: var(--isnad-amber); }
.isnad-callout.danger { border-left-color: var(--isnad-red); }

/* Blockquote */
.isnad-quote {
  border-left: 3px solid var(--isnad-green);
  padding: 0.75rem 1.2rem;
  margin: 1.2rem 0;
  font-style: italic;
  color: var(--isnad-muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

/* Terminal block */
.isnad-terminal {
  background: #0a0f0d;
  border: 1px solid rgba(150,163,157,0.15);
  border-radius: 6px;
  padding: 0.9rem 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--isnad-muted);
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  margin: 0.75rem 0;
}

/* Feature block */
.isnad-feature {
  background: var(--isnad-surface);
  border: 1px solid rgba(150,163,157,0.15);
  border-radius: 10px;
  padding: 1.5rem;
  margin: 1.5rem 0;
}
.isnad-feature h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--isnad-text);
}
.isnad-feature .feat-attr {
  font-size: 0.8rem;
  color: var(--isnad-muted);
  opacity: 0.7;
  margin-bottom: 0.5rem;
}

/* Badges */
.isnad-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
  justify-content: center;
}
.isnad-badges img {
  height: 20px;
}

/* Limitation card */
.limitation-card {
  background: var(--isnad-surface);
  border: 1px solid rgba(150,163,157,0.1);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  margin-bottom: 0.6rem;
}
.limitation-card h4 {
  font-size: 0.95rem;
  color: var(--isnad-text);
  margin-bottom: 0.35rem;
}
.limitation-card p {
  font-size: 0.9rem;
  color: var(--isnad-muted);
  line-height: 1.6;
  margin: 0;
}

/* Roadmap items */
.roadmap-section { margin-bottom: 1.5rem; }
.roadmap-section h4 {
  font-size: 0.95rem;
  color: var(--isnad-text);
  margin-bottom: 0.5rem;
}
.roadmap-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.roadmap-list li {
  font-size: 0.9rem;
  color: var(--isnad-muted);
  line-height: 1.6;
  margin-bottom: 0.35rem;
  padding-left: 1rem;
  position: relative;
}
.roadmap-list li::before {
  content: "→";
  position: absolute;
  left: 0;
  color: var(--isnad-green);
}

/* Disambiguation */
.isnad-disambig {
  font-size: 0.8rem;
  color: var(--isnad-muted);
  opacity: 0.6;
  line-height: 1.6;
  padding: 1rem 0;
  border-top: 1px solid rgba(150,163,157,0.08);
  margin-top: 2rem;
}

/* Responsive: mobile TOC */
@media (max-width: 768px) {
  .isnad-page-layout { display: block; }
  .isnad-toc { display: none; }
  .isnad-toc-mobile {
    display: block;
    margin-bottom: 1.5rem;
  }
  .isnad-toc-mobile select {
    width: 100%;
    background: var(--isnad-surface);
    color: var(--isnad-text);
    border: 1px solid rgba(150,163,157,0.2);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-size: 0.9rem;
  }
}
@media (min-width: 769px) {
  .isnad-toc-mobile { display: none; }
}

/* ===== Print Stylesheet ===== */
@media print {
  @page { margin: 2cm; }
  body { background: #fff; color: #000; font-size: 11pt; line-height: 1.5; }
  .nav, .footer, .isnad-toc, .isnad-toc-mobile, .isnad-hero-btns,
  .chain-svg-container, .copy-btn, .isnad-badges, .isnad-hero::before,
  #chain-tooltip, .isnad-meta-strip { display: none !important; }
  
  .isnad-page { background: #fff; color: #000; font-family: 'Gentium Book Plus', Georgia, serif; }
  .isnad-page h1,.isnad-page h2,.isnad-page h3,.isnad-page h4 { color: #000; page-break-after: avoid; }
  .isnad-page p,.isnad-page li,.isnad-page td,.isnad-page th { color: #000; }
  .isnad-page code,.isnad-page pre { color: #333; background: #f5f5f5; border: 1px solid #ddd; }
  
  .isnad-sect { padding: 1.5rem 0; border-top: 1px solid #ccc; page-break-inside: avoid; }
  .isnad-hero { padding: 2rem 0 1rem; text-align: left; }
  .isnad-arabic { font-size: 2.5rem; color: #000; }
  .isnad-title-word { font-size: 1.8rem; }
  
  .isnad-table { font-size: 9pt; }
  .isnad-table th { background: #eee; color: #000; }
  .isnad-table td { color: #000; border-color: #ccc; }
  .isnad-table-wrap { overflow: visible; }
  
  .isnad-callout { background: #f9f9f9; border-left-color: #000; color: #000; }
  .isnad-callout strong { color: #000; }
  .isnad-feature { background: #f9f9f9; border-color: #ccc; }
  .isnad-quote { border-left-color: #000; color: #000; }
  .isnad-terminal { background: #f5f5f5; border-color: #ccc; color: #333; }
  .isnad-code,.isnad-bibtex { background: #f5f5f5; border-color: #ccc; }
  .isnad-code pre,.isnad-bibtex pre { color: #333; }
  
  .isnad-honest { background: #f9f9f9; border-left-color: #000; }
  .limitation-card { background: #f9f9f9; border-color: #ccc; }
  .status-chip { border: 1px solid #000; }
  
  details { display: block; }
  details summary { display: none; }
  
  a { color: #000; text-decoration: underline; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #666; }
  
  .isnad-disambig { border-top: 1px solid #ccc; color: #666; }
  
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ===== Reading Progress Bar ===== */
.reading-progress {
  position: fixed;
  top: 64px;
  left: 0;
  height: 3px;
  background: var(--isnad-green);
  z-index: 1001;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.1s linear;
}

/* ===== Skip Link ===== */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--isnad-green);
  color: #0B0F0E;
  padding: 0.5rem 1rem;
  z-index: 10000;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 6px 0;
}
.skip-link:focus {
  top: 0;
}

/* ===== Text balance ===== */
.isnad-page h1, .isnad-page h2, .isnad-page h3 {
  text-wrap: balance;
}
.isnad-page p {
  text-wrap: pretty;
}

/* ===== Tabular nums in tables ===== */
.isnad-table td, .isnad-table th {
  font-variant-numeric: tabular-nums lining-nums;
}

/* ===== Anchor offset for sticky nav ===== */
.isnad-sect { scroll-margin-top: 80px; }

/* ===== Mobile Animation Controls ===== */
@media (max-width: 640px) {
  .chain-desktop { display: none; }
  .chain-mobile { display: block; }
  .chain-ctrl-btn { 
    min-width: 44px; min-height: 44px; 
    padding: 0.65rem 0.85rem; font-size: 0.85rem; 
  }
  .isnad-matrix-wrap { 
    -webkit-overflow-scrolling: touch;
    position: relative;
  }
  .isnad-matrix-wrap::after {
    content: "scroll →";
    position: absolute;
    right: 0; top: 50%; transform: translateY(-50%);
    background: linear-gradient(90deg, transparent, rgba(11,15,14,0.9));
    color: #96A39D;
    font-size: 0.7rem;
    padding: 0.3rem 0.5rem;
    pointer-events: none;
  }
  #matrix-interactive select { width: 100%; min-height: 44px; }
}

/* Mobile Chain — Vertical layout */
.chain-mobile { display: none; padding: 1rem 0; }
.chain-mobile-steps { display: flex; flex-direction: column; gap: 0.5rem; }
.chain-mobile-step {
  background: var(--isnad-surface);
  border: 1px solid rgba(150,163,157,0.15);
  border-radius: 10px;
  padding: 1rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.chain-mobile-step:active { transform: scale(0.98); }
.chain-mobile-step.active { border-color: #2FBF71; }
.chain-mobile-step .step-dot {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
}
.chain-mobile-step .step-info { flex: 1; }
.chain-mobile-step .step-name { font-size: 0.9rem; color: #E8EDEB; font-weight: 600; }
.chain-mobile-step .step-grade { font-size: 0.78rem; color: #96A39D; }
.chain-mobile-step .step-type { font-size: 0.7rem; color: #96A39D; opacity: 0.7; }

.mobile-chain-result {
  background: var(--isnad-surface);
  border: 1px solid rgba(150,163,157,0.15);
  border-radius: 10px;
  padding: 1.2rem;
  margin-top: 0.75rem;
  text-align: center;
}
.mobile-chain-result .result-grade { font-size: 1.3rem; font-weight: 700; }
.mobile-chain-result .result-action { font-size: 1rem; font-weight: 600; margin-top: 0.25rem; }

/* Mobile Corroboration */
@media (max-width: 640px) {
  #corroboration-svg { min-width: auto; }
}

/* Table scroll gradient affordance */
.isnad-table-wrap {
  position: relative;
  -webkit-overflow-scrolling: touch;
}
.isnad-table-wrap::before {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 30px;
  background: linear-gradient(90deg, transparent, rgba(11,15,14,0.95));
  pointer-events: none;
  z-index: 1;
}
.isnad-table-wrap:has(+ *)::before { display: none; }

/* Ensure all interactive targets are ≥44px */
.chain-ctrl-btn, #matrix-interactive select, #matrix-interactive button,
.isnad-btn, .copy-btn, .nav-links a, .footer-social a {
  min-height: 44px; min-width: 44px;
}

/* ===== Mobile Fix Batch — Comprehensive ===== */

/* Prevent any horizontal overflow */
.isnad-page { overflow-x: hidden; }

/* Collapse TOC+content grid on mobile */
@media (max-width: 1023px) {
  .isnad-page-layout { display: block !important; }
  .isnad-toc { display: none !important; }
}

/* SVG scaling — never force min-width */
.isnad-page svg { max-width: 100%; height: auto; }
.isnad-page svg[width], .isnad-page svg[height] { max-width: 100%; height: auto; }

/* All tables wrapped with gradient affordance */
.isnad-table-wrap { 
  overflow-x: auto; 
  -webkit-overflow-scrolling: touch; 
  position: relative;
}
.isnad-table-wrap::before {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0; width: 40px;
  background: linear-gradient(90deg, transparent, rgba(11,15,14,0.95));
  pointer-events: none; z-index: 1;
}
.isnad-table-wrap::after {
  content: 'scroll →';
  position: absolute;
  right: 4px; top: 50%; transform: translateY(-50%);
  color: #96A39D; font-size: 0.7rem; pointer-events: none; z-index: 2;
}

/* Sticky first column on tables */
.isnad-table th:first-child,
.isnad-table td:first-child {
  position: sticky; left: 0;
  background: var(--isnad-bg); z-index: 1;
  min-width: 100px;
}
.isnad-table th:first-child { background: var(--isnad-surface); }

/* Tables must not overflow */
.isnad-table { min-width: auto !important; width: 100%; }
.isnad-table td, .isnad-table th { 
  min-width: 100px; 
  word-break: break-word;
  font-size: 0.85rem;
  padding: 0.55rem 0.6rem;
}

/* Code blocks — collapse on mobile, expand on desktop */
@media (max-width: 768px) {
  .isnad-code, .isnad-bibtex { 
    padding: 0.8rem; margin-top: 0.5rem; 
    font-size: 0.78rem;
  }
  .isnad-code pre, .isnad-bibtex pre { font-size: 0.75rem; line-height: 1.4; }
  .copy-btn { font-size: 0.7rem; padding: 0.25rem 0.5rem; min-height: 32px; }
}

/* Touch targets everywhere */
@media (max-width: 768px) {
  .chain-ctrl-btn { min-height: 44px; min-width: 44px; padding: 0.7rem 0.9rem; font-size: 0.85rem; }
  .isnad-btn { min-height: 44px; }
  .nav-links a { min-height: 44px; padding: 0.75rem 1rem; }
  .footer-social a { width: 44px; height: 44px; }
  .isnad-link-card { min-height: 60px; }
  details summary { min-height: 44px; padding: 0.75rem 0; }
  #matrix-interactive select { width: 100%; min-height: 44px; }
}

/* Matrix router — stack selectors on mobile */
@media (max-width: 768px) {
  #matrix-interactive > div { flex-direction: column; gap: 0.75rem; }
  #matrix-interactive > div > div { width: 100%; }
}

/* Hero text sizes on mobile */
@media (max-width: 480px) {
  .isnad-arabic { font-size: 2.8rem; }
  .isnad-title-word { font-size: 1.8rem; }
  .isnad-tagline { font-size: 1rem; }
  .isnad-sub-text { font-size: 0.9rem; }
  .isnad-meta-strip { font-size: 0.75rem; }
  .isnad-badges img { height: 18px; }
  .isnad-sect h2 { font-size: 1.3rem; }
  .isnad-sect-inner { padding: 0; }
}

/* Page section padding on mobile */
@media (max-width: 768px) {
  .isnad-sect { padding: 2.5rem 1rem; }
  .isnad-hero { padding: 6rem 1rem 3rem; }
  .chain-wrap { padding: 1rem 1rem 2rem; }
}

/* Chain controls on mobile */
@media (max-width: 640px) {
  .chain-controls { gap: 0.4rem; }
  .chain-controls .chain-ctrl-btn { flex: 1 1 calc(50% - 0.2rem); }
}

/* Corroboration SVG mobile */
@media (max-width: 640px) {
  #corroboration-svg { viewBox: 0 0 800 320; }
}

/* Font size adjustment for readability */
@media (max-width: 480px) {
  .isnad-page { font-size: 0.95rem; line-height: 1.65; }
  .isnad-sect p, .isnad-sect li { font-size: 0.9rem; }
}

/* Fix TOC mobile select */
.isnad-toc-mobile select {
  width: 100%; min-height: 44px;
  background: var(--isnad-surface); color: #E8EDEB;
  border: 1px solid rgba(150,163,157,0.2);
  padding: 0.7rem 0.9rem; border-radius: 6px; font-size: 0.9rem;
}

/* Ensure links are tappable */
@media (max-width: 768px) {
  .isnad-page a { min-height: 28px; display: inline-block; }
  .card-link { padding: 0.3rem 0; }
}

/* Evaluation tables on mobile — font size */
@media (max-width: 768px) {
  .isnad-table { font-size: 0.8rem; }
}

/* Status chips — always readable */
.status-chip { white-space: nowrap; }

/* Roadmap list indentation */
@media (max-width: 480px) {
  .roadmap-list li { padding-left: 0.75rem; font-size: 0.85rem; }
}

/* Limitation cards on mobile */
@media (max-width: 480px) {
  .limitation-card { padding: 0.85rem 1rem; }
  .limitation-card h4 { font-size: 0.9rem; }
  .limitation-card p { font-size: 0.85rem; }
}

/* Feature block on mobile */
@media (max-width: 480px) {
  .isnad-feature { padding: 1rem; }
  .isnad-feature h3 { font-size: 1rem; }
}

/* Disambiguation on mobile */
@media (max-width: 480px) {
  .isnad-disambig { font-size: 0.75rem; padding: 0.75rem 0; }
}

/* Terminal block on mobile */
@media (max-width: 480px) {
  .isnad-terminal { font-size: 0.75rem; padding: 0.7rem; }
}

/* Callout on mobile */
@media (max-width: 480px) {
  .isnad-callout { padding: 0.8rem 1rem; font-size: 0.85rem; }
}

/* ===== Layout Fix — Floating TOC + Consistent Widths ===== */

/* Content column — all sections at consistent 900px */
.isnad-content-col { max-width: 900px; margin: 0 auto; }
.isnad-sect-inner { max-width: 900px; margin: 0 auto; }

/* Floating TOC — desktop only, fixed position */
@media (min-width: 1024px) {
  .isnad-toc {
    position: fixed;
    top: 120px;
    left: 20px;
    width: 170px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding: 0;
    font-size: 0.85rem;
    z-index: 50;
  }
  .isnad-toc a {
    display: block;
    color: var(--isnad-muted);
    text-decoration: none;
    padding: 0.3rem 0 0.3rem 0.6rem;
    border-left: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    line-height: 1.4;
  }
  .isnad-toc a:hover, .isnad-toc a.active {
    color: var(--isnad-green);
    border-left-color: var(--isnad-green);
  }
  /* Push content right to avoid TOC overlap */
  .isnad-page .isnad-content-col { margin-left: 200px; }
  .isnad-page .isnad-hero { margin-left: auto; margin-right: auto; }
}

@media (max-width: 1023px) {
  .isnad-toc { display: none; }
}

/* Mobile chain — pulse to indicate interactivity */
@keyframes chainPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(47,191,113,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(47,191,113,0); }
}
.chain-mobile-step { animation: none; }
.chain-mobile-step:first-child { animation: chainPulse 2s ease-in-out 3; }
.chain-mobile-step:active { animation: none; transform: scale(0.97); }

/* Better visual rhythm — reduce text density in bottom sections */
.isnad-sect p { margin-bottom: 0.85rem; }
.isnad-sect ul { margin-bottom: 0.85rem; }

/* Links section — compact grid on mobile */
@media (max-width: 480px) {
  .isnad-links { grid-template-columns: repeat(2, 1fr); }
  .isnad-link-card { padding: 0.75rem; }
}

/* FAQ — tighter spacing */
@media (max-width: 480px) {
  #faq h3 { font-size: 0.95rem; margin-top: 1.2rem; }
  #faq p { font-size: 0.85rem; }
}

/* Evaluation tables — tighter on mobile */
@media (max-width: 480px) {
  .isnad-table { font-size: 0.75rem; }
  .isnad-table td, .isnad-table th { padding: 0.4rem 0.5rem; min-width: 80px; }
}

/* Better section separation */
.isnad-sect + .isnad-sect { border-top: 1px solid rgba(150,163,157,0.08); }

/* Hero buttons — better mobile */
@media (max-width: 480px) {
  .isnad-hero-btns { gap: 0.5rem; }
  .isnad-hero-btns .isnad-btn { flex: 1 1 calc(50% - 0.25rem); font-size: 0.85rem; }
}

/* Corroboration buttons on mobile */
@media (max-width: 480px) {
  #corroboration-anim .chain-ctrl-btn { flex: 1; }
}

/* Matrix router — result card emphasis */
#mx-result { 
  border: 2px solid var(--isnad-green);
  transition: border-color 0.3s ease, transform 0.2s ease;
}

/* Footer on mobile */
@media (max-width: 480px) {
  .isnad-page .footer-inner { grid-template-columns: 1fr; gap: 1rem; }
  .isnad-page .footer-social { gap: 0.5rem; }
}

/* ===== TOC Fix — Simple sticky sidebar ===== */
.isnad-page-layout { position: relative; max-width: 1100px; margin: 0 auto; }

@media (min-width: 1024px) {
  .isnad-toc {
    position: sticky;
    top: 100px;
    float: left;
    width: 170px;
    margin-right: 2rem;
    padding: 0;
    font-size: 0.85rem;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }
  .isnad-content-col { 
    max-width: 900px; 
    margin-left: 190px;
    padding: 0 1rem;
  }
}

@media (max-width: 1023px) {
  .isnad-toc { display: none; }
  .isnad-content-col { max-width: 900px; margin: 0 auto; padding: 0 1rem; }
}

/* ===== TOC Final — overlay sidebar, doesn't affect content ===== */
@media (min-width: 1024px) {
  .isnad-toc {
    position: fixed;
    top: 100px;
    left: 0;
    width: 170px;
    padding: 0.5rem 0 0.5rem 0.75rem;
    font-size: 0.8rem;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    z-index: 40;
    background: linear-gradient(90deg, rgba(11,15,14,0.95), transparent);
    pointer-events: none;
  }
  .isnad-toc a { pointer-events: auto; }
  .isnad-content-col { max-width: 900px; margin: 0 auto; margin-left: 190px; padding: 0 1rem; }
  .isnad-hero, .isnad-sect:not(.isnad-page-layout *) { max-width: 900px; margin-left: auto; margin-right: auto; }
}

/* ===== Hero Animation ===== */
.hero-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.hero-grid-bg {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(15,118,110,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15,118,110,0.04) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 30%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 30%, transparent 70%);
  animation: gridShift 20s linear infinite;
}

@keyframes gridShift {
  0% { transform: translate(0, 0); }
  100% { transform: translate(60px, 60px); }
}

.hero-particle {
  position: absolute;
  border-radius: 50%;
  background: var(--accent-light);
  opacity: 0;
  pointer-events: none;
}

.hero-particle.p1 { width: 2px; height: 2px; left: 15%; top: 20%; animation: particle1 8s ease-in-out infinite; animation-delay: 0s; }
.hero-particle.p2 { width: 3px; height: 3px; left: 75%; top: 15%; animation: particle2 10s ease-in-out infinite; animation-delay: 2s; }
.hero-particle.p3 { width: 1.5px; height: 1.5px; left: 45%; top: 60%; animation: particle3 7s ease-in-out infinite; animation-delay: 4s; }
.hero-particle.p4 { width: 2.5px; height: 2.5px; left: 85%; top: 70%; animation: particle4 12s ease-in-out infinite; animation-delay: 1s; }
.hero-particle.p5 { width: 1px; height: 1px; left: 25%; top: 80%; animation: particle5 9s ease-in-out infinite; animation-delay: 3s; }
.hero-particle.p6 { width: 2px; height: 2px; left: 60%; top: 35%; animation: particle6 11s ease-in-out infinite; animation-delay: 5s; }

@keyframes particle1 {
  0%, 100% { opacity: 0; transform: translate(0, 0); }
  20%, 80% { opacity: 0.6; }
  50% { opacity: 1; transform: translate(40px, -20px); }
}

@keyframes particle2 {
  0%, 100% { opacity: 0; transform: translate(0, 0); }
  25%, 75% { opacity: 0.5; }
  50% { opacity: 0.9; transform: translate(-30px, 25px); }
}

@keyframes particle3 {
  0%, 100% { opacity: 0; transform: translate(0, 0); }
  30%, 70% { opacity: 0.7; }
  50% { opacity: 1; transform: translate(20px, -15px); }
}

@keyframes particle4 {
  0%, 100% { opacity: 0; transform: translate(0, 0); }
  20%, 80% { opacity: 0.4; }
  50% { opacity: 0.8; transform: translate(-25px, -30px); }
}

@keyframes particle5 {
  0%, 100% { opacity: 0; transform: translate(0, 0); }
  15%, 85% { opacity: 0.5; }
  50% { opacity: 0.7; transform: translate(15px, 20px); }
}

@keyframes particle6 {
  0%, 100% { opacity: 0; transform: translate(0, 0); }
  25%, 75% { opacity: 0.6; }
  50% { opacity: 1; transform: translate(-35px, -10px); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-grid-bg, .hero-particle { animation: none; }
  .hero-grid-bg { mask-image: none; -webkit-mask-image: none; }
}

@media (max-width: 768px) {
  .hero-bg { opacity: 0.5; }
  .hero-grid-bg { background-size: 40px 40px; }
}

/* ===== Hero Animation v2 — Orbs + Particles ===== */
.hero-orbs {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.hero-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  animation: orbFloat 12s ease-in-out infinite;
}

.orb-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, var(--accent-light), transparent);
  top: -20%; left: -10%;
  animation-delay: 0s;
}

.orb-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, var(--accent-light), transparent);
  bottom: -10%; right: -5%;
  animation-delay: -4s;
}

.orb-3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(20,184,166,0.5), transparent);
  top: 40%; left: 50%;
  animation-delay: -8s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.1); }
  66% { transform: translate(-20px, 15px) scale(0.95); }
}

/* More particles */
.hero-particle.p7 { width: 2px; height: 2px; left: 10%; top: 50%; animation: particle7 13s ease-in-out infinite; animation-delay: 0s; }
.hero-particle.p8 { width: 3px; height: 3px; left: 70%; top: 80%; animation: particle8 10s ease-in-out infinite; animation-delay: 6s; }

@keyframes particle7 {
  0%, 100% { opacity: 0; transform: translate(0, 0); }
  20%, 80% { opacity: 0.5; }
  50% { opacity: 0.9; transform: translate(50px, -30px); }
}

@keyframes particle8 {
  0%, 100% { opacity: 0; transform: translate(0, 0); }
  25%, 75% { opacity: 0.6; }
  50% { opacity: 1; transform: translate(-40px, -20px); }
}

/* More visible grid */
.hero-grid-bg {
  background-size: 50px 50px;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 20%, transparent 60%);
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 20%, transparent 60%);
}

@media (max-width: 768px) {
  .orb-1 { width: 300px; height: 300px; }
  .orb-2 { width: 250px; height: 250px; }
  .orb-3 { width: 200px; height: 200px; }
  .hero-orb { filter: blur(50px); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-orb { animation: none; opacity: 0.08; }
  .hero-grid-bg { animation: none; mask-image: none; -webkit-mask-image: none; }
  .hero-particle { display: none; }
}

/* 6-column metrics grid */
@media (min-width: 981px) {
  .metrics-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ===== Hero Animation v3 — Actually visible ===== */
.hero-orb {
  opacity: 0.25 !important;
  filter: blur(60px) !important;
  animation: orbFloatVisible 8s ease-in-out infinite;
}

@keyframes orbFloatVisible {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.2; }
  25% { transform: translate(60px, -30px) scale(1.3); opacity: 0.35; }
  50% { transform: translate(-30px, 20px) scale(0.9); opacity: 0.2; }
  75% { transform: translate(40px, 10px) scale(1.2); opacity: 0.3; }
}

.orb-1 { width: 600px; height: 600px; top: -30%; left: -15%; }
.orb-2 { width: 500px; height: 500px; bottom: -20%; right: -10%; }
.orb-3 { width: 400px; height: 400px; top: 35%; left: 45%; }

.hero-particle {
  opacity: 0.5 !important;
  width: 4px !important;
  height: 4px !important;
  background: var(--accent-light) !important;
  box-shadow: 0 0 8px rgba(20,184,166,0.6);
}

.hero-particle.p1 { width: 5px; height: 5px; left: 10%; top: 15%; animation: p1 6s ease-in-out infinite; }
.hero-particle.p2 { width: 6px; height: 6px; left: 80%; top: 10%; animation: p2 8s ease-in-out infinite; animation-delay: 1s; }
.hero-particle.p3 { width: 3px; height: 3px; left: 50%; top: 60%; animation: p3 7s ease-in-out infinite; animation-delay: 2s; }
.hero-particle.p4 { width: 5px; height: 5px; left: 90%; top: 70%; animation: p4 9s ease-in-out infinite; animation-delay: 0.5s; }
.hero-particle.p5 { width: 4px; height: 4px; left: 30%; top: 80%; animation: p5 6.5s ease-in-out infinite; animation-delay: 3s; }
.hero-particle.p6 { width: 6px; height: 6px; left: 65%; top: 30%; animation: p6 7.5s ease-in-out infinite; animation-delay: 1.5s; }
.hero-particle.p7 { width: 3px; height: 3px; left: 15%; top: 45%; animation: p7 8.5s ease-in-out infinite; animation-delay: 0s; }
.hero-particle.p8 { width: 5px; height: 5px; left: 75%; top: 85%; animation: p8 6s ease-in-out infinite; animation-delay: 4s; }

@keyframes p1 { 0%,100%{opacity:0.2;transform:translate(0,0)} 50%{opacity:1;transform:translate(80px,-50px)} }
@keyframes p2 { 0%,100%{opacity:0.3;transform:translate(0,0)} 50%{opacity:0.9;transform:translate(-60px,40px)} }
@keyframes p3 { 0%,100%{opacity:0.2;transform:translate(0,0)} 50%{opacity:1;transform:translate(50px,-30px)} }
@keyframes p4 { 0%,100%{opacity:0.3;transform:translate(0,0)} 50%{opacity:0.8;transform:translate(-80px,-40px)} }
@keyframes p5 { 0%,100%{opacity:0.2;transform:translate(0,0)} 50%{opacity:0.9;transform:translate(40px,60px)} }
@keyframes p6 { 0%,100%{opacity:0.4;transform:translate(0,0)} 50%{opacity:1;transform:translate(-50px,-60px)} }
@keyframes p7 { 0%,100%{opacity:0.2;transform:translate(0,0)} 50%{opacity:0.7;transform:translate(70px,30px)} }
@keyframes p8 { 0%,100%{opacity:0.3;transform:translate(0,0)} 50%{opacity:1;transform:translate(-70px,-20px)} }

@media (max-width: 768px) {
  .orb-1 { width: 300px; height: 300px; }
  .orb-2 { width: 250px; height: 250px; }
  .orb-3 { width: 200px; height: 200px; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-orb, .hero-particle { animation: none !important; opacity: 0.1 !important; }
  .hero-grid-bg { animation: none; }
}
