/* =====================================================================
   TypeRider Tool Stylesheet  -  v1.0
   Portable design system for any tool / utility page.
   Drop this file in and link it from <head>:
       <link rel="stylesheet" href="/assets/css/tool-styles.css">

   Provides:
     - CSS custom properties (light + dark themes via [data-theme="light"])
     - Typography (Space Mono + DM Sans)
     - .tool-wrap, .tool-panel layout primitives
     - .btn / .btn-primary / .btn-secondary
     - .info-grid + .info-card
     - .hero-label, .toast, .drop (file drop zones)
     - Form controls (input, textarea, select)
     - Stat cards, slider rows
     - Reduced-motion + focus-visible accessibility
   ===================================================================== */

/* ---------- Design tokens ---------- */
:root {
    --bg: #0d0d10;
    --surface: #16161c;
    --surface2: #1e1e27;
    --border: #2a2a38;
    --accent: #f5a623;
    --accent2: #e8855a;
    --text: #e8e8f0;
    --muted: #9090a8;
    --success: #4eca8b;
    --danger: #e74c3c;
    --mono: 'Space Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --sans: 'DM Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    --radius: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
    --bg: #f5f4f0;
    --surface: #ffffff;
    --surface2: #f0efe9;
    --border: #dddbd4;
    --text: #1a1a24;
    --muted: #8a8a9a;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

/* ---------- Accessibility ---------- */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- Tool layout primitives ---------- */
.tool-wrap {
    max-width: 900px;
    margin: 0 auto;
}

.tool-wrap h1 {
    font-size: 28px;
    font-weight: 300;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.tool-wrap p.desc {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 24px;
}

.hero-label {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 8px;
    text-decoration: none;
    display: block;
}

.tool-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.tool-panel label {
    display: block;
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin-bottom: 8px;
}

/* ---------- Form controls ---------- */
.tool-panel textarea {
    width: 100%;
    min-height: 140px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-family: var(--mono);
    font-size: 14px;
    resize: vertical;
    box-sizing: border-box;
}

.tool-panel input[type="text"],
.tool-panel input[type="email"],
.tool-panel input[type="url"],
.tool-panel input[type="number"],
.tool-panel input[type="search"],
.tool-panel input[type="password"],
.tool-panel input[type="tel"],
.tool-panel select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-family: var(--mono);
    font-size: 14px;
    margin-bottom: 12px;
    box-sizing: border-box;
}

.tool-panel input:focus,
.tool-panel textarea:focus,
.tool-panel select:focus {
    outline: none;
    border-color: var(--accent);
}

/* ---------- Buttons ---------- */
.btn-row {
    display: flex;
    gap: 10px;
    margin: 16px 0;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    line-height: 1.2;
}

.btn-primary {
    background: var(--accent);
    color: #111;
}

.btn-primary:hover {
    opacity: 0.85;
}

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

/* ---------- Info cards (always shown below the tool) ---------- */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 40px;
}

.info-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.info-card h4 {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--accent);
    margin-bottom: 8px;
}

.info-card p {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.6;
}

/* ---------- Stat cards (used in calculators) ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin: 20px 0;
}

.stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.stat-val {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    font-family: var(--mono);
}

.stat-lbl {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

/* ---------- Input grid (used in calculators) ---------- */
.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
}

.input-group input,
.input-group select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-family: var(--mono);
    font-size: 15px;
    width: 100%;
    box-sizing: border-box;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--accent);
}

/* ---------- File drop zone ---------- */
.drop {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    background: var(--bg);
    cursor: pointer;
    transition: all 0.2s;
}

.drop.over {
    border-color: var(--accent);
    background: var(--surface2);
}

.drop p {
    color: var(--muted);
    font-size: 14px;
    margin: 0;
}

/* ---------- Toast notification ---------- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--accent);
    color: #111;
    padding: 12px 20px;
    border-radius: 8px;
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 600;
    z-index: 999;
    animation: tr-slideIn 0.3s ease-out;
}

@keyframes tr-slideIn {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive helpers ---------- */
@media (max-width: 600px) {
    .input-grid { grid-template-columns: 1fr; }
    .stats { grid-template-columns: 1fr 1fr; }
}

/* ---------- Fake Error Preview ---------- */
.error-preview {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 16px;
}
.error-preview > .error-box {
    width: 80%;
    max-width: 80%;
    margin: 0;
}
