/* ==========================================================================
   Site theme for inner pages (Bootstrap 4 pages)
   Brings the homepage look (purple / lavender, rounded cards, purple footer)
   to every page. Load AFTER bootstrap + style.css + site-chrome.css.
   Navbar/footer/floating buttons live in site-chrome.css (shared with home).
   ========================================================================== */

:root {
    --ssm-primary: #6d19be;
    --ssm-primary-dark: #4f0f94;
    --ssm-dark: #221644;
    --ssm-accent: #f29a16;
    --ssm-text: #1c174c;
    --ssm-muted: #514a70;
    --ssm-border: #e5ddf4;
    --ssm-soft: #f3ecfe;
    --ssm-bg: #faf7ff;
    --ssm-danger: #b42318;
    --site-radius: 18px;
    --site-shadow: 0 10px 30px rgba(73, 33, 140, .08);
    --site-shadow-hover: 0 16px 40px rgba(73, 33, 140, .16);
    --site-nav-height: 72px;
}

body {
    color: var(--ssm-text);
    background: #fff;
    line-height: 1.65;
}

a { color: var(--ssm-primary); }
a:hover { color: var(--ssm-primary-dark); }

a:focus-visible,
button:focus-visible {
    outline: 3px solid var(--ssm-primary);
    outline-offset: 3px;
}

h1, h2, h3, h4, h5, h6 { color: var(--ssm-dark); }

/* Content that starts directly under the fixed navbar */
body { padding-top: var(--site-nav-height); }
header.jarallax { margin-top: calc(-1 * var(--site-nav-height)); }

/* Full-width carousel used as a page hero (scholar.php) */
body > .carousel {
    height: min(78vh, 640px) !important;
    margin-top: 0 !important;
}

body > .carousel .backscreen {
    background: linear-gradient(120deg, rgba(42, 11, 85, .85) 0%, rgba(79, 15, 148, .7) 55%, rgba(109, 25, 190, .45) 100%);
}

.carousel-caption,
.carousel-caption h1,
.carousel-caption h2,
.carousel-caption h3,
.carousel-caption h4,
.carousel-caption h5,
.carousel-caption .lead {
    color: #fff;
}

.carousel-caption h1,
.carousel-caption .display-4 {
    font-weight: 700 !important;
    text-shadow: 0 2px 18px rgba(20, 6, 45, .35);
}

/* ---------- Page header (header.jarallax) ---------- */
header.jarallax {
    position: relative;
    overflow: hidden;
    background-color: var(--ssm-primary-dark);
}

header.jarallax .page-image {
    position: relative;
    z-index: 1;
    margin-top: 0;
    padding: calc(var(--site-nav-height) + 4.5rem) 1.25rem 6.5rem;
    color: #fff;
    background:
        radial-gradient(circle at 85% 0%, rgba(196, 160, 250, .45), transparent 45%),
        linear-gradient(120deg, rgba(42, 11, 85, .92) 0%, rgba(79, 15, 148, .82) 50%, rgba(109, 25, 190, .62) 100%);
}

header.jarallax .page-image::after {
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: clamp(40px, 5vw, 80px);
    background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 96' preserveAspectRatio='none'%3e%3cpath fill='%23ffffff' fill-opacity='.18' d='M0 25 C175 4 275 72 470 48 C670 22 775 18 945 49 C1120 80 1280 16 1440 38 L1440 96 L0 96 Z'/%3e%3cpath fill='%23ffffff' d='M0 65 C150 38 290 86 465 66 C655 44 780 52 940 72 C1120 93 1280 40 1440 65 L1440 96 L0 96 Z'/%3e%3c/svg%3e") center bottom / 100% 100% no-repeat;
    content: "";
    pointer-events: none;
}

header.jarallax .page-image h1,
header.jarallax .page-image .display-4 {
    max-width: 960px;
    margin: 0 auto;
    color: #fff;
    font-size: clamp(1.9rem, 4vw, 3rem);
    font-weight: 700 !important;
    line-height: 1.3;
    text-shadow: 0 2px 18px rgba(20, 6, 45, .35);
}

header.jarallax .page-image .lead {
    max-width: 760px;
    margin: .9rem auto 0;
    color: rgba(255, 255, 255, .88);
    font-size: 1.1rem;
    font-weight: 400;
}

