/* =========================================================
   YFPC — FINAL RESPONSIVE SYSTEM
   Mobile / Tablet / iPad / Desktop / Large Desktop
   Loaded last so it normalizes page-specific styles safely.
========================================================= */

:root {
    --site-max: 1240px;
    --site-gutter: 24px;
}

html {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
}

body {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: clip;
}

.site-header {
    position: fixed;
    inset: 0 0 auto;
}

main,
.site-header,
.navbar,
.site-footer,
section,
footer {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

main {
    display: block;
}

.container,
.nav-inner,
.topbar-inner,
.footer-grid,
.footer-bottom-inner {
    width: min(var(--site-max), calc(100% - (var(--site-gutter) * 2)));
    max-width: var(--site-max);
    margin-inline: auto;
}

.container,
main > section > .container,
main > .section > .container {
    min-width: 0;
}

img,
video,
svg,
iframe,
canvas {
    max-width: 100%;
}

*,
*::before,
*::after {
    min-width: 0;
}

/* Prevent common content from creating accidental horizontal scroll. */
h1,
h2,
h3,
h4,
h5,
p,
a,
button,
label,
input,
textarea,
select,
strong,
span {
    overflow-wrap: anywhere;
}

/* Keep navigation labels intact. */
.nav-menu > a,
.dropdown-trigger,
.nav-donate,
.nav-subscribe,
.brand-copy,
.footer-legal a {
    overflow-wrap: normal;
}

/* =========================================================
   HEADER — DESKTOP
========================================================= */
@media (min-width: 1200px) {

    .nav-inner {
        min-height: 82px;
        gap: 16px;
    }

    .brand {
        width: 188px;
        min-width: 188px;
        gap: 10px;
    }

    .brand-logo {
        width: 54px;
        height: 54px;
    }

    .brand-copy strong {
        font-size: 1.02rem;
    }

    .brand-copy small {
        font-size: .56rem;
        letter-spacing: 0;
    }

    .nav-menu {
        flex: 1 1 auto;
        min-width: 0;
        justify-content: flex-end;
        gap: 0;
    }

    .nav-menu > a,
    .dropdown-trigger {
        min-height: 40px;
        padding-inline: 6px;
        font-size: .72rem;
    }

    .nav-donate {
        margin-left: 5px;
        padding-inline: 13px !important;
    }

    .nav-subscribe {
        padding-inline: 9px !important;
    }

    .nav-socials {
        display: none;
    }
}

/* =========================================================
   HEADER — COMPACT DESKTOP / TABLET
========================================================= */
@media (min-width: 769px) and (max-width: 1199px) {

    .topbar {
        display: none;
    }

    .nav-inner {
        min-height: 74px;
        width: min(100%, calc(100% - 32px));
    }

    .brand-copy {
        display: none;
    }

    .nav-toggle {
        display: block;
    }

    .nav-menu {
        position: absolute;
        top: 100%;
        left: 16px;
        right: 16px;
        width: auto;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        max-height: calc(100vh - 88px);
        overflow-y: auto;
        padding: 12px;
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 16px;
        box-shadow: 0 20px 50px rgba(0,0,0,.14);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(-10px);
    }

    .nav-menu.open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0);
    }

    .nav-menu > a,
    .dropdown-trigger {
        width: 100%;
        min-height: 50px;
        justify-content: space-between;
        padding-inline: 15px;
        border-radius: 9px;
        font-size: .92rem;
    }

    .nav-menu > a::after,
    .dropdown-trigger::after {
        display: none;
    }

    .nav-dropdown {
        width: 100%;
    }

    .dropdown-menu {
        position: static;
        display: none;
        width: auto;
        min-width: 0;
        margin: 0 5px 5px;
        padding: 5px;
        border: 0;
        border-radius: 9px;
        box-shadow: none;
        background: #f8f8f8;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
    }

    .nav-dropdown.open .dropdown-menu {
        display: block;
    }

    .nav-dropdown.open .dropdown-trigger span {
        transform: rotate(180deg);
    }

    .nav-subscribe,
    .nav-donate {
        width: 100%;
        justify-content: center !important;
        margin: 7px 0 0 !important;
    }

    .nav-socials {
        display: flex;
        justify-content: center;
        margin: 12px 0 4px;
        padding-top: 14px;
        border-top: 1px solid rgba(11,11,11,.08);
    }
}

/* =========================================================
   GENERAL DESKTOP GRID NORMALIZATION
========================================================= */
@media (min-width: 1200px) {

    .hero-content {
        grid-template-columns: minmax(0, 1fr) 300px;
        gap: 70px;
    }

    .split-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: clamp(50px, 6vw, 80px);
    }

    .service-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .stats-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .rebis-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .programme-feature-grid {
        grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr) minmax(0, .85fr);
    }

    .programme-content-grid,
    .programme-hero-grid,
    .donate-hero-grid,
    .donation-layout,
    .trust-grid,
    .recruitment-layout,
    .mission-grid,
    .community-content-grid,
    .newcomer-content-grid,
    .vocational-content-grid,
    .yfpc-contact-layout {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
}

