/* Default Light Mode Variables */
:root {
    --background-color: #d1d1d1;
    --text-color: #000000;
    --event-info-bg: #007bff;
    --event-info-text: #ffffff;
    --table-bg: #ffffff;
    --table-border: #cccccc;
    --table-header-bg: #007bff;
    --table-header-text: #ffffff;
    --table-row-even: #f9f9f9;
    --table-row-odd: #f2e6ff;
    --section-bg: #f9f9f9;
    --section-border: #dddddd;
    --comment-bg: #f1f1f1;
    --toggle-slider-bg: #cccccc;
    --toggle-checked-bg: #66bb6a;
}

/* Dark Mode – lighter slate style, better outdoors */
body.dark-mode {
    --background-color: #1f2937;
    --text-color: #f3f4f6;
    --event-info-bg: #2563eb;
    --event-info-text: #f9fafb;
    --table-bg: #111827;
    --table-border: #374151;
    --table-header-bg: #4338ca;
    --table-header-text: #e5e7eb;
    --table-row-even: #111827;
    --table-row-odd: #111827;
    --section-bg: #111827;
    --section-border: #374151;
    --comment-bg: #111827;
    --toggle-slider-bg: #111827;
    --toggle-checked-bg: #22c55e;
}

/* Global box sizing to avoid overflow issues */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Base Layout */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--background-color);
    color: var(--text-color);
}

/* Logos */
.corner-logo {
    pointer-events: none;
    z-index: 1000;
}

.left-logo {
    position: fixed;
    top: 10px;
    left: 10px;
    max-width: 500px;
    height: auto;
}

.right-logo {
    position: fixed;
    top: 10px;
    right: 10px;
    max-width: 300px;
    height: auto;
}

/* Header */
header {
    width: 100%;
    text-align: center;
    margin-top: 20px;
}

.logo {
    max-width: 400px;
    height: auto;
}

/* Event Info */
.event-info {
    margin-top: 20px;
    padding: 10px 20px;
    background-color: var(--event-info-bg);
    color: var(--event-info-text);
    border-radius: 8px;
    font-size: 1.1rem;
    text-align: center;
    max-width: 600px;
    width: 100%;
}

.event-info h2 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: bold;
}

.event-info p {
    margin: 5px 0;
    font-size: 1rem;
}

/* Court Table */
.court-table {
    width: 75.5%;
    margin-top: 20px;
    border-collapse: collapse;
    background-color: var(--table-bg);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow: hidden;
}

.court-table th,
.court-table td {
    border: 1px solid var(--table-border);
    padding: 10px 12px;
    font-size: 1rem;
}

/* Header cells: left-aligned */
.court-table th {
    background-color: var(--table-header-bg);
    color: var(--table-header-text);
    text-align: left;
}

.court-table td {
    background-color: var(--table-row-even);
    text-align: left;
}

.court-table tbody tr:nth-child(odd) td {
    background-color: var(--table-row-odd);
}

.header-right {
    text-align: right;
}

.no-data {
    text-align: center;
    font-style: italic;
}

