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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(180deg, #e8f4f0 0%, #d4e8d8 50%, #c4dcc4 100%);
    min-height: 100vh;
    color: #333;
}

/* Toned down grass background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(152, 190, 100, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(118, 160, 70, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(140, 180, 90, 0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* Header */
.header {
    text-align: center;
    padding: 30px 20px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    backdrop-filter: blur(10px);
}

.header h1 {
    font-size: 2.5em;
    color: #2c5f3f;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1em;
    color: #666;
}

/* Small slogan under subtitle */
.slogan {
    color: #2c5f3f;
    font-style: italic;
    margin-top: 6px;
    font-weight: 600;
    font-size: 0.95em;
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* Location Section */
.location-section {
    background: rgba(255, 255, 255, 0.8);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.location-input-group {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.location-input-group label {
    font-weight: 600;
    color: #2c5f3f;
    align-self: center;
}

.autocomplete-wrapper {
    flex: 1;
    min-width: 200px;
    position: relative;
}

#locationInput {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #c4dcc4;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #c4dcc4;
    border-top: none;
    border-radius: 0 0 8px 8px;
    list-style: none;
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.autocomplete-list li {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #e8f4f0;
    transition: background-color 0.2s;
    font-size: 0.95em;
    color: #333;
}

/* Highlighted/selected suggestion for keyboard navigation */
.autocomplete-list li.selected {
    background-color: #e8f4f0;
    color: #2c5f3f;
    font-weight: 600;
}

.autocomplete-list li:last-child {
    border-bottom: none;
}

.autocomplete-list li:hover {
    background-color: #e8f4f0;
    color: #2c5f3f;
    font-weight: 500;
}

#locationInput:focus {
    outline: none;
    border-color: #2c5f3f;
    box-shadow: 0 0 5px rgba(44, 95, 63, 0.2);
}

.location-btn, .search-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.location-btn {
    background: #90c695;
    color: white;
}

.location-btn:hover {
    background: #7ab87f;
}

.search-btn {
    background: #2c5f3f;
    color: white;
}

.search-btn:hover {
    background: #1f4429;
}

.location-display {
    font-size: 1.1em;
    color: #2c5f3f;
    font-weight: 500;
}

/* Risk Section */
.risk-section {
    background: rgba(255, 255, 255, 0.85);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.risk-section h2 {
    color: #2c5f3f;
    margin-bottom: 20px;
    font-size: 1.6em;
}

/* Score Display */
.score-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.score-display {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 30px;
    background: linear-gradient(135deg, rgba(196, 220, 196, 0.3), rgba(144, 198, 149, 0.2));
    border-radius: 10px;
    border: 2px solid #c4dcc4;
}

.score-value {
    font-size: 3.5em;
    font-weight: bold;
    color: #2c5f3f;
    min-width: 120px;
    text-align: center;
}

.score-label {
    font-size: 1.8em;
    color: #666;
}

/* Color Bar */
.color-bar-section {
    margin: 25px 0;
}

.color-bar {
    width: 100%;
    height: 40px;
    border-radius: 20px;
    background: linear-gradient(90deg, #2ecc71, #f1c40f, #e67e22, #e74c3c);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
}

.color-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, rgba(255,255,255,0.3) 0%, transparent 50%, rgba(0,0,0,0.1) 100%);
    border-radius: 20px;
}

.bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    color: #555;
    font-weight: 500;
}

/* Score marker (needle/arrow) */
.score-marker {
    position: absolute;
    top: 0;
    height: 100%;
    width: 2px;
    background: rgba(0,0,0,0.85);
    transform: translateX(-50%);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    pointer-events: none;
    transition: left 500ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Alert banner */
.alert-banner {
    width: 100%;
    background: linear-gradient(90deg, #f39c12, #e74c3c);
    color: #fff;
    padding: 10px 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    position: relative;
    margin-top: 8px;
    border-radius: 6px;
}
.alert-banner .alert-inner {
    display: flex;
    align-items: center;
    gap: 12px;
}
.alert-banner #alertTitle { font-weight: 700; margin-right: 8px; }
.alert-banner .modal-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
}
.alert-visible { display: block !important; }

/* Scoring settings */
.scoring-settings {
    margin-top: 18px;
    padding: 12px;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 6px;
    background: #fbfbfb;
}
.scoring-settings label { display: block; margin: 6px 0; font-size: 0.95em; }
.scoring-settings input[type="number"] { width: 100px; margin-left: 8px; }
.muted { color: #666; font-size: 0.9em; }

/* Test Alert button style tweak */
#testAlertBtn { background: #d35400; color: #fff; padding: 10px 14px; border-radius: 8px; font-weight: 700; }

/* Make alert/prompt checkboxes and labels clearer */
.profile-form label input[type="checkbox"] { transform: scale(1.1); margin-right: 8px; }
.profile-form label { display: inline-flex; align-items: center; gap: 8px; }
.score-marker .marker-arrow {
    position: relative;
    bottom: -16px;
    font-size: 16px;
    color: rgba(0,0,0,0.9);
    text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}

/* Ensure full gradient visible on mobile - use explicit color stops */
.color-bar {
    background: linear-gradient(90deg, #2ecc71 0%, #8fd07f 25%, #f1c40f 50%, #e67e22 75%, #e74c3c 100%);
}

/* Risk Assessment Box */
.risk-assessment-box {
    background: #f0f7f4;
    border-left: 5px solid #2c5f3f;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    line-height: 1.6;
    color: #333;
}

.risk-assessment-box p {
    margin-bottom: 10px;
}

.risk-assessment-box strong {
    color: #2c5f3f;
}

/* Weather Section */
.weather-section {
    background: rgba(255, 255, 255, 0.85);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.weather-section h2 {
    color: #2c5f3f;
    margin-bottom: 20px;
    font-size: 1.6em;
}

.weather-section h3 {
    color: #2c5f3f;
    margin: 25px 0 15px 0;
    font-size: 1.2em;
}

/* Current Conditions */
.current-conditions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.condition-card {
    background: linear-gradient(135deg, #f0f7f4, #e8f4f0);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #c4dcc4;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.condition-label {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 8px;
    font-weight: 500;
}

.condition-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #2c5f3f;
}

/* Weather Details Box */
.weather-details-box {
    background: #f8faf9;
    border: 1px solid #d4e8d8;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
}

.weather-details {
    line-height: 1.8;
    color: #333;
}

.weather-details p {
    margin-bottom: 10px;
}

.weather-details strong {
    color: #2c5f3f;
}

/* Forecast Section */
.forecast-section {
    margin-top: 25px;
}

.forecast-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 15px;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    background: #f8faf9;
    border-radius: 8px;
    border: 1px solid #d4e8d8;
}

.forecast-hour {
    background: white;
    border: 1px solid #c4dcc4;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    font-size: 0.85em;
}

.forecast-hour-time {
    font-weight: 600;
    color: #2c5f3f;
    margin-bottom: 5px;
}

.forecast-hour-data {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8em;
    color: #555;
}

.forecast-hour-data span {
    margin: 2px 0;
}

/* Info Section */
.info-section {
    background: rgba(255, 255, 255, 0.8);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-left: 5px solid #90c695;
}

.info-section h3 {
    color: #2c5f3f;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.info-section p {
    color: #555;
    line-height: 1.7;
    margin-bottom: 12px;
}

.external-link {
    color: #2c5f3f;
    text-decoration: none;
    font-weight: 600;
    border-bottom: 2px solid #90c695;
    transition: all 0.3s ease;
    display: inline-block;
}

.external-link:hover {
    color: #90c695;
    border-bottom-color: #2c5f3f;
}

/* Disclaimer Section */
.disclaimer-section {
    background: rgba(255, 255, 255, 0.7);
    padding: 20px;
    border-radius: 10px;
    border-left: 5px solid #e74c3c;
    margin-top: 30px;
    font-size: 0.85em;
    line-height: 1.6;
    color: #666;
}

.disclaimer-section h4 {
    color: #c0392b;
    margin-bottom: 12px;
    font-size: 1em;
    font-weight: 700;
}

.disclaimer-section p {
    margin-bottom: 10px;
    color: #555;
}

/* Footer */
.site-footer {
    background: rgba(255,255,255,0.8);
    padding: 12px 20px;
    border-radius: 8px;
    margin-top: 24px;
    text-align: center;
    border-left: 4px solid rgba(0,0,0,0.04);
    /* Hidden by default; will reveal when scrolled to bottom */
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 240ms ease, transform 240ms ease;
    pointer-events: none;
}
.site-footer.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.site-footer-inner p {
    font-size: 0.82em;
    color: #666;
    margin: 0;
}

/* Info Section Tables */
.info-section h4 {
    color: #2c5f3f;
    margin-top: 20px;
    margin-bottom: 12px;
    font-size: 1.05em;
    font-weight: 700;
}

/* Horse profile layout */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 16px;
    align-items: start;
}

.profile-form input, .profile-form select, .profile-form textarea {
        width: 100%;
        padding: 8px 10px;
        margin-bottom: 10px;
        border: 1px solid #cfded1;
        border-radius: 6px;
}

/* Make checkboxes a bit larger and easier to tap */
.profile-form input[type="checkbox"] {
    width: 18px;
    height: 18px;
    vertical-align: middle;
}

/* BCS guide modal grid */
.bcs-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-top: 8px;
}
.bcs-option {
    padding: 10px 8px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    border-radius: 4px;
}
.bcs-option:hover { background: #f5f5f5; }

/* Visible focus ring for keyboard users */
.bcs-option:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
.autocomplete-list li:focus-visible,
.profile-form button:focus-visible {
    outline: 3px solid rgba(44,95,63,0.25);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(144,198,149,0.12);
}

/* Utility for screen-reader only content */
.visually-hidden {
    position: absolute !important;
    height: 1px; width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
    border: 0; padding: 0; margin: -1px;
}

/* BCS modal detail preview */
.modal-bcs-detail {
    margin-top: 12px;
    padding: 12px;
    background: #fff;
    border: 1px solid #e8f4f0;
    border-radius: 8px;
    display: flex;
    gap: 12px;
    align-items: center;
}
.modal-bcs-detail .bcs-detail-visual { width: 120px; height: 84px; display:flex; align-items:center; justify-content:center; }
.modal-bcs-detail p { margin: 0; color: #333; font-size: 0.95em; }
.bcs-label { display: block; margin-top: 6px; font-weight: 600; color: #2c5f3f; font-size: 0.95em; }

/* Incident log sizing tweaks */
.incident-list textarea,
.incident-form textarea {
    min-height: 120px;
}

@media (min-width: 900px) {
    .incident-list textarea,
    .incident-form textarea {
        min-height: 180px;
    }
}

.checkbox-row { display: flex; gap: 10px; margin-bottom: 10px; }

.profile-form-actions { display: flex; gap: 8px; margin-top: 6px; }

.profile-list ul { list-style: none; padding-left: 0; max-height: 180px; overflow-y: auto; }
.profile-list li { padding: 8px 10px; border: 1px solid #e8f4f0; margin-bottom: 6px; border-radius: 6px; display:flex; justify-content:space-between; align-items:center; }
.profile-list li button { margin-left: 8px; }

.incident-list { margin-top: 10px; max-height: 160px; overflow-y: auto; }
.incident-item { background: #fff; border: 1px solid #e8f4f0; padding: 8px; border-radius: 6px; margin-bottom: 6px; font-size: 0.9em; }

@media (max-width: 768px) {
    .profile-grid { grid-template-columns: 1fr; }
}

.info-table, .risk-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.info-table th, .risk-table th {
    background: #e8f4f0;
    color: #2c5f3f;
    padding: 12px 15px;
    text-align: left;
    font-weight: 700;
    border-bottom: 2px solid #90c695;
}

.info-table td, .risk-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #e8f4f0;
    color: #555;
    line-height: 1.5;
}

.info-table tr:last-child td, .risk-table tr:last-child td {
    border-bottom: none;
}

.info-table tr:hover, .risk-table tr:hover {
    background: #f9fdfb;
}

.risk-table td:first-child {
    font-weight: 600;
    color: #2c5f3f;
    width: 80px;
}

.risk-table td:nth-child(2) {
    font-weight: 600;
    color: #2c5f3f;
    width: 120px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8em;
    }

    .score-display {
        flex-direction: column;
        gap: 5px;
        padding: 20px;
        align-items: center;
    }

    .score-value {
        font-size: 2.5em;
        min-width: auto;
        text-align: center;
    }

    .score-label {
        font-size: 1.2em;
        text-align: center;
    }

    .current-conditions {
        grid-template-columns: repeat(2, 1fr);
    }

    .location-input-group {
        flex-direction: column;
    }

    .location-input-group label {
        width: 100%;
    }

    #locationInput,
    .location-btn,
    .search-btn {
        width: 100%;
    }

    .forecast-container {
        grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .header {
        padding: 20px 10px;
    }

    .header h1 {
        font-size: 1.5em;
    }

    .risk-section,
    .weather-section,
    .info-section {
        padding: 15px;
    }

    .score-value {
        font-size: 2em;
    }

    .score-display {
        align-items: center;
    }

    .score-label {
        text-align: center;
    }

    .current-conditions {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .condition-value {
        font-size: 1.3em;
    }

    /* Mobile: ensure color bar still shows full gradient and marker visible */
    .color-bar {
        height: 36px;
        background: linear-gradient(90deg, #2ecc71 0%, #8fd07f 25%, #f1c40f 50%, #e67e22 75%, #e74c3c 100%);
    }
    .score-marker {
        width: 3px;
    }
    .score-marker .marker-arrow { bottom: -14px; font-size: 14px; }
}

/* Loading animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading {
    animation: spin 1s linear infinite;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    border-radius: 15px;
    padding: 40px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    position: relative;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #2c5f3f;
}

.modal-forecast-detail {
    margin-top: 20px;
}

.modal-forecast-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.modal-forecast-section {
    background: #f0f8f5;
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #2c5f3f;
    text-align: center;
}

.modal-label {
    font-size: 0.85em;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.modal-large-value {
    font-size: 2.2em;
    font-weight: 700;
    color: #2c5f3f;
}

.modal-risk-assessment {
    background: #e8f4f0;
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #90c695;
}

.modal-risk-assessment h3 {
    color: #2c5f3f;
    margin-bottom: 10px;
}

.modal-risk-assessment p {
    color: #333;
    line-height: 1.6;
}

@media (max-width: 480px) {
    .modal-content {
        padding: 25px;
        max-height: 95vh;
    }
    
    .modal-forecast-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .modal-large-value {
        font-size: 1.8em;
    }
}
