/* ============================================
   DESIGN SYSTEM - CSS VARIABLES
   ============================================ */
:root {
    /* Light Theme - Warm Neutrals */
    --bg-primary: hsl(40 20% 98%);
    --bg-secondary: hsl(40 15% 96%);
    --bg-muted: hsl(40 10% 94%);
    --text-primary: hsl(220 20% 10%);
    --text-secondary: hsl(220 10% 40%);
    --text-muted: hsl(220 5% 60%);
    --border: hsl(40 10% 88%);
    
    /* Amber Accent */
    --primary: hsl(35 90% 50%);
    --primary-hover: hsl(35 90% 45%);
    --primary-light: hsl(35 90% 95%);
    
    /* Shadows */
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-large: 0 10px 15px rgba(0, 0, 0, 0.1);
    
    /* Success */
    --success: hsl(142 71% 45%);
    --success-light: hsl(142 71% 95%);
    
    /* Danger */
    --danger: hsl(0 84% 60%);
}

[data-theme="dark"] {
    /* Dark Theme - Deep Navy */
    --bg-primary: hsl(220 25% 8%);
    --bg-secondary: hsl(220 20% 12%);
    --bg-muted: hsl(220 15% 16%);
    --text-primary: hsl(40 20% 98%);
    --text-secondary: hsl(40 15% 75%);
    --text-muted: hsl(40 10% 55%);
    --border: hsl(220 15% 20%);
    
    --primary: hsl(35 90% 50%);
    --primary-hover: hsl(35 90% 55%);
    --primary-light: hsl(35 90% 15%);
    
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-large: 0 10px 15px rgba(0, 0, 0, 0.5);
    
    --success: hsl(142 71% 50%);
    --success-light: hsl(142 71% 15%);
}

/* ============================================
   BASE STYLES - Mobile Optimized
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
}

/* Mobile touch optimizations */
button, a, .btn-clear, .btn-copy, .theme-toggle {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-width: 44px;
    min-height: 44px;
}

/* ============================================
   HEADER - Frozen/Sticky
   ============================================ */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

[data-theme="dark"] .header {
    background: rgba(15, 20, 35, 0.7);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Logo icon container - NO BLINK FIX */
.logo-icon {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Logo images - overlapping for smooth transition */
.logo-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

/* Light theme logo visibility */
[data-theme="light"] .logo-light,
html:not([data-theme]) .logo-light {
    opacity: 1;
    visibility: visible;
    z-index: 2;
}

[data-theme="light"] .logo-dark,
html:not([data-theme]) .logo-dark {
    opacity: 0;
    visibility: hidden;
    z-index: 1;
}

/* Dark theme logo visibility */
[data-theme="dark"] .logo-light {
    opacity: 0;
    visibility: hidden;
    z-index: 1;
}

[data-theme="dark"] .logo-dark {
    opacity: 1;
    visibility: visible;
    z-index: 2;
}

/* Custom icon option (if using single icon instead of theme-switching) */
.logo-custom-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

/* Remove any fallback icon */
.logo-fallback {
    display: none !important;
}

.logo-text {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.theme-toggle {
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    background: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background: var(--bg-secondary);
}

.theme-toggle svg {
    width: 1.25rem;
    height: 1.25rem;
    transition: transform 0.3s ease;
}

/* Theme toggle icon colors */
[data-theme="dark"] .theme-toggle svg {
    color: white;
    stroke: white;
    stroke-width: 2;
}

[data-theme="light"] .theme-toggle svg {
    color: hsl(220 20% 10%);
    stroke: hsl(220 20% 10%);
}

.theme-toggle.rotating svg {
    animation: rotate360 0.6s ease;
}

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

/* ============================================
   CONTAINER & LAYOUT
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ============================================
   HERO SECTION
   ============================================ */
.hero {
    text-align: center;
    margin-bottom: 3rem;
}

.hero-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary), hsl(35 90% 60%));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-description {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* ============================================
   SANITIZER CARD
   ============================================ */
.sanitizer-card {
    background: var(--bg-secondary);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--shadow-medium);
    margin-bottom: 3rem;
}

.sanitizer-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: var(--bg-muted);
    border-color: var(--primary);
    color: var(--primary);
}

.action-btn svg {
    width: 1rem;
    height: 1rem;
}

.action-btn.success {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success);
}

textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    resize: vertical;
    transition: all 0.2s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

textarea::placeholder {
    color: var(--text-muted);
}

/* ============================================
   SANITIZE BUTTON
   ============================================ */
.btn-primary {
    width: 70px;
    height: 70px;
    border-radius: 70px;
    border: none;
    background: linear-gradient(135deg, var(--primary), hsl(35 90% 60%));
    color: white;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: var(--shadow-medium);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    width: 220px;
    transform: translateY(-2px);
    box-shadow: var(--shadow-large);
}

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

.btn-icon {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-icon svg {
    width: 1.5rem;
    height: 1.5rem;
}

/* Custom sanitize icon - sized to fill the 70px button, mirrored.
   No filter needed: logo-icon.png has a transparent background,
   so the cream-coloured stars render directly on the orange button. */
.sanitize-icon {
    width: 2.75rem;
    height: 2.75rem;
    object-fit: contain;
    /* no mirror — logo-icon.png mini star is already upper-left */
}

/* Fade+shrink icon on hover. Uses opacity instead of
   transform: scale(0) alone, so it doesn't overwrite
   the scaleX(-1) mirror on the child img. */
.btn-primary:hover .btn-icon {
    opacity: 0;
    transform: scale(0);
}

.btn-text {
    position: absolute;
    white-space: nowrap;
    transform: scale(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary:hover .btn-text {
    transform: scale(1);
}

/* ============================================
   STATS BAR
   ============================================ */
.stats-bar {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    animation: slideUp 0.3s ease;
}

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

.stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.stat:hover {
    background: var(--bg-secondary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Size Reduction - Vibrant Orange */
.stat-accent .stat-value {
    color: hsl(35 90% 50%);
}

/* ============================================
   REFERENCE SECTION
   ============================================ */
.reference {
    margin-bottom: 3rem;
}

.reference-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.reference-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.ref-section {
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
}

.ref-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.ref-section-header svg {
    width: 1.5rem;
    height: 1.5rem;
    color: var(--primary);
}

.ref-section-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.ref-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ref-list li {
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.ref-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: bold;
}

.ref-list code {
    background: var(--bg-muted);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--primary);
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 2rem 1.5rem;
    margin-top: 4rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.footer-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.footer-copy {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.footer-copy a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.footer-copy a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* ============================================
   RESPONSIVE - Mobile
   ============================================ */
@media (max-width: 768px) {
    .sanitizer-panels {
        grid-template-columns: 1fr;
    }
    
    .stats-bar {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .logo-icon,
    .logo-custom-icon {
        width: 32px;
        height: 32px;
    }
}

/* Retina display support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo-custom-icon {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}
