/* ===== Public panel chart =====
   Colours and font come from admin → Site settings → Theme (printed as CSS variables in chart.php).
   These are only the fallbacks. */
:root {
    --c-page-bg: #000000;
    --c-head-bg: #0a0360;
    --c-head-border: #ff0000;
    --c-head-text: #ffffff;
    --c-latest-bg: #ffe600;
    --c-latest-border: #ff0000;
    --c-latest-title: #0000ff;
    --c-latest-number: #000000;
    --c-table-border: #7b3fe4;
    --c-table-bg: #ffffff;
    --c-table-head-bg: #ffffff;
    --c-line: #555555;
    --c-number: #000000;
    --c-red: #ff0000;
    --c-shadow: #f5c400;
    --c-button-bg: #ffffff;
    --c-button-border: #f5c400;
    --c-button-text: #ff0000;
    --chart-font: Georgia, "Times New Roman", serif;
    --fs: 1;
}

* { box-sizing: border-box; }
.chart-public {
    min-height: 100vh;
    margin: 0;
    background: var(--c-page-bg);
    color: var(--c-head-text);
    font-family: var(--chart-font);
}
.chart-public a { text-decoration: none; }
.chart-shell { width: 100%; padding: 4px 4px 24px; }

/* Title boxes */
.reference-title,
.reference-intro {
    margin: 0 0 4px;
    border: 3px solid var(--c-head-border);
    background: var(--c-head-bg);
    color: var(--c-head-text);
    text-align: center;
}
.reference-title { padding: 6px 8px; }
.reference-title h1 {
    margin: 0;
    font: italic 700 calc(clamp(20px, 3.4vw, 30px) * var(--fs))/1.25 var(--chart-font);
}
.reference-intro { padding: 6px 10px 7px; }
.reference-intro h2 {
    margin: 0 0 4px;
    font: italic 700 calc(clamp(15px, 2.4vw, 22px) * var(--fs))/1.2 var(--chart-font);
}
.reference-intro p {
    margin: 0;
    font: italic 700 calc(clamp(11px, 1.2vw, 15px) * var(--fs))/1.15 var(--chart-font);
}

