/* =========================================================
   TML SINGLE POST
   ========================================================= */

.tml-single {
    min-height: 70vh;
}

/* Title */

.tml-single-head {
    padding: 44px 0 32px;
    border-bottom: 1px solid var(--tml-line);
}

.tml-single-head__inner {
    max-width: 900px;
    margin: 0 auto;
}

.tml-single-kicker {
    margin: 0 0 13px;

    color: var(--tml-blue);

    font-size: 0.72rem;
    line-height: 1;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.tml-single-head h1 {
    max-width: 900px;

    margin: 0;

    color: var(--tml-ink);

    font-size: clamp(2rem, 5vw, 2.9rem);
    line-height: 1.24;
    font-weight: 800;
    letter-spacing: -0.045em;
    word-break: keep-all;
}

.tml-single-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;

    margin-top: 18px;

    color: var(--tml-muted);
    font-size: 0.82rem;
}

.tml-single-meta a {
    color: var(--tml-blue);
    font-weight: 650;
}

/* Article */

.tml-single-content-wrap {
    width: 100%;
    padding: 42px 0 70px;
}

.tml-entry {
    width: 100%;
    max-width: 900px;

    margin: 0 auto;

    color: #263142;

    font-size: 17px;
    line-height: 1.85;

    word-break: keep-all;
    overflow-wrap: break-word;
}

.tml-entry > *:first-child {
    margin-top: 0;
}

.tml-entry p {
    margin-top: 0;
    margin-bottom: 1.45em;
}

.tml-entry ul,
.tml-entry ol {
    margin-top: 0;
    margin-bottom: 1.45em;
    padding-left: 1.4em;
}

.tml-entry li + li {
    margin-top: 0.45em;
}