/* =========================================================
   TABLET / IPAD LANDSCAPE
========================================================= */
@media (min-width: 769px) and (max-width: 1199px) {

    :root {
        --site-gutter: 24px;
    }

    .section {
        padding: 88px 0;
    }

    .hero {
        min-height: 850px;
    }

    .hero-content {
        grid-template-columns: minmax(0, 1fr) 270px;
        gap: 35px;
        padding-top: 88px;
    }

    .hero h1 {
        font-size: clamp(48px, 7vw, 76px);
    }

    .split-grid,
    .programme-content-grid,
    .programme-hero-grid,
    .donate-hero-grid,
    .donation-layout,
    .trust-grid,
    .recruitment-layout,
    .mission-grid,
    .community-content-grid,
    .newcomer-content-grid,
    .vocational-content-grid,
    .yfpc-contact-layout {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 42px;
    }

    .service-grid,
    .programme-service-grid,
    .content-grid,
    .gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat {
        border-bottom: 1px solid var(--line);
    }

    .rebis-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .programme-feature-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: auto;
    }

    .programme-feature {
        min-height: 300px;
    }

    .footer-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 42px 34px;
        padding: 62px 0 52px;
    }

    .footer-brand {
        grid-column: 1 / -1;
    }

    .footer-bottom-inner {
        min-height: 82px;
    }
}

/* =========================================================
   IPAD PORTRAIT
========================================================= */
@media (min-width: 601px) and (max-width: 768px) {

    :root {
        --site-gutter: 20px;
    }

    .section {
        padding: 76px 0;
    }

    .hero {
        min-height: 820px;
    }

    .hero-content,
    .split-grid,
    .programme-content-grid,
    .programme-hero-grid,
    .donate-hero-grid,
    .donation-layout,
    .trust-grid,
    .recruitment-layout,
    .mission-grid,
    .community-content-grid,
    .newcomer-content-grid,
    .vocational-content-grid,
    .yfpc-contact-layout {
        grid-template-columns: 1fr;
        gap: 34px;
    }

    .hero-content {
        padding-top: 82px;
    }

    .hero-panel {
        max-width: 390px;
    }

    .service-grid,
    .programme-service-grid,
    .content-grid,
    .gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .rebis-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .programme-feature-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: auto;
    }

    .footer-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 36px 28px;
    }

    .footer-brand,
    .newsletter {
        grid-column: 1 / -1;
    }
}

/* =========================================================
   MOBILE
========================================================= */
@media (max-width: 600px) {

    :root {
        --site-gutter: 15px;
    }

    .container,
    main > section > .container,
    main > .section > .container,
    .nav-inner,
    .topbar-inner,
    .footer-grid,
    .footer-bottom-inner {
        width: calc(100% - 30px);
    }

    .section {
        padding: 66px 0;
    }

    .hero {
        min-height: 780px;
    }

    .hero-content {
        display: block;
        padding-top: 90px;
    }

    .hero-copy {
        width: 100%;
        max-width: none;
    }

    .hero h1 {
        font-size: clamp(42px, 12vw, 62px);
        margin: 20px 0;
    }

    .hero-copy > p {
        font-size: 16px;
    }

    .hero-actions {
        width: 100%;
    }

    .hero-actions .btn {
        flex: 1 1 auto;
    }

    .hero-panel {
        width: 100%;
        max-width: none;
        margin-top: 30px;
    }

    .hero-scroll {
        display: none;
    }

    .split-grid,
    .programme-content-grid,
    .programme-hero-grid,
    .donate-hero-grid,
    .donation-layout,
    .trust-grid,
    .recruitment-layout,
    .mission-grid,
    .community-content-grid,
    .newcomer-content-grid,
    .vocational-content-grid,
    .yfpc-contact-layout,
    .service-grid,
    .programme-service-grid,
    .content-grid,
    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .impact-header {
        grid-template-columns: 1fr;
        gap: 22px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat {
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: 28px 18px;
    }

    .stat:nth-child(odd) {
        border-right: 1px solid var(--line);
    }

    .stat:last-child,
    .stat:nth-last-child(2) {
        border-bottom: 0;
    }

    .rebis-grid {
        grid-template-columns: 1fr;
    }

    .programme-feature-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .programme-feature {
        min-height: 270px;
    }

    .section-heading h2 {
        font-size: clamp(34px, 10vw, 48px);
    }

    .lead {
        font-size: 18px;
    }

    .content-hero,
    .article-page,
    .dashboard-hero,
    .donate-hero,
    .programme-hero {
        padding-top: 132px;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 34px;
        padding: 52px 0 44px;
    }

    .footer-brand,
    .newsletter {
        grid-column: auto;
    }

    .footer-logo-image {
        width: min(275px, 100%);
        max-width: 100%;
    }

    .footer-bottom-inner {
        min-height: auto;
        padding: 24px 0;
        flex-direction: column;
        justify-content: center;
        text-align: center;
        gap: 15px;
    }

    .footer-legal {
        justify-content: center;
        flex-wrap: wrap;
    }

    .yfpc-live-chat {
        right: 12px;
        bottom: 12px;
    }

    .back-top {
        right: 12px;
        bottom: 82px;
    }
}

/* =========================================================
   SMALL PHONES
========================================================= */
@media (max-width: 420px) {

    :root {
        --site-gutter: 12px;
    }

    .container,
    main > section > .container,
    main > .section > .container,
    .nav-inner,
    .footer-grid,
    .footer-bottom-inner {
        width: calc(100% - 24px);
    }

    .hero {
        min-height: 760px;
    }

    .hero h1 {
        font-size: 41px;
    }

    .hero-actions {
        flex-direction: column;
    }

    .hero-actions .btn {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat,
    .stat:nth-child(odd) {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .stat:last-child {
        border-bottom: 0;
    }

    .btn {
        min-height: 50px;
    }

    .programme-advert,
    .yfpc-advert-card {
        min-height: 430px;
    }
}

/* =========================================================
   FORM / TABLE SAFETY
========================================================= */

form,
.form-card,
.programme-form,
.recruitment-form,
.live-form,
table {
    max-width: 100%;
}

input,
textarea,
select,
button {
    max-width: 100%;
}

textarea {
    resize: vertical;
}

.table-wrap,
.table-responsive,
.overflow-auto,
.cms-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* =========================================================
   REDUCED MOTION
========================================================= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
