/* Components for the public module pages (News & Events, Library, Book Shop,
   Museum, Spaces, About). Base styles, header, page hero and footer live in
   xgrr-ui.css. */

/* Colours come from the theme tokens of xgrr-ui.css (light + dark). */
:root {
    --xg-blue: var(--brand-text);   /* blue text, borders and focus rings */
    --xg-fill: var(--brand);        /* blue backgrounds behind white text */
    --xg-navy: var(--heading);
    --xg-text: var(--ink);
    --xg-muted: var(--muted);
    --xg-border: var(--line);
    --xg-soft: var(--soft);
    --xg-ok: #15803d;
    --xg-warn: #b45309;
    --xg-bad: #b91c1c;
    --xg-ok-bg: #dcfce7;
    --xg-warn-bg: #fef3c7;
    --xg-bad-bg: #fee2e2;
    --xg-notice-bg: #eef2ff;
}
html[data-theme="dark"] {
    --xg-ok: #4ade80;
    --xg-warn: #fbbf24;
    --xg-bad: #f87171;
    --xg-ok-bg: #0f2e1d;
    --xg-warn-bg: #33260b;
    --xg-bad-bg: #3a1515;
    --xg-notice-bg: #17254a;
}

/* ---------- page body ---------- */
.site-main { padding: 48px 0 64px; color: var(--xg-text); }
.page-intro { font-size: 17px; line-height: 1.7; color: var(--xg-muted); max-width: 820px; margin-bottom: 28px; }
.section-title { font-size: 24px; font-weight: 700; color: var(--xg-navy); margin: 36px 0 16px; }
.section-title:first-child { margin-top: 0; }

