/* ==========================================================================
   Sala de Muestras - Flavor Mapping Tool
   Art Direction: Warm, artisanal, sophisticated coffee aesthetic
   Production-ready with touch optimizations
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600&family=DM+Sans:wght@400;500&display=swap');

:root {
    /* Warm, earthy palette inspired by coffee */
    --bg-color: #f7f5f2;
    --bg-warm: #f2ede6;
    --text-color: #2c2418;
    --text-warm: #4a3f2f;
    --secondary-text: #8b7e6a;
    --accent-coffee: #6b4423;
    --accent-cream: #d4c4a8;
    --accent-green: #5a7247;
    --accent-red: #a94438;
    
    /* Glassmorphism with warmth */
    --widget-bg: rgba(247, 245, 242, 0.88);
    --widget-border: rgba(107, 68, 35, 0.12);
    --shadow-soft: 0 8px 32px rgba(44, 36, 24, 0.08);
    --shadow-lifted: 0 12px 48px rgba(44, 36, 24, 0.12);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Touch target minimum */
    --touch-target-min: 44px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

html {
    touch-action: manipulation;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-color);
    background-image: 
        radial-gradient(ellipse at 20% 30%, rgba(212, 196, 168, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(107, 68, 35, 0.06) 0%, transparent 50%);
    color: var(--text-color);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
    /* Prevent pull-to-refresh on mobile */
    overscroll-behavior: none;
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ==========================================================================
   Stopwatch Widget - Refined, unobtrusive
   ========================================================================== */

.stopwatch-widget {
    position: fixed;
    top: 24px;
    right: 24px;
    background: var(--widget-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 20px;
    padding: 18px 22px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--widget-border);
    z-index: 100;
    min-width: 150px;
    transition: var(--transition);
}

.stopwatch-widget:hover {
    box-shadow: var(--shadow-lifted);
    transform: translateY(-2px);
}

.stopwatch-display {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 32px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    text-align: center;
    margin-bottom: 14px;
    color: var(--text-warm);
}

.centiseconds {
    font-size: 20px;
    color: var(--secondary-text);
    font-weight: 400;
}

.stopwatch-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.sw-btn {
    /* Touch-friendly: minimum 44px */
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    border-radius: 50%;
    border: 1.5px solid var(--widget-border);
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-warm);
    color: var(--text-warm);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    user-select: none;
}

.sw-btn.primary {
    background: rgba(90, 114, 71, 0.12);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.sw-btn.primary.running {
    background: rgba(169, 68, 56, 0.12);
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.sw-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.sw-btn:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.sw-btn:active:not(:disabled) {
    transform: scale(0.95);
    background: var(--accent-cream);
}

.lap-list {
    max-height: 100px;
    overflow-y: auto;
    margin-top: 14px;
    border-top: 1px solid var(--widget-border);
    padding-top: 10px;
    display: none;
    -webkit-overflow-scrolling: touch;
}

.lap-list:not(:empty) {
    display: block;
}

.lap-item {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    color: var(--text-warm);
}

.lap-item span:first-child {
    color: var(--secondary-text);
    font-weight: 500;
}

/* ==========================================================================
   Search Box
   ========================================================================== */

.search-container {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 100;
    width: 320px;
}

.search-input {
    width: 100%;
    /* Touch-friendly padding */
    padding: 14px 16px;
    min-height: var(--touch-target-min);
    background: var(--widget-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--widget-border);
    border-radius: 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 16px; /* Prevents iOS zoom on focus */
    color: var(--text-warm);
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
    touch-action: manipulation;
}

.search-input::placeholder {
    color: var(--secondary-text);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-coffee);
    box-shadow: var(--shadow-lifted);
}

.search-results {
    margin-top: 8px;
    max-height: 250px;
    overflow-y: auto;
    background: var(--widget-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--widget-border);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    display: none;
    -webkit-overflow-scrolling: touch;
}

.search-results.visible {
    display: block;
}

.search-result-item {
    /* Touch-friendly: minimum 44px height */
    padding: 14px 16px;
    min-height: var(--touch-target-min);
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--widget-border);
    font-size: 14px;
    color: var(--text-warm);
    touch-action: manipulation;
}

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

.search-result-item:hover,
.search-result-item:active {
    background: var(--bg-warm);
}

.search-result-item.no-results {
    cursor: default;
    color: var(--secondary-text);
    font-style: italic;
}

.search-result-item.no-results:hover,
.search-result-item.no-results:active {
    background: transparent;
}

/* ==========================================================================
   Main Content & Flavor Wheel
   ========================================================================== */

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
}

#flavor-wheel {
    width: 100%;
    height: calc(100vh - 120px);
    max-height: 850px;
    touch-action: pan-x pan-y;
}

/* ==========================================================================
   Flavor Info - Top centered on desktop, bottom card on mobile
   ========================================================================== */

