/**
 * Single post (blog article) styles.
 *
 * Hand-written CSS on purpose: the theme's Tailwind bundle (dist/style.css) is
 * pre-built and there is no build tooling in the repo, so new utility classes
 * would not exist at runtime. Every colour used here already exists in the
 * theme palette (assets/css/main.css) - no new colours are introduced.
 *
 * @package Exotic
 */

/* ==========================================================================
   1. Reading progress bar
   ========================================================================== */

.article-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 60;
    background: transparent;
    pointer-events: none;
}

.article-progress__bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #2563EB 0%, #00B4D8 100%);
    transform-origin: 0 50%;
    transition: width 0.1s linear;
}

/* ==========================================================================
   2. Article hero
   ========================================================================== */

.article-hero {
    position: relative;
    background-color: #09235D;
    background-size: cover;
    background-position: center;
}

.article-hero--plain {
    background-color: #ffffff;
}

.article-hero__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(9, 35, 93, 0.55) 0%, rgba(9, 35, 93, 0.75) 100%);
}

.article-hero--plain .article-hero__overlay {
    display: none;
}

.article-hero__inner {
    position: relative;
    z-index: 1;
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
}

@media (min-width: 768px) {
    .article-hero__inner {
        padding-top: 4.5rem;
        padding-bottom: 4.5rem;
    }
}

.article-hero__title {
    font-size: 1.75rem;
    line-height: 1.2;
    font-weight: 700;
    margin: 0 0 1rem;
    text-wrap: balance;
}

@media (min-width: 640px) {
    .article-hero__title {
        font-size: 2.25rem;
    }
}

@media (min-width: 1024px) {
    .article-hero__title {
        font-size: 3rem;
    }
}

/* Breadcrumb: single line with ellipsis on small screens instead of wrapping. */
.article-breadcrumb {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.article-breadcrumb ol {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    max-width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

.article-breadcrumb li {
    display: flex;
    align-items: center;
    min-width: 0;
}

/* max-width and text-overflow need a block-level box to take effect. */
.article-breadcrumb__current {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 12rem;
}

@media (min-width: 768px) {
    .article-breadcrumb__current {
        max-width: 32rem;
    }
}

/* Meta row */
.article-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem 1.25rem;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.article-meta__item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.article-meta__item svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    opacity: 0.85;
}

/* ==========================================================================
   3. Share buttons
   ========================================================================== */

.article-share {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.article-share__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
}

.article-share__btn svg {
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
}

.article-share__btn--fb {
    background-color: #2563EB;
    color: #ffffff;
    border: 1px solid #2563EB;
}

.article-share__btn--fb:hover {
    background-color: #09235D;
    border-color: #09235D;
}

.article-share__btn--ghost {
    background-color: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.45);
}

.article-share__btn--ghost:hover {
    background-color: #ffffff;
    color: #09235D;
    border-color: #ffffff;
}

.article-hero--plain .article-share__btn--ghost {
    background-color: #ffffff;
    color: #09235D;
    border-color: #e5e7eb;
}

.article-hero--plain .article-share__btn--ghost:hover {
    background-color: #f3f4f6;
}

/* ==========================================================================
   4. Table of contents
   ========================================================================== */

.article-toc {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    margin: 0 0 2.5rem;
    overflow: hidden;
}

.article-toc__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    list-style: none;
    font-weight: 700;
    color: #09235D;
    font-size: 1rem;
    min-height: 44px;
    user-select: none;
}

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

.article-toc__summary:hover {
    background-color: #f3f4f6;
}

.article-toc__summary-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.article-toc__summary-label svg {
    width: 1.125rem;
    height: 1.125rem;
    color: #2563EB;
    flex-shrink: 0;
}

.article-toc__chevron {
    width: 1.125rem;
    height: 1.125rem;
    color: #686868;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.article-toc[open] .article-toc__chevron {
    transform: rotate(180deg);
}

.article-toc__body {
    padding: 0 1.25rem 1.25rem;
}

.article-toc__list {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: toc-item;
}

.article-toc__list--sub {
    margin: 0.25rem 0 0.5rem 0.75rem;
    padding-left: 0.75rem;
    border-left: 1px solid #e5e7eb;
}

.article-toc__item {
    margin: 0;
}

