/* Rich content styles ---------------------------------------------------------
   Used by the product Long Description editors (TinyMCE) and the storefront product page.

   The editor saves formatting as plain inline styles on the saved HTML:
     font size   <span style="font-size: 18px">
     text color  <span style="color: #e03131">
     highlight   <span style="background-color: #fff3bf">
     alignment   <p style="text-align: center">
   Inline styles always win over the rules below, so nothing here may use !important on size, color or alignment.

   The .rte-size-* / .rte-align-* classes are kept for content created earlier (the previous custom editor)
   and for the .docx import, which writes relative sizes and alignment as classes. */

.rte-size-sm { font-size: 0.8125em; }
.rte-size-md { font-size: 1.125em; }
.rte-size-lg { font-size: 1.5em; }
.rte-size-xl { font-size: 2em; }

/* Scoped one level higher than the theme's ".tpdescription__content p / li" alignment rules, but still
   weaker than an inline style, so a later alignment chosen in the editor wins. */
.rte-align-left,
.tpdescription__content .rte-align-left       { text-align: left; }
.rte-align-center,
.tpdescription__content .rte-align-center     { text-align: center; }
.rte-align-right,
.tpdescription__content .rte-align-right      { text-align: right; }
.rte-align-justify,
.tpdescription__content .rte-align-justify    { text-align: justify; }

/* Storefront product description ---------------------------------------------
   These rules replace the inline <style> that used to live in product-details.blade.php.
   Important: font size, color and alignment chosen in the editor are inline styles on <span> / <p>.
   Nothing below may force a font size or color on spans, or that formatting is lost. */

.tpdescription__content {
    font-family: var(--tp-ff-jost, 'Jost', 'Noto Sans Sinhala', sans-serif);
    font-size: 16px;
    line-height: 1.75;
    color: var(--tp-text-body, #4D5574);
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* One consistent family, base size and leading for block text. A size chosen in the editor lives on a child
   <span>, so the block element itself can keep a fixed 16px. */
.tpdescription__content p,
.tpdescription__content li,
.tpdescription__content td,
.tpdescription__content th {
    font-family: var(--tp-ff-jost, 'Jost', 'Noto Sans Sinhala', sans-serif) !important;
    font-size: 16px !important;
    line-height: 1.75 !important;
}

/* Spans only get the font family and leading. Their size comes from the editor and must not be forced. */
.tpdescription__content span {
    font-family: var(--tp-ff-jost, 'Jost', 'Noto Sans Sinhala', sans-serif) !important;
    line-height: 1.75 !important;
}

.tpdescription__content p {
    margin: 0 0 14px;
    text-align: justify;
    text-justify: inter-word;
}

.tpdescription__content h1,
.tpdescription__content h2,
.tpdescription__content h3,
.tpdescription__content h4,
.tpdescription__content h5,
.tpdescription__content h6 {
    font-family: var(--tp-ff-jost, 'Jost', 'Noto Sans Sinhala', sans-serif);
    color: var(--tp-heading-primary, #0B1119);
    font-weight: 600;
    line-height: 1.35;
    margin: 22px 0 10px;
}

.tpdescription__content h1 { font-size: 28px; }
.tpdescription__content h2 { font-size: 24px; }
.tpdescription__content h3 { font-size: 21px; }
.tpdescription__content h4 { font-size: 19px; }
.tpdescription__content h5,
.tpdescription__content h6 { font-size: 17px; }

.tpdescription__content a { color: #2d6a4f; text-decoration: underline; }
.tpdescription__content img { max-width: 100%; height: auto; }

/* Bold text is slightly darker than body text, but must keep a color chosen in the editor.
   The editor wraps colored text in <span style="color: ...">, so bold text inside such a span inherits it. */
.tpdescription__content strong,
.tpdescription__content b {
    font-weight: 600;
    color: var(--tp-heading-primary, #0B1119);
}

.tpdescription__content span[style*="color:"] strong,
.tpdescription__content span[style*="color:"] b {
    color: inherit;
}

.tpdescription__content blockquote {
    margin: 0 0 14px;
    padding: 8px 16px;
    border-left: 3px solid #2d6a4f;
    background: #f8f9fa;
}

/* Lists: the theme reset removes bullets and indentation, so restore them. */
.tpdescription__content ul,
.tpdescription__content ol {
    margin: 0 0 14px;
    padding-left: 1.6rem;
}

.tpdescription__content ul { list-style: disc outside; }
.tpdescription__content ol { list-style: decimal outside; }
.tpdescription__content ul ul { list-style: circle outside; }
.tpdescription__content ul ul ul { list-style: square outside; }

.tpdescription__content ul ul,
.tpdescription__content ol ol,
.tpdescription__content ul ol,
.tpdescription__content ol ul,
.tpdescription__content li > ul,
.tpdescription__content li > ol {
    margin: 6px 0 0;
}

.tpdescription__content li {
    display: list-item;
    list-style: inherit;
    margin-bottom: 6px;
    text-align: left;
}

.tpdescription__content li::marker { color: #2d6a4f; }
.tpdescription__content li > p { margin: 0; }

/* Tables (typed in the editor or imported from Word). */
.tpdescription__content table {
    max-width: 100%;
    margin-bottom: 15px;
    border-collapse: collapse;
}

.tpdescription__content td,
.tpdescription__content th {
    padding: 6px 10px;
    border: 1px solid #dde3da;
    vertical-align: top;
}

.tpdescription__content th {
    background: #f4f7f2;
    font-weight: 600;
    text-align: left;
}

.tpdescription__content sup,
.tpdescription__content sub {
    line-height: 0;
}

/* Small screens: let wide tables scroll sideways instead of breaking the page. */
@media (max-width: 768px) {
    .tpdescription__content {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        display: block !important;
    }

    .tpdescription__content table {
        width: 100% !important;
        max-width: none !important;
        min-width: 550px;
    }

    .tpdescription__content table th,
    .tpdescription__content table td {
        font-size: 13px !important;
        padding: 8px 6px !important;
        white-space: nowrap !important;
    }
}