/* Tag buttons inside the header (about pages) */
header.jarallax .btn,
header.jarallax .btn.bg-alpha {
    margin: .25rem;
    padding: .45rem 1.1rem;
    color: #fff !important;
    background: rgba(255, 255, 255, .14) !important;
    border: 1px solid rgba(255, 255, 255, .45) !important;
    border-radius: 999px;
    font-weight: 500;
    backdrop-filter: blur(4px);
}

header.jarallax .btn:hover,
header.jarallax .btn.active {
    color: var(--ssm-primary) !important;
    background: #fff !important;
    border-color: #fff !important;
}

@media (max-width: 767.98px) {
    header.jarallax .page-image { padding: calc(var(--site-nav-height) + 2.5rem) 1rem 4.5rem; }
}

/* ---------- Section headings ---------- */
.border-short-bottom {
    color: var(--ssm-primary);
    font-weight: 700 !important;
}

.border-short-bottom::after {
    width: 56px;
    height: 4px;
    margin-left: -28px;
    border-radius: 4px;
    background: var(--ssm-primary);
}

/* ---------- Cards ---------- */
.card {
    overflow: hidden;
    border: 1px solid var(--ssm-border);
    border-radius: var(--site-radius);
    background: #fff;
    box-shadow: var(--site-shadow);
    transition: transform .2s ease, box-shadow .2s ease;
}

.row > [class*="col"] > .card.h-100:hover,
section[class*="col"] > .card.h-100:hover {
    transform: translateY(-4px);
    box-shadow: var(--site-shadow-hover);
}

.card-img-top { border-radius: 0; object-fit: cover; }

.card-title {
    color: var(--ssm-dark);
    font-weight: 600;
    line-height: 1.45;
}

.card-text { color: var(--ssm-muted); }

.card-header,
.card-footer { background: var(--ssm-soft); border-color: var(--ssm-border); }

