/* ============================================
   CHROMASTRIP — Small Caps Formatter
   Aesthetic: Editorial Darkroom / Luxury Tool
   Matches Hex Color Cleaner suite
   ============================================ */

:root {
    --clr-bg: #0b0b0f;
    --clr-surface: #141419;
    --clr-surface-raised: #1c1c24;
    --clr-border: rgba(255, 255, 255, 0.06);
    --clr-border-focus: rgba(255, 255, 255, 0.15);
    --clr-text: #e8e6f0;
    --clr-text-muted: #6e6b7b;
    --clr-text-dim: #3d3b47;
    --clr-accent: #c4f55a;
    --clr-accent-glow: rgba(196, 245, 90, 0.15);
    --clr-accent-2: #f5c55a;
    --clr-accent-2-glow: rgba(245, 197, 90, 0.15);
    --clr-danger: #ff6b6b;
    --clr-success: #6bffc1;
    --clr-warm: #ffb86c;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --font-display: 'Instrument Serif', Georgia, serif;
    --font-body: 'Satoshi', -apple-system, sans-serif;
    --font-mono: 'DM Mono', 'SF Mono', monospace;
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Reset --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background-color: var(--clr-bg);
    color: var(--clr-text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem 1.5rem;
    overflow-x: hidden;
    position: relative;
}

::selection {
    background: var(--clr-accent-2);
    color: var(--clr-bg);
}

/* --- Ambient Background --- */
.ambient-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0;
    animation: glowPulse 14s ease-in-out infinite;
}

.glow-1 {
    width: 550px;
    height: 550px;
    background: radial-gradient(circle, rgba(245, 197, 90, 0.07), transparent 70%);
    top: -12%;
    left: -8%;
    animation-delay: 0s;
}

.glow-2 {
    width: 480px;
    height: 480px;
    background: radial-gradient(circle, rgba(196, 245, 90, 0.05), transparent 70%);
    bottom: -8%;
    right: -8%;
    animation-delay: 5s;
}

.glow-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(255, 184, 108, 0.04), transparent 70%);
    top: 40%;
    left: 60%;
    animation-delay: 9s;
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.12); }
}

.grain-overlay {
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    background-repeat: repeat;
    opacity: 0.5;
}

/* --- App Container --- */
.app {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    animation: fadeUp 0.8s var(--ease-out-expo) both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Top Bar --- */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0.25rem;
    margin-bottom: 3rem;
    animation: fadeUp 0.8s var(--ease-out-expo) 0.1s both;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.brand-mark {
    width: 10px;
    height: 10px;
    background: var(--clr-accent-2);
    border-radius: 3px;
    transform: rotate(45deg);
    box-shadow: 0 0 12px var(--clr-accent-2-glow);
}

.brand-name {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--clr-text-muted);
}

.topbar-tag {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--clr-text-dim);
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--clr-border);
    border-radius: 100px;
}

/* --- Hero --- */
.hero {
    margin-bottom: 2.5rem;
    padding: 0 0.25rem;
    animation: fadeUp 0.8s var(--ease-out-expo) 0.2s both;
}

.hero-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--clr-accent-2);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hero-label::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 1px;
    background: var(--clr-accent-2);
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 6vw, 3.2rem);
    font-weight: 400;
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: var(--clr-text);
    margin-bottom: 1rem;
}

.hero-title-italic {
    font-style: italic;
    color: var(--clr-accent-2);
}

.hero-desc {
    font-size: 1rem;
    line-height: 1.65;
    color: var(--clr-text-muted);
    max-width: 460px;
}

.hero-desc code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--clr-surface-raised);
    padding: 0.15em 0.45em;
    border-radius: var(--radius-sm);
    color: var(--clr-accent-2);
    border: 1px solid var(--clr-border);
}

/* --- Workspace --- */
.workspace {
    display: flex;
    flex-direction: column;
    animation: fadeUp 0.8s var(--ease-out-expo) 0.35s both;
}