.tml-entry a {
    color: var(--tml-blue);

    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.tml-entry strong {
    color: var(--tml-ink);
}

/* Headings */

.tml-entry h2 {
    position: relative;

    margin: 2.25em 0 0.85em;
    padding-left: 15px;

    color: var(--tml-ink);

    font-size: 28px;
    line-height: 1.4;
    font-weight: 750;
    letter-spacing: -0.035em;

    word-break: keep-all;

    scroll-margin-top: 100px;
}

.tml-entry h2::before {
    content: "";

    position: absolute;

    left: 0;
    top: 0.18em;
    bottom: 0.18em;

    width: 4px;

    border-radius: 4px;
    background: var(--tml-blue);
}

.tml-entry h3 {
    margin: 1.9em 0 0.7em;
    padding-bottom: 9px;

    color: var(--tml-ink);

    border-bottom: 1px solid var(--tml-line);

    font-size: 21px;
    line-height: 1.45;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.tml-entry h4 {
    margin: 1.7em 0 0.6em;

    color: var(--tml-ink);

    font-size: 18px;
    line-height: 1.5;
}

/* Quote */

.tml-entry blockquote {
    margin: 2em 0;
    padding: 18px 20px;

    border-left: 4px solid #b9c9ed;

    color: #475467;
    background: var(--tml-soft);
}

.tml-entry blockquote p:last-child {
    margin-bottom: 0;
}

/* Images */

.tml-entry figure {
    margin-top: 2em;
    margin-bottom: 2em;
}

.tml-entry figcaption {
    margin-top: 8px;

    color: var(--tml-muted);

    font-size: 0.75rem;
    line-height: 1.6;
    text-align: center;
}

.tml-entry .alignwide {
    width: min(
        1040px,
        calc(100vw - 32px)
    );

    max-width: none;

    margin-left: 50%;
    transform: translateX(-50%);
}

/* Core Gutenberg tables
 *
 * Ported from the final TMS table behavior.
 * - desktop: clean centered table, body cells may wrap
 * - mobile: natural column width + horizontal scrolling
 * - no vertical grid clutter
 */

.tml-entry .wp-block-table {
    display: block;

    width: 100%;
    max-width: 100%;

    margin: 2em 0;

    overflow-x: auto;
    overflow-y: hidden;

    transform: none;

    -webkit-overflow-scrolling: touch;
}

.tml-entry .wp-block-table table {
    width: max-content !important;
    min-width: 100% !important;
    max-width: none !important;

    border-collapse: collapse !important;

    table-layout: auto !important;

    font-size: 14px;
    line-height: 1.5;
}

.tml-entry .wp-block-table thead,
.tml-entry .wp-block-table thead tr {
    border: none !important;
}

.tml-entry .wp-block-table thead th {
    padding: 11px 9px !important;

    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom:
        2px solid #4285f4 !important;

    background: #f2f7fc !important;
    color: #333 !important;

    text-align: center !important;
    vertical-align: middle !important;

    font-weight: 700 !important;

    white-space: nowrap !important;
}

.tml-entry .wp-block-table tbody td {
    padding: 10px 9px !important;

    border-left: none !important;
    border-right: none !important;
    border-bottom:
        1px solid #e0e0e0 !important;

    color: #555 !important;
    background: #fff;

    text-align: center !important;
    vertical-align: middle !important;

    line-height: 1.5 !important;

    white-space: normal;
    word-break: keep-all !important;
}

.tml-entry
.wp-block-table
tbody
tr:nth-child(even) {
    background: transparent;
}

@media (min-width: 700px) {

    .tml-entry .wp-block-table table {
        border-top:
            1px solid #eee !important;
    }
}

@media (max-width: 699px) {

    .tml-entry .wp-block-table {
        width: 100%;
        max-width: 100%;

        margin: 1.8em 0;

        overflow-x: auto;
        overflow-y: hidden;

        transform: none;

        white-space: nowrap;

        -webkit-overflow-scrolling: touch;
    }

    .tml-entry .wp-block-table table {
        width: max-content !important;
        min-width: 100% !important;

        table-layout: auto !important;

        border-collapse: collapse !important;

        font-size: 14px;
        line-height: 1.45;
    }

    .tml-entry .wp-block-table thead th {
        padding:
            10px 8px !important;
    }

    .tml-entry .wp-block-table tbody td {
        padding:
            9px 8px !important;

        white-space: nowrap;
        word-break: keep-all !important;
    }
}

/* Code */

.tml-entry pre {
    max-width: 100%;

    padding: 18px;

    overflow-x: auto;

    border-radius: 8px;

    color: #f8fafc;
    background: #101828;

    font-size: 13px;
    line-height: 1.65;
}

.tml-entry code {
    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Consolas,
        monospace;
}

/* === TML NATIVE H2 TOC — DIRECT PORT FROM TMS === */

/*
 * Lightweight native TOC
 * - HTML details/summary
 * - no JavaScript
 * - closed by default
 */

.tml-toc {
    margin: 24px 0 32px;
    border: 1px solid #dce6f4;
    border-radius: 12px;
    background: #f8fafc;
    overflow: hidden;
}

.tml-toc__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    color: #17243a;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.tml-toc__summary::-webkit-details-marker {
    display: none;
}

.tml-toc__summary::marker {
    content: "";
}

.tml-toc__heading {
    display: flex;
    align-items: baseline;
    gap: 9px;
    min-width: 0;
}

.tml-toc__title {
    color: #17243a;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.4;
}

.tml-toc__meta {
    color: #7a8798;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
}

.tml-toc__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #edf4ff;
    color: #1769d2;
    font-size: 19px;
    font-weight: 500;
    line-height: 1;
}

.tml-toc__toggle::before {
    content: "+";
}

.tml-toc[open] .tml-toc__toggle::before {
    content: "−";
}

.tml-toc__body {
    padding: 4px 14px 14px;
    border-top: 1px solid #e6edf6;
}

.tml-toc__list {
    display: grid;
    gap: 1px;
    margin: 0;
    padding: 8px 0 0;
    list-style: none;
}

.tml-toc__item {
    margin: 0;
    padding: 0;
}

