/* Temperature Snake Helper - Mobile-First PWA */
/* A cozy, crafty aesthetic for temperature tracking */

:root {
    /* Earthy, yarn-inspired palette */
    --color-bg: #f7f3ed;
    --color-bg-warm: #faf6f0;
    --color-surface: #ffffff;
    --color-primary: #2d5a4a;
    --color-primary-light: #3d7a64;
    --color-primary-dark: #1d3a32;
    --color-accent: #e07b53;
    --color-accent-light: #f4a582;
    --color-text: #2a2a28;
    --color-text-muted: #6b6b67;
    --color-border: #e5e0d8;
    
    /* Temperature gradient colors */
    --temp-cold: #4a90d9;
    --temp-cool: #7ec8e3;
    --temp-mild: #98d977;
    --temp-warm: #f9d057;
    --temp-hot: #e85d4c;
    
    /* Typography */
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Borders & Shadows */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 100px;
    --shadow-sm: 0 2px 8px rgba(45, 90, 74, 0.06);
    --shadow-md: 0 4px 20px rgba(45, 90, 74, 0.1);
    --shadow-lg: 0 8px 40px rgba(45, 90, 74, 0.12);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100dvh;
    overflow-x: hidden;
    
    /* Subtle yarn texture pattern */
    background-image: 
        radial-gradient(ellipse at 20% 30%, rgba(224, 123, 83, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(45, 90, 74, 0.03) 0%, transparent 50%),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0c1 10 5 15 15 15-10 0-14 5-15 15-1-10-5-15-15-15 10 0 14-5 15-15z' fill='%232d5a4a' fill-opacity='0.02'/%3E%3C/svg%3E");
}

/* App Container */
.app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: var(--space-md);
    padding-bottom: env(safe-area-inset-bottom, var(--space-md));
}

/* Header */
.header {
    text-align: center;
    padding: var(--space-xl) 0 var(--space-lg);
    animation: fadeSlideDown 0.6s ease-out;
}

.snake-icon {
    font-size: 3.5rem;
    line-height: 1;
    margin-bottom: var(--space-sm);
    animation: wiggle 3s ease-in-out infinite;
    display: inline-block;
}

.back-to-hub {
    display: inline-block;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-primary);
    text-decoration: none;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    transition: background 0.2s;
    margin-bottom: var(--space-sm);
}

.back-to-hub:hover {
    background: rgba(45, 90, 74, 0.08);
}

@keyframes wiggle {
    0%, 100% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
}

.header h1 {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-xs);
}

.subtitle {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

/* Main Content */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* Search Form */
.search-form {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    animation: fadeSlideUp 0.5s ease-out 0.1s both;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-wrapper {
    position: relative;
    display: flex;
    gap: var(--space-sm);
}

.input-wrapper input {
    flex: 1;
}

input[type="text"],
input[type="date"] {
    width: 100%;
    padding: var(--space-md);
    font-family: var(--font-body);
    font-size: 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-warm);
    color: var(--color-text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="date"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(45, 90, 74, 0.1);
}

input[type="date"] {
    cursor: pointer;
}

/* Webkit date picker styling */
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.locate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-warm);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.locate-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.locate-btn:active {
    transform: scale(0.95);
}

/* Submit Button */
.submit-btn {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 500;
    color: white;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-sm), 0 4px 12px rgba(45, 90, 74, 0.25);
    position: relative;
    overflow: hidden;
    margin-top: var(--space-sm);
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), 0 6px 20px rgba(45, 90, 74, 0.3);
}

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

.submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-loading {
    display: none;
}

.submit-btn.loading .btn-text {
    display: none;
}

.submit-btn.loading .btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

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

/* Result Card */
.result-card {
    display: none;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-xl) var(--space-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: fadeScaleIn 0.4s ease-out;
}

.result-card.visible {
    display: block;
}

.result-header {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
}

.result-date {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--color-primary);
}

.result-location {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.result-temp {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0.1em;
    margin-bottom: var(--space-sm);
}

.temp-value {
    font-family: var(--font-display);
    font-size: 5rem;
    font-weight: 700;
    line-height: 1;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.temp-unit {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 300;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
}

.result-label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-lg);
}

/* Temperature Bar */
.temp-bar {
    height: 12px;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, 
        var(--temp-cold) 0%, 
        var(--temp-cool) 25%, 
        var(--temp-mild) 50%, 
        var(--temp-warm) 75%, 
        var(--temp-hot) 100%
    );
    position: relative;
    margin-bottom: var(--space-sm);
}

.temp-bar-fill {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.3);
}

.temp-bar-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: white;
    border: 3px solid var(--color-primary);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: left 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.temp-scale {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* Error Card */
.error-card {
    display: none;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-xl) var(--space-lg);
    box-shadow: var(--shadow-md);
    text-align: center;
    border: 2px solid var(--color-accent-light);
    animation: shake 0.5s ease-out;
}

.error-card.visible {
    display: block;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.error-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-md);
}

.error-message {
    color: var(--color-text);
    margin-bottom: var(--space-lg);
    line-height: 1.5;
}

.retry-btn {
    padding: var(--space-sm) var(--space-lg);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-accent);
    background: transparent;
    border: 2px solid var(--color-accent);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s;
}

.retry-btn:hover {
    background: var(--color-accent);
    color: white;
}

/* History Section */
.history-section {
    display: none;
    animation: fadeSlideUp 0.4s ease-out;
}

.history-section.visible {
    display: block;
}

.history-section h2 {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.history-item:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.history-item:active {
    transform: scale(0.98);
}

.history-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-item-date {
    font-weight: 500;
    font-size: 0.9rem;
}

.history-item-location {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.history-item-temp {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
}

.clear-history-btn {
    width: 100%;
    padding: var(--space-sm);
    margin-top: var(--space-md);
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color 0.2s;
}

.clear-history-btn:hover {
    color: var(--color-accent);
}

/* Footer */
.footer {
    text-align: center;
    padding: var(--space-xl) 0 var(--space-md);
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.footer a {
    color: var(--color-primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.footer-note {
    margin-top: var(--space-xs);
    opacity: 0.7;
}

/* Animations */
@keyframes fadeSlideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes fadeScaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* PWA Install Prompt (optional enhancement) */
.install-prompt {
    position: fixed;
    bottom: var(--space-lg);
    left: var(--space-md);
    right: var(--space-md);
    max-width: 480px;
    margin: 0 auto;
    padding: var(--space-md) var(--space-lg);
    background: var(--color-primary);
    color: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: none;
    align-items: center;
    gap: var(--space-md);
    animation: fadeSlideUp 0.4s ease-out;
    z-index: 100;
}

.install-prompt.visible {
    display: flex;
}

.install-prompt-text {
    flex: 1;
    font-size: 0.9rem;
}

.install-prompt-btn {
    padding: var(--space-sm) var(--space-md);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-primary);
    background: white;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    white-space: nowrap;
}

.install-prompt-close {
    padding: var(--space-sm);
    background: transparent;
    border: none;
    color: white;
    opacity: 0.7;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #1a1f1c;
        --color-bg-warm: #232a26;
        --color-surface: #2a322d;
        --color-text: #e8e6e3;
        --color-text-muted: #9a9a96;
        --color-border: #3a423c;
    }
    
    .temp-value {
        background: linear-gradient(135deg, #5aab8c 0%, var(--color-accent-light) 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }
}

/* Larger phones / small tablets */
@media (min-width: 400px) {
    .header h1 {
        font-size: 2rem;
    }
    
    .temp-value {
        font-size: 6rem;
    }
}

