/* CSP helpers: replace inline style="..." so style-src can drop 'unsafe-inline' */
.overflow-visible {
    overflow: visible;
}
.border-0 {
    border: 0;
}

body {
    font-family: 'Inter', sans-serif;
}

.gradient-bg {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.card-shadow {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.input-focus:focus {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.table-row:hover {
    background-color: #f8fafc;
}

/* Answer-first result treatment (roadmap 1.3) */
.next-amavasya-hero {
    position: relative;
    overflow: hidden;
    border: 1px solid #ddd6fe;
    background: linear-gradient(135deg, #faf5ff 0%, #eef2ff 100%);
}

.next-amavasya-hero::before,
.next-amavasya-hero::after {
    content: '';
    position: absolute;
    border-radius: 9999px;
    pointer-events: none;
}

.next-amavasya-hero::before {
    width: 10rem;
    height: 10rem;
    top: -5rem;
    right: -3rem;
    background: rgba(196, 181, 253, 0.32);
    filter: blur(18px);
}

.next-amavasya-hero::after {
    width: 7rem;
    height: 7rem;
    bottom: -4rem;
    left: 28%;
    background: rgba(191, 219, 254, 0.45);
    filter: blur(16px);
}

.next-amavasya-hero__content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.next-amavasya-hero__layout {
    position: relative;
    z-index: 1;
}

.next-amavasya-hero__icon {
    flex: 0 0 auto;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    color: #ffffff;
    background: linear-gradient(135deg, #9333ea 0%, #4f46e5 100%);
    box-shadow: 0 8px 18px rgba(99, 102, 241, 0.25);
}

.next-amavasya-hero__eyebrow {
    margin: 0 0 0.2rem;
    color: #6d28d9;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.next-amavasya-hero__title {
    margin: 0;
    color: #1f2937;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.4;
}

.next-amavasya-hero__detail {
    margin: 0.25rem 0 0;
    color: #4b5563;
    font-size: 0.95rem;
}

.next-amavasya-hero__date {
    color: #374151;
    font-weight: 600;
}

.next-amavasya-hero__relative {
    color: #6d28d9;
    font-weight: 700;
}

.result-row--past {
    opacity: 0.52;
}

.result-row--next {
    background: linear-gradient(90deg, #faf5ff 0%, #eef2ff 100%);
    box-shadow: inset 4px 0 0 #8b5cf6;
}

.result-row--next:hover {
    background: linear-gradient(90deg, #f3e8ff 0%, #e0e7ff 100%);
}

.share-action-btn {
    min-height: 2.75rem;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.share-action-btn:active {
    transform: scale(0.98);
}

.share-action-btn:focus-visible {
    outline: 3px solid rgba(139, 92, 246, 0.35);
    outline-offset: 2px;
}

.share-status {
    min-height: 1.25rem;
}

.share-actions--compact {
    position: relative;
    z-index: 1;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(139, 92, 246, 0.2);
}

.share-actions--compact .share-actions__layout {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.share-actions--compact .share-status {
    margin-top: 0.5rem;
}

@media (min-width: 1024px) {
    .next-amavasya-hero__layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 2rem;
    }

    .share-actions--compact {
        min-width: 19rem;
        margin-top: 0;
        padding-top: 0;
        padding-left: 2rem;
        border-top: 0;
        border-left: 1px solid rgba(139, 92, 246, 0.2);
    }
}

.share-copy-fallback {
    position: fixed;
    left: -10000px;
    top: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
}

@media (max-width: 767px) {
    .results-table-shell {
        overflow: visible;
        background: transparent;
        box-shadow: none;
    }

    .results-table-shell>.overflow-x-auto {
        overflow: visible;
    }

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

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

    .responsive-results-table tbody {
        border: 0;
    }

    .responsive-results-table tbody tr {
        display: flex;
        flex-direction: column;
        margin-bottom: 1rem;
        overflow: hidden;
        border: 1px solid #e5e7eb;
        border-radius: 1rem;
        background: #ffffff;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    }

    .responsive-results-table tbody tr:last-child {
        margin-bottom: 0;
    }

    .responsive-results-table tbody td {
        display: grid;
        grid-template-columns: 5.75rem minmax(0, 1fr);
        gap: 0.75rem;
        align-items: start;
        width: 100%;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid #f3f4f6;
        font-size: 0.875rem;
        line-height: 1.4;
        overflow-wrap: anywhere;
    }

    .responsive-results-table tbody td::before {
        content: attr(data-label);
        color: #6b7280;
        font-family: 'Inter', sans-serif;
        font-size: 0.7rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .responsive-results-table tbody td[data-field='date'] {
        order: -1;
        display: block;
        padding: 1rem;
        border-bottom-color: #ede9fe;
        background: linear-gradient(135deg, #faf5ff 0%, #eef2ff 100%);
        color: #1f2937;
        font-size: 1.05rem;
    }

    .responsive-results-table tbody td[data-field='date']::before {
        content: none;
    }

    .responsive-results-table tbody td:last-child {
        border-bottom: 0;
    }

    .responsive-results-table tbody tr.result-row--past {
        opacity: 0.78;
    }

    .responsive-results-table tbody tr.result-row--next {
        border-color: #8b5cf6;
        box-shadow: 0 10px 28px rgba(124, 58, 237, 0.2);
    }

    .responsive-results-table tbody tr.result-row--next td[data-field='date']::after {
        content: 'Next';
        float: right;
        margin-left: 0.5rem;
        padding: 0.2rem 0.55rem;
        border-radius: 9999px;
        background: #7c3aed;
        color: #ffffff;
        font-family: 'Inter', sans-serif;
        font-size: 0.65rem;
        font-weight: 700;
        letter-spacing: 0.05em;
        text-transform: uppercase;
    }

    .share-action-btn {
        flex: 1 1 8rem;
    }
}

@media (max-width: 640px) {
    .next-amavasya-hero__content {
        align-items: flex-start;
    }

    .next-amavasya-hero__icon {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 0.9rem;
    }

    .next-amavasya-hero__title {
        font-size: 1.1rem;
    }
}

.kshaya-badge {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.variant-badge {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
}

.loading-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

.coord-help {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.coord-help .info-icon {
    cursor: help;
    transition: color 0.2s ease, transform 0.2s ease;
}

.coord-help:hover .info-icon,
.coord-help:focus .info-icon,
.coord-help:focus-within .info-icon {
    color: #9333ea !important;
    transform: scale(1.15);
}

.coord-help:focus {
    outline: 2px solid #a855f7;
    outline-offset: 2px;
    border-radius: 0.25rem;
}

.coord-help-bubble {
    position: absolute;
    left: 50%;
    top: calc(100% + 0.75rem);
    margin-top: 0;
    width: 20rem;
    transform: translateX(-50%) translateY(4px);
    padding: 0;
    border: none;
    border-radius: 1rem;
    background: white;
    color: #374151;
    box-shadow:
        0 4px 6px -1px rgba(147, 51, 234, 0.05),
        0 10px 30px -5px rgba(147, 51, 234, 0.1),
        0 20px 60px -10px rgba(147, 51, 234, 0.08);
    font-size: 0.8rem;
    line-height: 1.5;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    z-index: 50;
}

/* Triangle arrow */
.coord-help-bubble::before {
    content: '';
    position: absolute;
    top: -0.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 0.5rem solid transparent;
    border-right: 0.5rem solid transparent;
    border-bottom: 0.5rem solid white;
}

/* Colored top strip */
.coord-help-bubble::after {
    content: '';
    position: absolute;
    top: -0.35rem;
    left: 50%;
    transform: translateX(-50%);
    width: 2.5rem;
    height: 0.35rem;
    border-radius: 0.5rem 0.5rem 0 0;
    background: linear-gradient(135deg, #a855f7 0%, #9333ea 100%);
}

.coord-help:hover .coord-help-bubble,
.coord-help:focus .coord-help-bubble,
.coord-help:focus-within .coord-help-bubble {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* City autocomplete dropdown */
.city-autocomplete {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.25rem;
    max-height: 18rem;
    overflow-y: auto;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    z-index: 50;
    list-style: none;
    padding: 0;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.95rem;
    color: #374151;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

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

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: #f3e8ff;
    color: #6b21a8;
}

.autocomplete-item strong {
    font-weight: 600;
    color: #111827;
}

.autocomplete-item span {
    font-size: 0.8rem;
    color: #6b7280;
}

.autocomplete-item:hover span,
.autocomplete-item.active span {
    color: #6b21a8;
}

/* No-results / helper text inside dropdown */
.autocomplete-empty {
    padding: 0.75rem 1rem;
    color: #6b7280;
    font-size: 0.9rem;
}

/* Compact, responsive form rows */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
}

/* .hidden (display:none) and .form-row (display:flex) have equal
   specificity, so source order decides the winner. This rule adds
   specificity so the hidden state always wins regardless of order. */
.form-row.hidden {
    display: none;
}

.form-row>.field-year {
    flex: 0 0 6rem;
    min-width: 0;
}

.form-row>.field-city {
    flex: 1 1 0;
    min-width: 12rem;
}

.form-row>.field-coord,
.form-row>.field-tz {
    flex: 1 1 0;
    min-width: 10rem;
}

.label-compact {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    line-height: 1rem;
    color: #4b5563;
}

.input-compact {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    min-height: 2.25rem;
    box-sizing: border-box;
}

/* Matches .input-compact's actual rendered height (incl. its 1px border) */
.form-btn-height {
    min-height: 2.375rem;
}

.tz-display {
    flex: 1 1 0;
    min-width: 0;
    padding: 0.5rem 0.75rem;
    min-height: 2.25rem;
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.tz-edit-btn {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    flex: 0 0 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.seasonal-name {
    margin-top: 0.35rem;
    color: #6b21a8;
    font-family: Inter, sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: normal;
}

.masa-label {
    margin-top: 0.2rem;
    color: #4b5563;
    font-family: Inter, sans-serif;
    font-size: 0.8125rem;
    font-weight: 400;
    white-space: normal;
}

.festival-date {
    margin-bottom: 1rem;
    padding: 1rem 1.25rem;
    border: 1px solid #e9d5ff;
    border-radius: 1rem;
    background: #faf5ff;
}
