/**
 * Homepage-only styles extracted from index.php.
 * Keep reusable design-system rules in dist/custom.css.
 */

/* ─── Base & Performance ─────────────────────────────────────────── */
* {
    -webkit-font-smoothing: antialiased;
}

html {
    text-size-adjust: 100%;
    background: #eef6ff;
}

body {
    overflow-x: hidden;
    background: #eef6ff;
}

/* ─── Reduced Motion ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ─── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: linear-gradient(180deg, #F0F9FF 0%, #E0F2FE 100%);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #22D3EE, #0EA5E9, #2563EB, #6366F1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #67E8F9, #38BDF8, #3B82F6, #818CF8);
}

::selection {
    background: rgba(34, 211, 238, 0.3);
}

/* ─── Hero Slider ────────────────────────────────────────────────── */
.hero-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.8s ease;
    will-change: opacity;
}

.hero-slide.active {
    opacity: 1;
}

/* ─── Reveal Animations ──────────────────────────────────────────── */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s cubic-bezier(0.5, 0, 0, 1), transform 0.6s cubic-bezier(0.5, 0, 0, 1);
    will-change: opacity, transform;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* ─── Link Arrows ────────────────────────────────────────────────── */
.link-arrow {
    transition: color 0.2s ease;
}

.link-arrow::after {
    content: ' ›';
    transition: margin 0.2s ease;
}

.link-arrow:hover::after {
    margin-left: 3px;
}

