/* Portiva blog, v2. Loaded after site.v3.css on blog pages only (generated by Web/scripts/build-blog.mjs).
   Same rules as the rest of the site: ink on white, hairlines, flat surfaces, no shadows, no gradients, color only for
   data. Logical properties throughout, so the Arabic (right-to-left) pages mirror correctly.
   Cache: served with a one-year immutable Cache-Control. Never edit a published version: copy it to blog.v3.css,
   change that, update SITE.css in Web/content/blog/i18n.mjs and rebuild. */

/* ---------- Header: language menu (details/summary, no script) ---------- */

.lang-menu { position: relative; margin-inline-start: 8px; }
.lang-menu summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 999px;
  color: var(--text); font-size: 0.9375rem; white-space: nowrap; position: relative;
}
.lang-menu summary::after {
  content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg); opacity: 0.6;
}
.lang-menu summary::before { content: ""; position: absolute; inset: -4px -2px; }
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary:hover { border-color: var(--ink); }
.lang-menu[open] summary::after { transform: translateY(1px) rotate(225deg); }
.lang-menu ul {
  position: absolute; inset-inline-end: 0; top: calc(100% + 10px); z-index: 40; list-style: none; margin: 0; padding: 6px;
  min-width: 220px; background: var(--card); border: 1px solid var(--line-2); border-radius: 16px;
}
.lang-menu li a {
  display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 10px;
  color: var(--text); text-decoration: none; font-size: 0.9375rem;
}
.lang-menu li a:hover { background: var(--bg-2); }
.lang-menu li a[aria-current] { font-weight: 600; }
.lang-menu li a[aria-current]::after { content: ""; margin-inline-start: auto; width: 10px; height: 6px; border-left: 1.75px solid currentColor; border-bottom: 1.75px solid currentColor; transform: translateY(-2px) rotate(-45deg); }

@media (max-width: 379px) {
  .lang-menu { margin-inline-start: 4px; }
  .lang-menu summary { padding: 0 12px; gap: 6px; }
}

/* ---------- Breadcrumb ---------- */

.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; font-size: 0.875rem; color: var(--text-3); }
.crumbs li { margin: 0; display: flex; align-items: center; }
.crumbs li + li::before { content: "/"; margin-inline-end: 8px; color: var(--line-2); }
.crumbs a { display: inline-flex; align-items: center; min-height: 44px; color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }

/* ---------- Article ---------- */

.post { padding-top: clamp(24px, 4vw, 56px); }
.post .doc { max-width: 42rem; }
.post-head { padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.post .doc h1 { margin-top: 12px; font-size: clamp(2.125rem, 1.5rem + 2.8vw, 3.375rem); letter-spacing: -0.04em; line-height: 1.06; }
.post .doc .meta { margin-top: 18px; }
.doc .post-note {
  margin-top: 24px; color: var(--text-3); font-size: 0.875rem; line-height: 1.55;
}

.post-body { font-size: 1.125rem; line-height: 1.7; }
.post-body > p:first-child { margin-top: 0; }
.post-body p, .post-body ul, .post-body ol { margin-top: 20px; }
.post-body li + li { margin-top: 10px; }
.post-body h2 { margin-top: 64px; font-size: clamp(1.5rem, 1.3rem + 0.8vw, 2rem); line-height: 1.2; }
.post-body h3 { margin-top: 40px; font-size: 1.25rem; line-height: 1.3; }
.post-body h2 + p, .post-body h3 + p { margin-top: 14px; }
.post-body strong { font-weight: 600; color: var(--text); }
.post-body a { text-decoration-color: var(--line-2); }
.post-body a:hover { text-decoration-color: currentColor; }

.doc .tldr { margin-top: 32px; padding: 26px 28px; border-radius: var(--radius-lg); background: var(--bg-2); }
.doc .tldr p { margin: 0; font-size: 1.125rem; line-height: 1.6; }
.doc .tldr p + p { margin-top: 12px; }
.doc .tip { margin-top: 24px; padding: 18px 22px; border-radius: var(--radius); border: 1px solid var(--line); font-size: 1.0625rem; }
.doc .tip p { margin: 0; }
.doc .tip p + p { margin-top: 8px; }
.doc blockquote { margin: 24px 0 0; padding-inline-start: 18px; border-inline-start: 2px solid var(--ink); }

/* Table of contents inside articles */
.post-body .toc { margin: 40px 0 0; }

.table-wrap {
  margin-top: 24px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
}
.doc table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; line-height: 1.45; font-variant-numeric: tabular-nums; }
.doc caption { caption-side: top; text-align: start; padding: 14px 16px 10px; font-size: 0.875rem; font-weight: 600; color: var(--text-2); }
.doc th, .doc td { padding: 11px 16px; text-align: start; vertical-align: top; border-top: 1px solid var(--line); }
.doc thead th { border-top: 0; font-size: 0.8125rem; font-weight: 600; color: var(--text-3); background: var(--bg-2); }
.doc caption + thead th { border-top: 1px solid var(--line); }
.doc tbody th { font-weight: 600; }
.doc td { color: var(--text-2); }

.doc .sources { font-size: 0.9375rem; line-height: 1.6; color: var(--text-2); }
.doc .sources a { color: var(--text); }
.doc .sources li + li { margin-top: 10px; }

/* ---------- App Store card ---------- */

