/* Small UX refinements (2026-10-08). Loaded after the theme styles. */

/* Article tables: wrap long cells instead of one 2000px-wide line on phones. */
.post-content table {
  white-space: normal;
  border-radius: 6px;
  box-shadow: 0 0 0 1px #e5e7eb;
  margin: 1.5rem 0;
}
.post-content table th,
.post-content table td {
  white-space: normal;
  width: auto;
  min-width: 9rem;
  vertical-align: top;
  line-height: 1.85;
  font-size: 15px;
}
.post-content table th {
  background-color: #e01f26;
  border-color: #c81a20;
}
.post-content table td:first-child {
  font-weight: 600;
  background-color: #fafafa;
  min-width: 6.5rem;
}
@media (max-width: 768px) {
  .post-content table th,
  .post-content table td {
    min-width: 6rem;
    font-size: 14px;
    padding: 8px;
  }
  .post-content table td:first-child {
    min-width: 4.5rem;
  }
}

/* Product and article cards: gentle lift on hover. */
.tm-card {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
@media (hover: hover) {
  .tm-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px -12px rgba(224, 31, 38, 0.35);
  }
}
@media (prefers-reduced-motion: reduce) {
  .tm-card,
  .tm-card:hover {
    transition: none;
    transform: none;
  }
}

/* Visible keyboard focus in the brand colour. */
a:focus-visible,
button:focus-visible {
  outline: 2px solid #e01f26;
  outline-offset: 2px;
}

/* Home: machine category cards («دسته بندی دستگاه‌های تولیدی»). */
.tm-cat-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e2e5ed;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
  position: relative;
}
.tm-cat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: #e01f26;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s ease;
  z-index: 1;
}
.tm-cat-media {
  display: block;
  aspect-ratio: 4 / 3;
  background: #fff;
  padding: 6px;
  overflow: hidden;
}
.tm-cat-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.4s ease;
}
.tm-cat-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px 14px;
  border-top: 1px solid #f0f1f4;
  text-align: center;
}
.tm-cat-title {
  margin: 0;
  font-weight: 700;
  color: #222;
  font-size: 15px;
  line-height: 1.6;
}
.tm-cat-cta {
  font-size: 12px;
  font-weight: 600;
  color: #e01f26;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tm-cat-cta i {
  transition: transform 0.25s ease;
}
@media (min-width: 768px) {
  .tm-cat-media { padding: 10px; }
  .tm-cat-title { font-size: 18px; }
  .tm-cat-cta { font-size: 14px; }
  .tm-cat-body { padding: 14px 12px 18px; }
}
@media (min-width: 1024px) {
  .tm-cat-title { font-size: 20px; }
}
@media (hover: hover) {
  .tm-cat-card:hover {
    border-color: #e01f26;
    box-shadow: 0 14px 30px -16px rgba(224, 31, 38, 0.45);
    transform: translateY(-3px);
  }
  .tm-cat-card:hover::before { transform: scaleX(1); }
  .tm-cat-card:hover .tm-cat-media img { transform: scale(1.04); }
  .tm-cat-card:hover .tm-cat-title { color: #e01f26; }
  [dir="rtl"] .tm-cat-card:hover .tm-cat-cta i { transform: translateX(-4px); }
  [dir="ltr"] .tm-cat-card:hover .tm-cat-cta i { transform: translateX(4px); }
}
@media (prefers-reduced-motion: reduce) {
  .tm-cat-card,
  .tm-cat-card:hover,
  .tm-cat-card:hover .tm-cat-media img,
  .tm-cat-card::before { transition: none; transform: none; }
}

/* Single post / news: comfortable reading. */
body.single-post .post-content,
body.single-news .post-content {
  color: #2b2b2b;
}
body.single-post .post-content > *,
body.single-news .post-content > * {
  max-width: 46rem;
  margin-left: auto;
  margin-right: auto;
}
body.single-post .post-content > table,
body.single-news .post-content > table,
body.single-post .post-content > figure,
body.single-news .post-content > figure {
  max-width: 100%;
}
body.single-post .post-content p,
body.single-post .post-content li,
body.single-news .post-content p,
body.single-news .post-content li {
  font-size: 16px;
  line-height: 2.05;
  text-align: start;
}
body.single-post .post-content p,
body.single-news .post-content p {
  margin-bottom: 1.1em;
}
body.single-post .post-content h2,
body.single-news .post-content h2 {
  margin-top: 2.2rem;
  margin-bottom: 0.9rem;
  line-height: 1.7;
}
body.single-post .post-content h3,
body.single-news .post-content h3 {
  margin-top: 1.6rem;
  margin-bottom: 0.6rem;
  line-height: 1.7;
}
body.single-post .post-content ul,
body.single-post .post-content ol,
body.single-news .post-content ul,
body.single-news .post-content ol {
  margin-bottom: 1.2em;
}
body.single-post .post-content img,
body.single-news .post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}
@media (min-width: 1024px) {
  body.single-post .post-content p,
  body.single-post .post-content li,
  body.single-news .post-content p,
  body.single-news .post-content li {
    font-size: 17px;
    text-align: justify;
  }
}

/* Call to action under the article. */
.tm-post-cta {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 24px 0 8px;
  padding: 18px;
  background: #fff;
  border: 1px solid #f1c9cb;
  border-inline-start: 4px solid #e01f26;
  border-radius: 8px;
}
.tm-post-cta-title {
  font-weight: 700;
  font-size: 16px;
  color: #222;
  margin: 0 0 4px;
}
.tm-post-cta-text {
  font-size: 14px;
  color: #555;
  margin: 0;
  line-height: 1.9;
}
.tm-post-cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.tm-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid #e01f26;
  color: #e01f26;
  background: #fff;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.tm-btn:hover { background: #fdf0f0; }
