/*
Theme Name: COPDEM Monitor
Theme URI: https://electionmonitor.copdem.org
Description: Companion theme for the COPDEM Election Monitor plugin. Mobile-first and app-like for polling-unit agents (bottom tab bar, offline indicator, works with "PWA for WP"), with a public homepage featuring an election countdown, live coverage figures and links to live results and incident reports. Light for slow networks: system fonts, no web fonts, no theme jQuery.
Author: COPDEM
Version: 1.2.0
Requires at least: 6.2
Requires PHP: 7.4
License: GPL-2.0-or-later
Text Domain: copdem-monitor
*/

:root {
    --primary: #0b6b35;
    --primary-dark: #085028;
    --primary-light: #2e8150;
    --primary-tint: #e7f0eb;
    --accent: #c8102e;
    --accent-dark: #a40d26;
    --accent-tint: #faeaec;
    --amber: #b7791f;
    --red: var(--accent);
    --ink: #1c2420;
    --muted: #5f6b64;
    --line: #e1e7e3;
    --bg: #f4f7f5;
    --card: #ffffff;
    --radius: 12px;
    --max: 1140px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --tabbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.6; color: var(--ink); background: var(--bg); }
img, video { max-width: 100%; height: auto; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-dark); }
:focus-visible { outline: 3px solid #f2b84b; outline-offset: 2px; }
h1, h2, h3, h4 { color: var(--primary); line-height: 1.25; font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 4.5vw, 2.4rem); margin: .3em 0 .5em; }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); margin: 1.4em 0 .6em; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 16px; }
.screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(1px,1px,1px,1px); white-space: nowrap; }
.skip-link:focus { position: fixed; top: 8px; left: 8px; z-index: 1000; width: auto; height: auto; clip: auto; background: #fff; color: var(--primary); padding: .6em 1em; border: 2px solid var(--primary); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45em; background: var(--primary); color: #fff; text-decoration: none; font-weight: 700; padding: .75em 1.3em; border-radius: 10px; border: 2px solid var(--primary); line-height: 1.2; font-size: 1rem; cursor: pointer; }
.btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-accent { background: var(--accent); border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-light { background: #fff; color: var(--primary); border-color: #fff; }
.btn-light:hover { background: var(--primary-tint); color: var(--primary); border-color: var(--primary-tint); }
.btn-outline { background: transparent; color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.6); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.12); border-color: #fff; color: #fff; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-sm { padding: .5em .9em; font-size: .9rem; border-radius: 8px; }

/* ---------- Status strips ---------- */
.announce { background: #fff6e0; color: #6b4a00; font-size: .92rem; border-bottom: 1px solid #f3dfae; }
.announce .wrap { padding-top: .55em; padding-bottom: .55em; }
.announce a { color: #6b4a00; font-weight: 700; }
.offline-bar { display: none; background: #7c2d12; color: #fff; font-size: .9rem; text-align: center; padding: .5em 16px; position: sticky; top: 0; z-index: 70; }
.is-offline .offline-bar { display: block; }

/* ---------- Header ---------- */
.site-header { background: var(--primary); color: #fff; position: sticky; top: 0; z-index: 60; box-shadow: 0 2px 10px rgba(0,0,0,.2); border-bottom: 3px solid var(--accent); }
.is-offline .site-header { top: 2.2em; }
.site-header .wrap { display: flex; align-items: center; gap: 1em; min-height: 64px; }
.brand { display: flex; align-items: center; gap: .6em; text-decoration: none; color: #fff; margin-right: auto; min-width: 0; }
.brand:hover { color: #fff; }
.brand-mark { flex: none; width: 48px; height: 48px; display: block; }
.brand-mark img { width: 48px; height: 48px; display: block; border-radius: 50%; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
@media (max-width: 600px) { .brand-mark, .brand-mark img { width: 40px; height: 40px; } }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 800; font-size: 1.05rem; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-tag { font-size: .75rem; color: rgba(255,255,255,.78); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.primary-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: .15em; }
.primary-nav a { display: block; color: rgba(255,255,255,.88); text-decoration: none; font-weight: 600; font-size: .95rem; padding: .45em .75em; border-radius: 8px; }
.primary-nav a:hover, .primary-nav .current-menu-item > a, .primary-nav .current_page_item > a { background: rgba(255,255,255,.12); color: #fff; }
.primary-nav ul ul { display: none; }
.header-actions { display: flex; gap: .5em; align-items: center; flex: none; }
.header-user { font-size: .85rem; color: rgba(255,255,255,.78); max-width: 14em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-toggle { display: none; background: transparent; color: #fff; border: 2px solid rgba(255,255,255,.5); border-radius: 8px; padding: .35em .7em; font: inherit; font-weight: 700; cursor: pointer; }

@media (max-width: 900px) {
    .primary-nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--primary-dark); padding: .5em 16px 1em; }
    .primary-nav.is-open { display: block; }
    .primary-nav ul { flex-direction: column; }
    .primary-nav ul ul { display: block; padding-left: 1em; }
    .nav-toggle { display: inline-block; }
    .header-actions .btn, .header-user { display: none; }
}

/* ---------- Bottom tab bar (phones) ---------- */
.tabbar { display: none; }
@media (max-width: 768px) {
    body.has-tabbar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
    .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(15,23,42,.08); padding-bottom: env(safe-area-inset-bottom); }
    .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--tabbar-h); color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 700; letter-spacing: .01em; }
    .tabbar a svg { width: 24px; height: 24px; }
    .tabbar a[aria-current="page"] { color: var(--primary); }
    .tabbar a[aria-current="page"] svg { stroke-width: 2.4; }
    .tabbar .tab-cta { color: var(--accent); }
}

/* ---------- Page layout ---------- */
.site-main { min-height: 60vh; }
.page-head { background: #fff; border-bottom: 1px solid var(--line); padding: 1.4em 0 .6em; }
.page-head h1 { margin: .1em 0 .3em; }
.page-head .lede { color: var(--muted); margin: 0 0 .6em; max-width: 46em; }
.live-pill { display: inline-flex; align-items: center; gap: .4em; background: var(--accent-tint); color: var(--red); font-weight: 800; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; padding: .25em .7em; border-radius: 999px; }
.live-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(185,28,28,.5); } 70% { box-shadow: 0 0 0 8px rgba(185,28,28,0); } 100% { box-shadow: 0 0 0 0 rgba(185,28,28,0); } }
@media (prefers-reduced-motion: reduce) { .live-pill::before { animation: none; } }
.content { padding: 1.5em 0 3em; }
.content-narrow { max-width: 780px; }
.entry-content > *:first-child { margin-top: 0; }
.entry-content .wp-block-image img { border-radius: 10px; }
.prose-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4em 1.6em; }

/* App pages ([cem_register], [cem_login], [cem_agent_dashboard]) */
.layout-app .page-head { display: none; }
.layout-app .content { padding-top: .5em; }
.app-crumb { display: flex; align-items: center; justify-content: space-between; gap: 1em; padding: 1em 0 0; font-size: .9rem; color: var(--muted); }
.app-crumb a { font-weight: 600; }

/* ---------- Plugin integration (COPDEM Election Monitor) ---------- */
.cem-card { font-family: inherit !important; border-radius: var(--radius) !important; box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 8px 24px rgba(15,23,42,.05) !important; }
.cem-card h2, .cem-card h3, .cem-card legend { color: var(--primary) !important; }
.cem-btn-primary { background: var(--primary) !important; border-radius: 10px !important; }
.cem-btn-primary:hover { background: var(--primary-dark) !important; }
.cem-card input:focus, .cem-card select:focus, .cem-card textarea:focus { border-color: var(--primary) !important; }
.cem-tab-link.active { color: var(--primary) !important; border-bottom-color: var(--primary) !important; }
@media (max-width: 600px) {
    .cem-card { margin: .75rem auto 1.25rem !important; padding: 1.15rem 1rem !important; }
    .cem-tab-link.active { background: var(--primary-tint) !important; border-color: var(--primary) !important; }
    .cem-card input[type=text], .cem-card input[type=email], .cem-card input[type=tel], .cem-card input[type=password],
    .cem-card input[type=number], .cem-card select, .cem-card textarea { font-size: 16px !important; } /* stops iOS zooming into fields */
}
.layout-wide .cem-public-results, .layout-wide .cem-public-reports { max-width: none !important; }
.cem-card input:focus, .cem-card select:focus, .cem-card textarea:focus { box-shadow: 0 0 0 3px var(--primary-tint) !important; }
.cem-btn-secondary { color: var(--primary) !important; background: var(--primary-tint) !important; }
.cem-results-level h4.cem-level-heading, .cem-report-category { color: var(--primary) !important; }
.cem-status-submitted { background: var(--primary-tint) !important; color: var(--primary) !important; }
.cem-inbox-item-unread { border-left-color: var(--accent) !important; background: var(--accent-tint) !important; }
.cem-chart-bar { background: linear-gradient(90deg, var(--primary), var(--primary-light)) !important; }
.cem-share-facebook:hover, .cem-share-telegram:hover { background: var(--primary-tint) !important; border-color: var(--primary) !important; }

/* ---------- Front page ---------- */
.hero { background: radial-gradient(120% 140% at 100% 0%, var(--primary-light) 0%, var(--primary) 45%, var(--primary-dark) 100%); color: #fff; padding: 2.6em 0 3.2em; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: linear-gradient(90deg, var(--primary-light) 0 33.3%, #fff 33.3% 66.6%, var(--accent) 66.6%); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 2.4em; align-items: center; }
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; gap: 1.6em; } }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .75rem; font-weight: 800; color: #ffd0d6; margin: 0; }
.hero h1 { color: #fff; font-size: clamp(1.9rem, 5.5vw, 3rem); margin: .25em 0 .35em; }
.hero p.lead { font-size: 1.08rem; color: rgba(255,255,255,.88); max-width: 36em; margin: 0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .7em; margin-top: 1.5em; }
.countdown-card { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2); border-radius: 16px; padding: 1.3em 1.4em; }
.countdown-card .label { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.78); font-weight: 700; margin: 0; }
.countdown-card .election { font-size: 1.05rem; font-weight: 700; margin: .25em 0 .9em; }
.countdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5em; }
.countdown div { background: rgba(0,0,0,.22); border-bottom: 3px solid var(--accent); border-radius: 10px; padding: .6em .2em; text-align: center; }
.countdown b { display: block; font-size: clamp(1.5rem, 5vw, 2.1rem); line-height: 1.1; font-variant-numeric: tabular-nums; }
.countdown span { font-size: .72rem; color: rgba(255,255,255,.78); text-transform: uppercase; letter-spacing: .08em; }
.countdown-card .date { font-size: .85rem; color: rgba(255,255,255,.78); margin: .9em 0 0; }
.countdown-card.is-live .countdown { display: none; }

.stats { margin-top: -1.6em; position: relative; z-index: 2; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); background: #fff; border-radius: 16px; box-shadow: 0 10px 30px rgba(15,23,42,.1); overflow: hidden; }
.stat { padding: 1.1em 1.2em; text-align: center; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat b { display: block; font-size: clamp(1.4rem, 4.5vw, 2.1rem); color: var(--primary); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .85rem; color: var(--muted); }
@media (max-width: 520px) { .stat { padding: .9em .4em; } .stat span { font-size: .72rem; } }

.section { padding: 2.6em 0; }
.section-white { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .5em 1em; }
.section-head h2 { margin: 0 0 .7em; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1em; counter-reset: step; }
.steps li { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2em 1.2em 1em; position: relative; counter-increment: step; }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; margin-bottom: .7em; }
.steps li:nth-child(even)::before { background: var(--accent); }
.steps strong { display: block; color: var(--primary); font-size: 1.05rem; margin-bottom: .25em; }
.steps span { color: var(--muted); font-size: .93rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1em; }
.tile { display: flex; gap: 1em; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2em; text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--primary); transform: translateY(-2px); color: var(--ink); }
.tile-icon { flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-tint); color: var(--primary); }
.tile-icon svg { width: 24px; height: 24px; }
.tile.tile-red .tile-icon { background: var(--accent-tint); color: var(--accent); }
.tile.tile-green .tile-icon { background: var(--primary-tint); color: var(--primary); }
.tile strong { display: block; color: var(--primary); font-size: 1.05rem; }
.tile span { color: var(--muted); font-size: .92rem; }
.support { background: var(--primary); color: rgba(255,255,255,.88); border-left: 6px solid var(--accent); border-radius: 16px; padding: 1.6em 1.8em; display: grid; grid-template-columns: 1fr auto; gap: 1.2em; align-items: center; }
.support h2 { color: #fff; margin: 0 0 .3em; }
.support p { margin: 0; }
.support-actions { display: flex; flex-wrap: wrap; gap: .6em; }
@media (max-width: 720px) { .support { grid-template-columns: 1fr; padding: 1.3em; } }

/* ---------- Posts ---------- */
.post-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1em; }
.post-list li { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1em 1.3em; }
.post-list h2 { font-size: 1.2rem; margin: .1em 0 .3em; }
.post-list h2 a { text-decoration: none; }
.meta { color: var(--muted); font-size: .88rem; }
.pagination .nav-links { display: flex; flex-wrap: wrap; gap: .35em; margin: 1.5em 0; }
.pagination .page-numbers { padding: .4em .8em; background: #fff; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Footer ---------- */
.site-footer { background: var(--primary-dark); color: rgba(255,255,255,.72); border-top: 4px solid var(--accent); font-size: .92rem; }
.site-footer a { color: #fff; }
.footer-top { display: grid; grid-template-columns: minmax(0, 1.5fr) repeat(2, minmax(0, 1fr)); gap: 2em; padding: 2.4em 16px 1.6em; }
@media (max-width: 760px) { .footer-top { grid-template-columns: 1fr; gap: 1.4em; } }
.site-footer h2 { color: #fff; font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; margin: 0 0 .7em; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: .35em 0; }
.site-footer li a { color: rgba(255,255,255,.72); text-decoration: none; }
.site-footer li a:hover { color: #fff; text-decoration: underline; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.1); padding: 1em 16px 1.3em; font-size: .82rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5em; }

@media print {
    .site-header, .tabbar, .site-footer, .announce, .offline-bar { display: none !important; }
    body { background: #fff; padding: 0 !important; }
}
