/* ========================================
   CSS Specificity Calculator Visual — Styles
   ======================================== */

/* -- Design Tokens -- */
:root {
    --bg-primary: #0a0a12;
    --bg-secondary: #12121e;
    --bg-card: rgba(20, 20, 35, 0.7);
    --bg-card-hover: rgba(25, 25, 45, 0.8);
    --bg-input: rgba(15, 15, 28, 0.9);

    --text-primary: #f0f0f5;
    --text-secondary: #9090aa;
    --text-muted: #606078;

    --color-primary: #6C63FF;
    --color-primary-glow: rgba(108, 99, 255, 0.3);
    --color-secondary: #E040FB;
    --color-accent: #00E5FF;

    --color-inline: #FF5252;
    --color-id: #FFD740;
    --color-class: #69F0AE;
    --color-element: #448AFF;

    --border-color: rgba(255, 255, 255, 0.06);
    --border-focus: var(--color-primary);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px var(--color-primary-glow);

    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-smooth: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(108, 99, 255, 0.12), transparent),
        radial-gradient(ellipse 60% 40% at 80% 60%, rgba(224, 64, 251, 0.06), transparent);
}

code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    padding: 2px 6px;
    background: rgba(108, 99, 255, 0.12);
    border-radius: 4px;
    color: var(--color-accent);
}

/* -- Glass Card -- */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* -- Layout -- */
.app-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100vh;
}

/* -- Header -- */
.app-header {
    padding: 24px 0 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 32px;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 18, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    flex-shrink: 0;
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.3;
}

.tagline {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.5px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* -- Buttons -- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
    white-space: nowrap;
}

.btn-primary {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--color-primary), #8B5CF6);
    color: #fff;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 28px var(--color-primary-glow);
}

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

.btn-ghost {
    padding: 8px 14px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover {
    background: rgba(108, 99, 255, 0.08);
    color: var(--text-primary);
    border-color: rgba(108, 99, 255, 0.3);
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: rgba(108, 99, 255, 0.1);
    color: var(--color-primary);
}

/* -- Main Content -- */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 60px;
}

/* -- Input Section -- */
.input-section {
    padding: 24px;
}

.input-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.input-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.input-field-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 4px 4px 4px 16px;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.input-field-container:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.input-prefix {
    color: var(--color-primary);
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    opacity: 0.7;
}

.selector-input {
    flex: 1;
    padding: 10px 8px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9375rem;
    min-width: 0;
}

