/*
Theme Name: LIVE4D
Theme URI: https://live4d.io
Author: BizJaya
Author URI: https://bizjaya.com
Description: Purpose-built theme for LIVE4D — 4D lottery results, ported from the original React/Tailwind design. Requires the LIVE4D Core plugin for result data.
Version: 0.1.0
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 8.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: live4d
*/

/* ============================================================ reset + base */

*, *::before, *::after { box-sizing: border-box; }

:root {
    --l4d-purple: #7c3aed;
    --l4d-indigo: #4f46e5;
    --l4d-slate: #1e293b;
    --l4d-slate-2: #334155;
    --l4d-yellow: #facc15;
    --l4d-bg: #f9fafb;
    --l4d-border: #e5e7eb;
    --l4d-text: #111827;
    --l4d-muted: #6b7280;
    --l4d-radius: 8px;
}

body {
    margin: 0;
    background: var(--l4d-bg);
    color: var(--l4d-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }
a { color: var(--l4d-purple); }

.l4d-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 16px;
}

.screen-reader-text {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ================================================================= header */

.l4d-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--l4d-border);
}

.l4d-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0;
}

.l4d-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-weight: 700;
    font-size: 20px;
    flex-shrink: 0;
}

.l4d-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border-radius: var(--l4d-radius);
    background: linear-gradient(135deg, #10b981, #0d9488);
    color: #fff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, .3);
}

.l4d-brand-text {
    background: linear-gradient(90deg, var(--l4d-purple), var(--l4d-indigo));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.l4d-nav ul {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.l4d-nav a {
    display: block;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
}

.l4d-nav a:hover,
.l4d-nav .current-menu-item > a {
    color: var(--l4d-purple);
    background: #f5f3ff;
}

.l4d-lang {
    display: flex;
    align-items: center;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.l4d-lang a {
    display: block;
    padding: 4px 8px;
    border: 1px solid var(--l4d-border);
    border-radius: 6px;
    font-size: 12px;
    text-transform: uppercase;
    text-decoration: none;
    color: #374151;
    background: #fff;
}

.l4d-lang .current-lang a { border-color: var(--l4d-purple); color: var(--l4d-purple); }

.l4d-menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--l4d-border);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
}

/* ================================================================= layout */

.l4d-main { padding: 32px 0 48px; }

.l4d-page-head { text-align: center; margin-bottom: 40px; }
.l4d-page-head h1 { font-size: 36px; font-weight: 700; margin: 0 0 12px; }
.l4d-page-head p { color: var(--l4d-muted); margin: 0 auto; max-width: 60ch; }

.l4d-section-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 16px;
}

/* ========================================================= region + search */

.l4d-regions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.l4d-region {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    padding: 12px 20px;
    border: 1px solid var(--l4d-border);
    border-radius: var(--l4d-radius);
    background: #fff;
    color: #374151;
    font-size: 15px;
    text-decoration: none;
    transition: border-color .15s, box-shadow .15s;
}

.l4d-region:hover { border-color: #c4b5fd; }

.l4d-region.is-active {
    background: linear-gradient(90deg, var(--l4d-purple), var(--l4d-indigo));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 12px rgba(124, 58, 237, .3);
}

.l4d-region-code {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    opacity: .7;
}

.l4d-search {
    display: flex;
    gap: 10px;
    margin-bottom: 28px;
}

.l4d-search input[type="search"] {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
    border: 1px solid var(--l4d-border);
    border-radius: var(--l4d-radius);
    background: #fff;
    font-size: 15px;
}

.l4d-search input[type="search"]:focus {
    outline: 2px solid var(--l4d-purple);
    outline-offset: -1px;
}

.l4d-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: 0;
    border-radius: var(--l4d-radius);
    background: linear-gradient(90deg, var(--l4d-purple), var(--l4d-indigo));
    color: #fff;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.l4d-btn:hover { filter: brightness(1.08); }

.l4d-btn-ghost {
    background: #fff;
    color: #374151;
    border: 1px solid var(--l4d-border);
}

/* ================================================================== cards */

.l4d-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
}

.l4d-card {
    background: #fff;
    border: 1px solid var(--l4d-border);
    border-radius: var(--l4d-radius);
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .12);
}

.l4d-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--l4d-slate);
    color: #fff;
}

.l4d-card-title {
    flex: 1;
    min-width: 0;
}

.l4d-card-title h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.l4d-card-date {
    margin: 2px 0 0;
    font-size: 14px;
    color: #cbd5e1;
    line-height: 1.25;
}

.l4d-card-logo {
    flex-shrink: 0;
    width: 48px; height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 6px;
    background: rgba(255, 255, 255, .1);
}

.l4d-card-logo img { max-height: 100%; object-fit: contain; }

.l4d-card-body { padding: 16px; }

/* top three prizes */