#flavor-info {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    background: transparent;
    padding: 8px 16px;
    z-index: 50;
    min-height: 24px;
    pointer-events: none;
}

#flavor-name {
    display: none; /* Hidden on desktop */
}

#flavor-path {
    font-family: 'DM Sans', sans-serif;
    color: var(--secondary-text);
    font-size: 12px;
    letter-spacing: 0.04em;
    font-weight: 400;
    white-space: nowrap;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

#flavor-path.visible {
    opacity: 1;
}

/* ==========================================================================
   Sunburst Wheel Interactions
   ========================================================================== */

.slice {
    cursor: pointer;
    transition: fill-opacity 0.2s ease, filter 0.2s ease;
    touch-action: manipulation;
}

.slice:hover {
    filter: brightness(1.05);
}

/* Touch feedback for wheel slices */
.slice.touched {
    filter: brightness(1.1);
}

/* ==========================================================================
   Mobile Toggle Button
   ========================================================================== */

.toggle-btn {
    display: none;
    position: fixed;
    bottom: 110px;
    right: 24px;
    /* Touch-friendly size */
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1.5px solid var(--widget-border);
    background: var(--widget-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: var(--shadow-soft);
    font-size: 24px;
    cursor: pointer;
    z-index: 100;
    transition: var(--transition);
    color: var(--accent-coffee);
    touch-action: manipulation;
    user-select: none;
}

.toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lifted);
}

.toggle-btn:active {
    transform: scale(0.95);
    background: var(--accent-cream);
}

/* ==========================================================================
   Mobile Responsive Design
   ========================================================================== */

@media (max-width: 767px) {
    body {
        overflow-y: auto;
    }
    
    .stopwatch-widget {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        border-radius: 0 0 24px 24px;
        display: none;
        padding: 48px 24px 24px;
        box-shadow: var(--shadow-lifted);
    }
    
    .stopwatch-widget.visible {
        display: block;
        animation: slideDown 0.3s ease;
    }
    
    @keyframes slideDown {
        from { transform: translateY(-100%); opacity: 0; }
        to { transform: translateY(0); opacity: 1; }
    }
    
    .stopwatch-display {
        font-size: 56px;
    }
    
    .centiseconds {
        font-size: 32px;
    }
    
    .sw-btn {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
    
    .toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    main {
        padding: 12px;
        padding-bottom: 100px; /* Room for bottom info card */
    }
    
    #flavor-wheel {
        height: calc(100vh - 180px);
    }
    
    /* Mobile: Bottom info card */
    #flavor-info {
        position: fixed;
        top: auto;
        bottom: 24px;
        left: 12px;
        right: 12px;
        transform: none;
        background: var(--widget-bg);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        border: 1px solid var(--widget-border);
        border-radius: 16px;
        padding: 14px 18px;
        box-shadow: var(--shadow-soft);
        min-height: 56px;
        pointer-events: auto;
    }
    
    #flavor-name {
        display: block;
        font-family: 'Cormorant Garamond', Georgia, serif;
        font-size: 20px;
        font-weight: 500;
        color: var(--text-warm);
        margin-bottom: 2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    #flavor-path {
        font-size: 11px;
        white-space: normal;
        line-height: 1.4;
        opacity: 0.8;
    }
    
    #flavor-path.visible {
        opacity: 1;
    }
    
    .search-container {
        top: 12px;
        left: 12px;
        right: 12px;
        width: auto;
    }
    
    .search-input {
        font-size: 16px;
        padding: 12px 14px;
    }
    
    .search-results {
        max-height: 200px;
    }
    
    .search-result-item {
        padding: 16px;
        min-height: 48px;
    }
}

/* ==========================================================================
   Tablet / Touch Desktop
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
    /* Touch-only device optimizations */
    .sw-btn:hover:not(:disabled) {
        transform: none;
        box-shadow: none;
    }
    
    .toggle-btn:hover {
        transform: none;
        box-shadow: var(--shadow-soft);
    }
    
    .search-result-item:hover {
        background: transparent;
    }
    
    .slice:hover {
        filter: none;
    }
}

/* ==========================================================================
   Custom Scrollbar
   ========================================================================== */

.lap-list::-webkit-scrollbar,
.search-results::-webkit-scrollbar {
    width: 4px;
}

.lap-list::-webkit-scrollbar-track,
.search-results::-webkit-scrollbar-track {
    background: transparent;
}

.lap-list::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb {
    background: var(--accent-cream);
    border-radius: 2px;
}

.lap-list::-webkit-scrollbar-thumb:hover,
.search-results::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-text);
}

/* ==========================================================================
   Subtle Animations
   ========================================================================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#flavor-wheel svg {
    animation: fadeIn 0.6s ease;
}

/* ==========================================================================
   Print Styles (hide interactive elements)
   ========================================================================== */

@media print {
    .stopwatch-widget,
    .search-container,
    .toggle-btn,
    #flavor-info {
        display: none !important;
    }
    
    body {
        background: white;
    }
}
