/* ═══════════════════════════════════════════════════════════
   Free Bounce — Tools UI Kit
   Unified preset stack for all tool pages.
   Derived from the main site's visual identity.

   Usage:
     <link rel="stylesheet" href="../css/tools-kit.css">
     <link rel="stylesheet" href="../css/sliders.css">
     <link rel="stylesheet" href="../css/watermark.css">

   Set accent on <body>:
     data-accent="blue"    → all tools
     default               → silver (main site brand)
   ═══════════════════════════════════════════════════════════ */

/* ─── 1. RESET ─── */
*, ::before, ::after { box-sizing: border-box; margin: 0; padding: 0; }
html { line-height: 1.5; -webkit-text-size-adjust: 100%; tab-size: 4; }
body { line-height: inherit; }
h1, h2, h3, h4, h5, h6 { font-size: inherit; font-weight: inherit; }
a { color: inherit; text-decoration: inherit; }
ul, ol { list-style: none; }
img, svg, video, canvas, audio, iframe { display: block; vertical-align: middle; }
img, video { max-width: 100%; height: auto; }
button, input, select, textarea { font-family: inherit; font-size: 100%; font-weight: inherit; line-height: inherit; color: inherit; margin: 0; padding: 0; }
button { cursor: pointer; background: transparent; border: none; }

/* ─── 2. DESIGN TOKENS ─── */
:root {
    /* Surfaces */
    --tk-bg:        #000000;
    --tk-surface:   #141414;
    --tk-panel:     #1a1a1a;
    --tk-raised:    #222222;
    --tk-border:    #2a2a2a;
    --tk-border-lt: rgba(255,255,255,0.06);

    /* Text */
    --tk-text:      #e4e4e7;
    --tk-text-dim:  #a1a1aa;
    --tk-text-mute: #71717a;

    /* Accent (default: silver/blue brand) */
    --tk-accent:       #94a3b8;
    --tk-accent-vivid: #38bdf8;
    --tk-accent-glow:  56,189,248;
    --tk-accent-bg:    rgba(56,189,248,0.08);
    --tk-accent-bg-h:  rgba(56,189,248,0.15);

    /* Spacing scale */
    --tk-sp-1: 4px;
    --tk-sp-2: 8px;
    --tk-sp-3: 12px;
    --tk-sp-4: 16px;
    --tk-sp-5: 20px;
    --tk-sp-6: 24px;
    --tk-sp-8: 32px;

    /* Radius */
    --tk-radius-sm: 6px;
    --tk-radius:    8px;
    --tk-radius-lg: 12px;
    --tk-radius-xl: 16px;
    --tk-radius-full: 9999px;

    /* Transitions */
    --tk-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --tk-dur:  0.2s;

    /* Typography */
    --tk-font:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --tk-font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
}

/* Blue accent (all tools) */
[data-accent="blue"] {
    --tk-accent:       #3b82f6;
    --tk-accent-vivid: #60a5fa;
    --tk-accent-glow:  59,130,246;
    --tk-accent-bg:    rgba(59,130,246,0.08);
    --tk-accent-bg-h:  rgba(59,130,246,0.15);
}

/* ─── 3. BASE ─── */
body {
    font-family: var(--tk-font);
    background-color: var(--tk-bg);
    color: var(--tk-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    width: 100vw;
    height: 100dvh;
}

/* ─── 4. SURFACES ─── */
.tk-panel {
    background: var(--tk-panel);
    border: 1px solid var(--tk-border);
    border-radius: var(--tk-radius-lg);
}

.tk-raised {
    background: var(--tk-raised);
    border: 1px solid var(--tk-border);
    border-radius: var(--tk-radius);
}

.tk-inset {
    background: var(--tk-surface);
    border: 1px solid rgba(0,0,0,0.4);
    border-radius: var(--tk-radius);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

/* ─── 5. HEADER / TOOLBAR ─── */
.tk-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--tk-sp-3) var(--tk-sp-4);
    background: var(--tk-panel);
    border-bottom: 1px solid var(--tk-border);
    flex-shrink: 0;
    z-index: 10;
}

.tk-header-title {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.02em;
    color: var(--tk-text);
}