/* --- Panels --- */
.panel {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.panel:hover {
    border-color: var(--clr-border-focus);
}

.panel-input {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
}

.panel-output {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    border-top: none;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--clr-border);
    background: rgba(255, 255, 255, 0.01);
}

.panel-header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--clr-text-dim);
    flex-shrink: 0;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.panel-dot.active {
    background: var(--clr-accent-2);
    box-shadow: 0 0 8px var(--clr-accent-2-glow);
}

.panel-dot-accent {
    background: var(--clr-accent-2);
    box-shadow: 0 0 8px var(--clr-accent-2-glow);
}

.panel-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--clr-text-muted);
}

.char-badge {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--clr-text-dim);
    padding: 0.2rem 0.55rem;
    border: 1px solid var(--clr-border);
    border-radius: 100px;
    transition: color 0.3s ease, border-color 0.3s ease;
}

.char-badge.has-content {
    color: var(--clr-text-muted);
    border-color: var(--clr-border-focus);
}

.panel-action {
    background: none;
    border: 1px solid var(--clr-border);
    color: var(--clr-text-dim);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

.panel-action:hover {
    border-color: var(--clr-border-focus);
    color: var(--clr-text);
    background: var(--clr-surface-raised);
}

/* --- Textarea --- */
.textarea-wrap {
    position: relative;
}

textarea {
    width: 100%;
    height: 150px;
    padding: 1.25rem;
    background: transparent;
    border: none;
    outline: none;
    resize: vertical;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--clr-text);
    caret-color: var(--clr-accent-2);
}

textarea::placeholder {
    color: var(--clr-text-dim);
    font-family: var(--font-body);
}

/* --- Action Bar --- */
.action-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
    position: relative;
    z-index: 2;
    background: var(--clr-surface);
    border-left: 1px solid var(--clr-border);
    border-right: 1px solid var(--clr-border);
}

.action-line {
    flex: 1;
    height: 1px;
    background: var(--clr-border);
}

.btn-convert {
    background: var(--clr-accent-2);
    border: none;
    cursor: pointer;
    border-radius: 100px;
    padding: 0;
    overflow: hidden;
    transition: transform 0.2s var(--ease-spring), box-shadow 0.3s ease;
    flex-shrink: 0;
}

.btn-convert:hover {
    transform: scale(1.04);
    box-shadow: 0 6px 30px var(--clr-accent-2-glow), 0 0 60px rgba(245, 197, 90, 0.06);
}

.btn-convert:active {
    transform: scale(0.97);
}

.btn-convert-inner {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.7rem 1.6rem;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--clr-bg);
    letter-spacing: 0.02em;
}

.live-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--clr-text-dim);
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--clr-border);
    border-radius: 100px;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.live-badge.active {
    color: var(--clr-success);
    border-color: rgba(107, 255, 193, 0.2);
}

.live-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--clr-text-dim);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.live-badge.active .live-dot {
    background: var(--clr-success);
    box-shadow: 0 0 6px rgba(107, 255, 193, 0.5);
    animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* --- Output --- */
.output-body {
    padding: 1.25rem;
    min-height: 80px;
}

.output-text {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--clr-text-muted);
    word-break: break-word;
    white-space: pre-wrap;
    transition: color 0.3s ease;
    user-select: all;
}

.output-text.has-content {
    color: var(--clr-text);
    font-size: 1.15rem;
    letter-spacing: 0.02em;
}

/* --- Character Map --- */
.charmap-section {
    border-top: 1px solid var(--clr-border);
}

.charmap-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1.25rem;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--clr-text-dim);
    transition: color 0.2s ease, background 0.2s ease;
}

.charmap-toggle:hover {
    color: var(--clr-text-muted);
    background: rgba(255, 255, 255, 0.015);
}

.charmap-chevron {
    margin-left: auto;
    font-size: 0.6rem;
    transition: transform 0.3s var(--ease-out-expo);
}

.charmap-chevron.open {
    transform: rotate(180deg);
}