.article-toc__link {
    display: block;
    padding: 0.4rem 0;
    color: #09235D;
    text-decoration: none;
    line-height: 1.45;
    font-size: 0.9375rem;
    transition: color 0.15s ease;
}

.article-toc__link:hover,
.article-toc__link:focus-visible {
    color: #2563EB;
    text-decoration: underline;
}

.article-toc__list > .article-toc__item > .article-toc__link {
    font-weight: 600;
    counter-increment: toc-item;
}

.article-toc__list > .article-toc__item > .article-toc__link::before {
    content: counter(toc-item) ". ";
    color: #2563EB;
    font-weight: 700;
}

.article-toc__list--sub .article-toc__link {
    font-weight: 400;
    font-size: 0.875rem;
    color: #4b5563;
    padding: 0.3rem 0;
}

.article-toc__link.is-active {
    color: #2563EB;
    font-weight: 600;
}

/* Mobile: keep a very long TOC from pushing the article off-screen. */
@media (max-width: 1023px) {
    .article-toc__body {
        max-height: 60vh;
        overflow-y: auto;
    }
}

/* ==========================================================================
   5. Article body typography
   ========================================================================== */

.article-body {
    font-size: 1.0625rem;
    line-height: 1.75;
    color: #4b5563;
}

@media (min-width: 768px) {
    .article-body {
        font-size: 1.125rem;
        line-height: 1.8;
    }
}

.article-body > * {
    max-width: 68ch;
}

.article-body > .wp-block-table,
.article-body > figure,
.article-body > .wp-block-image,
.article-body > .article-callout {
    max-width: 100%;
}

/* Paragraphs */
.article-body p {
    font-size: inherit;
    line-height: inherit;
    color: #4b5563;
    margin: 0 0 1.35em;
}

.article-body > p:first-of-type {
    font-size: 1.1875rem;
    line-height: 1.7;
    color: #374151;
}

@media (min-width: 768px) {
    .article-body > p:first-of-type {
        font-size: 1.3125rem;
    }
}

.article-body p:last-child {
    margin-bottom: 0;
}

/* Headings */
.article-body h2,
.article-body h3,
.article-body h4 {
    color: #09235D;
    scroll-margin-top: 6.5rem;
    text-wrap: balance;
}

.article-body h2 {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.25;
    margin: 2.75rem 0 1rem;
    padding-top: 1.75rem;
    border-top: 1px solid #e5e7eb;
    position: relative;
}

@media (min-width: 768px) {
    .article-body h2 {
        font-size: 1.875rem;
    }
}

.article-body h2::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 0;
    width: 3rem;
    height: 3px;
    background: linear-gradient(90deg, #2563EB 0%, #00B4D8 100%);
    border-radius: 3px;
}

.article-body > h2:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.article-body > h2:first-child::before {
    display: none;
}

.article-body h3 {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.35;
    margin: 2rem 0 0.75rem;
}

@media (min-width: 768px) {
    .article-body h3 {
        font-size: 1.5rem;
    }
}

.article-body h4 {
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 1.5rem 0 0.5rem;
}

/* Anchor link revealed on hover (pointer devices only). */
.article-body .article-anchor {
    position: absolute;
    left: -1.5rem;
    top: 1.75rem;
    color: #2563EB;
    text-decoration: none;
    opacity: 0;
    font-weight: 400;
    transition: opacity 0.15s ease;
}

.article-body h3 .article-anchor {
    top: 0;
}

.article-body h3 {
    position: relative;
}

@media (hover: hover) and (min-width: 1280px) {
    .article-body h2:hover .article-anchor,
    .article-body h3:hover .article-anchor,
    .article-body .article-anchor:focus-visible {
        opacity: 1;
    }
}

/* Links inside headings keep the heading colour - a blue link inside a big
   navy heading reads as broken text. */
.article-body h2 a,
.article-body h3 a,
.article-body h4 a {
    color: inherit;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-color: #00B4D8;
}

.article-body h2 a:hover,
.article-body h3 a:hover,
.article-body h4 a:hover {
    color: #2563EB;
}

/* Links */
.article-body a {
    color: #2563EB;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.15s ease;
}

.article-body a:hover {
    color: #00B4D8;
}

.article-body strong,
.article-body b {
    color: #09235D;
    font-weight: 600;
}