.tk-header-sub {
    font-size: 11px;
    color: var(--tk-text-mute);
    font-family: var(--tk-font-mono);
}

.tk-header-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--tk-sp-1);
    padding: var(--tk-sp-1) var(--tk-sp-2);
    background: var(--tk-accent-bg);
    color: var(--tk-accent-vivid);
    border-radius: var(--tk-radius-sm);
    font-size: 11px;
    font-weight: 600;
}

/* ─── 6. BUTTONS ─── */
.tk-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--tk-sp-2);
    padding: var(--tk-sp-2) var(--tk-sp-4);
    border-radius: var(--tk-radius);
    font-size: 13px;
    font-weight: 600;
    transition: all var(--tk-dur) var(--tk-ease);
    user-select: none;
}

.tk-btn:active { transform: scale(0.96); }

.tk-btn-primary {
    background: var(--tk-accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(var(--tk-accent-glow), 0.25);
}
.tk-btn-primary:hover {
    filter: brightness(1.15);
    box-shadow: 0 4px 16px rgba(var(--tk-accent-glow), 0.35);
}

.tk-btn-secondary {
    background: var(--tk-raised);
    color: var(--tk-text-dim);
    border: 1px solid var(--tk-border);
}
.tk-btn-secondary:hover {
    background: var(--tk-panel);
    color: var(--tk-text);
    border-color: rgba(255,255,255,0.1);
}

.tk-btn-ghost {
    background: transparent;
    color: var(--tk-text-dim);
}
.tk-btn-ghost:hover {
    background: var(--tk-accent-bg);
    color: var(--tk-text);
}

.tk-btn-icon {
    width: 36px; height: 36px;
    padding: 0;
    border-radius: var(--tk-radius-full);
    background: var(--tk-raised);
    color: var(--tk-text-dim);
    border: 1px solid var(--tk-border);
}
.tk-btn-icon:hover {
    background: var(--tk-panel);
    color: var(--tk-text);
}

.tk-btn-accent-icon {
    width: 48px; height: 48px;
    padding: 0;
    border-radius: var(--tk-radius-full);
    background: var(--tk-accent);
    color: #fff;
    box-shadow: 0 4px 12px rgba(var(--tk-accent-glow), 0.3);
}
.tk-btn-accent-icon:hover {
    filter: brightness(1.1);
    box-shadow: 0 6px 20px rgba(var(--tk-accent-glow), 0.4);
}

/* ─── 7. DROP ZONE ─── */
.tk-dropzone {
    position: relative;
    border: 2px dashed var(--tk-border);
    border-radius: var(--tk-radius-xl);
    background: var(--tk-surface);
    transition: all 0.3s var(--tk-ease);
    overflow: hidden;
}
.tk-dropzone.dragover {
    border-color: var(--tk-accent);
    background: var(--tk-accent-bg);
    transform: scale(1.005);
}
.tk-dropzone.active {
    box-shadow: inset 0 0 40px rgba(var(--tk-accent-glow), 0.1);
    border-color: rgba(var(--tk-accent-glow), 0.3);
}

.tk-dropzone-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--tk-text-mute);
    pointer-events: none;
    transition: opacity 0.3s;
}

/* ─── 8. LABELS & VALUES ─── */
.tk-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tk-text-mute);
}

.tk-value {
    font-size: 12px;
    font-family: var(--tk-font-mono);
    color: var(--tk-accent-vivid);
}

.tk-mono {
    font-family: var(--tk-font-mono);
}

/* ─── 9. SCROLLBAR ─── */
.tk-scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.tk-scroll::-webkit-scrollbar { width: 4px; height: 4px; }
.tk-scroll::-webkit-scrollbar-track { background: var(--tk-surface); }
.tk-scroll::-webkit-scrollbar-thumb { background: var(--tk-border); border-radius: 2px; }

/* ─── 10. COLOR INPUT ─── */
input[type=color] {
    -webkit-appearance: none; appearance: none;
    border: none; width: 32px; height: 32px;
    padding: 0; overflow: hidden;
    border-radius: var(--tk-radius-sm);
    cursor: pointer;
    background: transparent;
}
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: none; border-radius: 4px; }

