/* Marslia — responsive foundations & cross-browser fixes */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body.marslia-site {
    overflow-x: clip;
    min-width: 0;
}

body.marslia-site img,
body.marslia-site video,
body.marslia-site iframe,
body.marslia-site svg {
    max-width: 100%;
    height: auto;
}

body.marslia-site :where(a, p, li, td, th, blockquote, figcaption) {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Prevent iOS zoom on form focus */
body.marslia-site input[type="search"],
body.marslia-site input[type="text"],
body.marslia-site input[type="email"],
body.marslia-site textarea,
body.marslia-site select {
    font-size: max(16px, 1rem);
}

/* 404 page */
.marslia-404-main {
    margin-top: 0 !important;
    max-width: 100% !important;
    padding: 0 !important;
}

.marslia-404 {
    padding: 3rem 1rem 4rem;
    background:
        radial-gradient(ellipse 70% 50% at 50% 0%, rgba(56, 189, 248, 0.1), transparent 60%),
        #f4f8fb;
    min-height: 50vh;
    display: flex;
    align-items: center;
}

.marslia-404__container {
    max-width: 560px;
    margin: 0 auto;
    text-align: center;
}

.marslia-404__code {
    display: block;
    font-size: clamp(4rem, 15vw, 7rem);
    font-weight: 800;
    line-height: 1;
    color: rgba(13, 122, 140, 0.15);
    margin-bottom: 0.5rem;
}

.marslia-404__title {
    margin: 0 0 0.75rem;
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 800;
    color: #0f172a;
}

.marslia-404__desc {
    margin: 0 0 1.5rem;
    color: #64748b;
    font-size: 1.02rem;
    line-height: 1.75;
}

.marslia-404__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.65rem;
}

.marslia-404__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0.65rem 1.35rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.marslia-404__btn--primary {
    background: #0d7a8c;
    color: #fff;
    border: 2px solid #0d7a8c;
}

.marslia-404__btn--primary:hover {
    background: #0a5f6d;
    border-color: #0a5f6d;
}

.marslia-404__btn--secondary {
    background: #fff;
    color: #0d7a8c;
    border: 2px solid #0d7a8c;
}

.marslia-404__btn--secondary:hover {
    background: #f0f9ff;
}

/* Generic pages (Privacy, Sample, etc.) */
.marslia-page-main {
    margin-top: 0 !important;
    max-width: 100% !important;
    padding: 0 !important;
    background: #fff;
}

.marslia-page-main__container {
    max-width: 820px;
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
}

.marslia-page-main__title {
    margin: 0 0 1.25rem;
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    font-weight: 800;
    color: #0f172a;
    line-height: 1.35;
}

.marslia-page-main__content {
    color: #1e293b;
    font-size: 1.05rem;
    line-height: 1.85;
}

.marslia-page-main__content h2,
.marslia-page-main__content h3 {
    color: #0f172a;
    font-weight: 800;
    margin: 1.75rem 0 0.75rem;
}

.marslia-page-main__content p {
    margin: 0 0 1rem;
}

.marslia-page-main__content a {
    color: #0d7a8c;
    font-weight: 600;
}

.marslia-page-main__content img {
    border-radius: 12px;
}

.marslia-page-main__content table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
    margin: 1rem 0;
}

.marslia-page-main__content pre {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
    border-radius: 10px;
    background: #f8fafc;
    font-size: 0.9rem;
}

/* Single article — content overflow safety */
.marslia-single__content table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
    margin: 1rem 0;
}