/* Title bar above bottom section (Match Support / Weather / News) */
.weather-section-title {
    width: 75.5%;
    margin-top: 24px;
    padding: 8px 16px;
    background-color: var(--event-info-bg);
    color: var(--event-info-text);
    border-radius: 8px 8px 0 0;
    font-size: 1.05rem;
    font-weight: 600;
    text-align: left;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

/* Make the card sit directly under the blue bar and share corners */
.weather-section-title + .weather-personal-section {
    margin-top: 0;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

/* Weather & Personal Section */
.weather-personal-section {
    width: 75.5%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-top: 30px;
    margin-left: auto;
    margin-right: auto;
    background-color: var(--section-bg);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--section-border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Four columns: match support, weather text, news, graphics */
.personal-details,
.weather-details,
.tennis-news,
.weather-graphics {
    flex: 1 1 0;
    max-width: 25%;
}

/* Headings */
.personal-details h3,
.weather-details h3,
.tennis-news h3,
.weather-graphics h3 {
    color: var(--event-info-bg);
    margin-bottom: 10px;
}

/* Column 1 text */
.personal-details p {
    margin: 8px 0;
}

/* Column 2 text */
.weather-details span {
    display: block;
    margin-bottom: 5px;
}

/* Column 3: Tennis news */
.tennis-news {
    display: flex;
    flex-direction: column;
}

.tennis-news ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tennis-news li {
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.tennis-news a {
    color: #0f4ab8;
    text-decoration: none;
}

.tennis-news a:hover {
    text-decoration: underline;
}

.tennis-news .news-empty {
    font-style: italic;
    color: #666666;
}

/* Column 4: graphics */
.weather-graphics {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

/* Animated icon container */
.weather-animation {
    width: 90px;
    height: 90px;
    margin-top: 8px;
    position: relative;
    border-radius: 50%;
    display: inline-block;
}

/* Sunny icon – bright sun with spinning rays */
.weather-animation.sunny {
    background: radial-gradient(circle at 30% 30%, #fff9c4, #ffeb3b, #fbc02d);
    box-shadow: 0 0 18px rgba(255, 235, 59, 0.9);
    animation: spin-sun 6s linear infinite, sun-pulse 2.5s ease-in-out infinite;
    overflow: visible;
}

.weather-animation.sunny::before {
    content: "";
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 6px solid rgba(255, 235, 59, 0.8);
    box-shadow: 0 0 25px rgba(255, 235, 59, 0.7);
    animation: sun-rays 6s linear infinite;
}

/* Rainy icon – cloud + falling rain */
.weather-animation.rainy {
    background: linear-gradient(to bottom, #4fc3f7 0%, #0288d1 60%, #0277bd 100%);
    border-radius: 50%;
    box-shadow: 0 0 14px rgba(33, 150, 243, 0.8);
    overflow: visible;
}

.weather-animation.rainy::before {
    content: "";
    position: absolute;
    width: 70%;
    height: 45%;
    top: 16%;
    left: 15%;
    border-radius: 50%;
    background: #eceff1;
    box-shadow:
        -12px 8px 0 0 #eceff1,
        12px 8px 0 0 #eceff1;
}

.weather-animation.rainy::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 55%;
    transform: translateX(-50%);
    width: 6px;
    height: 22px;
    background-image: linear-gradient(
        to bottom,
        rgba(33, 150, 243, 0),
        rgba(33, 150, 243, 1)
    );
    animation: rain-fall 0.7s linear infinite;
}

/* Stormy / thunder icon */
.weather-animation.stormy {
    background: radial-gradient(circle at 30% 20%, #cfd8dc, #78909c, #455a64);
    border-radius: 50%;
    box-shadow: 0 0 16px rgba(96, 125, 139, 0.9);
    overflow: visible;
}

.weather-animation.stormy::before {
    content: "";
    position: absolute;
    width: 70%;
    height: 45%;
    top: 18%;
    left: 15%;
    border-radius: 50%;
    background: #cfd8dc;
    box-shadow:
        -12px 8px 0 0 #cfd8dc,
        12px 8px 0 0 #cfd8dc;
}

.weather-animation.stormy::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 54%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 10px 22px 10px;
    border-color: transparent transparent #ffeb3b transparent;
    filter: drop-shadow(0 0 8px rgba(255, 241, 118, 0.9));
    animation: flash 0.8s infinite;
}

/* Night / moon icon – crescent moon in a starry night sky */
.weather-animation.night {
    width: 110px;
    height: 110px;
    border-radius: 24px;
    background:
        radial-gradient(circle at 12% 18%, #f9fafb 1.2px, transparent 1.4px),
        radial-gradient(circle at 72% 24%, #e5e7eb 1.2px, transparent 1.4px),
        radial-gradient(circle at 30% 72%, #cbd5f5 1.2px, transparent 1.4px),
        radial-gradient(circle at 82% 82%, #f9fafb 1.2px, transparent 1.4px),
        radial-gradient(circle at 18% 60%, #e5e7eb 1.2px, transparent 1.4px),
        radial-gradient(circle at 20% 15%, #1f2937 0, #020617 55%, #000000 100%);
    position: relative;
    box-shadow: 0 0 22px rgba(15, 23, 42, 0.9);
    overflow: hidden;
}

/* Full moon disc */
.weather-animation.night::before {
    content: "";
    position: absolute;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    top: 24px;
    left: 24px;
    background-image: radial-gradient(
        circle at 30% 25%,
        #fffdf2,
        #fef3c7 45%,
        #fde68a 75%,
        #fbbf24 100%
    );
    box-shadow:
        0 0 12px rgba(254, 252, 232, 0.9),
        0 0 22px rgba(250, 204, 21, 0.8);
    animation: moon-glow 4s ease-in-out infinite;
}

/* Dark disc to cut crescent */
.weather-animation.night::after {
    content: "";
    position: absolute;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    top: 26px;
    left: 40px;
    background-color: #020617;
    box-shadow: -4px 0 12px rgba(15, 23, 42, 0.9);
}

/* UV and Temperature Indicators */
#uv-index {
    font-weight: 600;
}

#temperature {
    font-weight: 600;
}

.uv-low {
    color: #2e7d32;
}

.uv-medium {
    color: #ef6c00;
}

.uv-high {
    color: #c62828;
    animation: flash 1s infinite;
}

.temp-low {
    color: #2e7d32;
}

.temp-medium {
    color: #ef6c00;
}

.temp-high {
    color: #c62828;
    animation: flash 1s infinite;
}

/* Reminders */
.reminder-message {
    margin-top: 4px;
}

.reminder-ok {
    color: green;
    font-size: 1em;
}

.reminder-warning {
    color: yellow;
    font-size: 1.5em;
    animation: flash 1s infinite;
}

/* Comments Box */
#comments-box {
    width: 100%;
    max-width: 800px;
    margin-top: 20px;
    padding: 10px;
    display: none;
    background-color: var(--comment-bg);
    border-radius: 8px;
    border: 1px solid var(--section-border);
}

#comments-box textarea {
    width: 100%;
    height: 100px;
    padding: 10px;
    border: 1px solid var(--table-border);
    border-radius: 8px;
    font-size: 1rem;
}

/* Theme Toggle */
#theme-toggle-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--toggle-slider-bg);
    transition: 0.4s;
    border-radius: 34px;
}

.slider::before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: #ffffff;
    transition: 0.4s;
    border-radius: 50%;
}

.switch input:checked + .slider {
    background-color: var(--toggle-checked-bg);
}

.switch input:checked + .slider::before {
    transform: translateX(26px);
}

/* Animations */
@keyframes spin-sun {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes sun-pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.06);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes sun-rays {
    0% {
        transform: rotate(0deg);
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
    100% {
        transform: rotate(360deg);
        opacity: 1;
    }
}

@keyframes flash {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
    100% {
        opacity: 1;
    }
}

@keyframes rain-fall {
    0% {
        opacity: 1;
        transform: translate(-50%, 0);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, 140%);
    }
}

@keyframes moon-glow {
    0% {
        box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    }
    50% {
        box-shadow: 0 0 22px rgba(59, 130, 246, 1);
    }
    100% {
        box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    }
}

/* Responsive up to 1080px – general tablet-ish tweaks */
@media (max-width: 1080px) {
    .court-table {
        width: 95%;
    }

    .weather-section-title {
        width: 95%;
    }

    .weather-personal-section {
        flex-direction: column;
        width: 95%;
        margin-top: 20px;
    }

    .personal-details,
    .weather-details,
    .tennis-news,
    .weather-graphics {
        max-width: 100%;
    }
}

/* Hide fixed logos on very small / touch landscape */
@media (max-width: 600px),
(orientation: landscape) and (pointer: coarse) {
    .corner-logo {
        display: none;
    }
}

/* Proper mobile layout – card-style fixtures, no horizontal scroll */
@media (max-width: 600px) {
    body {
        align-items: stretch;
        padding-left: 8px;
        padding-right: 8px;
        overflow-x: hidden;
    }

    header {
        margin-top: 10px;
    }

    .logo {
        max-width: 260px;
    }

    .event-info {
        max-width: 100%;
        width: 100%;
        margin-top: 12px;
        padding: 12px 16px;
        border-radius: 10px;
        font-size: 0.95rem;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    }

    .event-info h2 {
        font-size: 1.2rem;
    }

    .event-info p {
        font-size: 0.95rem;
    }

    /* Turn the table into stacked modern cards */
    .court-table {
        width: 100%;
        margin-top: 16px;
        border-radius: 0;
        box-shadow: none;
        border-collapse: separate;
        background: transparent;
    }

    .court-table thead {
        display: none;
    }

    .court-table,
    .court-table tbody {
        display: block;
        width: 100%;
    }

    .court-table tr {
        display: block;
        width: 100%;
        margin-bottom: 14px;
        background: linear-gradient(135deg, #ffffff, #f5f7ff);
        border-radius: 14px;
        border: 1px solid rgba(148, 163, 184, 0.35);
        box-shadow: 0 3px 10px rgba(15, 23, 42, 0.22);
        padding: 10px 12px;
        position: relative;
        overflow: hidden;
    }

    .court-table tr::before {
        content: "";
        position: absolute;
        inset: 0;
        border-left: 4px solid #2563eb;
        opacity: 0.9;
        pointer-events: none;
    }

    .court-table td {
        display: flex;
        width: 100%;
        border: none;
        border-bottom: 1px solid rgba(148, 163, 184, 0.6);
        padding: 6px 2px;
        font-size: 0.9rem;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
        background-color: transparent;
        word-break: break-word;
        flex-wrap: wrap;
    }

    .court-table td:last-child {
        border-bottom: none;
    }

    /* Mobile labels on left, values on right */
    .court-table td::before {
        flex: 0 0 52%;
        max-width: 58%;
        font-weight: 600;
        opacity: 0.8;
        font-size: 0.78rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: #64748b;
    }

    .court-table td:nth-child(1)::before {
        content: "Round";
    }

    .court-table td:nth-child(2)::before {
        content: "Division";
    }

    .court-table td:nth-child(3)::before {
        content: "Home Team";
    }

    .court-table td:nth-child(4)::before {
        content: "Club";
    }

    .court-table td:nth-child(5)::before {
        content: "Visiting Team";
    }

    .court-table td:nth-child(6)::before {
        content: "Courts";
    }

    .court-table td:nth-child(7)::before {
        content: "How Many Courts";
    }

    .court-table td:nth-child(8)::before {
        content: "Times Had 4 Courts";
    }

    /* Emphasise team names + courts */
    .court-table td:nth-child(3),
    .court-table td:nth-child(5) {
        font-weight: 600;
        color: #0f172a;
    }

    .court-table td:nth-child(7),
    .court-table td:nth-child(8) {
        font-weight: 600;
        color: #0f766e;
    }

    /* No-data row: show as single centered message */
    .court-table td.no-data {
        display: block;
        text-align: center;
        border-bottom: none;
        font-size: 0.95rem;
        padding: 10px 6px;
    }

    .court-table td.no-data::before {
        content: "";
    }

    .weather-section-title {
        width: 100%;
        margin-top: 16px;
        padding: 10px 14px;
        border-radius: 10px 10px 0 0;
        font-size: 0.98rem;
        text-align: left;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    }

    .weather-section-title + .weather-personal-section {
        border-radius: 0 0 10px 10px;
    }

    .weather-personal-section {
        width: 100%;
        margin-top: 0;
        padding: 12px 12px 14px 12px;
        border-radius: 0 0 10px 10px;
        gap: 12px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
        flex-direction: column;
    }

    .personal-details,
    .weather-details,
    .tennis-news,
    .weather-graphics {
        max-width: 100%;
    }

    .personal-details p,
    .weather-details span,
    .tennis-news li {
        font-size: 0.9rem;
    }

    .weather-graphics {
        align-items: flex-start;
        margin-top: 4px;
    }

    .weather-animation {
        width: 84px;
        height: 84px;
        margin-top: 4px;
    }

    /* Scale moon + cutout for smaller container so it doesn't clip */
    .weather-animation.night::before {
        width: 44px;
        height: 44px;
        top: 18px;
        left: 18px;
    }

    .weather-animation.night::after {
        width: 40px;
        height: 40px;
        top: 20px;
        left: 32px;
    }

    #comments-box {
        max-width: 100%;
    }
}

/* Dark-mode overrides for mobile cards – lighter slate, still punchy */
@media (max-width: 600px) {
    body.dark-mode .court-table tr {
        background: linear-gradient(135deg, #111827, #1f2937);
        border-color: rgba(148, 163, 184, 0.6);
        box-shadow: 0 2px 8px rgba(15, 23, 42, 0.8);
    }

    body.dark-mode .court-table tr::before {
        border-left-color: #22c55e;
    }

    body.dark-mode .court-table td::before {
        color: #e5e7eb;
    }

    body.dark-mode .court-table td:nth-child(3),
    body.dark-mode .court-table td:nth-child(5) {
        color: #f9fafb;
    }

    body.dark-mode .court-table td:nth-child(7),
    body.dark-mode .court-table td:nth-child(8) {
        color: #6ee7b7;
    }

    body.dark-mode .event-info {
        box-shadow: 0 2px 8px rgba(15, 23, 42, 0.85);
    }

    body.dark-mode .weather-section-title {
        box-shadow: 0 2px 8px rgba(15, 23, 42, 0.85);
    }

    body.dark-mode .weather-personal-section {
        box-shadow: 0 2px 8px rgba(15, 23, 42, 0.85);
    }
}

.sneaky-login-link {
    color: white;
    text-decoration: none;
}

.sneaky-login-link:hover {
    color: white;
    text-decoration: none;
}

/* Brighter links in dark mode */
body.dark-mode a {
    color: white;
    text-decoration: none;
}

body.dark-mode a:hover {
    color: #bfdbfe;
    text-decoration: underline;
}

/* Extra pop for tennis news links in dark mode */
body.dark-mode .tennis-news a {
    color: #bfdbfe;
}

body.dark-mode .tennis-news a:hover {
    color: #e5e7eb;
}
