/*
   WORD COUNTER - EXPERT WEB TOOLS
*/

@font-face { font-family: 'Inter';       src: url('/fonts/inter-v20-latin-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Orbitron';    src: url('/fonts/orbitron-v35-latin-700.woff2')  format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Roboto Mono'; src: url('/fonts/roboto-mono-v31-latin-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
    --bg-dark:          #0a0a0f;
    --primary-accent:   #3b82f6;
    --secondary-accent: #8b5cf6;
    --text-main:        #ffffff;
    --text-muted:       #94a3b8;
    --card-bg:          rgba(25, 25, 35, 0.6);
    --card-border:      rgba(255, 255, 255, 0.08);
    --input-bg:         rgba(255, 255, 255, 0.05);
    --font-heading:     'Orbitron', sans-serif;
    --font-body:        'Inter', sans-serif;
    --font-code:        'Roboto Mono', monospace;
}

/* Light Theme Variables */
html.light-theme {
    --bg-dark:          #f8fafc;
    --primary-accent:   #2563eb;
    --secondary-accent: #7c3aed;
    --text-main:        #0f172a;
    --text-muted:       #475569;
    --card-bg:          #ffffff;
    --card-border:      rgba(0, 0, 0, 0.1);
    --input-bg:         #f1f5f9;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    width: 100%;
    max-width: 100%;
    transition: background-color 0.2s ease;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

/* --- Accessibility --- */
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}

/* Custom Scrollbars */
::-webkit-scrollbar        { width: 8px; height: 8px; }
::-webkit-scrollbar-track  { background: rgba(150,150,150,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb  { background: rgba(150,150,150,0.3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(150,150,150,0.5); }

textarea {
    scrollbar-width: thin;
    scrollbar-color: rgba(150,150,150,0.3) transparent;
}

.background-glow {
    position: fixed; top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle at center, rgba(59,130,246,0.08) 0%, rgba(10,10,15,0) 50%);
    z-index: -1; pointer-events: none;
}
html.light-theme .background-glow {
    background: radial-gradient(circle at center, rgba(37,99,235,0.05) 0%, transparent 50%);
}

/* --- Header --- */
.tool-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.5rem 5%; max-width: 1400px; margin: 0 auto; width: 100%;
    flex-wrap: wrap; gap: 10px;
}
.header-right {
    display: flex; align-items: center; gap: 1rem;
}
.back-btn {
    color: var(--text-muted); text-decoration: none;
    display: flex; align-items: center; gap: 8px;
    transition: color 0.3s; border-radius: 4px; padding: 2px 4px;
}
.back-btn:hover         { color: var(--primary-accent); }
.back-btn:focus-visible { outline: 2px solid var(--primary-accent); color: var(--primary-accent); }
.logo      { font-family: var(--font-heading); font-size: 1.2rem; }
.logo span { color: var(--primary-accent); }

/* Theme Toggle Button */
.theme-toggle-btn {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 1.25rem; transition: color 0.2s; padding: 6px;
    display: flex; align-items: center; justify-content: center;
}
.theme-toggle-btn:hover         { color: var(--primary-accent); }
.theme-toggle-btn:focus-visible { outline: 2px solid var(--primary-accent); border-radius: 4px; }


/* --- Main Layout --- */
.main-content   { flex-grow: 1; padding: 2rem 5%; max-width: 1000px; margin: 0 auto; width: 100%; }
.tool-container { display: flex; flex-direction: column; gap: 1.5rem; }

/* Cards */
.card {
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: 16px; padding: 1.5rem;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 15px 50px rgba(0,0,0,0.1);
}

.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem; gap: 10px;
}
.card-title {
    font-family: var(--font-heading); font-size: 1.5rem; margin: 0; color: var(--text-main);
}
.card h3 {
    font-family: var(--font-heading); font-size: 1rem; color: var(--text-muted);
    margin-bottom: 1rem; display: flex; align-items: center; gap: 8px;
    text-transform: uppercase; letter-spacing: 1px;
}
.card h3 i { color: var(--primary-accent); }

/* Input Area */
.input-card textarea {
    width: 100%; min-height: 250px;
    background: var(--input-bg); border: 1px solid var(--card-border);
    border-radius: 8px; padding: 1rem; color: var(--text-main);
    font-family: var(--font-body); font-size: 1.1rem;
    line-height: 1.6; resize: vertical; outline: none;
    transition: border-color 0.2s;
}
.input-card textarea:focus         { border-color: var(--primary-accent); }
.input-card textarea:focus-visible { outline: none; }

.action-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.icon-btn {
    background: transparent; border: 1px solid var(--card-border);
    color: var(--text-muted);
    min-width: 44px; min-height: 44px;
    border-radius: 8px; cursor: pointer; transition: all 0.2s;
    font-size: 1rem; display: flex; align-items: center; justify-content: center;
    font-family: var(--font-body);
}
.icon-btn:hover         { border-color: var(--primary-accent); color: var(--primary-accent); background: rgba(59,130,246,0.1); }
.icon-btn:focus-visible { outline: 2px solid var(--primary-accent); }
.icon-btn.remove:hover  { border-color: #ef4444; color: #ef4444; background: rgba(239,68,68,0.1); }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    gap: 1.5rem;
}

/* Metrics List */
.metrics-list { display: flex; flex-direction: column; gap: 12px; }
.metric-item {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid rgba(150,150,150,0.2); padding-bottom: 8px;
}
.metric-item:last-child { border-bottom: none; }
.metric-item .label     { color: var(--text-muted); font-size: 0.9rem; }
.metric-item .value     { font-family: var(--font-code); font-size: 1.2rem; font-weight: bold; color: var(--text-main); }
.metric-item .value.highlight { color: var(--primary-accent); }

/* Progress Bars */
.progress-section { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 15px; }
.progress-group   { font-size: 0.85rem; }
.progress-label   { display: flex; justify-content: space-between; margin-bottom: 5px; color: var(--text-muted); }

.progress-counter                { color: var(--text-muted); font-family: var(--font-code); transition: color 0.2s; }
.progress-counter.count-warning  { color: #f59e0b; }
.progress-counter.count-exceeded { color: #ef4444; }

.progress-track { width: 100%; height: 6px; background: rgba(150,150,150,0.2); border-radius: 3px; overflow: hidden; }
.progress-fill  {
    height: 100%; width: 0%;
    background: var(--primary-accent); border-radius: 3px;
    transition: width 0.3s ease, background-color 0.3s ease;
}
.progress-fill.limit-warning  { background: #f59e0b; }
.progress-fill.limit-exceeded { background: #ef4444; }

/* Keyword List */
.keyword-list   { list-style: none; max-height: 220px; overflow-y: auto; padding-right: 4px; }
.keyword-list::-webkit-scrollbar       { width: 5px; }
.keyword-list::-webkit-scrollbar-thumb { background: rgba(150,150,150,0.3); border-radius: 3px; }

.keyword-list li {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0; border-bottom: 1px solid rgba(150,150,150,0.2); font-size: 0.9rem;
}
.keyword-list li:last-child { border-bottom: none; }
.keyword-name   { color: var(--text-main); word-break: break-word; margin-right: 8px; }
.keyword-stats  { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.keyword-count  {
    color: var(--primary-accent); font-family: var(--font-code); font-weight: bold;
    background: rgba(59,130,246,0.1); padding: 2px 8px;
    border-radius: 12px; font-size: 0.85rem;
}
.keyword-density { color: var(--text-muted); font-size: 0.8rem; width: 45px; text-align: right; }
.placeholder     { color: var(--text-muted); font-style: italic; text-align: center; padding: 1rem 0; }

/* Toast Notification */
.toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: #1e1e24; border: 1px solid var(--primary-accent);
    color: #fff; padding: 10px 20px; border-radius: 8px; z-index: 2000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    font-size: 0.9rem; white-space: nowrap;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s;
}
html.light-theme .toast { background: #ffffff; color: #0f172a; border-color: var(--primary-accent); }
.toast.toast-visible { opacity: 1; pointer-events: auto; }
.toast.toast-error   { border-color: #ef4444; }
.toast.toast-info    { border-color: var(--primary-accent); }
.hidden { display: none !important; }

/* Info Section */
.info-section {
    margin-top: 4rem; padding: 0 1rem;
    max-width: 1000px; margin-left: auto; margin-right: auto;
}
.info-section > h2 {
    font-family: var(--font-heading); color: var(--text-main);
    margin-bottom: 2rem; font-size: 1.5rem; text-align: center;
    margin-top: 4rem;
}
.info-grid   { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 2rem; margin-bottom: 2rem; }
.info-grid h3 { color: var(--primary-accent); font-family: var(--font-heading); font-size: 1.1rem; margin-bottom: 0.5rem; }
.info-grid i  { margin-right: 8px; }
.info-grid p  { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; }

.faq-container    { margin-top: 2rem; max-width: 800px; margin-left: auto; margin-right: auto; background: var(--card-bg); padding: 2rem; border-radius: 16px; border: 1px solid var(--card-border); }
.faq-container h3 { font-family: var(--font-heading); color: var(--text-main); margin-bottom: 1.5rem; border-bottom: 1px solid var(--card-border); padding-bottom: 0.5rem; }
.faq-container h4 { color: var(--secondary-accent); font-size: 1rem; margin-bottom: 0.5rem; margin-top: 1.5rem; font-family: var(--font-body); }
.faq-container p  { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 1rem; line-height: 1.6; }

footer       { text-align: center; padding: 3rem 0; color: var(--text-muted); font-size: 0.9rem; border-top: 1px solid var(--card-border); margin-top: 3rem; }
footer a     { color: var(--text-main); text-decoration: none; }
footer a:hover { color: var(--primary-accent); text-decoration: underline; }

/* === RESPONSIVE === */

@media (max-width: 768px) {
    .stats-grid  { grid-template-columns: 1fr; }
    .info-grid   { grid-template-columns: 1fr; }
    .input-card textarea { resize: none; min-height: 200px; }
    .action-buttons { gap: 6px; }
}

@media (max-width: 480px) {
    .tool-header    { padding: 1rem; flex-direction: column; align-items: flex-start; }
    .header-right   { display: flex; width: 100%; justify-content: space-between; flex-direction: row-reverse; }
    .main-content   { padding: 1rem; }
    .card           { padding: 1rem; border-radius: 12px; }
    .card-title     { font-size: 1.2rem; }
    .card h3        { font-size: 0.85rem; }
    .input-card textarea { font-size: 1rem; min-height: 160px; }
    .metric-item .value  { font-size: 1rem; }
    .keyword-count  { padding: 2px 6px; font-size: 0.8rem; }
    .action-buttons { gap: 4px; }
    .icon-btn       { min-width: 40px; min-height: 40px; font-size: 0.9rem; }
    .info-grid      { grid-template-columns: 1fr; }
    .faq-container  { padding: 1.5rem 1rem; }
    .faq-container h3 { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration:  0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}