.cta {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: start;
  margin-top: 56px; padding: 28px; border-radius: var(--radius-xl); background: var(--bg-2);
}
.cta .app-icon { width: 64px; height: 64px; }
.doc .cta h2, .cta h2 { margin: 0; font-size: 1.375rem; letter-spacing: -0.02em; line-height: 1.2; }
.cta p { margin-top: 10px; color: var(--text-2); font-size: 1rem; line-height: 1.55; }
.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px; margin-top: 22px; }
.cta .cta-row .cta-note { margin: 0; max-width: 20rem; font-size: 0.875rem; color: var(--text-3); }
@media (max-width: 519px) {
  .cta { grid-template-columns: minmax(0, 1fr); padding: 24px; }
  .cta .app-icon { width: 56px; height: 56px; }
}

/* ---------- Blog home ---------- */

.blog-home { padding-top: clamp(40px, 6vw, 88px); }
.blog-head { max-width: 46rem; }
.blog-head h1 { font-size: clamp(2.5rem, 1.5rem + 4.4vw, 4.5rem); letter-spacing: -0.045em; line-height: 1.02; text-wrap: balance; }
.blog-head .intro { margin-top: 22px; color: var(--text-2); font-size: clamp(1.125rem, 1rem + 0.45vw, 1.3125rem); line-height: 1.5; text-wrap: pretty; }

/* ---------- Article cards (blog home, related) ---------- */

.post-grid { list-style: none; margin: clamp(40px, 6vw, 64px) 0 0; padding: 0; display: grid; gap: 16px; }
@media (min-width: 680px) { .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1040px) { .post-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.post-card { margin: 0; }
.post-card article {
  position: relative; height: 100%; display: flex; flex-direction: column;
  padding: 28px; border-radius: var(--radius-lg); background: var(--bg-2);
}
.post-card:hover article { background: var(--bg-3); }
.post-card h2, .post-card h3 { margin: 0; font-size: 1.3125rem; letter-spacing: -0.02em; line-height: 1.25; text-wrap: balance; }
.post-card h2 a, .post-card h3 a { text-decoration: none; }
.post-card h2 a::after, .post-card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.post-card a:focus-visible { outline: none; }
.post-card a:focus-visible::after { outline: 2px solid var(--ink); outline-offset: 3px; }
.post-card p { margin-top: 12px; color: var(--text-2); font-size: 0.9875rem; line-height: 1.55; }
.post-card .meta { margin-top: auto; padding-top: 22px; font-size: 0.8125rem; color: var(--text-3); }

@media (min-width: 680px) {
  .post-card.featured { grid-column: 1 / -1; }
  .post-card.featured article { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 12px 48px; padding: 40px; background: var(--band); color: var(--band-text); }
  .post-card.featured:hover article { background: var(--band); }
  .post-card.featured h2 { grid-row: 1 / span 2; font-size: clamp(1.75rem, 1.2rem + 1.6vw, 2.5rem); letter-spacing: -0.035em; line-height: 1.1; }
  .post-card.featured p { margin-top: 0; color: var(--band-text-2); font-size: 1.0625rem; }
  .post-card.featured .meta { color: var(--band-text-2); padding-top: 0; margin-top: 0; align-self: end; }
  .post-card.featured a:focus-visible::after { outline-color: var(--band-text); }
}

.post-more { padding-bottom: clamp(72px, 9vw, 120px); }
.related { border-top: 1px solid var(--line); padding-top: clamp(48px, 6vw, 72px); }
.related > h2, .other-langs > h2 { font-size: clamp(1.5rem, 1.3rem + 0.8vw, 2rem); letter-spacing: -0.03em; }
.related .post-grid { margin-top: 28px; }
.related .post-card h3 { font-size: 1.1875rem; }

/* ---------- Other languages, feed ---------- */

.other-langs { margin-top: clamp(48px, 6vw, 72px); }
.blog-home .other-langs { border-top: 1px solid var(--line); padding-top: clamp(40px, 5vw, 56px); }
.other-langs > h2 { font-size: 1.25rem; letter-spacing: -0.015em; }
.lang-list { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.lang-list li { margin: 0; }
.lang-list a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line-2); border-radius: 999px; text-decoration: none; font-size: 0.9375rem;
}
.lang-list a:hover { border-color: var(--ink); }
.feed-link { margin-top: 32px; font-size: 0.875rem; color: var(--text-3); padding-bottom: 24px; }
.blog-home .cta { margin-top: clamp(56px, 7vw, 88px); max-width: 52rem; }

/* ---------- Right-to-left (Arabic) ---------- */

/* Negative tracking breaks Arabic letter joining: reset it everywhere on RTL pages. */
[dir="rtl"] :is(h1, h2, h3, h4, p, a, li, span, strong, b, summary, small) { letter-spacing: 0 !important; }
[dir="rtl"] body { font-size: 1.125rem; line-height: 1.7; }
[dir="rtl"] :is(h1, h2, h3, h4) { line-height: 1.4; }
[dir="rtl"] .post-body { font-size: 1.1875rem; line-height: 1.85; }
[dir="rtl"] .wordmark { direction: ltr; }
[dir="rtl"] .store-badge { direction: rtl; }
[dir="rtl"] .footer-nav { justify-content: start; }

@media (max-width: 479px) {
  .post-body { font-size: 1.0625rem; }
  .doc .tldr { padding: 22px; }
  .post-card article { padding: 24px; }
}

@media print {
  .lang-menu, .cta, .lang-list, .feed-link, .crumbs, .post-more { display: none; }
}
