/* =========================================================
   MassaSoftware — main stylesheet (Bootstrap 5 compatible)
   Mobile-first: base styles are for small screens, media
   queries enhance progressively for tablet/desktop.
   ========================================================= */

:root {
    --ms-radius: .5rem;
    --ms-footer-bg: #212529;
}

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

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

main {
    flex: 1 0 auto;
    width: 100%;
}

/* ---------- Accessibility ---------- */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 2000;
    background: #fff;
    color: #0d6efd;
    padding: .75rem 1rem;
    border-radius: 0 0 .5rem 0;
    font-weight: 600;
}

.skip-link:focus {
    left: 0;
}

:focus-visible {
    outline: 3px solid #0d6efd;
    outline-offset: 2px;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5 {
    overflow-wrap: break-word;
    word-break: break-word;
}

p, li, td, th {
    overflow-wrap: break-word;
}

.text-break {
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* ---------- Cards ---------- */
.category-card,
.software-card {
    transition: transform .15s ease, box-shadow .15s ease;
    border: 1px solid rgba(0, 0, 0, .075);
}

.category-card:hover,
.software-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .12);
}

.software-thumb {
    height: 140px;
    object-fit: cover;
    background: #6c757d;
}

.software-card .card-title {
    line-height: 1.3;
    min-height: 2.6em;
}

/* ---------- Search form ---------- */
.search-form {
    width: 100%;
}

.search-form .form-control {
    min-width: 0;         /* prevents flex overflow on small screens */
    flex: 1 1 auto;
}

.search-form .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* ---------- Ads ---------- */
.ad-banner {
    max-height: 180px;
    object-fit: cover;
    width: 100%;
}

.sidebar-ads {
    position: fixed;
    right: 8px;
    top: 90px;
    width: 160px;
    z-index: 1030;
    opacity: .95;
}

.sidebar-ads img {
    max-width: 160px;
}

/* ---------- Footer ---------- */
footer.bg-dark {
    background: var(--ms-footer-bg) !important;
}

.footer-links li {
    margin-bottom: .5rem;
}

.footer-links a {
    color: #f8f9fa;
    text-decoration: none;
    display: inline-block;
    padding: .25rem 0;      /* comfortable touch target */
}

.footer-links a:hover,
.footer-links a:focus {
    color: #6ea8fe;
    text-decoration: underline;
}

footer a {
    overflow-wrap: anywhere;
}

/* ---------- Forms ---------- */
.form-control,
.form-select {
    min-height: 44px;      /* touch-friendly */
    font-size: 1rem;
}

.btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.form-label {
    font-weight: 500;
}

input[type="file"] {
    padding: .5rem;
}

/* ---------- Tables (stack on very small screens) ---------- */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* ---------- Privacy pages ---------- */
.privacy-content {
    line-height: 1.7;
    background: #fff;
    padding: 1rem;
    border: 1px solid rgba(0, 0, 0, .075);
    border-radius: var(--ms-radius);
}

.privacy-content h1 {
    margin-bottom: .25rem;
}

.privacy-content h2 {
    margin-top: 1.75rem;
    padding-bottom: .25rem;
    border-bottom: 2px solid #e9ecef;
}

.privacy-content ul {
    padding-left: 1.25rem;
}

.privacy-content li {
    margin-bottom: .4rem;
}

.privacy-table {
    font-size: .95rem;
    min-width: 640px;
}

.privacy-table th,
.privacy-table td {
    vertical-align: top;
}

/* Column labels for the stacked (phone) layout */
@media (max-width: 575.98px) {
    .table-responsive .privacy-table tbody td:nth-child(2)::before { content: "Examples"; }
    .table-responsive .privacy-table tbody td:nth-child(3)::before { content: "Purpose"; }
    .table-responsive .privacy-table tbody td:nth-child(4)::before { content: "Recipients"; }

    /* Long paragraphs read better left-aligned, label above the text */
    .table-responsive table.table-stackable.privacy-table tbody td {
        display: block;
        text-align: left;
    }

    .table-responsive table.table-stackable.privacy-table tbody td::before {
        display: block;
        margin-bottom: .15rem;
        text-align: left;
    }
}

/* ---------- Banners / hero ---------- */
.display-5 {
    font-weight: 700;
}

/* =========================================================
   Tablet and up
   ========================================================= */
@media (min-width: 576px) {
    .software-thumb {
        height: 160px;
    }

    .privacy-content {
        padding: 2rem;
    }
}

@media (min-width: 768px) {
    .software-thumb {
        height: 180px;
    }

    .search-form .form-control {
        font-size: 1.1rem;
    }

    .software-card .card-title {
        min-height: 0;
    }
}

@media (min-width: 1200px) {
    /* Keep content clear of the fixed sidebar ads */
    main.container {
        padding-right: 190px;
    }
}

/* =========================================================
   Small-screen refinements
   ========================================================= */
@media (max-width: 575.98px) {
    h1, .display-5 {
        font-size: 1.75rem;
    }

    .lead {
        font-size: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    .btn-lg {
        font-size: 1rem;
        padding: .6rem 1rem;
    }

    /* Stack table rows as label/value cards on phones */
    .table-responsive table.table-stackable {
        min-width: 0 !important;
    }

    .table-responsive table.table-stackable tbody th {
        display: block;
        border-bottom: 1px dashed #eee;
        padding: .5rem 0;
        font-weight: 700;
        text-align: left;
        background: transparent;
    }

    .table-responsive table.table-stackable thead {
        display: none;
    }

    .table-responsive table.table-stackable tbody tr {
        display: block;
        border: 1px solid #dee2e6;
        border-radius: .5rem;
        margin-bottom: .75rem;
        padding: .5rem .75rem;
        background: #fff;
    }

    .table-responsive table.table-stackable tbody td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        border: none;
        border-bottom: 1px dashed #eee;
        padding: .5rem 0;
        text-align: right;
    }

    .table-responsive table.table-stackable tbody td:last-child {
        border-bottom: none;
    }

    .table-responsive table.table-stackable tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        text-align: left;
        color: #495057;
    }
}

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

    .category-card,
    .software-card {
        transition: none;
    }
}
