:root {
    --font-ui: "Figtree", system-ui, sans-serif;
    --font-display: "Fraunces", Georgia, "Times New Roman", serif;

    --ink: #152028;
    --ink-soft: rgba(21, 32, 40, 0.72);
    --ink-faint: rgba(21, 32, 40, 0.48);
    --paper: rgba(247, 250, 248, 0.82);
    --paper-strong: rgba(255, 255, 255, 0.92);
    --line: rgba(21, 32, 40, 0.1);
    --accent: #1f6f6a;
    --accent-soft: rgba(31, 111, 106, 0.14);
    --shadow: 0 14px 40px rgba(18, 36, 42, 0.12);
    --radius: 20px;
    --radius-sm: 14px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --max: 880px;
    --pad: clamp(0.85rem, 3vw, 1.5rem);
}

body[data-theme="night"] {
    --ink: #eef4f2;
    --ink-soft: rgba(238, 244, 242, 0.78);
    --ink-faint: rgba(238, 244, 242, 0.5);
    --paper: rgba(12, 20, 26, 0.72);
    --paper-strong: rgba(18, 28, 36, 0.88);
    --line: rgba(238, 244, 242, 0.14);
    --accent: #7ec8bf;
    --accent-soft: rgba(126, 200, 191, 0.18);
    --shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font-ui);
    color: var(--ink);
    line-height: 1.45;
    background:
        radial-gradient(1000px 640px at 8% -8%, rgba(164, 214, 208, 0.42), transparent 55%),
        radial-gradient(860px 520px at 100% 0%, rgba(242, 214, 168, 0.32), transparent 50%),
        linear-gradient(165deg, #d7ebe6 0%, #eef3ef 45%, #d9e4df 100%);
    background-attachment: fixed;
    overflow-x: hidden;
    transition: color 0.45s var(--ease), background 0.55s var(--ease);
}

body[data-theme="night"] {
    background:
        radial-gradient(900px 560px at 12% -12%, rgba(48, 86, 102, 0.55), transparent 55%),
        radial-gradient(760px 480px at 100% 8%, rgba(28, 48, 72, 0.6), transparent 50%),
        linear-gradient(165deg, #0d161c 0%, #15232c 48%, #101820 100%);
}

.bg-video {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -2;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s var(--ease);
}

.bg-video.is-ready {
    opacity: 0.38;
}

body[data-theme="night"] .bg-video.is-ready {
    opacity: 0.32;
}

.sky-overlay {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(
        180deg,
        rgba(247, 250, 248, 0.58) 0%,
        rgba(247, 250, 248, 0.16) 38%,
        rgba(247, 250, 248, 0.78) 100%
    );
}

body[data-theme="night"] .sky-overlay {
    background: linear-gradient(
        180deg,
        rgba(8, 14, 18, 0.58) 0%,
        rgba(8, 14, 18, 0.26) 40%,
        rgba(8, 14, 18, 0.82) 100%
    );
}

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

.app {
    width: min(100% - (var(--pad) * 2), var(--max));
    margin: 0 auto;
    padding: var(--pad) 0 calc(var(--pad) + 2rem);
}

/* ——— Top bar ——— */
.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem 1rem;
    margin-bottom: 1.35rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    flex: 0 0 auto;
}

.search {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex: 1 1 auto;
    width: 100%;
    max-width: 440px;
    min-width: 0;
    height: 48px;
    margin-left: auto;
    padding: 0.25rem 0.25rem 0.25rem 0.85rem;
    background: var(--paper-strong);
    border: 1px solid var(--line);
    border-radius: 14px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
    transition: border-color 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease;
}

.search:focus-within {
    border-color: rgba(31, 111, 106, 0.45);
    box-shadow: var(--shadow), 0 0 0 4px var(--accent-soft);
}

.search-icon {
    color: var(--ink-faint);
    flex-shrink: 0;
}

.search input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    outline: none;
    font: inherit;
    font-size: 0.95rem;
    color: var(--ink);
    padding: 0.55rem 0.35rem;
}

.search input::placeholder {
    color: var(--ink-faint);
}

.search-btn {
    border: none;
    cursor: pointer;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    color: #f7faf8;
    background: var(--accent);
    padding: 0 1rem;
    height: 100%;
    min-height: 40px;
    border-radius: 10px;
    white-space: nowrap;
    flex: 0 0 auto;
    transition: transform 0.2s var(--ease), filter 0.2s ease;
}

.search-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.search-btn:active {
    transform: translateY(0);
}

body[data-theme="night"] .search-btn {
    color: #0f1c18;
}

body.is-refreshing .search {
    opacity: 0.7;
    pointer-events: none;
}

/* ——— Status ——— */
.status-line {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-height: 42vh;
    color: var(--ink-soft);
    font-size: 1rem;
}

body.is-loading .status-line,
body.is-error .status-line {
    display: flex;
    animation: fade-in 0.4s ease both;
}

body.is-loading .content,
body.is-error .content {
    display: none !important;
}

.loader {
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

body.is-error .loader {
    display: none;
}

/* ——— Content ——— */
.content {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

.content.is-animating > * {
    animation: rise 0.65s var(--ease) both;
}

.content.is-animating > *:nth-child(1) { animation-delay: 0.04s; }
.content.is-animating > *:nth-child(2) { animation-delay: 0.1s; }
.content.is-animating > *:nth-child(3) { animation-delay: 0.16s; }
.content.is-animating > *:nth-child(4) { animation-delay: 0.22s; }

/* ——— Hero ——— */
.hero {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: clamp(1.15rem, 3vw, 1.7rem);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) + 2px);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
}

.hero-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem 1rem;
}