/* Lists */
.article-body ul,
.article-body ol {
    margin: 0 0 1.5rem;
    padding: 0;
    list-style: none;
}

.article-body li {
    position: relative;
    padding-left: 1.75rem;
    margin-bottom: 0.6rem;
    line-height: 1.7;
    color: #4b5563;
}

.article-body ul > li::before {
    content: "";
    position: absolute;
    left: 0.25rem;
    top: 0.72em;
    width: 0.4375rem;
    height: 0.4375rem;
    border-radius: 50%;
    background-color: #00B4D8;
}

.article-body ol {
    counter-reset: article-ol;
}

.article-body ol > li {
    counter-increment: article-ol;
}

.article-body ol > li::before {
    content: counter(article-ol) ".";
    position: absolute;
    left: 0;
    top: 0;
    color: #2563EB;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.article-body li > ul,
.article-body li > ol {
    margin: 0.6rem 0 0;
}

/* Blockquote */
.article-body blockquote {
    margin: 2rem 0;
    padding: 1.25rem 1.25rem 1.25rem 1.5rem;
    background-color: #f9fafb;
    border-left: 4px solid #00B4D8;
    border-radius: 0 0.75rem 0.75rem 0;
    color: #374151;
    font-style: italic;
}

.article-body blockquote p:last-child {
    margin-bottom: 0;
}

.article-body blockquote cite {
    display: block;
    margin-top: 0.75rem;
    font-size: 0.875rem;
    font-style: normal;
    color: #686868;
}

/* Separator */
.article-body hr {
    margin: 2.5rem 0;
    border: 0;
    height: 1px;
    background-color: #e5e7eb;
}

/* Images and figures */
.article-body figure {
    margin: 2rem 0;
}

.article-body img {
    max-width: 100%;
    height: auto;
    border-radius: 0.75rem;
}

.article-body figcaption {
    margin-top: 0.625rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: #686868;
    text-align: center;
}

/* Code */
.article-body code {
    background-color: #f3f4f6;
    padding: 0.15em 0.4em;
    border-radius: 0.25rem;
    font-size: 0.9em;
    color: #09235D;
}

.article-body pre {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1rem;
    overflow-x: auto;
    margin: 1.5rem 0;
}

/* ==========================================================================
   6. Tables - scrollable on tablet, stacked cards on phones
   ========================================================================== */

.article-body figure.wp-block-table,
.article-body .article-table-wrap {
    margin: 2rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.article-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
    line-height: 1.6;
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    overflow: hidden;
}

.article-body table th,
.article-body table td {
    padding: 0.75rem 1rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid #e5e7eb;
}

.article-body table thead th {
    background-color: #09235D;
    color: #ffffff;
    font-weight: 600;
}

.wp-block-table .has-fixed-layout td,
.wp-block-table .has-fixed-layout th {
    word-break: break-word;
    text-wrap: auto;
}

.article-body table tbody tr:nth-child(even) {
    background-color: #f9fafb;
}

.article-body table tbody tr:last-child th,
.article-body table tbody tr:last-child td {
    border-bottom: 0;
}

.article-body table td strong {
    color: #09235D;
}

/* Phones: turn each row into a labelled card so nothing is cut off. */
@media (max-width: 639px) {
    .article-body table.has-mobile-cards {
        /* display:block drops out of table layout entirely, so Gutenberg's
           .has-fixed-layout can no longer reserve a phantom header row. */
        display: block;
        table-layout: auto;
        border: 0;
        background: transparent;
    }

    .article-body table.has-mobile-cards tbody {
        display: block;
    }

    .article-body table.has-mobile-cards thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .article-body table.has-mobile-cards tbody tr {
        display: block;
        background-color: #ffffff;
        border: 1px solid #e5e7eb;
        border-radius: 0.75rem;
        margin-bottom: 0.75rem;
        overflow: hidden;
    }

    .article-body table.has-mobile-cards tbody tr:nth-child(even) {
        background-color: #ffffff;
    }

    .article-body table.has-mobile-cards tbody td {
        display: block;
        padding: 0.625rem 0.875rem;
        border-bottom: 1px solid #f3f4f6;
    }

    .article-body table.has-mobile-cards tbody td:last-child {
        border-bottom: 0;
    }

    .article-body table.has-mobile-cards tbody td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 0.6875rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: #686868;
        margin-bottom: 0.2rem;
    }
}

