/* =========================================================
   ParsiDate theme - single post content styles
   Scope: .entry-content
   RTL first, uses CSS logical properties so it also works LTR.
   Overrides Tailwind Preflight (which strips list markers).
   ========================================================= */

.entry-content {
  /* Design tokens, sampled from the live theme */
  --ec-ink:        #1e1e1e;
  --ec-body:       #3a3a3a;
  --ec-muted:      #767676;
  --ec-brand:      #3858e9;
  --ec-brand-dark: #2a45c4;
  --ec-brand-tint: rgba(56, 88, 233, .08);
  --ec-surface:    #f6f6f6;
  --ec-line:       #e5e5e5;
  --ec-radius:     14px;

  color: var(--ec-body);
  font-size: 1rem;
  line-height: 2.05;
  overflow-wrap: break-word;
}

/* Kill the leading and trailing gap so the block sits flush */
.entry-content > *:first-child { margin-block-start: 0; }
.entry-content > *:last-child  { margin-block-end: 0; }


/* ---------------------------------------------------------
   1. Headings
   --------------------------------------------------------- */
.entry-content h2,
.entry-content h3,
.entry-content h4,
.entry-content h5,
.entry-content h6 {
  color: var(--ec-ink);
  font-weight: 800;
  line-height: 1.65;
  scroll-margin-top: 96px; /* clears the sticky header on anchor jumps */
}

.entry-content h2 {
  font-size: clamp(1.375rem, 1.15rem + 1vw, 1.625rem);
  margin-block: 2.75rem .9rem;
  padding-inline-start: .75rem;
  border-inline-start: 4px solid var(--ec-brand);
}

.entry-content h3 {
  font-size: clamp(1.125rem, 1rem + .55vw, 1.25rem);
  margin-block: 2.25rem .7rem;
}

.entry-content h4 {
  font-size: 1.0625rem;
  margin-block: 1.75rem .55rem;
  color: var(--ec-body);
}

.entry-content h5,
.entry-content h6 {
  font-size: 1rem;
  margin-block: 1.5rem .5rem;
}

/* A heading right after a heading should not double the gap */
.entry-content h2 + h3,
.entry-content h3 + h4 { margin-block-start: 1.25rem; }


/* ---------------------------------------------------------
   2. Paragraphs and inline text
   --------------------------------------------------------- */
.entry-content p {
  margin-block: 0 1.15rem;
}

.entry-content strong,
.entry-content b {
  font-weight: 700;
  color: var(--ec-ink);
}

.entry-content em,
.entry-content i { font-style: italic; }

.entry-content mark {
  background: linear-gradient(transparent 58%, rgba(56, 88, 233, .22) 58%);
  color: inherit;
  padding-inline: .15em;
}

.entry-content small,
.entry-content .text-small {
  display: inline-block;
  font-size: .8125rem;
  line-height: 1.9;
  color: var(--ec-muted);
}

/* A standalone note line: a paragraph that only holds a <small> */
.entry-content p > small:only-child {
  display: block;
  padding-inline-start: .75rem;
  border-inline-start: 2px solid var(--ec-line);
}

.entry-content sup,
.entry-content sub { font-size: .7em; line-height: 0; }

.entry-content abbr[title] {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: help;
}

.entry-content del { color: var(--ec-muted); }

.entry-content kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .8125em;
  direction: ltr;
  unicode-bidi: isolate;
  padding: .15em .45em;
  border: 1px solid var(--ec-line);
  border-block-end-width: 2px;
  border-radius: 6px;
  background: #fff;
  color: var(--ec-ink);
}


/* ---------------------------------------------------------
   3. Links
   --------------------------------------------------------- */
.entry-content a {
  color: var(--ec-brand);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(56, 88, 233, .38);
  text-underline-offset: .28em; /* Persian descenders need the clearance */
  overflow-wrap: anywhere;      /* long URLs stop breaking the layout */
  transition: color .18s ease, text-decoration-color .18s ease, background-color .18s ease;
  border-radius: 3px;
}

.entry-content a:hover,
.entry-content a:focus-visible {
  color: var(--ec-brand-dark);
  text-decoration-color: currentColor;
  text-decoration-thickness: 2px;
}

.entry-content a:focus-visible {
  outline: 2px solid var(--ec-brand);
  outline-offset: 3px;
  text-decoration: none;
}

/* A link that wraps an image should not be underlined */
.entry-content a:has(> img),
.entry-content figure a { text-decoration: none; }

/* External links get a small marker */
.entry-content a[target="_blank"]:not(:has(img))::after {
  content: "";
  display: inline-block;
  inline-size: .62em;
  block-size: .62em;
  margin-inline-start: .3em;
  background: currentColor;
  opacity: .65;
  vertical-align: baseline;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M14 3h7v7h-2V6.41l-9.29 9.3-1.42-1.42 9.3-9.29H14V3zM5 5h5v2H7v10h10v-3h2v5H5V5z'/></svg>") center / contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M14 3h7v7h-2V6.41l-9.29 9.3-1.42-1.42 9.3-9.29H14V3zM5 5h5v2H7v10h10v-3h2v5H5V5z'/></svg>") center / contain no-repeat;
}