.charmap-grid {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
    gap: 4px;
    padding: 0 1.25rem 1.25rem;
}

.charmap-grid.open {
    display: grid;
    animation: fadeUp 0.4s var(--ease-out-expo) both;
}

.charmap-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0.5rem 0.25rem;
    border-radius: var(--radius-sm);
    background: var(--clr-surface-raised);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.charmap-cell:hover {
    border-color: var(--clr-border-focus);
    background: rgba(255, 255, 255, 0.04);
    transform: translateY(-2px);
}

.charmap-cell:active {
    transform: translateY(0);
}

.charmap-original {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--clr-text-dim);
    line-height: 1;
}

.charmap-converted {
    font-size: 0.95rem;
    color: var(--clr-accent-2);
    line-height: 1;
}

/* --- Stats Bar --- */
.stats-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 1.5rem 0;
    margin-top: 1.5rem;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.5s var(--ease-out-expo);
    animation: fadeUp 0.8s var(--ease-out-expo) 0.5s both;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--clr-text);
    transition: color 0.3s ease;
}

.stat-label {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--clr-text-dim);
}

.stat-divider {
    width: 1px;
    height: 28px;
    background: var(--clr-border);
}

/* --- Toast Notification --- */
.toast {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 1.25rem;
    background: var(--clr-surface-raised);
    border: 1px solid var(--clr-border);
    border-radius: 100px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    transition: transform 0.5s var(--ease-spring);
    overflow: hidden;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--clr-success);
    color: var(--clr-bg);
    display: grid;
    place-items: center;
    font-size: 0.6rem;
    flex-shrink: 0;
}

.toast.error .toast-icon {
    background: var(--clr-danger);
}

#notification-text {
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--clr-text);
    white-space: nowrap;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--clr-accent-2);
    width: 100%;
    transform-origin: left;
    transform: scaleX(0);
}

.toast.show .toast-progress {
    animation: progressShrink 3s linear forwards;
}

.toast.error .toast-progress {
    background: var(--clr-danger);
}

@keyframes progressShrink {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* --- Footer --- */
.app-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 2.5rem 0 1rem;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--clr-text-dim);
    letter-spacing: 0.05em;
    animation: fadeUp 0.8s var(--ease-out-expo) 0.6s both;
}

.footer-sep {
    color: var(--clr-border-focus);
}

/* --- Home FAB --- */
.home-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    background: var(--clr-surface-raised);
    border: 1px solid var(--clr-border);
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--clr-text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    z-index: 100;
    transition: all 0.3s var(--ease-spring);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.home-fab:hover {
    background: var(--clr-accent-2);
    color: var(--clr-bg);
    border-color: var(--clr-accent-2);
    transform: scale(1.1);
    box-shadow: 0 8px 30px var(--clr-accent-2-glow);
}

/* --- Focus Visible --- */
*:focus-visible {
    outline: 2px solid var(--clr-accent-2);
    outline-offset: 2px;
}

textarea:focus-visible {
    outline: none;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--clr-text-dim);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--clr-text-muted);
}

/* --- Responsive --- */
@media (max-width: 640px) {
    body {
        padding: 1.25rem 1rem;
    }

    .hero-title {
        font-size: 2rem;
    }

    .hero {
        margin-bottom: 2rem;
    }

    .topbar {
        margin-bottom: 2rem;
    }

    .panel-header {
        padding: 0.75rem 1rem;
    }

    textarea {
        height: 120px;
        padding: 1rem;
        font-size: 0.92rem;
    }

    .output-body {
        padding: 1rem;
    }

    .btn-convert-inner {
        padding: 0.6rem 1.3rem;
        font-size: 0.8rem;
    }

    .stats-bar {
        gap: 1rem;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .home-fab {
        width: 42px;
        height: 42px;
        bottom: 1rem;
        right: 1rem;
    }

    .charmap-grid {
        grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    }
}

/* --- Shake animation (injected via JS but defined here as fallback) --- */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}