@font-face {
  font-family: 'IRANSansX';
  src: url('/fonts/IRANSansX-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'IRANSansX';
  src: url('/fonts/IRANSansX-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  /* Product tokens from app.directyar.com, extended with a violet used only for accents and gradients. */
  --gray-50: #f6f8fa;
  --gray-100: #eef1f5;
  --gray-200: #dde2ea;
  --gray-500: #68768b;
  --gray-700: #364154;
  --gray-900: #101927;
  --brand-50: #e2f6fa;
  --brand-500: #08aece;
  --brand-600: #058ca8;
  --brand-700: #066d82;
  --violet-500: #7c6cf0;
  --warning-50: #fffaeb;
  --warning-700: #b54708;
  --bg: #fbfcfe;
  --fg: var(--gray-900);
  --fg-muted: #4a566a;
  --border: #e3e8f0;
  --surface: #ffffff;
  --surface-2: #f2f5f9;
  --code-bg: #eaf0f6;
  --shadow-sm: 0 1px 2px rgb(16 25 39 / 6%), 0 1px 1px rgb(16 25 39 / 4%);
  --shadow-md: 0 10px 30px -12px rgb(6 109 130 / 28%), 0 2px 6px rgb(16 25 39 / 6%);
  --glass: rgb(251 252 254 / 78%);
  --hero-a: rgb(8 174 206 / 22%);
  --hero-b: rgb(124 108 240 / 16%);
  --radius: 16px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0f19;
    --fg: #eef1f5;
    --fg-muted: #b4bdcc;
    --border: #202b3e;
    --surface: #101826;
    --surface-2: #162033;
    --code-bg: #1b2638;
    --brand-50: #0c2f38;
    --brand-600: #4ac5dc;
    --brand-700: #82daea;
    --warning-50: #2a2108;
    --warning-700: #fedf89;
    --gray-500: #8d99ad;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-md: 0 14px 34px -14px rgb(0 0 0 / 70%), 0 0 0 1px rgb(74 197 220 / 12%);
    --glass: rgb(10 15 25 / 78%);
    --hero-a: rgb(8 174 206 / 20%);
    --hero-b: rgb(124 108 240 / 18%);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'IRANSansX', Tahoma, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-600); text-underline-offset: 4px; }
a:hover { color: var(--brand-700); }
h1, h2, h3, h4 { line-height: 1.5; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.4rem); margin-top: 0.6rem; }
img { max-width: 100%; height: auto; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand-500) 70%, transparent); outline-offset: 2px; border-radius: 6px; }

/* Header: translucent, blurs the page under it. */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-row { display: flex; align-items: center; gap: 14px; min-height: 68px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--fg); text-decoration: none; }
.brand:hover { color: var(--fg); }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; color: #fff;
  background: linear-gradient(135deg, var(--brand-500), var(--violet-500));
  box-shadow: 0 6px 14px -6px rgb(8 174 206 / 70%);
}
.main-nav { display: flex; gap: 4px; }
.main-nav a { color: var(--fg-muted); text-decoration: none; padding: 6px 14px; border-radius: 999px; transition: background-color 0.15s, color 0.15s; }
.main-nav a:hover { background: var(--surface-2); color: var(--fg); }
.main-nav a.active { background: var(--brand-50); color: var(--brand-700); }
.search-form { flex: 1 1 220px; margin-inline-start: auto; max-width: 360px; }
.search-form input, .hero-search input {
  width: 100%; font: inherit; color: var(--fg); background: var(--surface-2);
  border: 1px solid transparent; transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.search-form input { padding: 8px 18px; border-radius: 999px; }
.search-form input:focus, .hero-search input:focus { outline: none; background: var(--surface); border-color: var(--brand-500); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-500) 22%, transparent); }
::placeholder { color: var(--gray-500); opacity: 1; }

.button {
  display: inline-flex; align-items: center; font: inherit; text-decoration: none; cursor: pointer;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700)); color: #fff;
  padding: 9px 20px; border-radius: 999px; border: 1px solid transparent;
  box-shadow: 0 6px 16px -8px rgb(6 109 130 / 80%); transition: transform 0.15s, box-shadow 0.15s;
}
.button:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 10px 20px -8px rgb(6 109 130 / 80%); }
.button-small { padding: 6px 16px; font-size: 0.9rem; }
.button-outline { background: transparent; color: var(--brand-600); border-color: var(--brand-600); box-shadow: none; }
.button-outline:hover { background: var(--brand-50); color: var(--brand-700); box-shadow: none; transform: none; }

main { padding-bottom: 72px; min-height: 60vh; }

