/**
 * Sunlight App - Your Daily Sun
 * Bright, optimistic, celebratory. One card that flows like a warm day.
 * @version 9.2.0
 */

/* =============================================================================
   THEME VARIABLES
   ============================================================================= */

.app-page.app-sunlight,
body.sunlight-app-page {
    --sunlight-accent: #D97706;
    --sunlight-accent-light: #F59E0B;
    --sunlight-accent-hover: #B45309;
    --sunlight-logged: #10b981;
    --sunlight-logged-dark: #059669;
    --sunlight-border: rgb(217 119 6 / 12%);
    --sunlight-tint: rgb(217 119 6 / 5%);
}

/* =============================================================================
   BASE LAYOUT
   ============================================================================= */

.sunlight-app-page {
    background-color: #FFFCF5;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.app-container {
    max-width: 420px;
    margin: 0 auto;
    padding: 80px 20px 40px;
    display: flex;
    flex-direction: column;
}

/* =============================================================================
   UNIFIED SUNLIGHT CARD
   Combines hero + button + streak + week into one flowing experience
   ============================================================================= */

.sunlight-card {
    background: linear-gradient(180deg, #FFFDF5 0%, #FEF3C7 100%);
    border-radius: 20px;
    box-shadow: 0 4px 24px rgb(217 119 6 / 8%);
    border: 1px solid var(--sunlight-border);
    padding: 32px 28px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

/* =============================================================================
   HERO SECTION (now part of unified card, no separate card styling)
   ============================================================================= */

.hero-section {
    text-align: center;
}

.sun-status {
    display: flex;
    justify-content: center;
    align-items: center;
}

.status-icon {
    font-size: 56px;
    display: block;
    transition: transform 0.3s ease-in-out;
}

.hero-message {
    margin-top: 12px;
}

.hero-title {
    font-size: 22px;
    font-weight: 700;
    color: #92400E;
    margin: 0 0 8px 0;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 15px;
    color: #A8A29E;
    margin: 0;
    line-height: 1.5;
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
}

/* Logged state */
.hero-section.logged .hero-title {
    color: var(--sunlight-logged-dark);
}

.hero-section.logged .hero-subtitle {
    color: #6EE7B7;
}

/* Nighttime state */
.hero-section.night .hero-title {
    color: #6B7280;
}

.hero-section.night .hero-subtitle {
    color: #9CA3AF;
}

/* =============================================================================
   SUN TO CHECKMARK ANIMATION
   ============================================================================= */

@keyframes sun-to-checkmark {
    0% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
    5% {
        transform: scale(1.1) translateY(0);
        opacity: 0.9;
    }
    15% {
        transform: scale(1.2) translateY(-10px);
        opacity: 0.7;
    }
    25% {
        transform: scale(1.3) translateY(-15px);
        opacity: 0.4;
    }
    35% {
        transform: scale(1.4) translateY(-20px);
        opacity: 0.1;
    }
    45% {
        transform: scale(0);
        opacity: 0;
    }
    65% {
        transform: scale(0.7);
        opacity: 1;
    }
    85% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.sun-animation {
    animation: sun-to-checkmark 1s ease-in-out;
    will-change: transform, opacity;
    transform-origin: center center;
}

@media (prefers-reduced-motion: reduce) {
    .sun-animation {
        animation: none;
    }
}

/* =============================================================================
   BUTTONS
   ============================================================================= */

.button-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.sunlight-app-page .btn-primary.btn-primary {
    background: var(--sunlight-accent) !important;
    color: white !important;
    border: none !important;
    border-radius: 14px;
    padding: 16px 48px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 12px rgb(217 119 6 / 20%);
    min-height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 200px;
}

.sunlight-app-page .btn-primary.btn-primary:hover {
    background: var(--sunlight-accent-hover) !important;
    box-shadow: 0 4px 16px rgb(217 119 6 / 28%);
    transform: translateY(-1px);
}

.sunlight-app-page .btn-primary.btn-primary:active {
    transform: translateY(0);
}

.sunlight-app-page .btn-primary.btn-primary:disabled,
.sunlight-app-page .btn-primary.btn-primary.logged {
    background: var(--sunlight-logged) !important;
    color: white !important;
    cursor: default;
    box-shadow: 0 2px 12px rgb(16 185 129 / 20%);
}

.sunlight-app-page .btn-primary.btn-primary.logged:hover {
    transform: none;
}

/* Muted button at night */
.hero-section.night ~ .button-container .btn-primary.btn-primary {
    background: #9CA3AF !important;
    box-shadow: 0 2px 12px rgb(156 163 175 / 15%);
}

.hero-section.night ~ .button-container .btn-primary.btn-primary:hover {
    background: #6B7280 !important;
    box-shadow: 0 4px 16px rgb(107 114 128 / 20%);
}

/* =============================================================================
   STREAK & WEEK HEADER
   ============================================================================= */

.streak-container {
    width: 100%;
    text-align: center;
}

.streak-display {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--sunlight-accent-light);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
}

/* =============================================================================
   WEEK VIEW
   ============================================================================= */

.week-progress {
    width: 100%;
    padding-top: 4px;
    border-top: 1.5px dashed rgb(217 119 6 / 15%);
}

.week-progress-title {
    font-size: 12px;
    font-weight: 700;
    color: #92400E;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin: 12px 0 12px 0;
    text-align: center;
}

.week-view--dots {
    padding: 0;
}

.week-view--dots .week-days {
    display: flex;
    justify-content: space-between;
    gap: 4px;
}

.week-view--dots .week-day {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 8px;
    background: transparent;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.week-view--dots .week-day.today {
    background: rgb(217 119 6 / 8%);
    border: 1.5px solid rgb(217 119 6 / 15%);
}

.week-view--dots .week-day.logged {
    transform: scale(1.05);
}

.week-view--dots .day-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgb(217 119 6 / 8%);
    border: 2px solid rgb(217 119 6 / 15%);
    transition: all 0.2s ease;
}

.week-view--dots .week-day.logged .day-dot {
    background: var(--sunlight-logged);
    border-color: var(--sunlight-logged-dark);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.week-view--dots .week-day.today .day-dot {
    background: var(--sunlight-accent-light);
    border-color: var(--sunlight-accent);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.week-view--dots .week-day.today.logged .day-dot {
    background: var(--sunlight-logged);
    border-color: var(--sunlight-logged-dark);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.week-view--dots .day-label {
    font-size: 12px;
    font-weight: 700;
    color: #A8A29E;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.week-view--dots .week-day.today .day-label {
    color: #92400E;
}

.week-view--dots .week-day.logged .day-label {
    color: var(--sunlight-logged-dark);
}

/* Missed (past unlogged) days — muted treatment */
.week-view--dots .week-day.missed .day-dot {
    background: rgb(168 162 158 / 10%);
    border-color: rgb(168 162 158 / 20%);
    border-style: dashed;
}

.week-view--dots .week-day.missed .day-label {
    color: #D6D3D1;
}

/* Clickable logged days for undo */
.week-view--dots .week-day.logged.clickable {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.week-view--dots .week-day.logged.clickable:hover {
    transform: scale(1.1);
}

.week-view--dots .week-day.logged.clickable:hover .day-dot {
    box-shadow: 0 3px 12px rgba(16, 185, 129, 0.4);
}

.week-view--dots .week-day.logged.clickable:focus {
    outline: none;
}

.week-view--dots .week-day.logged.clickable:focus-visible .day-dot {
    outline: 2px solid var(--sunlight-logged);
    outline-offset: 2px;
}

/* =============================================================================
   UV FORECAST — Inline within sunlight card
   ============================================================================= */

.uv-inline {
    width: 100%;
    text-align: center;
    color: #78350F;
    overflow: hidden;
}

.uv-inline:empty {
    display: none;
}

/* Inline prompt (location enable / error) */
.uv-inline-prompt {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgb(217 119 6 / 5%);
    border-radius: 12px;
    border: 1.5px dashed rgb(217 119 6 / 15%);
}

.uv-inline-prompt--error {
    border-color: rgb(220 38 38 / 20%);
    background: rgb(220 38 38 / 5%);
}

.uv-inline-prompt__icon {
    font-size: 16px;
    flex-shrink: 0;
}

.uv-inline-prompt__text {
    font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
    font-size: 13px;
    color: #A8A29E;
    line-height: 1.4;
}

.uv-inline-prompt--error .uv-inline-prompt__text {
    color: #dc2626;
    font-size: 12px;
}

.uv-inline-prompt__btn {
    background: var(--sunlight-accent);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 6px 16px;
    font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.uv-inline-prompt__btn:hover {
    background: var(--sunlight-accent-hover);
    transform: translateY(-1px);
}

.uv-inline-prompt__btn:active {
    transform: translateY(0);
}

/* Loading state */
.uv-inline__loading-text {
    font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
    font-size: 13px;
    color: #A8A29E;
    margin: 0;
    padding: 12px 0;
}

/* ---------------------------------------------------------------------------
   Current UV Display
   --------------------------------------------------------------------------- */

.uv-current {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 4px 0 8px;
}

.uv-current__prefix {
    font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: #A8A29E;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    line-height: 1;
}

.uv-current__value {
    font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
    font-size: 48px;
    font-weight: 700;
    line-height: 1;
}

.uv-current__value--low { color: #16a34a; }
.uv-current__value--moderate { color: #ca8a04; }
.uv-current__value--high { color: #ea580c; }
.uv-current__value--very-high { color: #dc2626; }
.uv-current__value--extreme { color: #9333ea; }

.uv-current__level {
    display: inline-block;
    font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 2px 10px;
    border-radius: 20px;
    line-height: 1.4;
}

.uv-current__level--low { color: #15803d; background: rgba(22, 163, 74, 0.14); }
.uv-current__level--moderate { color: #a16207; background: rgba(202, 138, 4, 0.14); }
.uv-current__level--high { color: #c2410c; background: rgba(234, 88, 12, 0.14); }
.uv-current__level--very-high { color: #b91c1c; background: rgba(220, 38, 38, 0.14); }
.uv-current__level--extreme { color: #7e22ce; background: rgba(147, 51, 234, 0.14); }


/* ---------------------------------------------------------------------------
   Hourly Bar Chart (vertical bars)
   --------------------------------------------------------------------------- */

.uv-forecast__chart {
    width: 100%;
    margin: 2px 0 0;
}

.uv-chart__title {
    font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: #A8A29E;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin: 0 0 12px 0;
    text-align: left;
}

.uv-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 80px;
    padding: 0 4px;
    min-width: 0;
}

.uv-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    min-width: 0;
    position: relative;
    padding-top: 14px;
}

.uv-bar {
    width: 100%;
    max-width: 24px;
    min-height: 4px;
    border-radius: 6px 6px 2px 2px;
    transition: height 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.uv-bar-label {
    font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
    font-size: 9px;
    font-weight: 500;
    color: #A8A29E;
    white-space: nowrap;
    margin-top: 5px;
}

.uv-bar-label--hidden {
    visibility: hidden;
}

/* UV bar colors */
.uv-bar.uv-low { background: #4ade80; border: none; }
.uv-bar.uv-moderate { background: #facc15; border: none; }
.uv-bar.uv-high { background: #f97316; border: none; }
.uv-bar.uv-very-high { background: #ef4444; border: none; }
.uv-bar.uv-extreme { background: #a855f7; border: none; }

/* Peak hour highlight */
.uv-bar-col--peak .uv-bar {
    box-shadow: 0 0 12px rgb(217 119 6 / 30%);
    border: 1px solid rgb(217 119 6 / 20%);
}

.uv-bar-col--peak .uv-bar-label {
    color: #78350F;
    font-weight: 700;
}


/* When current hour is also peak hour, offset Now indicator above the peak label */
.uv-bar-col--current.uv-bar-col--peak .uv-now-indicator {
    top: -16px;
}

/* Current hour marker */
.uv-bar-col--current .uv-bar-label {
    color: var(--sunlight-accent);
    font-weight: 700;
}

/* ---------------------------------------------------------------------------
   Now Indicator (current time arrow on bar chart)
   --------------------------------------------------------------------------- */

.uv-now-indicator {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.uv-now-indicator__arrow {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--sunlight-accent);
}

.uv-now-indicator__text {
    font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
    font-size: 9px;
    font-weight: 700;
    color: var(--sunlight-accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}

/* Peak indicator arrow below peak bar */
.uv-peak-indicator {
    font-size: 6px;
    line-height: 1;
    color: #78350F;
    margin-top: 1px;
}

/* Peak label annotation on peak bar */
.uv-peak-label {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
    font-size: 10px;
    font-weight: 700;
    color: #78350F;
    white-space: nowrap;
    line-height: 1;
    pointer-events: none;
}

/* Risk summary above chart */
.uv-chart-risk {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 8px;
    font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
    font-size: 12px;
}

.uv-chart-risk__level {
    font-weight: 700;
}

.uv-chart-risk__level--low { color: #22c55e; }
.uv-chart-risk__level--moderate { color: #a16207; }
.uv-chart-risk__level--high { color: #c2410c; }
.uv-chart-risk__level--very-high { color: #b91c1c; }
.uv-chart-risk__level--extreme { color: #7e22ce; }

.uv-chart-risk__window {
    font-weight: 500;
    color: #A8A29E;
}

/* ---------------------------------------------------------------------------
   Combined Week View — UV ring on dots
   --------------------------------------------------------------------------- */

/* UV ring border colors on week dots */
.day-dot.uv-ring--low { border-color: #22c55e; }
.day-dot.uv-ring--moderate { border-color: #eab308; }
.day-dot.uv-ring--high { border-color: #f97316; }
.day-dot.uv-ring--very-high { border-color: #ef4444; }
.day-dot.uv-ring--extreme { border-color: #a855f7; }

/* Logged + UV ring: keep logged fill with UV border */
.week-view--dots .week-day.logged .day-dot.uv-ring--low { border-color: #22c55e; }
.week-view--dots .week-day.logged .day-dot.uv-ring--moderate { border-color: #eab308; }
.week-view--dots .week-day.logged .day-dot.uv-ring--high { border-color: #f97316; }
.week-view--dots .week-day.logged .day-dot.uv-ring--very-high { border-color: #ef4444; }
.week-view--dots .week-day.logged .day-dot.uv-ring--extreme { border-color: #a855f7; }

/* UV peak number label under the dot */
.day-uv {
    font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
    font-size: 9px;
    font-weight: 700;
    color: #A8A29E;
    line-height: 1;
    margin-top: -2px;
}

/* Reset/Change location footer */
.uv-forecast__reset {
    background: none;
    border: none;
    font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
    color: #78716C;
    font-size: 12px;
    cursor: pointer;
    padding: 12px 0 0 0;
    text-decoration: underline;
    text-decoration-color: rgb(120 113 108 / 40%);
    text-underline-offset: 2px;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.uv-forecast__reset:hover {
    color: #92400E;
    text-decoration-color: #92400E;
}

/* ---------------------------------------------------------------------------
   Animations
   --------------------------------------------------------------------------- */

@keyframes uv-bar-grow {
    from { height: 3px; }
}

@keyframes uv-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .uv-bar {
        transition: none;
    }
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 480px) {
    .app-container {
        padding: 76px 16px 32px;
    }

    .sunlight-card {
        padding: 24px 20px 24px;
        border-radius: 16px;
        gap: 16px;
    }

    .hero-title {
        font-size: 20px;
    }

    .hero-subtitle {
        font-size: 14px;
    }

    .status-icon {
        font-size: 48px;
    }

    .sunlight-app-page .btn-primary.btn-primary {
        padding: 14px 36px;
        font-size: 15px;
        min-width: 180px;
        border-radius: 12px;
    }

    .week-view--dots .week-days {
        gap: 2px;
    }

    .week-view--dots .week-day {
        padding: 10px 6px;
    }

    .week-view--dots .day-dot {
        width: 24px;
        height: 24px;
    }

    .week-view--dots .day-label {
        font-size: 10px;
    }

    .streak-container {
        padding: 0;
    }

    .week-progress {
        padding-top: 4px;
    }

    /* UV Inline responsive */
    .uv-inline-prompt {
        gap: 8px;
        padding: 10px 12px;
    }

    .uv-current__value {
        font-size: 40px;
    }

    .uv-current__prefix {
        font-size: 12px;
    }

    .uv-bars {
        height: 70px;
    }

    .uv-bar-label {
        font-size: 7px;
    }

    .uv-peak-label {
        font-size: 9px;
    }

}

@media (min-width: 768px) {
    .app-container {
        max-width: 500px;
        padding: 32px;
    }

    .sunlight-card {
        padding: 32px;
        border-radius: 24px;
    }
}

@media (min-width: 1024px) {
    .app-container {
        max-width: 560px;
        padding: 40px;
    }
}
