@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Inter:wght@400;500;600;700&display=swap');

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #020617;
    --surface: #0f172a;
    --surface-hover: #1e293b;
    --border: #1e293b;
    --border-focus: #0ea5e9;
    --accent: #38bdf8;
    --accent-dim: rgba(56, 189, 248, 0.15);
    --accent-glow: rgba(56, 189, 248, 0.4);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --error: #f87171;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --row-h: 104px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(56, 189, 248, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(56, 189, 248, 0.03) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
    z-index: 0;
}

.container {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 80px 24px 60px;
}

/* ---------- Header ---------- */
header {
    text-align: center;
    margin-bottom: 56px;
    animation: fadeDown 0.8s ease-out;
}

@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.logo-icon {
    color: var(--accent);
    filter: drop-shadow(0 0 12px var(--accent-glow));
}

.logo h1 {
    font-family: var(--font-mono);
    font-size: 2.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* ---------- No-JS banner ---------- */
.noscript-banner {
    padding: 14px 20px;
    margin-bottom: 20px;
    background: rgba(248, 113, 113, 0.1);
    border-left: 3px solid var(--error);
    color: var(--error);
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

/* ---------- Shorten card ---------- */
.shorten-card {
    background: var(--surface);
    border: 1px solid var(--border);
    margin-bottom: 32px;
    animation: fadeUp 0.6s ease-out 0.1s both;
    position: relative;
    overflow: hidden;
}

.shorten-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.6;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.shorten-form {
    display: block;
}

/* The row: 3 columns, all stretched to the same height */
.input-wrapper {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--border);
    min-height: var(--row-h);
}

/* Icon cell - flex centers the SVG inside its own box */
.input-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
    color: var(--text-dim);
    flex-shrink: 0;
    transition: color 0.2s;
}

.input-icon svg {
    display: block;
    width: 24px;
    height: 24px;
}

/* The input itself - vertical padding drives the row height */
#urlInput {
    flex: 1;
    min-width: 0;
    padding: 24px 16px;
    line-height: 1.4;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 1.125rem;
    outline: none;
    transition: color 0.2s;
}

#urlInput::placeholder {
    color: var(--text-dim);
    font-family: var(--font-sans);
}

/* Submit button - flex centers its text */
#shortenBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 48px;
    background: var(--accent);
    color: var(--bg);
    border: none;
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

#shortenBtn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
    opacity: 0;
    transition: opacity 0.2s;
}

#shortenBtn:hover::after {
    opacity: 1;
}

#shortenBtn:hover {
    background: #7dd3fc;
    box-shadow: 0 0 24px var(--accent-glow);
}

#shortenBtn:active {
    transform: scale(0.98);
}

#shortenBtn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

#shortenBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-loader {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--bg);
    border-top-color: transparent;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- Error / result ---------- */
.error-message {
    padding: 14px 20px;
    background: rgba(248, 113, 113, 0.1);
    border-left: 3px solid var(--error);
    color: var(--error);
    font-size: 0.9rem;
    font-family: var(--font-mono);
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.error-message ul {
    margin: 0.4rem 0 0 1.2rem;
    padding: 0;
    list-style: disc;
}

.error-message li {
    margin: 0.15rem 0;
}

.result {
    padding: 20px;
    background: var(--accent-dim);
    border-left: 3px solid var(--accent);
    animation: resultIn 0.35s ease-out;
}

@keyframes resultIn {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0); }
}

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

.result-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.result-icon {
    color: var(--accent);
    flex-shrink: 0;
}

#shortUrlDisplay {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--accent);
    font-size: 0.95rem;
    word-break: break-all;
}

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

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all 0.15s;
}

.action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

.action-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- Stats ---------- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    margin-bottom: 40px;
    animation: fadeUp 0.6s ease-out 0.2s both;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 28px 24px;
    text-align: left;
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: var(--accent);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.stat-card:hover::after {
    transform: scaleX(1);
}

.stat-card:hover {
    border-color: var(--border-focus);
    background: var(--surface-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.stat-icon {
    color: var(--accent);
    margin-bottom: 14px;
    opacity: 0.9;
}

.stat-number {
    display: block;
    font-family: var(--font-mono);
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 6px;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
}

/* ---------- Footer ---------- */
footer {
    text-align: center;
    margin-top: 80px;
    color: var(--text-dim);
    font-size: 0.8rem;
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}

footer .credit {
    font-size: 0.75rem;
    opacity: 0.55;
    margin-top: 0.5rem;
    font-family: var(--font-sans);
    letter-spacing: 0;
}

footer .credit a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: rgba(148, 163, 184, 0.4);
    text-underline-offset: 3px;
    transition: color 0.15s, text-decoration-color 0.15s;
}

footer .credit a:hover {
    color: var(--accent);
    text-decoration-color: currentColor;
}

/* ---------- Mascot ---------- */
.mascot {
    position: fixed;
    right: 24px;
    bottom: 0;
    width: 320px;
    aspect-ratio: 1000 / 1391;
    pointer-events: none;
    opacity: 0.92;
    z-index: 5;
    animation: mascot-bob 3.6s ease-in-out infinite;
    filter: drop-shadow(0 4px 16px rgba(56, 189, 248, 0.22));
    transition: opacity 0.3s, transform 0.3s;
}

.mascot img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    object-position: bottom center;
}

@keyframes mascot-bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

.mascot:hover {
    opacity: 1;
    transform: translateY(-4px);
}

/* ---------- Ligature fix ---------- */
#urlInput,
#shortUrlDisplay,
input[type="text"],
input[type="url"] {
    font-variant-ligatures: none;
    font-feature-settings: "liga" 0, "calt" 0, "dlig" 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .mascot {
        width: 220px;
        right: 12px;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 48px 16px 40px;
    }

    .logo h1 {
        font-size: 2rem;
    }

    /* Stack: icon hidden, input on top, button below */
    .input-wrapper {
        flex-direction: column;
        min-height: 0;
    }

    .input-icon {
        display: none;
    }

    #urlInput {
        padding: 28px 20px;
        font-size: 1rem;
    }

    #shortenBtn {
        padding: 24px 20px;
    }

    .stats-row {
        grid-template-columns: 1fr;
    }

    .result-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-actions {
        width: 100%;
    }

    .action-btn {
        flex: 1;
        justify-content: center;
    }

    .mascot {
        width: 150px;
        right: 8px;
        opacity: 0.5;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mascot { animation: none; }
    header,
    .shorten-card,
    .stats-row,
    .result,
    .error-message { animation: none; }
    html { scroll-behavior: auto; }
}
