/* Blog pages. Tokens, nav, hero, buttons and footer come from ../resources/resources.css */

/* resources.css clips .container; that would break the sticky table of contents */
.container { overflow: visible; }
html, body { overflow-x: clip; }

.nav-link.is-section { color: var(--primary); background: var(--primary-light); }

/* reading progress */
.read-progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 200; pointer-events: none; }
.read-progress span { display: block; height: 100%; background: var(--primary); transform: scaleX(0); transform-origin: right center; }

/* breadcrumb */
.breadcrumb { padding-top: 14px; }
.breadcrumb ol { display: flex; flex-wrap: wrap; align-items: center; list-style: none; font-size: 0.82rem; color: var(--text-muted); }
.breadcrumb li { display: inline-flex; align-items: center; }
.breadcrumb li + li::before { content: '‹'; margin: 0 8px; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.breadcrumb a:hover { color: var(--primary); }

/* post header */
.post-header { max-width: 860px; margin: 12px auto 32px; text-align: center; }
.post-header h1 { font-size: clamp(1.5rem, 4vw, 2.3rem); font-weight: 900; color: var(--dark); line-height: 1.65; margin: 16px 0 20px; text-wrap: balance; }
.post-header .grad { color: var(--primary); white-space: nowrap; }
.byline { display: inline-flex; align-items: center; gap: 12px; text-align: right; }
.avatar { flex-shrink: 0; width: 52px; height: 52px; border-radius: 50%; overflow: hidden; background: var(--primary-light); border: 2px solid var(--border-color); }
.avatar { position: relative; }
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.post-cover { max-width: 860px; margin: 0 auto 36px; }
.post-cover img { display: block; width: 100%; height: auto; border-radius: 18px; border: 1px solid var(--border-color); }
.byline-name { font-weight: 800; color: var(--dark); font-size: 0.95rem; }
.byline-meta { font-size: 0.8rem; color: var(--text-muted); }

/* layout: reading column + sticky table of contents */
.post-layout { display: grid; grid-template-columns: 240px minmax(0, 760px); gap: 40px; justify-content: center; align-items: start; margin-bottom: 56px; }
.toc-col { position: sticky; top: 92px; align-self: start; }
.toc { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 6px 16px; box-shadow: var(--shadow-sm); }
.toc summary { cursor: pointer; font-weight: 800; color: var(--dark); font-size: 0.9rem; min-height: 44px; display: flex; align-items: center; justify-content: space-between; list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc summary::after { content: '+'; font-size: 1.2rem; color: var(--primary); }
.toc[open] summary::after { content: '−'; }
.toc ol { list-style: none; padding-bottom: 8px; }
.toc a { display: flex; align-items: center; min-height: 40px; padding: 4px 12px; border-right: 2px solid var(--border-color); color: var(--text-muted); text-decoration: none; font-size: 0.85rem; line-height: 1.6; }
.toc a:hover { color: var(--dark); }
.toc a.active { color: var(--primary); border-right-color: var(--primary); font-weight: 800; }

/* article text */
.prose { min-width: 0; font-size: 1.02rem; line-height: 2.05; }
.prose p { margin-bottom: 18px; }
.prose section { margin-top: 44px; }
.prose h2 { font-size: clamp(1.25rem, 3vw, 1.55rem); font-weight: 900; color: var(--dark); line-height: 1.7; margin-bottom: 16px; scroll-margin-top: 92px; text-wrap: balance; }
.prose h3 { font-size: 1.05rem; font-weight: 800; color: var(--dark); line-height: 1.8; margin-bottom: 6px; }
.prose strong { color: var(--dark); }
/* keep English terms from breaking mid-phrase */
.prose span[lang="en"] { white-space: nowrap; }
.prose p a, .prose li a, .related a { color: var(--primary); text-underline-offset: 4px; }

.answer-box { background: var(--primary-light); border: 1px solid var(--border-color); border-right: 4px solid var(--primary); border-radius: var(--radius-sm); padding: 18px 20px; margin-bottom: 24px; }
.prose .answer-box .answer-title { font-size: 1rem; color: var(--primary); margin-bottom: 4px; }
.answer-box p { margin: 0; }

.note { font-size: 0.9rem; line-height: 1.95; background: var(--bg-card); border: 1px dashed var(--border-color); border-radius: var(--radius-sm); padding: 14px 18px; }

/* table */
.table-wrap { margin: 8px 0 18px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-card); }
.time-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; line-height: 1.8; }
.time-table caption { caption-side: top; text-align: right; padding: 12px 14px; font-weight: 800; color: var(--dark); border-bottom: 1px solid var(--border-color); }
.time-table th, .time-table td { padding: 12px 14px; text-align: right; vertical-align: top; border-bottom: 1px solid var(--border-color); }
.time-table thead th { background: var(--primary-light); color: var(--dark); font-weight: 800; }
.time-table tbody th { color: var(--dark); font-weight: 800; }
.time-table tbody tr:last-child > * { border-bottom: 0; }
.time-table td:nth-last-child(-n+2) { white-space: nowrap; font-weight: 800; color: var(--primary); }