.l4d-top {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.l4d-top-label {
    padding: 8px 4px;
    background: var(--l4d-yellow);
    color: #000;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    border-radius: 4px 4px 0 0;
}

.l4d-top-value {
    padding: 12px 4px;
    background: #f9fafb;
    border: 1px solid var(--l4d-border);
    border-top: 0;
    border-radius: 0 0 4px 4px;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    letter-spacing: .02em;
}

/* special / consolation blocks */

.l4d-block { margin-bottom: 16px; }
.l4d-block:last-child { margin-bottom: 0; }

.l4d-block-head {
    padding: 8px 12px;
    background: var(--l4d-slate);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    letter-spacing: .04em;
    border-radius: 4px 4px 0 0;
}

.l4d-block-body {
    background: #f9fafb;
    border: 1px solid var(--l4d-border);
    border-top: 0;
    border-radius: 0 0 4px 4px;
    display: grid;
    gap: 1px;
    padding: 4px;
    background-color: var(--l4d-border);
}

.l4d-block-body.cols-5 { grid-template-columns: repeat(5, 1fr); }
.l4d-block-body.cols-4 { grid-template-columns: repeat(4, 1fr); }

.l4d-num {
    background: #fff;
    padding: 8px 2px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .02em;
}

.l4d-num.is-empty { color: #d1d5db; }

.l4d-jackpot {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--l4d-border);
    font-size: 13px;
}

.l4d-jackpot span { color: var(--l4d-muted); }
.l4d-jackpot strong { color: var(--l4d-text); }

.l4d-empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--l4d-muted);
    background: #fff;
    border: 1px dashed var(--l4d-border);
    border-radius: var(--l4d-radius);
}

/* ========================================================= generic content */

.l4d-content {
    background: #fff;
    border: 1px solid var(--l4d-border);
    border-radius: var(--l4d-radius);
    padding: 32px;
}

.l4d-content h2 { font-size: 24px; margin-top: 32px; }
.l4d-content h2:first-child { margin-top: 0; }
.l4d-content img { border-radius: var(--l4d-radius); }

.l4d-cards-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.l4d-tile {
    background: #fff;
    border: 1px solid var(--l4d-border);
    border-radius: var(--l4d-radius);
    padding: 28px 20px;
    text-align: center;
}

.l4d-tile-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--l4d-purple);
    margin-bottom: 8px;
}

.l4d-tile-value {
    display: block;
    font-size: 32px;
    font-weight: 700;
}

.l4d-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.l4d-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    padding: 10px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 16px;
}

.l4d-chip.is-hot { background: #fee2e2; color: #b91c1c; }
.l4d-chip.is-cold { background: #dbeafe; color: #1d4ed8; }

.l4d-note {
    margin-top: 24px;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--l4d-border);
    border-radius: var(--l4d-radius);
    color: var(--l4d-muted);
    font-size: 14px;
    text-align: center;
}

/* ============================================================ past results */

.l4d-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 24px;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--l4d-border);
    border-radius: var(--l4d-radius);
}

.l4d-filters label { display: block; font-size: 13px; color: var(--l4d-muted); }

.l4d-filters select,
.l4d-filters input {
    padding: 9px 12px;
    border: 1px solid var(--l4d-border);
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
}

.l4d-pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 32px;
}

.l4d-pagination .page-numbers {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid var(--l4d-border);
    border-radius: 6px;
    background: #fff;
    text-decoration: none;
    color: #374151;
}

.l4d-pagination .page-numbers.current {
    background: var(--l4d-purple);
    border-color: var(--l4d-purple);
    color: #fff;
}

/* ================================================================= footer */

.l4d-footer {
    margin-top: 48px;
    padding: 40px 0 24px;
    background: var(--l4d-slate);
    color: #cbd5e1;
    font-size: 14px;
}

.l4d-footer-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 32px;
    margin-bottom: 32px;
}

.l4d-footer h4 { color: #fff; font-size: 15px; margin: 0 0 12px; }
.l4d-footer ul { list-style: none; margin: 0; padding: 0; }
.l4d-footer li { margin-bottom: 8px; }
.l4d-footer a { color: #cbd5e1; text-decoration: none; }
.l4d-footer a:hover { color: #fff; }

.l4d-footer-bottom {
    padding-top: 20px;
    border-top: 1px solid var(--l4d-slate-2);
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    color: #94a3b8;
    font-size: 13px;
}

.l4d-disclaimer {
    margin-top: 12px;
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.6;
}

/* ============================================================= responsive */

@media (max-width: 1024px) {
    .l4d-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .l4d-footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 782px) {
    .l4d-menu-toggle { display: inline-block; }
    .l4d-nav { display: none; width: 100%; }
    .l4d-nav.is-open { display: block; }
    .l4d-nav ul { flex-direction: column; align-items: stretch; }
    .l4d-header-inner { flex-wrap: wrap; }
    .l4d-grid,
    .l4d-cards-3 { grid-template-columns: minmax(0, 1fr); }
    .l4d-page-head h1 { font-size: 28px; }
    .l4d-content { padding: 20px; }
    .l4d-search { flex-direction: column; }
}