/* Home: the search box is the first thing to use. */
.hero {
  position: relative; text-align: center; margin: 20px 0 0; padding: 64px 20px 48px; border-radius: 28px; overflow: hidden;
  background:
    radial-gradient(60% 90% at 85% 0%, var(--hero-a), transparent 70%),
    radial-gradient(55% 90% at 10% 100%, var(--hero-b), transparent 70%),
    var(--surface);
  border: 1px solid var(--border);
}
.hero h1 { font-size: clamp(1.9rem, 1.3rem + 3vw, 3rem); margin: 0 0 0.35em; }
.hero > p { color: var(--fg-muted); max-width: 560px; margin: 0 auto; font-size: 1.05rem; }
.hero-search { display: flex; gap: 8px; max-width: 600px; margin: 28px auto 0; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow-md); }
.hero-search input { flex: 1; min-width: 0; padding: 10px 20px; border-radius: 999px; background: transparent; }
.hero-search input:focus { box-shadow: none; background: transparent; border-color: transparent; }
.hero-search:focus-within { border-color: var(--brand-500); box-shadow: var(--shadow-md), 0 0 0 4px color-mix(in srgb, var(--brand-500) 22%, transparent); }
.hero-search button {
  font: inherit; font-weight: 700; color: #fff; border: 0; padding: 0 26px; border-radius: 999px; cursor: pointer;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
}
.hero-search button:hover { filter: brightness(1.08); }
.hero-chips { display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; margin: 18px 0 0; font-size: 0.92rem; color: var(--gray-500); }
.hero-chips a { padding: 2px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--fg-muted); transition: border-color 0.15s, color 0.15s; }
.hero-chips a:hover { border-color: var(--brand-500); color: var(--brand-700); }

.doors { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin: 28px 0 48px; }
.door {
  position: relative; display: block; padding: 28px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--fg); text-decoration: none; box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.door:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--brand-500) 55%, var(--border)); color: var(--fg); }
.door-icon { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 18px; border-radius: 16px; color: var(--brand-700); background: var(--brand-50); }
.door-automation .door-icon { color: var(--violet-500); background: color-mix(in srgb, var(--violet-500) 14%, transparent); }
.door h2 { margin-bottom: 0.3em; font-size: 1.35rem; }
.door p { color: var(--fg-muted); margin: 0 0 16px; }
.door-cta { display: inline-block; padding: 2px 14px; border-radius: 999px; background: var(--surface-2); color: var(--brand-700); font-weight: 700; font-size: 0.9rem; }

.section-title { margin-top: 44px; font-size: 1.4rem; }
.lead { font-size: 1.1rem; color: var(--fg-muted); max-width: 70ch; }

/* Cards: one grid for every list, the whole card is the link. */
.card-list { list-style: none; padding: 0; margin: 18px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card {
  display: flex; align-items: flex-start; gap: 12px; height: 100%; padding: 20px 22px; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--fg); text-decoration: none; background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
a.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--brand-500) 55%, var(--border)); color: var(--fg); }
.card-body { flex: 1; min-width: 0; }
.card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.card p { margin: 0; color: var(--fg-muted); font-size: 0.93rem; line-height: 1.8; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-arrow { flex: none; display: grid; place-items: center; width: 32px; height: 32px; margin-top: 2px; border-radius: 50%; background: var(--surface-2); color: var(--brand-700); transition: transform 0.2s, background-color 0.2s, color 0.2s; }
a.card:hover .card-arrow { transform: translateX(-4px); background: var(--brand-600); color: #fff; }
.card-meta { display: inline-block; margin-top: 8px; color: var(--gray-500); font-size: 0.85rem; }
.empty { padding: 32px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface); color: var(--fg-muted); text-align: center; }

/* Breadcrumb */
.breadcrumb { display: flex; flex-wrap: wrap; gap: 8px; color: var(--gray-500); font-size: 0.88rem; margin-top: 24px; }
.breadcrumb a { color: var(--fg-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--brand-700); text-decoration: underline; }
.meta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; color: var(--gray-500); font-size: 0.9rem; }