/* ─── Gradient Text ──────────────────────────────────────────────── */
.gradient-text {
    background: linear-gradient(135deg, #1F5F7A, #3A9FC9, #7EC8E3, #22D3EE);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ─── Rainbow Bar ────────────────────────────────────────────────── */
.rainbow-bar {
    background: linear-gradient(90deg, #165066 0%, #1F5F7A 15%, #2E7D9B 30%, #3A9FC9 45%, #7EC8E3 60%, #22D3EE 75%, #67E8F9 90%, #B8E2F2 100%);
}

/* ─── Skeleton / Blur-up Loading ─────────────────────────────────── */
.img-skeleton {
    background:
        linear-gradient(90deg, rgba(126, 200, 227, 0) 0%, rgba(126, 200, 227, 0.25) 50%, rgba(126, 200, 227, 0) 100%),
        linear-gradient(135deg, #E0F2FE 0%, #BAE6FD 100%);
    background-size: 200% 100%, 100% 100%;
    animation: skeletonShine 1.6s linear infinite;
}

@keyframes skeletonShine {
    0% {
        background-position: -200% 0, 0 0;
    }

    100% {
        background-position: 200% 0, 0 0;
    }
}

.img-wrap {
    position: relative;
    overflow: hidden;
}

.img-wrap img {
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.58s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, transform;
}

.img-wrap img.loaded {
    opacity: 1;
}

/* ─── Institutional Homepage Sections ───────────────────────────── */
.home-page-shell {
    width: min(100%, 1440px);
    margin-inline: auto;
    background: #ffffff;
    box-shadow:
        0 0 0 1px rgba(148, 163, 184, 0.14),
        0 24px 60px rgba(15, 23, 42, 0.05);
}

.home-page-shell>section {
    width: 100%;
    max-width: 1440px;
    margin-inline: auto;
}

.home-page-divider {
    width: min(100%, 1440px);
    margin-inline: auto;
}

.home-hero {
    border-bottom: 1px solid rgba(125, 211, 252, 0.24);
}

.home-hero h1,
.home-hero p {
    text-shadow: 0 14px 34px rgba(2, 6, 23, 0.28);
}

.home-trust-card,
.home-evidence-item,
.home-pathway,
.home-announcement,
.home-quality-card,
.home-service {
    box-shadow: 0 12px 32px rgba(30, 58, 138, 0.06);
    transition:
        transform 0.26s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.26s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.26s cubic-bezier(0.4, 0, 0.2, 1),
        background-color 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}

.home-trust-card,
.home-evidence-item,
.home-pathway,
.home-announcement,
.home-service {
    transform: translate3d(0, 0, 0);
}

.home-trust-card:hover,
.home-trust-card:focus-within,
.home-evidence-item:hover,
.home-evidence-item:focus-within,
.home-pathway:hover,
.home-pathway:focus-visible,
.home-announcement:hover,
.home-announcement:focus-visible,
.home-service:hover,
.home-service:focus-visible {
    border-color: rgba(14, 165, 233, 0.48);
    box-shadow: 0 18px 42px rgba(14, 165, 233, 0.16);
}

.home-quality-card {
    position: relative;
    overflow: hidden;
}

.home-quality-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, #1D4ED8, #0EA5E9, #22D3EE);
}

/* ─── Glow Effects ───────────────────────────────────────────────── */
.glow-blue {
    box-shadow: 0 0 30px rgba(126, 200, 227, 0.4);
}

.glow-cyan {
    box-shadow: 0 0 30px rgba(34, 211, 238, 0.4);
}

.glow-navy {
    box-shadow: 0 0 30px rgba(46, 125, 155, 0.4);
}

/* ─── Homepage News Cards: match news_category hover polish ──────── */
section[aria-label="ข่าวสาร"] a.group.block.bg-white {
    position: relative;
    isolation: isolate;
    transform: translate3d(0, 0, 0);
    transition:
        transform 0.26s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.26s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.26s cubic-bezier(0.4, 0, 0.2, 1),
        background-color 0.26s cubic-bezier(0.4, 0, 0.2, 1) !important;
    outline: 1px solid rgba(14, 165, 233, 0.12);
    outline-offset: 0;
    will-change: transform, box-shadow;
}

section[aria-label="ข่าวสาร"] a.group.block.bg-white::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 3;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    box-shadow:
        inset 0 0 0 1px rgba(56, 189, 248, 0.72),
        inset 0 0 18px rgba(14, 165, 233, 0.12),
        0 0 0 1px rgba(125, 211, 252, 0.3),
        0 0 26px rgba(14, 165, 233, 0.28);
    transition: opacity 0.26s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}

section[aria-label="ข่าวสาร"] a.group.block.bg-white:hover,
section[aria-label="ข่าวสาร"] a.group.block.bg-white:focus-visible {
    transform: translate3d(0, -4px, 0);
    border-color: rgba(14, 165, 233, 0.72) !important;
    box-shadow:
        0 18px 48px rgba(14, 165, 233, 0.22),
        0 8px 24px rgba(15, 23, 42, 0.08) !important;
}

section[aria-label="ข่าวสาร"] a.group.block.bg-white:hover::before,
section[aria-label="ข่าวสาร"] a.group.block.bg-white:focus-visible::before {
    opacity: 1;
}

section[aria-label="ข่าวสาร"] a.group.block.bg-white:hover .img-wrap img.loaded,
section[aria-label="ข่าวสาร"] a.group.block.bg-white:focus-visible .img-wrap img.loaded {
    transform: scale(1.08);
}

section[aria-label="ข่าวสาร"] a.group.block.bg-white .absolute.inset-0 {
    transition: opacity 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (hover: none) {
    section[aria-label="ข่าวสาร"] a.group.block.bg-white:hover,
    section[aria-label="ข่าวสาร"] a.group.block.bg-white:focus-visible {
        transform: translate3d(0, 0, 0);
    }

    section[aria-label="ข่าวสาร"] a.group.block.bg-white:hover .img-wrap img.loaded,
    section[aria-label="ข่าวสาร"] a.group.block.bg-white:focus-visible .img-wrap img.loaded {
        transform: none;
    }
}

/* ─── Dark Mode: Homepage Surface System ─────────────────────────── */
:is(body.dark-mode, html.dark-mode body) {
    --home-bg: #0b1220;
    --home-surface: #111c2e;
    --home-surface-2: #16243a;
    --home-surface-3: #1b2d46;
    --home-border: rgba(96, 165, 250, 0.22);
    --home-border-strong: rgba(125, 211, 252, 0.34);
    --home-text: #e5eefb;
    --home-text-soft: #cbd5e1;
    --home-text-muted: #9aa9bd;
    --home-accent: #38bdf8;
    --home-accent-2: #22d3ee;
    --home-shadow: 0 20px 45px rgba(2, 6, 23, 0.36);
    background: var(--home-bg) !important;
    color: var(--home-text);
}

:is(html.dark-mode, html.dark) {
    background: #0b1220 !important;
}

:is(body.dark-mode, html.dark-mode body, html.dark body) {
    background: #0b1220 !important;
}

:is(body.dark-mode, html.dark-mode body, html.dark body) .home-page-shell {
    background: #0b1220 !important;
    box-shadow:
        0 0 0 1px rgba(96, 165, 250, 0.16),
        0 24px 70px rgba(2, 6, 23, 0.45);
}

:is(body.dark-mode, html.dark-mode body) main {
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, 0.14), transparent 30rem),
        linear-gradient(180deg, #0b1220 0%, #0f172a 42%, #0b1220 100%);
}

:is(body.dark-mode, html.dark-mode body) ::selection {
    background: rgba(56, 189, 248, 0.35);
    color: #f8fafc;
}

:is(body.dark-mode, html.dark-mode body) ::-webkit-scrollbar-track {
    background: #0b1220;
}

:is(body.dark-mode, html.dark-mode body) .hero-slide::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(8, 14, 26, 0.88), rgba(15, 23, 42, 0.72), rgba(15, 23, 42, 0.36));
    pointer-events: none;
}