.inline-cta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; border: 1px solid var(--border-color); background: var(--bg-card); border-radius: var(--radius-sm); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.prose .inline-cta p { flex: 1 1 300px; margin: 0; font-size: 0.93rem; }
.inline-cta .btn { flex: 0 0 auto; }

/* mistakes: numbered cards */
.mistake-list, .steps { list-style: none; counter-reset: item; }
.mistake-list li { counter-increment: item; position: relative; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 18px 62px 18px 18px; margin-bottom: 14px; }
.mistake-list li::before { content: counter(item, persian); position: absolute; right: 16px; top: 18px; width: 32px; height: 32px; border-radius: 10px; background: var(--primary-light); color: var(--primary); font-weight: 900; display: flex; align-items: center; justify-content: center; line-height: 1; }
.mistake-list p, .steps p { margin: 0; font-size: 0.96rem; }

/* roadmap: timeline */
.steps li { counter-increment: item; position: relative; padding: 0 56px 28px 0; }
.steps li::before { content: counter(item, persian); position: absolute; right: 0; top: 0; z-index: 1; width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 900; display: flex; align-items: center; justify-content: center; line-height: 1; }
.steps li:not(:last-child)::after { content: ''; position: absolute; right: 17px; top: 36px; bottom: 0; width: 2px; background: var(--border-color); }
.steps li:last-child { padding-bottom: 0; }
.step-tag { display: inline-block; font-size: 0.74rem; font-weight: 800; color: var(--primary); background: var(--primary-light); border-radius: var(--radius-full); padding: 2px 12px; margin-bottom: 4px; }

/* exam comparison */
.exam-grid { display: grid; gap: 12px; margin-bottom: 18px; }
.exam-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 16px 18px; }
.prose .exam-card h3 { text-align: right; color: var(--primary); }
.prose .exam-card p { margin: 0; font-size: 0.95rem; }

/* two-option comparison */
.compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.compare-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 18px; }
.compare-card.is-main { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.compare-card ul { padding-right: 20px; margin-bottom: 12px; font-size: 0.93rem; }
.compare-card li::marker { color: var(--primary); }
.prose .compare-card p { margin: 0; font-size: 0.93rem; }
.prose .compare-card .compare-level { display: inline-block; font-size: 0.76rem; font-weight: 800; color: var(--primary); background: var(--primary-light); border-radius: var(--radius-full); padding: 2px 12px; margin-bottom: 10px; }

/* book table: long text in every column */
.book-table td:nth-last-child(-n+2) { white-space: normal; font-weight: 400; color: inherit; }
.book-table td:first-of-type { font-weight: 800; color: var(--primary); }
.book-table tbody th { white-space: nowrap; }

/* daily routine */
.routine { list-style: none; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); margin-bottom: 24px; }
.routine li { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 18px; font-size: 0.95rem; }
.routine li + li { border-top: 1px solid var(--border-color); }
.routine b { flex-shrink: 0; color: var(--primary); background: var(--primary-light); border-radius: var(--radius-full); padding: 0 14px; font-size: 0.82rem; }

/* bilingual examples */
.ex { border-right: 3px solid var(--border-color); background: var(--primary-light); border-radius: 8px; padding: 8px 14px; margin-top: 10px; }
.prose .ex p { margin: 0; font-size: 0.9rem; line-height: 1.8; }
.prose .ex p[lang="en"] { text-align: left; font-weight: 700; color: var(--dark); }
.ex.good { border-right-color: #16a34a; }
.ex.bad { border-right-color: #dc2626; }
.prose .ex.bad p[lang="en"] { text-decoration: line-through; text-decoration-color: #dc2626; }
.prose .compare-card h3[lang="en"] { text-align: right; }
.grammar-table bdi { display: inline-block; text-align: right; }
/* both tense columns carry equal weight */
.book-table.grammar-table td:first-of-type { font-weight: 400; color: inherit; }

/* self-check */
.quiz-item { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); margin-bottom: 10px; }
.quiz-item summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 12px 18px; font-weight: 700; color: var(--dark); font-size: 0.94rem; }
.quiz-item summary::-webkit-details-marker { display: none; }
.quiz-item summary::after { content: 'پاسخ'; flex-shrink: 0; font-size: 0.76rem; color: var(--primary); background: var(--primary-light); border-radius: var(--radius-full); padding: 2px 12px; }
.quiz-item[open] summary::after { content: 'بستن'; }
.prose .quiz-item p { margin: 0; padding: 0 18px 16px; font-size: 0.93rem; }

/* phrases under the mistake cards */
.mistake-list .ex + p { margin-top: 10px; }
.prose h3.spaced { margin-top: 28px; }
.routine b[lang="en"] { flex-shrink: 1; text-align: left; border-radius: 10px; padding: 2px 12px; }

/* faq */
.faq-item { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); margin-bottom: 10px; }
.faq-item summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 12px 18px; font-weight: 800; color: var(--dark); font-size: 0.96rem; line-height: 1.8; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; flex-shrink: 0; font-size: 1.4rem; color: var(--primary); }
.faq-item[open] summary::after { content: '−'; }
.prose .faq-item p { margin: 0; padding: 0 18px 16px; font-size: 0.95rem; }