/* Latest result bar */
.latest-result {
    position: relative;
    margin: 6px 6px 14px;
    padding: 8px 60px 10px;
    border: 3px solid var(--c-latest-border);
    outline: 2px solid var(--c-latest-bg);
    outline-offset: -7px;
    background: var(--c-latest-bg);
    color: var(--c-latest-number);
    text-align: center;
}
.latest-name {
    margin: 0;
    color: var(--c-latest-title);
    font: italic 900 calc(clamp(18px, 2.4vw, 25px) * var(--fs))/1.1 Arial, sans-serif;
    letter-spacing: .5px;
    text-transform: uppercase;
}
.latest-numbers {
    margin: 2px 0 4px;
    color: var(--c-latest-number);
    font: 900 calc(clamp(18px, 2.3vw, 24px) * var(--fs))/1.15 Arial, sans-serif;
    letter-spacing: .6px;
}
.latest-numbers b { font-weight: 900; }
.latest-numbers.no-result { font-size: calc(16px * var(--fs)); }
.live-badge {
    position: absolute;
    top: 10px;
    right: 14px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #000;
    color: #fff;
    font: 700 9px/1.2 var(--chart-font);
}
.live-badge i { width: 7px; height: 7px; border-radius: 50%; background: #ff2d2d; box-shadow: 0 0 5px #ff2d2d; }
.refresh-button {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 6px;
    background: #a80000;
    color: #fff;
    font: 13px/1.3 Arial, sans-serif;
}
.refresh-button:hover { background: #7c0000; }
.demo-warning {
    margin: 6px;
    padding: 7px 10px;
    border: 2px solid #ffbd23;
    background: #fff3bd;
    color: #7d2600;
    font: 800 12px/1.3 Arial, sans-serif;
    text-align: center;
}

/* Go to bottom */
.chart-controls { display: flex; justify-content: center; margin: 0 0 6px; }
.bottom-button {
    display: inline-block;
    padding: 6px 6px;
    border: 3px solid var(--c-button-border);
    border-radius: 3px;
    background: var(--c-button-bg);
    color: var(--c-button-text);
    font: italic 700 calc(clamp(14px, 1.6vw, 18px) * var(--fs))/1 var(--chart-font);
}
.bottom-button:hover { filter: brightness(.95); }

/* ===== Table ===== (matches reference: horizontal row lines, digits at cell edges, big jodi in centre) */
.weekly-chart {
    width: min(100%, 820px);
    margin: 0 auto;
    border: 4px solid var(--c-table-border);
    background: var(--c-table-bg);
    color: var(--c-number);
}
.weekly-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: var(--c-table-bg);
    font-family: var(--chart-font);
}
.weekly-table thead th {
    height: calc(clamp(26px, 7vw, 32px) * var(--fs));
    padding: 2px 0;
    border-bottom: 1px solid var(--c-line);
    background: linear-gradient(var(--c-table-head-bg), #e2e2e2);
    color: var(--c-number);
    font: 700 calc(clamp(12px, 3.6vw, 15px) * var(--fs))/1 var(--chart-font);
    text-align: center;
}
.weekly-table .date-heading { width: 12.5%; }
.weekly-table tbody tr { border-bottom: 1px solid var(--c-line); }
.weekly-table tbody th.week-date {
    padding: 2px 1px;
    color: var(--c-number);
    font: italic 700 calc(clamp(7.5px, 2.2vw, 13px) * var(--fs))/1.05 var(--chart-font);
    text-align: center;
    text-shadow: 1px 1px 0 var(--c-shadow);
}
.week-date span { display: block; }
.weekly-table td {
    height: calc(clamp(42px, 11vw, 52px) * var(--fs));
    padding: 1px 0;
    overflow: hidden;
    text-align: center;
    vertical-align: middle;
}
/* Cell: open digits on the left edge, jodi in the centre, close digits on the right edge */
.day-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 clamp(1px, .5vw, 4px);
    color: var(--c-number);
}
.day-result:hover strong { text-decoration: underline; }
.panna-digits {
    flex: 0 0 auto;
    white-space: pre-line;
    color: var(--c-number);
    font: italic 700 calc(clamp(7px, 2vw, 11px) * var(--fs))/1.05 var(--chart-font);
    text-align: center;
    text-shadow: 1px 1px 0 var(--c-shadow);
}
.day-result strong {
    flex: 0 0 auto;
    color: var(--c-number);
    font: italic 700 calc(clamp(17px, 5.8vw, 25px) * var(--fs))/1 var(--chart-font);
    letter-spacing: -.5px;
    text-shadow: 1px 1px 0 var(--c-shadow);
}
.day-result.is-red strong,
.day-result.is-red .panna-digits { color: var(--c-red); }
.unpublished {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(1px, .5vw, 4px);
    color: var(--c-red);
    font: italic 700 calc(clamp(12px, 3.6vw, 18px) * var(--fs))/1 var(--chart-font);
}
.unpublished small { font-size: calc(clamp(7px, 2vw, 11px) * var(--fs)); line-height: 1.05; }

.chart-empty { margin: 0; padding: 12px; color: var(--c-number); font: 12px Arial, sans-serif; text-align: center; }
.chart-end {
    padding: 6px;
    border-top: 1px solid var(--c-line);
    color: var(--c-number);
    font: italic 700 calc(12px * var(--fs)) var(--chart-font);
    text-align: center;
}
.chart-disclaimer { margin: 12px 8px 4px; color: #c8c8c8; font: calc(11px * var(--fs))/1.45 Arial, sans-serif; text-align: center; }
.chart-footer { display: flex; justify-content: space-between; max-width: 820px; margin: 0 auto; padding: 8px 4px; color: #aaa; font: 11px Arial, sans-serif; }
.chart-footer a { color: #d7d0ff; }

@media (max-width: 600px) {
    .chart-shell { padding: 3px 3px 20px; }
    .reference-title, .reference-intro { border-width: 2px; }
    .latest-result { margin: 5px 3px 10px; padding: 6px 44px 8px; }
    .live-badge { top: 7px; right: 6px; padding: 2px 5px; font-size: 8px; }
    .weekly-chart { border-width: 3px; }
    .weekly-table .date-heading { width: 12%; }
}

/* Top/bottom navigation + bottom live box */

.chart-controls-bottom { margin: 10px 0 0; }
.bottom-live .latest-result { margin-top: 10px; }
.chart-footer { justify-content: center; }

/* Keep chart colours when printing or saving as PDF */
@media print {
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}

/* Same font style, but every digit the same height and width (Georgia's default
   "old-style" numbers make 0/1/2 look small and 3/4/5/7/9 drop below the line). */
.chart-public,
.chart-public * {
    font-variant-numeric: lining-nums tabular-nums;
    font-feature-settings: "lnum" 1, "tnum" 1;
}

/* One jodi/number style everywhere: same font, weight, slant and shadow
   in the chart cells and in the top/bottom live result boxes. */
.day-result strong,
.day-result.is-red strong {
    font-family: var(--chart-font);
    font-style: italic;
    font-weight: 700;
    letter-spacing: 0;
}
.latest-numbers {
    font: italic 700 calc(clamp(22px, 6vw, 30px) * var(--fs))/1.15 var(--chart-font);
    letter-spacing: 0;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, .18);
}
.latest-numbers b { padding: 0 3px; }

/* SEO helpers */
.latest-date { margin: 0 0 5px; color: #333; font: italic 700 calc(12px * var(--fs))/1.2 var(--chart-font); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Final jodi size: a little smaller, identical in every cell (same font, weight, slant,
   equal-height digits). Rule kept last so it wins over earlier sizes. */
.weekly-table .day-result strong,
.weekly-table .day-result.is-red strong {
    font: italic 700 calc(clamp(15px, 5vw, 22px) * var(--fs))/1 var(--chart-font);
    font-variant-numeric: lining-nums tabular-nums;
    font-feature-settings: "lnum" 1, "tnum" 1;
    letter-spacing: 0;
}

/* Live update flash when a new result arrives */
@keyframes live-flash { 0%, 100% { box-shadow: none; } 20%, 60% { box-shadow: 0 0 0 4px #ff0000, 0 0 18px #ffe600; } }
.latest-result.just-updated { animation: live-flash 1.4s ease-in-out 2; }
@media (prefers-reduced-motion: reduce) { .latest-result.just-updated { animation: none; outline: 3px solid #ff0000; } }