.card-header.bg-success { background: linear-gradient(120deg, var(--ssm-primary-dark), var(--ssm-primary)) !important; color: #fff; }

.warpper-card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.warpper-card-img img:hover { transform: scale(1.05); }

.sub-act {
    overflow: hidden;
    border: 1px solid var(--ssm-border);
    border-radius: var(--site-radius);
    background: #fff;
    box-shadow: var(--site-shadow);
}

.blog-content {
    border: 1px solid var(--ssm-border);
    border-radius: var(--site-radius);
    box-shadow: var(--site-shadow);
}

/* .jumbotron no longer exists in Bootstrap 5; keep its spacing (scholar.php) */
.jumbotron { padding: 4rem 1rem; background: var(--ssm-soft); border-radius: 0; }

/* ---------- Bootstrap 4 behaviour kept after moving to Bootstrap 5 ---------- */
/* BS5 underlines links by default; BS4 only did on hover */
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.btn:hover,
.card a:hover,
.page-link:hover,
.dropdown-item:hover,
.nav-link:hover { text-decoration: none; }

/* .card-columns (masonry) was removed in BS5: medias.php, stoptobacco.php.
   style.css already sets the column-count per breakpoint. */
.card-columns { column-gap: 1.25rem; orphans: 1; widows: 1; }

/* bootstrap-ssm gives inputs the lavender body background; keep fields white */
.form-control,
.form-select { background-color: #fff; }

.form-select {
    border-color: var(--ssm-border);
    border-radius: 12px;
}

.form-select:focus {
    border-color: #b48ef0;
    box-shadow: 0 0 0 .2rem rgba(109, 25, 190, .15);
}

/* scholar.php carousel uses <ol><li> indicators (BS4 markup): hide list numbers */
.carousel-indicators { list-style: none; }
.carousel-indicators li::marker { content: ""; }
.card-columns .card { display: inline-block; width: 100%; margin-bottom: .75rem; }

/* ---------- Buttons ---------- */
.btn {
    border-radius: 12px;
    font-weight: 600;
    transition: all .2s ease;
}

.btn-success,
.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, #8b3be0, var(--ssm-primary));
    border-color: var(--ssm-primary);
}

.btn-success:hover,
.btn-success:focus,
.btn-primary:hover,
.btn-primary:focus,
.btn-success:not(:disabled):not(.disabled):active,
.btn-primary:not(:disabled):not(.disabled):active {
    color: #fff;
    background: var(--ssm-dark);
    border-color: var(--ssm-dark);
}

.btn-warning {
    color: #fff;
    background: linear-gradient(135deg, #ffa928, var(--ssm-accent));
    border-color: var(--ssm-accent);
}

.btn-warning:hover { color: #fff; filter: brightness(1.05); }

.btn-secondary { background: var(--ssm-muted); border-color: var(--ssm-muted); }

/* Outline buttons used as filter chips (tags / columns) */
.btn-outline-warning,
.btn-outline-success,
.btn-outline-secondary,
.btn-outline-primary,
.btn-outline-info {
    color: var(--ssm-primary);
    background: #fff;
    border: 1.5px solid var(--ssm-border);
    border-radius: 999px;
    font-weight: 500;
}

.btn-outline-secondary { color: var(--ssm-muted); background: var(--ssm-soft); }

.btn-outline-warning:hover,
.btn-outline-success:hover,
.btn-outline-secondary:hover,
.btn-outline-primary:hover,
.btn-outline-info:hover,
.btn-outline-warning.active,
.btn-outline-success.active,
.btn-outline-primary.active,
.btn-outline-info.active,
.btn-outline-warning:not(:disabled):not(.disabled).active,
.btn-outline-success:not(:disabled):not(.disabled).active {
    color: #fff;
    background: var(--ssm-primary);
    border-color: var(--ssm-primary);
    box-shadow: 0 6px 16px rgba(109, 25, 190, .25);
}

.btn-group-custom .btn-danger { border-radius: 999px; }

/* Solid filter buttons (news.php) shown as chips too */
.btn-group-custom .btn-primary,
.btn-group-custom .btn-info {
    color: var(--ssm-primary);
    background: #fff;
    border: 1.5px solid var(--ssm-border);
    border-radius: 999px;
    font-weight: 500;
}

.btn-group-custom .btn-primary:hover,
.btn-group-custom .btn-info:hover,
.btn-group-custom .btn-primary.active,
.btn-group-custom .btn-info.active,
.btn-group-custom .btn-primary:not(:disabled):not(.disabled).active,
.btn-group-custom .btn-info:not(:disabled):not(.disabled).active {
    color: #fff;
    background: var(--ssm-primary);
    border-color: var(--ssm-primary);
    box-shadow: 0 6px 16px rgba(109, 25, 190, .25);
}

/* medias.php: cover + title link to medias-detail.php */
.media-card-link { display: block; overflow: hidden; color: inherit; text-decoration: none; }
.media-card-link:hover { color: var(--ssm-primary-dark); text-decoration: none; }
.media-card-link .card-img-top { transition: transform .4s ease; }
.media-card-link:hover .card-img-top { transform: scale(1.04); }
.card-title > .media-card-link { display: inline; }

/* medias.php: expanded "รายละเอียด" text comes from the database (safeRichText) */
.card-columns .collapse a {
    color: var(--ssm-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
    overflow-wrap: anywhere;
}
.card-columns .collapse img { max-width: 100%; height: auto; border-radius: 10px; }
.card-columns .collapse iframe { max-width: 100%; }

/* medias.php: card grid section follows the filter section; remove double spacing */
section.container:has(> .card-columns) { padding-top: 1rem !important; }

.btn-invite { border-radius: 999px; font-weight: 600; }

/* ---------- Text / badge utilities in brand colours ---------- */
.text-success { color: var(--ssm-primary) !important; }
.bg-success { background-color: var(--ssm-primary) !important; }
.border-success { border-color: var(--ssm-primary) !important; }
.text-warning { color: var(--ssm-accent) !important; }

.badge { border-radius: 6px; font-weight: 500; padding: .3em .7em; }
/* Badge colours come from bootstrap-ssm (success = brand purple, secondary = muted,
   warning = accent orange); keep white text on the orange like before. */
.badge.text-bg-warning { color: #fff !important; }

hr.bg-success { background: var(--ssm-border) !important; }
.progress-bar.bg-success { background: var(--ssm-primary) !important; }

/* ---------- Pagination ---------- */
.pagination { gap: .3rem; flex-wrap: wrap; }

.page-link {
    color: var(--ssm-primary);
    border: 1px solid var(--ssm-border);
    border-radius: 10px !important;
}

/* every button (Previous / numbers / "..." page picker / Next) gets the same height */
.pagination .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2.5rem;
    min-width: 2.5rem;
    padding: 0 .85rem;
    font-size: 1rem;
    line-height: 1;
}

.pagination select.page-link {
    -webkit-appearance: none;
    appearance: none;
    padding: 0 2rem 0 .85rem;
    font-family: inherit;
    cursor: pointer;
    background-color: var(--bs-pagination-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%236d19be' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .7rem center;
    background-size: .7rem;
}

.pagination select.page-link:hover,
.pagination select.page-link:focus {
    color: #fff;
    background-color: var(--ssm-primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
}

.pagination select.page-link option { color: var(--ssm-text); background: #fff; }

/* Previous / Next: words on larger screens, arrows on phones */
.pagination .pg-arrow { display: none; font-size: 1.35rem; line-height: 1; margin-top: -.15rem; }

@media (max-width: 575.98px) {
    /* the page markup floats the pagination right; centre it instead */
    nav:has(> .pagination) { float: none !important; }
    .pagination { justify-content: center; }
    .pagination .page-link { height: 2.35rem; min-width: 2.35rem; padding: 0 .6rem; font-size: .95rem; }
    .pagination select.page-link { padding: 0 1.75rem 0 .6rem; background-position: right .55rem center; }
    .pagination .pg-arrow { display: inline; }
    .pagination .pg-label {
        position: absolute; width: 1px; height: 1px; overflow: hidden;
        clip: rect(0 0 0 0); white-space: nowrap;
    }
}

.page-link:hover { color: #fff; background: var(--ssm-primary); border-color: var(--ssm-primary); }

.page-item.active .page-link {
    color: #fff;
    background: var(--ssm-primary);
    border-color: var(--ssm-primary);
}

/* ---------- Forms ---------- */
.form-control {
    border-color: var(--ssm-border);
    border-radius: 12px;
}

.form-control:focus {
    border-color: #b48ef0;
    box-shadow: 0 0 0 .2rem rgba(109, 25, 190, .15);
}

/* ---------- Article body ---------- */
#db-detail blockquote p,
blockquote {
    border-left-color: var(--ssm-primary) !important;
}

#db-detail p > sup { color: var(--ssm-primary) !important; }

.timeline li > .timeline-badge { border-color: var(--ssm-primary); }

#datetime span { color: var(--ssm-primary) !important; }

/* Card that sits directly under the navbar (search.php) */
body > section.container > .card:first-child { margin-top: 1.5rem; }

/* Section backgrounds that used grey */
.bg-light { background-color: var(--ssm-bg) !important; }
.bg-secondary { background-color: var(--ssm-soft) !important; }

/* ==========================================================================
   Mobile fixes (checked at 390px wide)
   ========================================================================== */

/* Header tag buttons (about pages): long labels wrap instead of running off screen */
header.jarallax .btn {
    max-width: 100%;
    white-space: normal;
}

/* search.php: result titles used .text-nowrap, which made the table wider than the phone */
.detail-srch .text-nowrap { white-space: normal !important; }
.detail-srch h6 { font-weight: 600; line-height: 1.45; }

/* search.php category badge: was grey text on grey */
.detail-srch .badge-outlined {
    padding: .3em .8em;
    color: var(--ssm-primary) !important;
    background: var(--ssm-soft) !important;
    border: 0 !important;
    border-radius: 999px;
    font-weight: 500;
}

@media (max-width: 575.98px) {
    /* one readable column: small thumbnail + text, no table header */
    .table-responsive > .table > thead { display: none; }
    .table-responsive > .table td { padding: .75rem .5rem; vertical-align: top; }
    .table-responsive > .table td.img-srch { width: 84px; padding-right: 0; }
    .table-responsive > .table td.img-srch img { width: 76px !important; border-radius: 8px; }

    /* search.php already swaps to the short #detail-srch text on phones
       (and hides #detail-srch-show); just keep that short text to 3 lines */
    .detail-srch #detail-srch {
        display: -webkit-box !important;
        overflow: hidden;
        font-size: .88rem;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
    }
}