/* ==========================================================================
   7. Article shell, tags, author, post navigation
   ========================================================================== */

.article-card {
    background-color: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 1px 2px 0 rgba(9, 35, 93, 0.05);
    padding: 1.25rem;
}

@media (min-width: 640px) {
    .article-card {
        padding: 2rem;
    }
}

@media (min-width: 1024px) {
    .article-card {
        border-radius: 1.5rem;
        padding: 2.5rem;
    }
}

.article-section {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid #e5e7eb;
}

.article-section__title {
    font-size: 1.0625rem;
    font-weight: 700;
    color: #09235D;
    margin: 0 0 1rem;
}

.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.article-tags a {
    display: inline-flex;
    align-items: center;
    background-color: #f3f4f6;
    color: #4b5563;
    padding: 0.4rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8125rem;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.article-tags a:hover {
    background-color: #2563EB;
    color: #ffffff;
}

.article-author {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    padding: 1.25rem;
}

.article-author img,
.article-author__avatar {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 9999px;
    object-fit: cover;
    flex-shrink: 0;
}

.article-author__avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #09235D;
    color: #ffffff;
    font-size: 1.375rem;
    font-weight: 700;
    line-height: 1;
}

.article-author__name {
    font-size: 1.0625rem;
    font-weight: 700;
    color: #09235D;
    margin: 0 0 0.35rem;
}

.article-author__bio {
    margin: 0;
    color: #4b5563;
    font-size: 0.9375rem;
    line-height: 1.6;
}

.article-nav {
    display: grid;
    gap: 0.75rem;
}

@media (min-width: 768px) {
    .article-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1rem;
    }
}

.article-nav__link {
    display: block;
    padding: 1rem;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    text-decoration: none;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    height: 100%;
}

.article-nav__link:hover {
    background-color: #ffffff;
    border-color: #2563EB;
}

.article-nav__label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #686868;
    margin: 0 0 0.4rem;
}

.article-nav__label svg {
    width: 0.875rem;
    height: 0.875rem;
    flex-shrink: 0;
}

.article-nav__title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #09235D;
    margin: 0;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-nav__link--next {
    text-align: right;
}

.article-nav__link--next .article-nav__label {
    justify-content: flex-end;
}

/* ==========================================================================
   8. Related posts
   ========================================================================== */

.related-card {
    display: flex;
    flex-direction: column;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    overflow: hidden;
    height: 100%;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.related-card:hover {
    box-shadow: 0 10px 24px -12px rgba(9, 35, 93, 0.35);
    transform: translateY(-2px);
}

.related-card__media {
    display: block;
    aspect-ratio: 16 / 9;
    background-color: #f3f4f6;
    overflow: hidden;
}

.related-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.related-card__body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    padding: 1.25rem;
}

.related-card__title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    margin: 0 0 0.5rem;
}

.related-card__title a {
    color: #09235D;
    text-decoration: none;
}

.related-card__title a:hover {
    color: #2563EB;
}

.related-card__excerpt {
    font-size: 0.875rem;
    line-height: 1.6;
    color: #686868;
    margin: 0 0 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.related-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: auto;
    font-size: 0.8125rem;
    color: #686868;
}

.related-card__more {
    color: #2563EB;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.related-card__more:hover {
    color: #09235D;
}

/* ==========================================================================
   9. Back to top
   ========================================================================== */

.back-to-top {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 40;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e5e7eb;
    border-radius: 9999px;
    background-color: #ffffff;
    color: #09235D;
    box-shadow: 0 8px 20px -8px rgba(9, 35, 93, 0.4);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background-color: #2563EB;
    color: #ffffff;
    border-color: #2563EB;
}

.back-to-top svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* ==========================================================================
   10. Misc / accessibility
   ========================================================================== */

.article-inline-banner {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    border-radius: 0.75rem;
}

.article-body a:focus-visible,
.article-toc__link:focus-visible,
.article-share__btn:focus-visible,
.back-to-top:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
    border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .article-progress__bar,
    .related-card,
    .back-to-top,
    .article-toc__chevron {
        transition: none;
    }

    .related-card:hover {
        transform: none;
    }
}