/* call to action */
.cta-card { text-align: center; background: linear-gradient(135deg, var(--primary-glow), transparent 70%), var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 28px 22px; box-shadow: var(--shadow-md); }
.cta-card h2 { font-size: 1.3rem; font-weight: 900; color: var(--dark); margin-bottom: 8px; scroll-margin-top: 92px; }
.cta-card p { max-width: 540px; margin: 0 auto 18px; }
.cta-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.cta-actions .btn { flex: 0 1 240px; }
.related { margin-top: 24px; font-size: 0.92rem; }
.reviewed { font-size: 0.8rem; color: var(--text-muted); }

/* blog index */
.post-list { display: grid; gap: 20px; max-width: 900px; margin: 32px auto; }
.post-card { position: relative; display: grid; grid-template-columns: 260px minmax(0, 1fr); background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-sm); transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease; }
.post-card:hover, .post-card:focus-within { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.post-card-art { display: flex; align-items: center; justify-content: center; gap: 12px; direction: rtl; min-height: 180px; padding: 20px; background: linear-gradient(135deg, var(--primary), #7c3aed); color: #fff; font-weight: 900; font-size: 1.6rem; }
.post-card-art .art-line { flex: 0 1 70px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.6); }
.post-card-art .art-to { font-size: 3rem; }
.post-card-body { padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.post-card h2 { font-size: 1.15rem; font-weight: 900; line-height: 1.8; }
.post-card h2 a { color: var(--dark); text-decoration: none; }
/* the whole card is clickable through the title link */
.post-card h2 a::after { content: ''; position: absolute; inset: 0; }
.post-card p { font-size: 0.92rem; color: var(--text-muted); }
.post-card-meta { font-size: 0.8rem; color: var(--text-muted); font-weight: 700; }
.post-card-more { color: var(--primary); font-weight: 800; font-size: 0.88rem; }
.post-card-art.alt { background: linear-gradient(135deg, #0f766e, var(--primary)); }
.post-card-art.alt .art-to { font-size: 2.4rem; }
.post-card-art.warm { background: linear-gradient(135deg, #b45309, #be185d); }
.post-card-art.grammar { background: linear-gradient(135deg, #4338ca, #0e7490); }
.post-card-art.grammar .art-to { font-size: 2.2rem; }
.post-card-art.mistakes { background: linear-gradient(135deg, #9f1239, #15803d); }
.blog-cta { max-width: 900px; margin: 0 auto 56px; }

@media (max-width: 1024px) {
  .post-layout { grid-template-columns: minmax(0, 760px); gap: 22px; }
  .toc-col { position: static; }
}

@media (max-width: 640px) {
  .res-nav-inner { gap: 6px; }
  .nav-links { gap: 2px; }
  .nav-link { padding: 8px 10px; font-size: 0.82rem; white-space: nowrap; }
  .brand { font-size: 1.05rem; white-space: nowrap; }
  .post-header { margin-bottom: 22px; }
  .prose { font-size: 0.98rem; }

  /* each table row becomes a card */
  .time-table, .time-table caption, .time-table tbody, .time-table tr, .time-table th, .time-table td { display: block; }
  .time-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .time-table tr { border-bottom: 1px solid var(--border-color); padding: 10px 0; }
  .time-table tbody tr:last-child { border-bottom: 0; }
  .time-table th, .time-table td { border: 0; padding: 3px 14px; }
  .time-table tbody th { font-size: 0.98rem; color: var(--primary); }
  .time-table td { display: flex; justify-content: space-between; gap: 14px; }
  .time-table td::before { content: attr(data-label); flex-shrink: 0; color: var(--text-muted); font-weight: 700; }
  .time-table td:first-of-type { display: block; color: var(--text-muted); }
  .time-table td:first-of-type::before { content: none; }

  .compare-grid { grid-template-columns: minmax(0, 1fr); }
  .book-table td, .book-table td:first-of-type { display: block; padding-block: 5px; }
  .book-table td::before, .book-table td:first-of-type::before { content: attr(data-label); display: block; font-size: 0.75rem; font-weight: 700; color: var(--text-muted); }
  .mistake-list li { padding: 62px 16px 16px; }
  .steps li { padding-right: 48px; }
  .inline-cta .btn, .cta-actions .btn { flex: 1 1 100%; }
  .post-card { grid-template-columns: minmax(0, 1fr); }
  .post-card-art { min-height: 120px; }
}

@media (max-width: 360px) {
  .brand { font-size: 0.95rem; }
  .nav-link { padding: 8px 6px; font-size: 0.78rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .post-card:hover, .post-card:focus-within { transform: none; }
}

@media print {
  .res-nav, .read-progress, .toc-col, .inline-cta, .cta-card, .footer { display: none; }
  .post-layout { display: block; }
}