/* Article: contents sit beside the text on wide screens and follow the reader. */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; margin-top: 8px; }
.toc { padding: 16px 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 0.92rem; }
.toc-title { display: block; margin-bottom: 6px; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc a { display: block; padding: 3px 12px; border-inline-start: 2px solid var(--border); color: var(--fg-muted); text-decoration: none; line-height: 1.7; }
.toc a:hover { color: var(--brand-700); border-inline-start-color: var(--brand-500); background: var(--surface-2); }
@media (min-width: 1180px) {
  .doc-layout { grid-template-columns: minmax(0, 1fr) 210px; gap: 40px; align-items: start; }
  .toc { order: 2; position: sticky; top: 92px; max-height: calc(100vh - 120px); overflow: auto; }
}

/* Topic menu: on the right (first column in RTL) of every page of a section. */
.with-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 16px; }
.side-main { min-width: 0; }
.side-main > :first-child, .side-main > article > :first-child { margin-top: 0; }
.side-main .breadcrumb { margin-top: 4px; }
.side { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.side-details > summary { cursor: pointer; padding: 12px 18px; font-weight: 700; list-style: none; }
.side-details > summary::-webkit-details-marker { display: none; }
.side-details > summary::after { content: '▾'; float: inline-end; color: var(--gray-500); }
.side nav { padding: 0 14px 16px; font-size: 0.93rem; }
.side-switch { display: flex; gap: 4px; padding: 4px; margin: 0 0 12px; background: var(--surface-2); border-radius: 999px; }
.side-switch a { flex: 1; text-align: center; padding: 4px 8px; border-radius: 999px; color: var(--fg-muted); text-decoration: none; font-size: 0.85rem; line-height: 1.7; }
.side-switch a[aria-current] { background: var(--surface); color: var(--brand-700); font-weight: 700; box-shadow: var(--shadow-sm); }
.side-home { display: block; padding: 6px 12px; margin-bottom: 8px; font-weight: 700; color: var(--fg); text-decoration: none; border-radius: var(--radius-sm); }
.side-group h2 { margin: 14px 12px 4px; font-size: 0.8rem; font-weight: 700; color: var(--gray-500); }
.side ul { list-style: none; margin: 0; padding: 0; }
.side nav a:not(.side-switch a) { display: block; padding: 5px 12px; border-radius: var(--radius-sm); color: var(--fg-muted); text-decoration: none; line-height: 1.7; }
.side nav a:not(.side-switch a):hover { background: var(--surface-2); color: var(--fg); }
.side-soon { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 12px; color: var(--gray-500); line-height: 1.7; cursor: default; }
.side-soon small { flex: none; padding: 0 8px; border-radius: 999px; background: var(--surface-2); font-size: 0.72rem; line-height: 1.7; }
.side nav a[aria-current='page'] { background: var(--brand-50); color: var(--brand-700); font-weight: 700; }
@media (min-width: 900px) {
  .with-side { grid-template-columns: 272px minmax(0, 1fr); gap: 36px; }
  .side { position: sticky; top: 88px; max-height: calc(100vh - 108px); overflow: auto; }
  .side-details > summary { display: none; }
  .side nav { padding-top: 14px; }
}

.prose { max-width: 740px; font-size: 1.04rem; }
.prose > :first-child { margin-top: 0; }
.prose h2 { margin-top: 2.2em; font-size: 1.55rem; scroll-margin-top: 92px; }
.prose h3 { margin-top: 1.7em; font-size: 1.2rem; scroll-margin-top: 92px; }
.prose li { margin: 0.4em 0; }
.prose ol, .prose ul { padding-inline-start: 26px; }
.prose li::marker { color: var(--brand-600); font-weight: 700; }
.prose code { background: var(--code-bg); color: var(--fg); padding: 2px 7px; border-radius: 7px; font-size: 0.9em; white-space: nowrap; }
.prose figure { margin: 28px 0; }
.prose figure img { display: block; width: 100%; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.prose figure img { cursor: zoom-in; }
.prose figcaption { margin-top: 10px; text-align: center; color: var(--gray-500); font-size: 0.9rem; }

.callout { margin: 24px 0; padding: 14px 20px; border-radius: var(--radius-sm); border-inline-start: 4px solid var(--brand-500); background: var(--brand-50); }
.callout p { margin: 0; }
.callout-title { display: block; margin-bottom: 2px; }
.callout-warning { border-inline-start-color: var(--warning-700); background: var(--warning-50); }
.callout-quote { border-inline-start-color: var(--gray-500); background: var(--surface-2); }

/* Previous / next as two big targets. */
.pager { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--border); }
.pager a { display: block; padding: 16px 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--fg); text-decoration: none; font-weight: 700; transition: border-color 0.2s, transform 0.2s; }
.pager a:hover { border-color: var(--brand-500); transform: translateY(-2px); color: var(--brand-700); }
.pager small { display: block; color: var(--gray-500); font-weight: 400; font-size: 0.85rem; }
.pager a[rel='prev'] { text-align: end; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 28px 0; color: var(--gray-500); font-size: 0.9rem; background: var(--surface); }
.footer-row { display: flex; justify-content: space-between; align-items: center; gap: 12px 24px; flex-wrap: wrap; }
.footer-row nav { display: flex; gap: 20px; flex-wrap: wrap; }
.footer-row a { color: var(--fg-muted); text-decoration: none; }
.footer-row a:hover { color: var(--brand-700); }