.marslia-single__content pre,
.marslia-single__content code {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.marslia-single__content pre {
    padding: 1rem;
    border-radius: 10px;
    background: #f8fafc;
    font-size: 0.9rem;
}

/* Pagination wrap on small screens */
.marslia-latest__pagination .page-numbers {
    margin-bottom: 0.35rem;
}

/* Touch-friendly targets */
@media (pointer: coarse) {
    .marslia-hero-menu a,
    .marslia-latest__more,
    .marslia-latest-card__read,
    .marslia-latest-card__cat,
    .marslia-single__tag,
    .marslia-toc__link,
    .marslia-latest__pagination .page-numbers {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .marslia-hero-search__btn,
    .marslia-search-form .marslia-hero-search__btn {
        min-height: 48px;
    }
}

/* ── Tablet ── */
@media (max-width: 900px) {
    .marslia-latest__head {
        gap: 0.75rem;
    }

    .marslia-taxonomy__toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .marslia-category__title {
        font-size: clamp(1.6rem, 5vw, 2.2rem);
    }
}

/* ── Mobile landscape & small tablets ── */
@media (max-width: 768px) {
    .marslia-hero-header__inner {
        padding: 1rem 1rem 1.5rem;
    }

    .marslia-hero-header__site-title {
        font-size: 1.35rem;
    }

    .marslia-hero-header__content {
        padding-top: 1.25rem;
    }

    .marslia-latest {
        padding: 1.75rem 0 2.5rem;
    }

    .marslia-latest__container {
        padding: 0 1rem;
    }

    .marslia-latest__head {
        flex-direction: column;
        align-items: stretch;
    }

    .marslia-latest__tab {
        justify-content: center;
        font-size: 1rem;
        padding: 0.65rem 1.1rem;
    }

    .marslia-latest__more {
        justify-content: center;
        width: 100%;
    }

    .marslia-single__container {
        padding: 0 1rem;
    }

    .marslia-single__hero {
        padding: 1.5rem 0 1.25rem;
    }

    .marslia-single__image {
        max-height: 280px;
        border-radius: 14px;
    }

    .marslia-read-also {
        padding: 0.85rem 1rem;
    }

    .marslia-search__head {
        flex-direction: column;
        align-items: flex-start;
    }

    .marslia-search-form {
        flex-direction: column-reverse;
        border-radius: 12px;
    }

    .marslia-search-form .marslia-hero-search__btn {
        flex: 0 0 auto;
        width: 100%;
        min-height: 48px;
        border-radius: 0 0 12px 12px;
    }

    .marslia-search-form .marslia-hero-search__field {
        min-height: 48px;
        border-radius: 12px 12px 0 0;
    }

    .marslia-taxonomy__breadcrumb {
        font-size: 0.82rem;
    }

    .marslia-category__hero-inner {
        padding: 1.5rem 1rem;
    }

    .marslia-category__icon {
        width: 52px;
        height: 52px;
    }

    .marslia-category__tags-list {
        justify-content: center;
    }

    .marslia-tag__cloud {
        padding: 1rem;
    }

    .marslia-tag__meta {
        flex-direction: column;
        align-items: center;
    }

    .marslia-footer__inner {
        padding: 2.25rem 1rem 1.25rem;
    }
}

/* ── Small phones ── */
@media (max-width: 480px) {
    .marslia-hero-header__site-title {
        font-size: 1.15rem;
        line-height: 1.3;
    }

    .marslia-hero-header__title--line1,
    .marslia-hero-header__title--line2 {
        font-size: clamp(1.35rem, 6vw, 1.75rem);
    }

    .marslia-hero-search {
        border-radius: 12px;
    }

    .marslia-hero-search__btn {
        width: 100%;
        flex: 0 0 auto;
        min-height: 48px;
    }

    .marslia-latest-card__body {
        padding: 1rem;
    }

    .marslia-latest-card__title {
        font-size: 1rem;
    }

    .marslia-toc__badge {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .marslia-toc__num {
        min-width: 1.5rem;
        height: 1.5rem;
        font-size: 0.72rem;
    }

    .marslia-category__stat {
        min-width: 100%;
    }

    .marslia-tag__pill {
        padding: 0.45rem 1rem;
        max-width: 100%;
    }

    .marslia-tag__title {
        font-size: 1.25rem;
        word-break: break-word;
    }

    .marslia-page-main__container {
        padding: 1.5rem 1rem 2.5rem;
    }

    .marslia-latest__pagination .page-numbers {
        padding: 0.45rem 0.65rem;
        font-size: 0.88rem;
    }
}

/* ── Very small screens ── */
@media (max-width: 360px) {
    .marslia-latest__tab-label {
        font-size: 0.92rem;
    }

    .marslia-single__title {
        font-size: 1.45rem;
    }

    .marslia-category__tag-chip,
    .marslia-tag__cloud-chip {
        font-size: 0.78rem;
        padding: 0.35rem 0.65rem;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .marslia-latest-card,
    .marslia-latest__more,
    .marslia-toc__link,
    .marslia-hero-menu a {
        transition: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: more) {
    .marslia-latest-card,
    .marslia-toc,
    .marslia-category__hero,
    .marslia-tag__hero {
        border-width: 2px;
    }
}

/* Print */
@media print {
    .marslia-hero-header,
    .marslia-footer,
    .marslia-latest--related,
    .marslia-read-also,
    .marslia-toc__toggle {
        display: none !important;
    }

    .marslia-single__content {
        font-size: 12pt;
        line-height: 1.6;
    }
}