/* ─── 11. LOADING OVERLAY ─── */
.tk-loading {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--tk-sp-4);
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.tk-loading.visible { display: flex; }
.tk-loading-text {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* ─── 12. TOAST ─── */
.tk-toast {
    position: fixed;
    bottom: var(--tk-sp-6);
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    padding: var(--tk-sp-2) var(--tk-sp-4);
    background: var(--tk-panel);
    border: 1px solid var(--tk-accent);
    border-radius: var(--tk-radius);
    font-size: 13px;
    color: var(--tk-text);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}
.tk-toast.visible { opacity: 1; }

/* ─── 13. TABS ─── */
.tk-tabs {
    display: flex;
    border-bottom: 1px solid var(--tk-border);
    flex-shrink: 0;
}
.tk-tab {
    flex: 1;
    padding: var(--tk-sp-2) var(--tk-sp-3);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
    color: var(--tk-text-mute);
    border-bottom: 2px solid transparent;
    transition: all var(--tk-dur);
    cursor: pointer;
    background: none;
}
.tk-tab:hover { color: var(--tk-text-dim); }
.tk-tab.active {
    color: #fff;
    border-bottom-color: var(--tk-accent);
    background: var(--tk-accent-bg);
}

/* ─── 14. DIVIDERS ─── */
.tk-divider {
    height: 1px;
    background: var(--tk-border);
    border: none;
}

/* ─── 15. TOGGLE / SWITCH ─── */
.tk-toggle {
    position: relative;
    width: 36px; height: 20px;
    background: var(--tk-raised);
    border: 1px solid var(--tk-border);
    border-radius: var(--tk-radius-full);
    cursor: pointer;
    transition: background var(--tk-dur);
}
.tk-toggle::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--tk-text-dim);
    transition: transform var(--tk-dur), background var(--tk-dur);
}
.tk-toggle.on {
    background: var(--tk-accent);
    border-color: var(--tk-accent);
}
.tk-toggle.on::after {
    transform: translateX(16px);
    background: #fff;
}

/* ─── 16. ANIMATIONS ─── */
@keyframes tk-spin { to { transform: rotate(360deg); } }
@keyframes tk-fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes tk-slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.tk-spin { animation: tk-spin 1s linear infinite; }
.tk-fade-in { animation: tk-fadeIn 0.3s var(--tk-ease) forwards; }
.tk-slide-up { animation: tk-slideUp 0.3s var(--tk-ease) forwards; }

/* ─── 17. MODAL ─── */
.tk-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--tk-sp-4);
}
.tk-modal-backdrop.visible { display: flex; }

.tk-modal {
    background: var(--tk-panel);
    border: 1px solid var(--tk-border);
    border-radius: var(--tk-radius-xl);
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    overflow: hidden;
    max-height: 90vh;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
}

.tk-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--tk-sp-4);
    border-bottom: 1px solid var(--tk-border);
    background: var(--tk-raised);
}

.tk-modal-body {
    padding: var(--tk-sp-5);
    overflow-y: auto;
}

/* ─── 18. INFO BANNER ─── */
.tk-info {
    padding: var(--tk-sp-3);
    background: var(--tk-accent-bg);
    border: 1px solid rgba(var(--tk-accent-glow), 0.2);
    border-radius: var(--tk-radius);
    font-size: 11px;
    color: var(--tk-accent-vivid);
    line-height: 1.5;
}

/* ─── 19. SELECT / INPUT ─── */
.tk-select {
    width: 100%;
    padding: var(--tk-sp-2) var(--tk-sp-3);
    background: var(--tk-raised);
    border: 1px solid var(--tk-border);
    border-radius: var(--tk-radius);
    color: var(--tk-text);
    font-size: 13px;
    outline: none;
}
.tk-select:focus { border-color: var(--tk-accent); }

.tk-input {
    background: var(--tk-raised);
    border: 1px solid var(--tk-border);
    border-radius: var(--tk-radius);
    padding: var(--tk-sp-2) var(--tk-sp-3);
    color: var(--tk-text);
    font-size: 13px;
    outline: none;
}
.tk-input:focus { border-color: var(--tk-accent); }

/* ─── 20. BADGE ─── */
.tk-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: var(--tk-radius-sm);
    background: var(--tk-accent-bg);
    color: var(--tk-accent-vivid);
}