/* ---------------------------------------------------------
   4. Lists  (Tailwind Preflight sets list-style:none, restore it)
   --------------------------------------------------------- */
.entry-content ul,
.entry-content ol {
  margin-block: 0 1.5rem;
  padding-inline-start: 1.5rem;
}

.entry-content ul { list-style: disc outside; }

/* Persian numerals for ordered lists in an RTL document */
.entry-content ol { list-style: persian outside; }
[dir="ltr"] .entry-content ol { list-style: decimal outside; }

.entry-content ul ul { list-style: circle outside; }
.entry-content ul ul ul { list-style: square outside; }
.entry-content ol ol { list-style: persian outside; }

.entry-content li {
  margin-block-end: .6rem;
  padding-inline-start: .35rem;
  line-height: 2;
}

.entry-content li::marker {
  color: var(--ec-brand);
  font-weight: 700;
}

/* Nested lists tuck in and lose the extra bottom gap */
.entry-content li > ul,
.entry-content li > ol {
  margin-block: .6rem 0;
  padding-inline-start: 1.35rem;
}

.entry-content li > p { margin-block-end: .5rem; }
.entry-content li:last-child { margin-block-end: 0; }

/* Term lists: bolded lead-in inside a list item reads as a definition */
.entry-content li > strong:first-child { color: var(--ec-ink); }

/* Optional variant: <ul class="is-style-check"> */
.entry-content ul.is-style-check {
  list-style: none;
  padding-inline-start: 0;
}
.entry-content ul.is-style-check > li {
  position: relative;
  padding-inline-start: 1.9rem;
}
.entry-content ul.is-style-check > li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  inset-block-start: .55em;
  inline-size: 1.15rem;
  block-size: 1.15rem;
  border-radius: 50%;
  background: var(--ec-brand-tint) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233858e9' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M20 6L9 17l-5-5'/></svg>") center / .72rem no-repeat;
}

/* Definition lists */
.entry-content dl { margin-block: 0 1.5rem; }
.entry-content dt { font-weight: 700; color: var(--ec-ink); margin-block-start: 1rem; }
.entry-content dd { margin: .35rem 0 0; padding-inline-start: 1rem; border-inline-start: 2px solid var(--ec-line); }


/* ---------------------------------------------------------
   5. Images and figures
   --------------------------------------------------------- */
.entry-content figure,
.entry-content .wp-block-image {
  margin-block: 2.25rem;
  margin-inline: 0;
}

.entry-content img {
  display: block;
  max-inline-size: 100%;
  block-size: auto;
  border-radius: var(--ec-radius);
}

/* Only standalone content images get the frame, not icons inside buttons */
.entry-content > figure img,
.entry-content > p > img,
.entry-content .wp-block-image img {
  margin: 0 auto;
  border: 1px solid var(--ec-line);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .18);
  background: var(--ec-surface);
}

.entry-content figcaption,
.entry-content .wp-element-caption {
  margin-block-start: .7rem;
  font-size: .8125rem;
  line-height: 1.9;
  color: var(--ec-muted);
  text-align: center;
}

.entry-content .alignright {
  float: inline-end;
  margin-inline-start: 1.5rem;
  margin-block: .5rem 1.25rem;
  /*max-inline-size: 42%;*/
}
.entry-content .alignleft {
  float: inline-start;
  margin-inline-end: 1.5rem;
  margin-block: .5rem 1.25rem;
  /*max-inline-size: 42%;*/
}
.entry-content .aligncenter { margin-inline: auto; }

@media (max-width: 640px) {
  .entry-content .alignright,
  .entry-content .alignleft {
    float: none;
    margin-inline: 0;
    max-inline-size: 100%;
  }
}

/* Lightbox trigger.
   The theme's script writes stale pixel left/right values inline, so on a
   narrow viewport the button escapes the figure and forces a horizontal
   scrollbar. These !important insets are required to beat that inline style. */
.entry-content .wp-lightbox-container { position: relative; }

.entry-content .wp-lightbox-container > .lightbox-trigger {
  position: absolute !important;
  inset-block-start: .75rem !important;
  inset-inline-end: .75rem !important;
  inset-block-end: auto !important;
  inset-inline-start: auto !important;
  transition: opacity .2s ease;
}

/* Fade in on pointer devices only, so it stays tappable on touch */
@media (hover: hover) and (pointer: fine) {
  .entry-content .wp-lightbox-container > .lightbox-trigger { opacity: 0; }
  .entry-content .wp-lightbox-container:hover > .lightbox-trigger,
  .entry-content .wp-lightbox-container:focus-within > .lightbox-trigger { opacity: 1; }
}


/* ---------------------------------------------------------
   6. Quotes and callouts
   --------------------------------------------------------- */