:is(body.dark-mode, html.dark-mode body) section[aria-label="ข้อมูลสำคัญของโรงเรียน"],
:is(body.dark-mode, html.dark-mode body) section[aria-label="ภาพรวมโรงเรียน"],
:is(body.dark-mode, html.dark-mode body) section[aria-label="ประกาศสำคัญ"],
:is(body.dark-mode, html.dark-mode body) section[aria-label="คุณภาพการศึกษา"],
:is(body.dark-mode, html.dark-mode body) section[aria-label="สถิติและผลงาน"],
:is(body.dark-mode, html.dark-mode body) section[aria-label="รางวัลโรงเรียนพระราชทาน"],
:is(body.dark-mode, html.dark-mode body) section[aria-label="ข่าวสาร"],
:is(body.dark-mode, html.dark-mode body) section[aria-label="บริการข้อมูลสาธารณะ"] {
    background: linear-gradient(180deg, #0b1220 0%, #101b2d 52%, #0b1220 100%) !important;
    color: var(--home-text);
}

:is(body.dark-mode, html.dark-mode body) .home-trust-card,
:is(body.dark-mode, html.dark-mode body) .home-evidence-item,
:is(body.dark-mode, html.dark-mode body) .home-pathway,
:is(body.dark-mode, html.dark-mode body) .home-announcement,
:is(body.dark-mode, html.dark-mode body) .home-quality-card,
:is(body.dark-mode, html.dark-mode body) .home-service,
:is(body.dark-mode, html.dark-mode body) .home-academic .rounded-full,
:is(body.dark-mode, html.dark-mode body) .home-academic .rounded-lg {
    background:
        linear-gradient(180deg, rgba(30, 41, 59, 0.98), rgba(17, 28, 46, 0.98)) !important;
    border-color: var(--home-border) !important;
    color: var(--home-text) !important;
    box-shadow: var(--home-shadow);
}

:is(body.dark-mode, html.dark-mode body) .home-trust h2,
:is(body.dark-mode, html.dark-mode body) .home-overview h2,
:is(body.dark-mode, html.dark-mode body) .home-announcements h2,
:is(body.dark-mode, html.dark-mode body) .home-academic h2,
:is(body.dark-mode, html.dark-mode body) .home-trust-card strong,
:is(body.dark-mode, html.dark-mode body) .home-pathway h3,
:is(body.dark-mode, html.dark-mode body) .home-announcement h3,
:is(body.dark-mode, html.dark-mode body) .home-quality-card h3,
:is(body.dark-mode, html.dark-mode body) .home-service h3 {
    color: var(--home-text) !important;
    -webkit-text-fill-color: currentColor;
}

:is(body.dark-mode, html.dark-mode body) .home-trust p,
:is(body.dark-mode, html.dark-mode body) .home-overview p,
:is(body.dark-mode, html.dark-mode body) .home-announcements p,
:is(body.dark-mode, html.dark-mode body) .home-academic p,
:is(body.dark-mode, html.dark-mode body) .home-trust-card span,
:is(body.dark-mode, html.dark-mode body) .home-service p,
:is(body.dark-mode, html.dark-mode body) .home-academic .rounded-lg {
    color: var(--home-text-muted) !important;
}

:is(body.dark-mode, html.dark-mode body) section[aria-label="บริการข้อมูลสาธารณะ"] .group,
:is(body.dark-mode, html.dark-mode body) section[aria-label="ข่าวสาร"] a.bg-white {
    background:
        linear-gradient(180deg, rgba(30, 41, 59, 0.98), rgba(17, 28, 46, 0.98)) !important;
    border-color: var(--home-border) !important;
    box-shadow: var(--home-shadow);
}

:is(body.dark-mode, html.dark-mode body) section[aria-label="บริการข้อมูลสาธารณะ"] .group:hover,
:is(body.dark-mode, html.dark-mode body) section[aria-label="ข่าวสาร"] a.bg-white:hover {
    border-color: var(--home-border-strong) !important;
    box-shadow: 0 24px 52px rgba(2, 6, 23, 0.44), 0 0 0 1px rgba(56, 189, 248, 0.12);
}

:is(body.dark-mode, html.dark-mode body) section[aria-label="บริการข้อมูลสาธารณะ"] h3,
:is(body.dark-mode, html.dark-mode body) section[aria-label="ข่าวสาร"] h2,
:is(body.dark-mode, html.dark-mode body) section[aria-label="ข่าวสาร"] h3,
:is(body.dark-mode, html.dark-mode body) section[aria-label="ข่าวสาร"] h4,
:is(body.dark-mode, html.dark-mode body) section[aria-label="สถิติและผลงาน"] h4 {
    color: var(--home-text) !important;
    -webkit-text-fill-color: currentColor;
}

:is(body.dark-mode, html.dark-mode body) section[aria-label="บริการข้อมูลสาธารณะ"] p,
:is(body.dark-mode, html.dark-mode body) section[aria-label="ข่าวสาร"] p {
    color: var(--home-text-muted) !important;
}

:is(body.dark-mode, html.dark-mode body) section[aria-label="สถิติและผลงาน"]>.grid>div {
    background:
        linear-gradient(135deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.98)) !important;
    border: 1px solid rgba(96, 165, 250, 0.16);
}