.tm-btn-primary { background: #e01f26; color: #fff; }
.tm-btn-primary:hover { background: #c81a20; color: #fff; }
@media (min-width: 768px) {
  .tm-post-cta {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
  }
  .tm-post-cta-title { font-size: 17px; }
}

/* Product tables on desktop: span the content column instead of shrinking to
   the left (main.css makes every table display:block for mobile scrolling). */
@media (min-width: 769px) {
  body.single-product .post-content table {
    display: table;
    overflow: visible;
  }
}

/* Single product: "compare and choose" links (2026-10-13). */
.tm-hub {
  background: #fff;
  border: 1px solid #f0f1f3;
  border-radius: 4px;
  padding: 18px 16px;
}
.tm-hub-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 14px;
}
.tm-hub-title {
  font-size: 17px;
  font-weight: 700;
  color: #222;
  margin: 0;
}
.tm-hub-lead {
  font-size: 14px;
  color: #6b7280;
  margin: 0;
}
.tm-hub-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tm-hub-link {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  padding: 14px 16px 14px 44px;
  border: 1px solid #e5e7eb;
  border-right: 3px solid #e01f26;
  border-radius: 6px;
  background: #fafafa;
  color: #222;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.tm-hub-kind {
  font-size: 12px;
  font-weight: 600;
  color: #e01f26;
}
.tm-hub-name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.6;
}
.tm-hub-sub {
  font-size: 13.5px;
  line-height: 1.8;
  color: #6b7280;
}
.tm-hub-arrow {
  position: absolute;
  left: 14px;
  top: 50%;
  margin-top: -10px;
  color: #9ca3af;
  transition: color 0.2s ease, transform 0.2s ease;
}
.tm-hub-link:hover,
.tm-hub-link:focus-visible {
  background: #fff;
  border-color: #f3c4c6;
  border-right-color: #e01f26;
  box-shadow: 0 6px 18px -10px rgba(224, 31, 38, 0.35);
}
.tm-hub-link:hover .tm-hub-arrow,
.tm-hub-link:focus-visible .tm-hub-arrow {
  color: #e01f26;
  transform: translateX(-3px);
}
@media (min-width: 768px) {
  .tm-hub {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 20px;
    align-items: center;
    padding: 20px 24px;
  }
  .tm-hub-head { margin-bottom: 0; }
  .tm-hub-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .tm-hub-link, .tm-hub-arrow { transition: none; }
  .tm-hub-link:hover .tm-hub-arrow { transform: none; }
}

/* Product page buy bar (2026-10-16): the price-inquiry button was grey and read as
   disabled; it is now the solid brand-red primary action, the catalogue is the
   outlined secondary action, and phones get a one-tap call button. */
.tm-buybar .tm-buybar-primary,
.tm-buybar .tm-buybar-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.tm-buybar .tm-buybar-primary {
  background: #e01f26;
  color: #fff !important;
  box-shadow: 0 6px 16px -8px rgba(224, 31, 38, 0.7);
}
.tm-buybar .tm-buybar-secondary {
  background: #fff;
  color: #c81a20 !important;
  box-shadow: inset 0 0 0 1.5px #e01f26;
}
.tm-buybar .tm-buybar-call {
  display: none;
}
@media (max-width: 767px) {
  .tm-buybar .tm-buybar-call {
    flex: 0 0 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: #fdf0f0;
    color: #c81a20 !important;
    box-shadow: inset 0 0 0 1px #f5c6c8;
  }
}
@media (hover: hover) {
  .tm-buybar .tm-buybar-primary:hover {
    background: #c81a20;
    transform: translateY(-1px);
  }
  .tm-buybar .tm-buybar-secondary:hover {
    background: #fdf0f0;
  }
}
@media (max-width: 767px) {
  .tm-buybar {
    box-shadow: 0 -6px 18px -12px rgba(16, 24, 40, 0.35);
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  }
  .tm-buybar .tm-buybar-primary,
  .tm-buybar .tm-buybar-secondary {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
    font-size: 13px;
    white-space: nowrap;
  }
}
@media (prefers-reduced-motion: reduce) {
  .tm-buybar .tm-buybar-primary,
  .tm-buybar .tm-buybar-primary:hover {
    transition: none;
    transform: none;
  }
}

/* Product descriptions on phones: justified Persian text left wide gaps between
   words in the narrow column; align to the start edge like the articles. */
@media (max-width: 1023px) {
  body.single-product .post-content p,
  body.single-product .post-content li {
    text-align: start;
    line-height: 2.05;
  }
}

/* Article reading polish (2026-10-20): answer-first lead, H2 accent, table rows, figures. */
body.single-post .post-content > p:first-child {
  background: #fff7f7;
  border: 1px solid #f6d5d6;
  border-inline-start: 4px solid #e01f26;
  border-radius: 8px;
  padding: 14px 16px;
  color: #2b2b2b;
}
body.single-post .post-content h2 {
  position: relative;
  padding-inline-start: 14px;
}
body.single-post .post-content h2::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0.35em;
  bottom: 0.35em;
  width: 4px;
  border-radius: 4px;
  background: #e01f26;
}
.post-content table tbody tr:nth-child(even) td:not(:first-child) {
  background-color: #fcfcfc;
}
.post-content table tbody tr {
  transition: background-color 0.15s ease;
}
@media (hover: hover) {
  .post-content table tbody tr:hover td {
    background-color: #fff3f3;
  }
}
body.single-post .post-content figure img {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 6px 18px rgba(0, 0, 0, 0.06);
}
@media (max-width: 768px) {
  body.single-post .post-content > p:first-child {
    padding: 12px 14px;
  }
}