.entry-content blockquote {
  margin-block: 2rem;
  margin-inline: 0;
  padding: 1.15rem 1.35rem;
  background: var(--ec-surface);
  border-inline-start: 4px solid var(--ec-brand);
  border-radius: 0 var(--ec-radius) var(--ec-radius) 0;
  color: var(--ec-ink);
  font-size: 1.02rem;
}
[dir="ltr"] .entry-content blockquote { border-radius: var(--ec-radius) 0 0 var(--ec-radius); }

.entry-content blockquote p:last-child { margin-block-end: 0; }
.entry-content blockquote cite {
  display: block;
  margin-block-start: .75rem;
  font-size: .8125rem;
  font-style: normal;
  color: var(--ec-muted);
}

/* Callout: add class="note" / "warning" / "tip" to a <p> or <div> */
.entry-content .note,
.entry-content .warning,
.entry-content .tip {
  margin-block: 1.75rem;
  padding: 1rem 1.15rem;
  border-radius: var(--ec-radius);
  border-inline-start: 4px solid;
  font-size: .96rem;
  line-height: 1.95;
}
.entry-content .note    { background: #eef2ff; border-color: #3858e9; color: #1e2a6b; }
.entry-content .tip     { background: #ecfdf5; border-color: #059669; color: #064e3b; }
.entry-content .warning { background: #fff7ed; border-color: #ea580c; color: #7c2d12; }
.entry-content .note > :last-child,
.entry-content .tip > :last-child,
.entry-content .warning > :last-child { margin-block-end: 0; }


/* ---------------------------------------------------------
   7. Code
   --------------------------------------------------------- */
.entry-content code,
.entry-content samp {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .875em;
  direction: ltr;          /* Latin code must not inherit RTL */
  unicode-bidi: isolate;
  padding: .18em .45em;
  background: var(--ec-surface);
  border: 1px solid var(--ec-line);
  border-radius: 6px;
  color: #b3306e;
  overflow-wrap: anywhere;
}

.entry-content pre {
  margin-block: 1.75rem;
  padding: 1.1rem 1.25rem;
  direction: ltr;
  text-align: left;
  background: #1e1e1e;
  color: #f5f5f5;
  border-radius: var(--ec-radius);
  overflow-x: auto;
  font-size: .875rem;
  line-height: 1.85;
  -webkit-overflow-scrolling: touch;
}
.entry-content pre code {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
}


/* ---------------------------------------------------------
   8. Tables
   --------------------------------------------------------- */
.entry-content .wp-block-table,
.entry-content .table-wrap {
  margin-block: 2rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.entry-content table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: .94rem;
  line-height: 1.85;
}

.entry-content th,
.entry-content td {
  padding: .7rem .9rem;
  border: 1px solid var(--ec-line);
  text-align: start;
  vertical-align: top;
}

.entry-content thead th {
  background: var(--ec-surface);
  color: var(--ec-ink);
  font-weight: 700;
  white-space: nowrap;
}

.entry-content tbody tr:nth-child(even) { background: #fafafa; }


/* ---------------------------------------------------------
   9. Separator
   --------------------------------------------------------- */
.entry-content hr {
  margin-block: 2.75rem;
  border: 0;
  block-size: 1px;
  background: linear-gradient(to left, transparent, var(--ec-line) 20%, var(--ec-line) 80%, transparent);
}

.entry-content hr.is-style-dots {
  block-size: auto;
  background: none;
  text-align: center;
  line-height: 1;
}
.entry-content hr.is-style-dots::before {
  content: "•••";
  color: var(--ec-line);
  font-size: 1.25rem;
  letter-spacing: .6em;
}


/* ---------------------------------------------------------
   10. Embeds
   --------------------------------------------------------- */
.entry-content iframe,
.entry-content video,
.entry-content .wp-block-embed__wrapper {
  max-inline-size: 100%;
  border-radius: var(--ec-radius);
}
.entry-content .wp-block-embed {
  margin-block: 2rem;
}
.entry-content .wp-block-embed.is-type-video .wp-block-embed__wrapper {
  position: relative;
  padding-block-end: 56.25%;
}
.entry-content .wp-block-embed.is-type-video .wp-block-embed__wrapper iframe {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
}


/* ---------------------------------------------------------
   11. Mobile
   --------------------------------------------------------- */
@media (max-width: 640px) {
  .entry-content { font-size: .9688rem; line-height: 1.95; }
  .entry-content ul,
  .entry-content ol { padding-inline-start: 1.25rem; }
  .entry-content figure,
  .entry-content .wp-block-image { margin-block: 1.75rem; }
  .entry-content h2 { margin-block-start: 2.25rem; }
}


/* ---------------------------------------------------------
   12. Print
   --------------------------------------------------------- */
@media print {
  .entry-content a { color: #000; text-decoration: underline; }
  .entry-content a[target="_blank"]::after { display: none; }
  .entry-content img { box-shadow: none; border: 1px solid #ccc; }
  .entry-content pre { background: #f4f4f4; color: #000; border: 1px solid #ccc; }
  .entry-content .lightbox-trigger { display: none; }
}