.tml-toc a.tml-toc__link,
.tml-toc a.tml-toc__link:visited {
    position: relative;
    display: block;
    padding: 7px 9px 7px 21px;
    border: 0;
    border-radius: 7px;
    box-shadow: none;
    color: #294766;
    font-size: 15px;
    font-weight: 550;
    line-height: 1.5;
    text-decoration: none !important;
}

.tml-toc a.tml-toc__link::before {
    content: "›";
    position: absolute;
    top: 7px;
    left: 8px;
    color: #1769d2;
    font-weight: 700;
}

.tml-toc a.tml-toc__link:hover,
.tml-toc a.tml-toc__link:focus {
    background: #edf4ff;
    color: #1769d2;
    text-decoration: none !important;
}

.tml-entry h2[id] {
    scroll-margin-top: 90px;
}

@media (max-width: 768px) {

    .tml-toc {
        margin: 20px 0 28px;
        border-radius: 10px;
    }

    .tml-toc__summary {
        padding: 12px 14px;
    }

    .tml-toc__title {
        font-size: 16px;
    }

    .tml-toc__meta {
        font-size: 12px;
    }

    .tml-toc__toggle {
        flex-basis: 26px;
        width: 26px;
        height: 26px;
        font-size: 18px;
    }

    .tml-toc__body {
        padding: 3px 9px 11px;
    }

    .tml-toc a.tml-toc__link,
    .tml-toc a.tml-toc__link:visited {
        padding: 6px 7px 6px 19px;
        font-size: 14px;
    }

    .tml-toc a.tml-toc__link::before {
        top: 6px;
        left: 6px;
    }
}

/* =========================================================
   RELATED POSTS
   ========================================================= */

.tml-related {
    padding: 52px 0 74px;

    border-top: 1px solid var(--tml-line);

    background: #fbfcfe;
}

.tml-single-wide {
    width: min(
        calc(100% - 40px),
        1180px
    );

    margin-inline: auto;
}

.tml-related__head p {
    margin: 0 0 10px;

    color: var(--tml-blue);

    font-size: 0.7rem;
    line-height: 1;
    font-weight: 800;
    letter-spacing: 0.1em;
}

.tml-related__head h2 {
    margin: 0;

    color: var(--tml-ink);

    font-size: 1.55rem;
    line-height: 1.3;
    letter-spacing: -0.03em;
}

.tml-related__grid {
    display: grid;
    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 26px;

    margin-top: 24px;
}

.tml-related-card {
    min-width: 0;
}

.tml-related-card__image {
    width: 100%;
    aspect-ratio: 16 / 9;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden;

    border: 1px solid var(--tml-line);
    border-radius: 9px;

    background: var(--tml-soft);
}

.tml-related-card__image img {
    width: 100%;
    height: 100%;

    object-fit: cover;
}

.tml-related-card__image span {
    color: #98a2b3;

    font-size: 0.7rem;
    font-weight: 750;
    letter-spacing: 0.08em;
}

.tml-related-card__body {
    padding-top: 12px;
}

.tml-related-card h3 {
    margin: 0;

    color: var(--tml-ink);

    font-size: 1rem;
    line-height: 1.5;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.tml-related-card h3 a:hover {
    color: var(--tml-blue);
}

.tml-related-card time {
    display: block;

    margin-top: 8px;

    color: #98a2b3;

    font-size: 0.75rem;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 899px) {
    .tml-related__grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 699px) {
    .tml-single-head {
        padding: 34px 0 26px;
    }

    .tml-single-head__inner {
        max-width: none;
    }

    .tml-single-head h1 {
        font-size: 2rem;
    }

    .tml-single-content-wrap {
        padding: 32px 0 54px;
    }

    .tml-entry {
        font-size: 16px;
        line-height: 1.82;
    }

    .tml-entry h2 {
        margin-top: 2em;

        font-size: 24px;

        scroll-margin-top: 82px;
    }

    .tml-entry h3 {
        font-size: 20px;
    }

.tml-single-wide {
        width: min(
            calc(100% - 28px),
            1180px
        );
    }

    .tml-related {
        padding: 42px 0 54px;
    }
}

@media (max-width: 520px) {
    .tml-related__grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}