.skip-link { position: absolute; inset-inline-start: 8px; top: -56px; background: var(--brand-600); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 20; }
.skip-link:focus { top: 8px; color: #fff; }
.card-list.numbered { counter-reset: item; }
.card-list.numbered .card::before {
  counter-increment: item; content: counter(item, persian); flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-50); color: var(--brand-700); font-weight: 700; font-size: 0.9rem;
}
.player { margin: 20px 0; border-radius: var(--radius); overflow: hidden; background: #000; box-shadow: var(--shadow-md); }
.player video { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.video-page .meta { margin: 8px 0 0; }
.chapter .section-title a { color: inherit; text-decoration: none; }
.chapter .section-title a:hover { color: var(--brand-600); }

/* One calm entrance for the hero; everything else answers the user's actions. */
@media (prefers-reduced-motion: no-preference) {
  .hero > * { animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  .hero > :nth-child(2) { animation-delay: 0.07s; }
  .hero > :nth-child(3) { animation-delay: 0.14s; }
  .hero > :nth-child(4) { animation-delay: 0.21s; }
  @keyframes rise { from { opacity: 0; transform: translateY(14px); } }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

@media (max-width: 640px) {
  .container { padding: 0 16px; }
  /* Compact header: brand and login on one row, then the two sections, then search. Not sticky, it would eat the screen. */
  .site-header { position: static; }
  .header-row { gap: 10px 12px; min-height: 0; padding-top: 10px; padding-bottom: 12px; }
  .header-row > .button { order: 2; margin-inline-start: auto; }
  .main-nav { order: 3; flex-basis: 100%; gap: 8px; }
  .main-nav a { flex: 1; text-align: center; padding: 8px 12px; background: var(--surface-2); }
  .search-form { order: 4; flex-basis: 100%; max-width: none; margin-inline-start: 0; }
  .search-form input { padding: 11px 18px; }
  .breadcrumb > :nth-last-child(-n+2) { display: none; }
  .breadcrumb { margin-top: 12px; }
  main { padding-bottom: 48px; }
  .prose { font-size: 1rem; }
  .prose h2 { font-size: 1.35rem; margin-top: 1.8em; }
  .prose figure { margin: 20px -4px; }
  .prose code { white-space: normal; overflow-wrap: anywhere; }
  .toc { padding: 12px 14px; }
  .toc a { padding: 6px 12px; }
  .pager { margin-top: 40px; }
  .doors { margin: 20px 0 32px; }
  .section-title { margin-top: 32px; }
  .button-small { padding: 8px 16px; }
  .hero-chips { gap: 6px; }
  .footer-row { flex-direction: column; align-items: flex-start; }
  .side-details > summary { padding: 14px 18px; }
  .side nav a:not(.side-switch a), .side-soon { padding-top: 8px; padding-bottom: 8px; }
  .lightbox button { min-width: 52px; height: 52px; }
  .hero { padding: 40px 16px 32px; border-radius: 22px; }
  .hero-search { border-radius: 22px; }
  .hero-search button { padding: 0 18px; }
  .card-list { grid-template-columns: 1fr; }
  .door { padding: 22px; }
}

/* Full-screen image viewer (zoom.js) */
body.lightbox-open { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgb(6 10 18 / 97%); display: flex; flex-direction: column; }
.lightbox-stage { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; touch-action: none; cursor: zoom-in; user-select: none; -webkit-user-select: none; }
.lightbox.zoomed .lightbox-stage { cursor: grab; }
.lightbox-stage img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; box-shadow: none; border: 0; border-radius: 6px; cursor: inherit; transform-origin: center; will-change: transform; }
.lightbox-bar { position: absolute; inset-inline: 0; bottom: max(16px, env(safe-area-inset-bottom)); display: flex; justify-content: center; gap: 8px; pointer-events: none; }
.lightbox button { pointer-events: auto; min-width: 48px; height: 48px; padding: 0 14px; border: 1px solid rgb(255 255 255 / 22%); border-radius: 999px; background: rgb(20 28 44 / 80%); color: #fff; font: inherit; font-size: 1.25rem; line-height: 1; cursor: pointer; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.lightbox button:hover { background: rgb(40 52 76 / 90%); }
.lightbox button:focus-visible { outline: 3px solid var(--brand-500); outline-offset: 2px; }
.lightbox-close { position: absolute; top: max(12px, env(safe-area-inset-top)); inset-inline-start: 12px; }