:is(body.dark-mode, html.dark-mode body) section[aria-label="สถิติและผลงาน"]>.grid>div:nth-child(1),
:is(body.dark-mode, html.dark-mode body) section[aria-label="สถิติและผลงาน"]>.grid>div:nth-child(4) {
    background: linear-gradient(135deg, #0f2c5f 0%, #1d4ed8 48%, #312e81 100%) !important;
}

:is(body.dark-mode, html.dark-mode body) section[aria-label="สถิติและผลงาน"] p {
    color: var(--home-text-soft) !important;
}

:is(body.dark-mode, html.dark-mode body) section[aria-label="สถิติและผลงาน"] a {
    color: #7dd3fc !important;
}

:is(body.dark-mode, html.dark-mode body) section[aria-label="รางวัลโรงเรียนพระราชทาน"]>div[aria-hidden="true"] .absolute,
:is(body.dark-mode, html.dark-mode body) section[aria-label="รางวัลโรงเรียนพระราชทาน"] .absolute.inset-0 {
    background: linear-gradient(135deg, rgba(8, 14, 26, 0.95), rgba(15, 23, 42, 0.9), rgba(12, 74, 110, 0.82)) !important;
}

:is(body.dark-mode, html.dark-mode body) section[aria-label="รางวัลโรงเรียนพระราชทาน"] h2,
:is(body.dark-mode, html.dark-mode body) section[aria-label="รางวัลโรงเรียนพระราชทาน"] p,
:is(body.dark-mode, html.dark-mode body) section[aria-label="รางวัลโรงเรียนพระราชทาน"] h4 {
    color: var(--home-text) !important;
}

:is(body.dark-mode, html.dark-mode body) section[aria-label="ข่าวสาร"] .text-pastel-blue-deep,
:is(body.dark-mode, html.dark-mode body) section[aria-label="ข่าวสาร"] .text-pastel-azure-dark,
:is(body.dark-mode, html.dark-mode body) section[aria-label="บริการข้อมูลสาธารณะ"] a {
    color: var(--home-accent) !important;
}

:is(body.dark-mode, html.dark-mode body) main :is(.text-pastel-navy, .text-pastel-navy-dark, .text-pastel-blue-deep, .text-pastel-cyan-dark, .text-pastel-azure-dark, .text-pastel-teal-dark, .text-pastel-indigo, .text-pastel-sapphire) {
    color: var(--home-accent) !important;
}

:is(body.dark-mode, html.dark-mode body) main :is(.text-gray-900, .text-gray-800) {
    color: var(--home-text) !important;
}

:is(body.dark-mode, html.dark-mode body) main :is(.text-gray-700, .text-gray-600, .text-gray-500, .text-gray-400) {
    color: var(--home-text-muted) !important;
}

:is(body.dark-mode, html.dark-mode body) section[aria-label="ข่าวสาร"] .img-skeleton,
:is(body.dark-mode, html.dark-mode body) .img-skeleton {
    background:
        linear-gradient(90deg, rgba(56, 189, 248, 0) 0%, rgba(56, 189, 248, 0.18) 50%, rgba(56, 189, 248, 0) 100%),
        linear-gradient(135deg, #111c2e 0%, #1e3a5f 100%);
    background-size: 200% 100%, 100% 100%;
}

:is(body.dark-mode, html.dark-mode body) section[aria-label="บริการข้อมูลสาธารณะ"] .group {
    border-color: rgba(96, 165, 250, 0.16) !important;
}

:is(body.dark-mode, html.dark-mode body) #backToTop {
    box-shadow: 0 16px 32px rgba(37, 99, 235, 0.35);
}

@media (max-width: 640px) {
    :is(body.dark-mode, html.dark-mode body) section[aria-label="ข่าวสาร"] a.bg-white,
    :is(body.dark-mode, html.dark-mode body) section[aria-label="บริการข้อมูลสาธารณะ"] .group {
        box-shadow: 0 14px 30px rgba(2, 6, 23, 0.34);
    }
}

/* ─── Focus Styles (A11Y) ────────────────────────────────────────── */
a:focus-visible,
button:focus-visible {
    outline: 2px solid #22D3EE;
    outline-offset: 3px;
    border-radius: 4px;
}