.hero-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.hero-region {
    font-size: 0.85rem;
    color: var(--ink-faint);
}

.dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--ink-faint);
    flex-shrink: 0;
}

.hero-main {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem 1.5rem;
}

.hero-copy {
    flex: 1 1 200px;
    min-width: 0;
}

#city {
    font-family: var(--font-display);
    font-size: clamp(2rem, 6vw, 3.25rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.08;
    color: var(--ink);
    margin-bottom: 0.4rem;
    word-break: break-word;
}

.condition {
    font-size: clamp(0.98rem, 2.4vw, 1.1rem);
    color: var(--ink-soft);
}

.hero-temp {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
    flex: 0 0 auto;
    color: var(--ink);
}

.condition-icon {
    width: 64px;
    height: 64px;
    object-fit: contain;
    filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.14));
    animation: float-icon 5s ease-in-out infinite;
}

.temp-block {
    display: flex;
    align-items: flex-start;
    line-height: 1;
}

.temp-value {
    font-family: var(--font-display);
    font-size: clamp(4.2rem, 14vw, 6.4rem);
    font-weight: 600;
    letter-spacing: -0.05em;
    color: var(--ink);
    line-height: 0.92;
}

.temp-unit {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 4vw, 2.1rem);
    font-weight: 600;
    color: var(--ink-soft);
    margin-top: 0.35em;
}

.hi-lo {
    font-size: 0.92rem;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}

/* ——— Metrics ——— */
.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.65rem;
}

.metric {
    padding: 0.95rem 1rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 0.28s var(--ease), background 0.28s ease, border-color 0.28s ease;
}

.metric:hover {
    transform: translateY(-3px);
    background: var(--paper-strong);
    border-color: rgba(31, 111, 106, 0.28);
}

.metric-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ink-faint);
    margin-bottom: 0.35rem;
}

.metric-value {
    display: block;
    font-size: clamp(1.05rem, 2.5vw, 1.2rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

/* ——— Panels ——— */
.panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0 0.1rem;
}

.panel-head h2 {
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 3vw, 1.4rem);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.panel-hint {
    font-size: 0.78rem;
    color: var(--ink-faint);
    flex-shrink: 0;
}

.hourly-track {
    display: flex;
    gap: 0.65rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    padding: 0.2rem 0.05rem 0.65rem;
    -webkit-overflow-scrolling: touch;
    cursor: grab;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.hourly-track::-webkit-scrollbar {
    display: none;
}

.hourly-track.is-dragging {
    cursor: grabbing;
    scroll-behavior: auto;
    scroll-snap-type: none;
    user-select: none;
}

.hourly-track:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 12px;
}

.hour-card {
    flex: 0 0 auto;
    width: 86px;
    min-height: 128px;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.35rem;
    padding: 0.85rem 0.5rem;
    text-align: center;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--ink);
    cursor: inherit;
    transition: transform 0.25s var(--ease), background 0.25s ease, border-color 0.25s ease;
}

.content.is-animating .hour-card {
    animation: rise 0.5s var(--ease) both;
}

.hour-card:hover {
    transform: translateY(-4px);
    background: var(--paper-strong);
    border-color: rgba(31, 111, 106, 0.3);
}

.hour-card.is-now {
    background: var(--accent-soft);
    border-color: rgba(31, 111, 106, 0.4);
}

.hour-time {
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--ink-soft);
}

.hour-card img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    display: block;
}

.hour-temp {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.daily-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.day-row {
    display: grid;
    grid-template-columns: 4.2rem 2rem minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.65rem;
    padding: 0.8rem 0.95rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--ink);
    transition: transform 0.25s var(--ease), background 0.25s ease;
}

.content.is-animating .day-row {
    animation: rise 0.5s var(--ease) both;
}

.day-row:hover {
    transform: translateX(3px);
    background: var(--paper-strong);
}

.day-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.day-row img {
    width: 34px;
    height: 34px;
    object-fit: contain;
}

.day-cond {
    font-size: 0.88rem;
    color: var(--ink-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.day-temps {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.day-high {
    font-weight: 700;
    font-size: 1rem;
    color: var(--ink);
}

.day-low {
    color: var(--ink-faint);
    font-size: 0.9rem;
}

/* ——— Motion ——— */
@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes float-icon {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ——— Breakpoints ——— */
@media (max-width: 640px) {
    .topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .search {
        flex: 0 0 auto;
        max-width: none;
        margin-left: 0;
        width: 100%;
        height: 48px;
        min-height: 48px;
        max-height: 48px;
        border-radius: 12px;
    }

    .hero-temp {
        align-items: flex-start;
        width: 100%;
    }

    .hero-main {
        flex-direction: column;
        align-items: flex-start;
    }

    .condition-icon {
        width: 56px;
        height: 56px;
    }

    .day-row {
        grid-template-columns: 3.4rem 1.9rem minmax(0, 1fr) auto;
        gap: 0.45rem;
        padding: 0.75rem 0.8rem;
    }

    .day-cond {
        font-size: 0.8rem;
    }
}

@media (max-width: 420px) {
    .search-btn {
        padding: 0.52rem 0.72rem;
        font-size: 0.78rem;
    }

    .metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hour-card {
        width: 78px;
        min-height: 118px;
        padding: 0.75rem 0.4rem;
    }

    .day-cond {
        display: none;
    }

    .day-row {
        grid-template-columns: 3.2rem 1.8rem auto;
    }
}

@media (min-width: 900px) {
    .app {
        padding-top: 1.75rem;
    }

    .metrics {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1100px) {
    .metrics {
        grid-template-columns: repeat(6, 1fr);
    }
}
