/* ==========================================================================
   1. Reset
   ========================================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ==========================================================================
   2. Design tokens
   ========================================================================== */

:root {
    --color-primary: #0176fe;
    --color-text: #1a1a1a;
    --color-border: #e0e0e0;
    --color-bg: #f5f7fa;
    --color-bg-card: #ffffff;
    --color-bg-hover: #e8eef5;
    --color-dst-active: #2e7d32;
    --color-dst-inactive: #a0522d;
    --color-dst-change: #8a8a2b;
    --color-countdown: #0078d4;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 3px 10px rgba(0, 0, 0, 0.08);
    --radius: 6px;
    --transition: 0.18s ease;
    /* existing… */
    --color-bg-muted: #f0f0f0;
    --color-border-muted: #e5e5e5;
    --color-btn-border: #b0b0b0;
    --color-btn-text: #707070;
    --color-status-ok: #2e7d32;
    --color-status-incident: #c62828;
    --color-status-yellow: #FFFF00;
    --color-meter-optimum: #2e7d32;
    --color-meter-suboptimum: #f9a825;
    --color-meter-critical: #c62828;
    --radius-sm: 4px;
    --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.1);
    --space-xs: 4px;
    --space-sm: 8px;
    --info-btn-size: 20px;
}

/* ==========================================================================
   3. Global
   ========================================================================== */

html {
    font-size: 18px;
}

body {
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.4;
    min-height: 100vh;
}

/* ==========================================================================
   4. Layout — grid: 4 columns
   ========================================================================== */

.grid-container {
    display: grid;
    grid-template-columns: minmax(250px, 0.9fr) repeat(3, 1fr);
    gap: var(--space-sm);
    padding: 8px;
    max-width: 1920px;
    margin: 0 auto;
    min-height: 100vh;
}

/* ==========================================================================
   5. HQ column
   ========================================================================== */

.column-heading img {
    height: 42px;
    width: auto;
}

#hq-clock {
    width: 20vmin;
    height: 20vmin;
}

.hq-date {
    font-weight: bold;
    font-size: inherit;
    letter-spacing: normal;
}

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

/* ==========================================================================
   6. other columns
   ========================================================================== */

.column {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    border: none;
    padding: 0;
    margin: 0;
    min-width: 0;
    overflow: visible;
    align-items: center;
    text-align: center;
}

.column-heading {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    padding: 7px 0;
    margin: 0 0 4px;
    border-radius: 0;
    min-height: 53px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
    line-height: 1.3;
}

/* ==========================================================================
   7. City cards (nested fieldsets)
   ========================================================================== */

.column>fieldset {
    width: 100%;
    text-align: center;
    background-color: var(--color-bg-muted);
    border: 1px solid var(--color-border-muted);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-card);
}

.column>fieldset:hover {
    background: var(--color-bg-hover);
    box-shadow: var(--shadow-md);
}

.column>fieldset>legend {
    width: 100%;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.3;
}

.column>fieldset>time {
    display: inline;
}

.column>fieldset.dst-active>legend {
    color: var(--color-dst-active);
}

/* ==========================================================================
   8. Typography — time display
   ========================================================================== */

time {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
}

/* ==========================================================================
   9. Info button
   ========================================================================== */