.xg-grid { display: grid; gap: 24px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.xg-grid.wide { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.xg-card { background: var(--surface); border: 1px solid var(--xg-border); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .2s, transform .2s; }
.xg-card:hover { box-shadow: 0 10px 24px -12px rgba(26, 54, 93, .35); transform: translateY(-2px); }
.xg-card .cover { aspect-ratio: 4 / 3; background: var(--xg-soft); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.xg-card .cover.portrait { aspect-ratio: 3 / 4; }
.xg-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.xg-card .cover.contain img { object-fit: contain; padding: 16px; }
.xg-card .cover .ph { font-size: 42px; color: var(--placeholder); }
.xg-card .cover:has(> .ph) { aspect-ratio: 16 / 7; }
.xg-card .body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.xg-card h3 { font-size: 18px; font-weight: 700; color: var(--xg-navy); margin: 0; line-height: 1.35; }
.xg-card h3 a { color: inherit; }
.xg-card .meta { font-size: 13px; color: var(--xg-muted); }
.xg-card p { font-size: 15px; line-height: 1.6; margin: 0; color: var(--xg-text); }
.xg-card .actions { margin-top: auto; padding-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }

.xg-btn { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 9px 18px; font-size: 14px; font-weight: 600; border: 1px solid var(--xg-blue); color: var(--xg-blue); background: var(--surface); text-decoration: none; cursor: pointer; }
.xg-btn:hover, .xg-btn:focus { background: var(--xg-fill); border-color: var(--xg-fill); color: #fff; text-decoration: none; }
.xg-btn.primary { background: var(--xg-fill); border-color: var(--xg-fill); color: #fff; }
.xg-btn.primary:hover { background: var(--navy-2); border-color: var(--navy-2); }
.xg-btn[disabled] { opacity: .6; cursor: not-allowed; }

.badge-pill { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; background: var(--xg-soft); color: var(--xg-navy); }
.badge-pill.ok { background: var(--xg-ok-bg); color: var(--xg-ok); }
.badge-pill.warn { background: var(--xg-warn-bg); color: var(--xg-warn); }
.badge-pill.bad { background: var(--xg-bad-bg); color: var(--xg-bad); }

.price { font-size: 18px; font-weight: 700; color: var(--xg-navy); }

.xg-panel { background: var(--xg-soft); border-radius: 12px; padding: 22px 24px; margin-bottom: 24px; }
.xg-panel h2, .xg-panel h3 { color: var(--xg-navy); font-weight: 700; }
.xg-panel.notice { background: var(--xg-notice-bg); border-left: 4px solid var(--xg-blue); }

.xg-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.xg-filters button, .xg-filters a { border: 1px solid var(--xg-border); background: var(--surface); color: var(--xg-text); border-radius: 999px; padding: 6px 14px; font-size: 14px; cursor: pointer; text-decoration: none; }
.xg-filters a:hover { border-color: var(--xg-blue); color: var(--xg-blue); text-decoration: none; }
.xg-filters button[aria-pressed="true"], .xg-filters a[aria-current="true"] { background: var(--xg-fill); border-color: var(--xg-fill); color: #fff; }

/* infinite scroll / pager (App\Libraries\Listing + public-site.js) */
.xg-pager { display: flex; justify-content: center; margin-top: 28px; }
.xg-pager-prev { margin-bottom: 18px; }
.xg-pager.is-loading [data-more] { pointer-events: none; opacity: .75; }
.xg-pager.is-loading [data-more]::before { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: xg-spin .8s linear infinite; }

/* Share bar (Site/_share.php) + event actions */
.xg-share { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 28px 0; padding: 14px 16px; border: 1px solid var(--xg-border); border-radius: 14px; background: var(--surface); }
.xg-share-label { font-weight: 700; color: var(--xg-navy); margin-right: 4px; }
.xg-share-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 40px; height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--xg-border); background: var(--surface); color: var(--xg-text); font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none !important; transition: transform .15s, background .15s, color .15s; }
.xg-share-btn:hover, .xg-share-btn:focus-visible { transform: translateY(-1px); color: #fff; }
.xg-share-btn.is-whatsapp:hover { background: #25d366; border-color: #25d366; }
.xg-share-btn.is-facebook:hover { background: #1877f2; border-color: #1877f2; }
.xg-share-btn.is-x:hover { background: #111; border-color: #111; }
.xg-share-btn.is-telegram:hover { background: #229ed9; border-color: #229ed9; }
.xg-share-btn.is-linkedin:hover { background: #0a66c2; border-color: #0a66c2; }
.xg-share-btn.is-email:hover, .xg-share-btn.is-copy:hover, .xg-share-btn.is-native:hover { background: var(--xg-fill); border-color: var(--xg-fill); }
.xg-share-btn.is-copy { font-size: 14px; }
.xg-share-btn.is-done { background: var(--xg-ok, #15803d); border-color: var(--xg-ok, #15803d); color: #fff; }
.xg-event-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--xg-border); }
.xg-event-actions-label { font-weight: 600; color: var(--xg-muted); font-size: 14px; margin-left: 4px; }
.xg-event-actions .xg-btn { padding: 7px 14px; }

/* Search box (Site/_search.php) */
.xg-search { position: relative; display: flex; gap: 8px; align-items: center; max-width: 640px; margin: 0 0 18px; }
.xg-search > .fa-search { position: absolute; left: 14px; color: var(--xg-muted); pointer-events: none; }
.xg-search input[type="search"] { flex: 1; min-width: 0; height: 44px; padding: 0 38px 0 40px; border: 1px solid var(--xg-border); border-radius: 999px; font-size: 15px; background: var(--input-bg); color: var(--xg-text); }
.xg-search input[type="search"]:focus { outline: none; border-color: var(--xg-blue); box-shadow: 0 0 0 3px rgba(43, 108, 176, .18); }
.xg-search input[type="search"]::-webkit-search-cancel-button { display: none; }
.xg-search .xg-search-clear { position: absolute; right: 108px; font-size: 22px; line-height: 1; color: var(--xg-muted); text-decoration: none; }
.xg-search .xg-btn { height: 44px; border-radius: 999px; padding: 0 20px; white-space: nowrap; }
.xg-search-summary { margin: -8px 0 16px; color: var(--xg-muted); font-size: 14px; }
.xg-search-section { margin-bottom: 36px; scroll-margin-top: 90px; }
@media (max-width: 480px) { .xg-search .xg-btn { padding: 0 14px; } .xg-search .xg-search-clear { right: 88px; } }
.xg-state { text-align: center; padding: 40px 16px; color: var(--xg-muted); grid-column: 1 / -1; }
.xg-spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--xg-border); border-top-color: var(--xg-blue); border-radius: 50%; vertical-align: -3px; animation: xg-spin .8s linear infinite; }
@keyframes xg-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .xg-spinner { animation: none; } .xg-card:hover { transform: none; } }

/* visible keyboard focus */
.xgrr-public a:focus-visible, .xgrr-public button:focus-visible, .xgrr-public input:focus-visible,
.xgrr-public select:focus-visible, .xgrr-public textarea:focus-visible { outline: 3px solid #ffbf47; outline-offset: 2px; }

/* ---------- forms ---------- */
.xg-form { background: var(--surface); border: 1px solid var(--xg-border); border-radius: 12px; padding: 24px; }
.xg-form .row > div { margin-bottom: 14px; }
.xg-form label { font-weight: 600; font-size: 14px; margin-bottom: 4px; display: block; }
.xg-form .form-control { border-radius: 8px; }
.xg-form .hint { font-size: 13px; color: var(--xg-muted); }
.xg-form .req { color: var(--xg-bad); }
.xg-alert { border-radius: 8px; padding: 12px 14px; margin-top: 12px; font-size: 14px; }
.xg-alert.ok { background: var(--xg-ok-bg); color: var(--xg-ok); }
.xg-alert.err { background: var(--xg-bad-bg); color: var(--xg-bad); }

/* ---------- article / event detail ---------- */
.article-cover { width: 100%; height: auto; aspect-ratio: 16 / 9; max-height: 460px; object-fit: cover; border-radius: 12px; margin-bottom: 24px; }
.article-meta { color: var(--xg-muted); font-size: 14px; margin-bottom: 18px; display: flex; gap: 16px; flex-wrap: wrap; }
.article-body { font-size: 17px; line-height: 1.8; max-width: 820px; }
.engagement { border-top: 1px solid var(--xg-border); margin-top: 36px; padding-top: 24px; max-width: 820px; }
.like-btn[aria-pressed="true"] { background: var(--xg-bad-bg); border-color: var(--xg-bad); color: var(--xg-bad); }
.comment { border-bottom: 1px solid var(--xg-border); padding: 14px 0; }
.comment .who { font-weight: 700; color: var(--xg-navy); }
.comment .when { font-size: 12px; color: var(--xg-muted); margin-left: 8px; }
.comment p { margin: 6px 0 0; white-space: pre-line; }

/* ---------- schedule table ---------- */
.xg-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 12px; overflow: hidden; }
.xg-table th, .xg-table td { padding: 12px 14px; border-bottom: 1px solid var(--xg-border); text-align: left; font-size: 15px; vertical-align: top; }
.xg-table th { background: var(--xg-soft); color: var(--xg-navy); }
@media (max-width: 640px) {
    .xg-table thead { display: none; }
    .xg-table tr { display: block; border-bottom: 2px solid var(--xg-border); }
    .xg-table td { display: block; border: 0; padding: 6px 14px; }
    .xg-table td::before { content: attr(data-label); display: block; font-size: 12px; color: var(--xg-muted); }
}

.video-frame { position: relative; aspect-ratio: 16 / 9; background: #000; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.board-photo { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