.selector-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.quick-examples {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.examples-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.example-chip {
    padding: 4px 12px;
    border: 1px solid var(--border-color);
    border-radius: 100px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.example-chip:hover {
    background: rgba(108, 99, 255, 0.1);
    border-color: rgba(108, 99, 255, 0.3);
    color: var(--color-primary);
}

/* -- Empty State -- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-icon {
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 0.9375rem;
    margin-bottom: 4px;
}

.empty-hint {
    font-size: 0.8125rem;
    opacity: 0.7;
}

/* -- Results List -- */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* -- Result Card -- */
.result-card {
    padding: 20px 24px;
    animation: slideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
    transform: translateY(12px);
}

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.result-selector {
    font-family: var(--font-mono);
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-all;
    flex: 1;
}

.result-delete {
    color: var(--text-muted);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.result-card:hover .result-delete {
    opacity: 1;
}

.result-delete:hover {
    color: var(--color-inline) !important;
}

/* -- Specificity Score -- */
.specificity-score {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.score-segment {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
}

.score-segment.inline {
    border-color: rgba(255, 82, 82, 0.25);
}

.score-segment.id {
    border-color: rgba(255, 215, 64, 0.25);
}

.score-segment.class {
    border-color: rgba(105, 240, 174, 0.25);
}

.score-segment.element {
    border-color: rgba(68, 138, 255, 0.25);
}

.score-segment.highlight.inline {
    background: rgba(255, 82, 82, 0.1);
    border-color: rgba(255, 82, 82, 0.5);
}

.score-segment.highlight.id {
    background: rgba(255, 215, 64, 0.1);
    border-color: rgba(255, 215, 64, 0.5);
}

.score-segment.highlight.class {
    background: rgba(105, 240, 174, 0.1);
    border-color: rgba(105, 240, 174, 0.5);
}

.score-segment.highlight.element {
    background: rgba(68, 138, 255, 0.1);
    border-color: rgba(68, 138, 255, 0.5);
}

.score-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.score-segment.inline .score-value {
    color: var(--color-inline);
}

.score-segment.id .score-value {
    color: var(--color-id);
}

.score-segment.class .score-value {
    color: var(--color-class);
}

.score-segment.element .score-value {
    color: var(--color-element);
}

.score-label {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.score-separator {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    color: var(--text-muted);
    opacity: 0.4;
    align-self: center;
    margin-bottom: 16px;
}

/* -- Visual Bar -- */
.specificity-bar {
    height: 10px;
    border-radius: 100px;
    overflow: hidden;
    display: flex;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.04);
}

.bar-segment {
    height: 100%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0;
}

.bar-segment.inline {
    background: linear-gradient(90deg, var(--color-inline), #FF7043);
}

.bar-segment.id {
    background: linear-gradient(90deg, var(--color-id), #FFC107);
}

.bar-segment.class {
    background: linear-gradient(90deg, var(--color-class), #00E676);
}

.bar-segment.element {
    background: linear-gradient(90deg, var(--color-element), #2979FF);
}

/* -- Breakdown -- */
.breakdown {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.breakdown-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 8px;
}

.breakdown-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.breakdown-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 100px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.breakdown-tag.id {
    background: rgba(255, 215, 64, 0.1);
    color: var(--color-id);
    border-color: rgba(255, 215, 64, 0.2);
}

.breakdown-tag.class {
    background: rgba(105, 240, 174, 0.1);
    color: var(--color-class);
    border-color: rgba(105, 240, 174, 0.2);
}

.breakdown-tag.element {
    background: rgba(68, 138, 255, 0.1);
    color: var(--color-element);
    border-color: rgba(68, 138, 255, 0.2);
}

.breakdown-tag.pseudo-class {
    background: rgba(105, 240, 174, 0.1);
    color: var(--color-class);
    border-color: rgba(105, 240, 174, 0.2);
}

.breakdown-tag.pseudo-element {
    background: rgba(68, 138, 255, 0.1);
    color: var(--color-element);
    border-color: rgba(68, 138, 255, 0.2);
}

.breakdown-tag.attribute {
    background: rgba(105, 240, 174, 0.1);
    color: var(--color-class);
    border-color: rgba(105, 240, 174, 0.2);
}

.breakdown-tag.combinator {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    border-color: rgba(255, 255, 255, 0.08);
}

.breakdown-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.breakdown-tag.id .breakdown-dot {
    background: var(--color-id);
}

.breakdown-tag.class .breakdown-dot {
    background: var(--color-class);
}

.breakdown-tag.element .breakdown-dot {
    background: var(--color-element);
}

.breakdown-tag.pseudo-class .breakdown-dot {
    background: var(--color-class);
}

.breakdown-tag.pseudo-element .breakdown-dot {
    background: var(--color-element);
}

.breakdown-tag.attribute .breakdown-dot {
    background: var(--color-class);
}

.breakdown-tag.combinator .breakdown-dot {
    background: var(--text-muted);
}

/* -- Comparison Section -- */
.comparison-section {
    padding: 24px;
}

.comparison-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.comparison-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.badge {
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.6875rem;
    font-weight: 600;
    background: rgba(108, 99, 255, 0.12);
    color: var(--color-primary);
}

.chart-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.chart-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chart-label {
    width: 140px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
}

.chart-bar-wrapper {
    flex: 1;
    height: 28px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
}

.chart-bar-segment {
    height: 100%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-bar-segment.inline {
    background: var(--color-inline);
}

.chart-bar-segment.id {
    background: var(--color-id);
}

.chart-bar-segment.class {
    background: var(--color-class);
}

.chart-bar-segment.element {
    background: var(--color-element);
}

.chart-total {
    width: 60px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: left;
    flex-shrink: 0;
}

.comparison-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* -- Reference Section -- */
.reference-section {
    padding: 24px;
}

.reference-section h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
}

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

.ref-card {
    padding: 16px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    text-align: center;
    transition: all var(--transition-base);
}

.ref-card:hover {
    background: rgba(255, 255, 255, 0.04);
    transform: translateY(-2px);
}

.ref-score {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.ref-score.inline {
    color: var(--color-inline);
}

.ref-score.id {
    color: var(--color-id);
}

.ref-score.class {
    color: var(--color-class);
}

.ref-score.element {
    color: var(--color-element);
}

.ref-card h3 {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.ref-card p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* -- Modal -- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    max-width: 560px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 28px;
    animation: scaleIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 700;
}

.modal-body p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 16px;
    line-height: 1.7;
}

.help-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.help-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
}

.help-badge {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.help-badge.inline {
    background: rgba(255, 82, 82, 0.15);
    color: var(--color-inline);
}

.help-badge.id {
    background: rgba(255, 215, 64, 0.15);
    color: var(--color-id);
}

.help-badge.class {
    background: rgba(105, 240, 174, 0.15);
    color: var(--color-class);
}

.help-badge.element {
    background: rgba(68, 138, 255, 0.15);
    color: var(--color-element);
}

.help-item strong {
    font-size: 0.8125rem;
    display: block;
    margin-bottom: 2px;
}

.help-item p {
    font-size: 0.8125rem;
    margin-bottom: 0;
    color: var(--text-muted);
}

.help-note {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: rgba(108, 99, 255, 0.08);
    border: 1px solid rgba(108, 99, 255, 0.15);
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* -- Toast -- */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    font-size: 0.8125rem;
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.success {
    border-color: rgba(105, 240, 174, 0.3);
}

.toast.error {
    border-color: rgba(255, 82, 82, 0.3);
}

@keyframes toastIn {
    from {
        transform: translateY(12px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.toast-exit {
    animation: toastOut 0.2s ease forwards;
}

@keyframes toastOut {
    to {
        transform: translateY(12px);
        opacity: 0;
    }
}

/* -- Responsive -- */
@media (max-width: 640px) {
    .app-container {
        padding: 0 12px;
    }

    .header-content {
        flex-wrap: wrap;
    }

    .header-actions .btn span {
        display: none;
    }

    .input-section {
        padding: 16px;
    }

    .input-field-container {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
    }

    .input-prefix {
        display: none;
    }

    .selector-input {
        font-size: 0.875rem;
    }

    .input-field-container .btn-primary {
        justify-content: center;
    }

    .specificity-score {
        flex-wrap: wrap;
    }

    .score-segment {
        min-width: calc(50% - 4px);
    }

    .score-separator {
        display: none;
    }

    .chart-label {
        width: 80px;
        font-size: 0.6875rem;
    }

    .comparison-legend {
        gap: 8px;
    }

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

    .quick-examples {
        gap: 6px;
    }

    .modal {
        padding: 20px;
        margin: 12px;
    }
}

@media (max-width: 400px) {
    .reference-grid {
        grid-template-columns: 1fr;
    }

    .score-segment {
        min-width: 100%;
    }
}