.column-heading button,
.column>fieldset>legend button {
    width: var(--info-btn-size);
    height: var(--info-btn-size);
    min-width: var(--info-btn-size);
    min-height: var(--info-btn-size);
    flex-shrink: 0;
    border-radius: 50%;
    border: 1.5px solid var(--color-btn-border);
    background: transparent;
    color: var(--color-btn-text);
    font-size: 0.75rem;
    /* fixed, not em → same size in both contexts */
    font-weight: 700;
    padding: 0;
    line-height: 1;
    display: inline-flex;
    /* centres the “i” reliably */
    align-items: center;
    justify-content: center;
    margin-left: 0.35em;
    vertical-align: middle;
    /* better than baseline + top offset */
    position: static;
    /* drop the relative + top hack */
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.column-heading button:hover,
.column-heading button:focus-visible,
.column>fieldset>legend button:hover,
.column>fieldset>legend button:focus-visible {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* ==========================================================================
   10. Info dialog
   ========================================================================== */

.info-dialog {
    inset: 50% auto auto 50%;
    translate: -50% -50%;
    margin: 0;
}

.info-dialog::backdrop {
    background: transparent;
}

/* ==========================================================================
   11. DST details (expandable status under city time)
   ========================================================================== */

.column>fieldset details {
    width: 100%;
}

.column>fieldset details summary time {
    display: inline;
}

.day-offset {
    margin-left: 0.35em;
    font-size: 0.8em;
    font-weight: 600;
    white-space: nowrap;
}

/* DST panel shown when details is open */
.column>fieldset details[open]> :not(summary) {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    line-height: 1.45;
}

.au1Countdown,
.au2Countdown,
.caCountdown,
.ukCountdown,
.nzCountdown {
    display: block;
    color: var(--color-countdown);
    font-weight: 500;
    margin-top: 2px;
}

.column meter {
    vertical-align: middle;
    width: 6em;
    height: 0.7em;
}

/* base track */
.column meter::-webkit-meter-bar {
    background: var(--color-bg-muted);
    border: none;
    border-radius: var(--radius-sm);
}

.column meter::-moz-meter-bar {
    background: var(--color-bg-muted);
    border-radius: var(--radius-sm);
}

/* force bar color by class (reliable across browsers) */
.column meter.meter-ok::-webkit-meter-optimum-value,
.column meter.meter-ok::-webkit-meter-suboptimum-value,
.column meter.meter-ok::-webkit-meter-even-less-good-value {
    background: var(--color-meter-optimum);
    border-radius: var(--radius-sm);
}

.column meter.meter-ok::-moz-meter-bar {
    background: var(--color-meter-optimum);
}

.column meter.meter-warn::-webkit-meter-optimum-value,
.column meter.meter-warn::-webkit-meter-suboptimum-value,
.column meter.meter-warn::-webkit-meter-even-less-good-value {
    background: var(--color-meter-suboptimum);
    border-radius: var(--radius-sm);
}

.column meter.meter-warn::-moz-meter-bar {
    background: var(--color-meter-suboptimum);
}

.column meter.meter-critical::-webkit-meter-optimum-value,
.column meter.meter-critical::-webkit-meter-suboptimum-value,
.column meter.meter-critical::-webkit-meter-even-less-good-value {
    background: var(--color-meter-critical);
    border-radius: var(--radius-sm);
}

.column meter.meter-critical::-moz-meter-bar {
    background: var(--color-meter-critical);
}

/* ==========================================================================
   12. Holidays
   ========================================================================== */

.holiday {
    margin-top: 8px;
    padding: 8px 10px;
    /* background: var(--color-bg-card); */
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    text-align: left;
    width: fit-content;
}

.holiday-region-group {
    margin-bottom: 10px;
}

.holiday-items {
    list-style: none;
}

.holiday-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    margin-bottom: 6px;
}

.holiday-nav button {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1.5px solid var(--color-btn-border);
    background: transparent;
    color: var(--color-btn-text);
    font-size: 0.9rem;
    font-weight: 700;
    padding: 0;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.holiday-nav button:hover:not(:disabled),
.holiday-nav button:focus-visible:not(:disabled) {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.holiday-nav button:disabled {
    opacity: 0.35;
    cursor: default;
}

#holidayMonth {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--color-primary);
    white-space: nowrap;
}

.holiday-empty {
    font-style: italic;
    color: var(--color-btn-text);
}

.holiday-region-group:last-child {
    margin-bottom: 0;
}

.holiday-region-name {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.holiday-item {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25em 0.5em;
    align-items: baseline;
    font-size: 0.85rem;
    line-height: 1.4;
    padding: 3px 0;
    color: var(--color-text);
}

.holiday-item mark {
    font-variant: small-caps;
    color: rgba(255, 127, 127, 0.9);
    background-color: rgba(127, 127, 31, 0.1);
}

/* ==========================================================================
   13. Vendor Status
   ========================================================================== */

/* Emergency */
.incident {
    margin-bottom: 1rem;
    padding: 12px;
    border: 1px solid #444;
    border-radius: 6px;
}

.incident h3 {
    margin-top: 0;
    color: #ff9800;
}

/* 3rd party Status */
.status-ok {
    color: var(--color-status-ok);
    font-weight: 700;
}

.status-incident {
    color: var(--color-status-incident);
    font-weight: 700;
}

.status-unknown {
    color: var(--color-status-yellow);
    font-weight: 700;
}

/* table */
#latestVersion table,
#latestVersion th,
#latestVersion td {
    border: 1px solid black;
}

#latestVersion table {
    border-collapse: collapse;
    margin: 0 auto;
}

#latestVersion th,
#latestVersion td {
    padding: 2px 3px;
}

/* collapsible Latest Releases */
.release-details {
    width: 100%;
}

.release-details summary {
    display: flex;
    align-items: center;
    justify-content: center;
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.release-details summary::-webkit-details-marker {
    display: none;
}

.release-details summary::before {
    content: "▸";
    margin-right: 0.35em;
    transition: transform var(--transition);
}

.release-details[open] summary::before {
    transform: rotate(90deg);
}

.release-details[open] summary .column-heading {
    color: var(--color-primary);
}

.release-details summary:hover .column-heading,
.release-details summary:focus-visible .column-heading {
    color: var(--color-primary);
}

/* ==========================================================================
   14. Responsive
   ========================================================================== */

@media (max-width: 640px) {
    .grid-container {
        grid-template-columns: 1fr;
        padding: 8px;
    }

    time {
        font-size: 1.15rem;
    }
}