/* ===== CSS Variables & Reset ===== */
:root {
    --bg-primary: #050505;
    --bg-secondary: #0a0a0a;
    --bg-card: rgba(12, 12, 12, 0.85);
    --bg-card-hover: rgba(18, 18, 18, 0.9);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(255, 255, 255, 0.12);
    --text-primary: #e8e8e8;
    --text-secondary: #888888;
    --text-muted: #555555;
    --accent-1: #ffffff;
    --accent-2: #cccccc;
    --accent-3: #aaaaaa;
    --accent-gradient: linear-gradient(135deg, #ffffff 0%, #b0b0b0 100%);
    --success: #4ade80;
    --error: #f87171;
    --warning: #fbbf24;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border-color);
    --shadow-glow: 0 0 40px rgba(255, 255, 255, 0.03);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

html {
    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);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
}

/* ===== Background Animation ===== */
.bg-animation {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(150px);
    opacity: 0.15;
    animation: float 25s ease-in-out infinite;
}

.bg-orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.08), transparent 70%);
    top: -200px;
    right: -100px;
    animation-delay: 0s;
}

.bg-orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.06), transparent 70%);
    bottom: -150px;
    left: -100px;
    animation-delay: -8s;
}

.bg-orb-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05), transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -16s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(40px, 30px) scale(1.02); }
}

/* ===== Main Layout ===== */
.main {
    position: relative;
    z-index: 1;
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 28px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ===== Hero Section ===== */
.hero {
    text-align: center;
    padding: 16px 0 4px;
}

.hero-title {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 6px;
    letter-spacing: -0.03em;
    color: #ffffff;
}

.gradient-text {
    background: linear-gradient(135deg, #ffffff 0%, #777777 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 0.88rem;
    color: var(--text-secondary);
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ===== Content Grid (IP + Lookup side by side) ===== */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}

/* ===== Glass Card ===== */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

.glass-card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-card), var(--shadow-glow);
}

/* ===== IP Card ===== */
.ip-card {
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Loading */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.loader {
    position: relative;
    width: 44px;
    height: 44px;
}

.loader-ring {
    position: absolute;
    inset: 0;
    border: 3px solid transparent;
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-ring::before, .loader-ring::after {
    content: '';
    position: absolute;
    border: 3px solid transparent;
    border-radius: 50%;
}

.loader-ring::before {
    inset: 4px;
    border-right-color: #888888;
    animation: spin 1.5s linear reverse infinite;
}

.loader-ring::after {
    inset: 10px;
    border-bottom-color: #555555;
    animation: spin 2s linear infinite;
}

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

.loading-text {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Result */
.ip-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.ip-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.ip-value-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ip-value {
    font-family: var(--font-mono);
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    font-weight: 600;
    color: #ffffff;
    letter-spacing: -0.02em;
}

.copy-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    font-size: 1rem;
    transition: all 0.25s ease;
    line-height: 1;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    transform: scale(1.05);
}

.copy-btn.copied {
    color: var(--success);
    border-color: rgba(74, 222, 128, 0.3);
    background: rgba(74, 222, 128, 0.08);
}

/* Divider */
.divider {
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
    margin: 14px 0;
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
    text-align: left;
}

.info-grid.compact .info-item {
    padding: 10px 12px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
}

.info-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

.info-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.06);
}

.as-icon, .org-icon, .isp-icon,
.loc-icon, .country-icon, .tz-icon {
    background: rgba(255, 255, 255, 0.06);
}

.info-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.info-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.info-value {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-word;
    line-height: 1.3;
}

/* Buttons */
.refresh-btn {
    margin-top: 14px;
    padding: 8px 22px;
    background: #ffffff;
    color: #050505;
    border: none;
    border-radius: 100px;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.1);
    background: #e0e0e0;
}

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

/* Error */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.error-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--error);
}

.error-message {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Hidden */
.hidden {
    display: none !important;
}

/* ===== Lookup Section ===== */
.lookup-section {
    display: flex;
    flex-direction: column;
}

.lookup-card {
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.lookup-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: #ffffff;
}

.lookup-desc {
    color: var(--text-secondary);
    font-size: 0.82rem;
    margin-bottom: 14px;
}

.lookup-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-wrapper {
    display: flex;
    gap: 8px;
}

.lookup-input {
    flex: 1;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    outline: none;
    transition: all 0.3s ease;
}

.lookup-input:focus {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
    background: rgba(255, 255, 255, 0.06);
}

.lookup-input::placeholder {
    color: var(--text-muted);
}

.lookup-btn {
    padding: 10px 20px;
    background: #ffffff;
    color: #050505;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.lookup-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(255, 255, 255, 0.1);
    background: #e0e0e0;
}

.input-hint {
    font-size: 0.72rem;
    min-height: 1em;
}

.input-hint.error {
    color: var(--error);
}

.input-hint.success {
    color: var(--success);
}

/* Lookup Result */
.lookup-result {
    flex: 1;
    overflow-y: auto;
}

.lookup-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.lookup-result-ip {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
}

.close-result-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    color: var(--text-secondary);
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s ease;
    line-height: 1;
}

.close-result-btn:hover {
    background: rgba(248, 113, 113, 0.12);
    color: var(--error);
    border-color: rgba(248, 113, 113, 0.2);
}

/* ===== Footer ===== */
.footer {
    position: relative;
    z-index: 1;
    padding: 16px 32px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer .dot {
    opacity: 0.4;
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: "JetBrains Mono", monospace;
}

.footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.footer a:hover {
    color: #ffffff;
}

/* ===== Animations ===== */
.ip-section, .lookup-section {
    animation: fadeUp 0.6s ease-out both;
}

.lookup-section {
    animation-delay: 0.15s;
}

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

.info-item {
    animation: fadeIn 0.4s ease-out both;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    body {
        height: auto;
        overflow: auto;
    }
    .main {
        padding: 16px 16px 0;
    }
    .content-grid {
        grid-template-columns: 1fr;
    }
    .ip-card, .lookup-card {
        padding: 24px 20px;
    }
    .ip-value {
        word-break: break-all;
    }
    .info-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .input-wrapper {
        flex-direction: column;
    }
    .hero {
        padding: 8px 0 0;
    }
    .footer {
        flex-direction: column;
        gap: 16px;
        text-align: center;
        justify-content: center;
        padding: 20px 16px;
    }
    .footer-left {
        flex-direction: column;
        gap: 6px;
    }
    .footer .dot {
        display: none;
    }
    .footer-right {
        justify-content: center;
    }
}

.visitor-count {
    color: var(--primary);
    font-weight: 600;
}

/* ===== Easter Egg: Homer Walking ===== */
.homer-walking {
    position: fixed;
    bottom: -10px; /* Slight offset so his feet hit the bottom edge */
    left: -200px;
    width: 140px;
    z-index: 1000;
    pointer-events: none; /* Passes clicks through to the elements behind */
    animation: walkAcross 35s linear infinite;
    opacity: 0.8;
}

.homer-walking img {
    width: 100%;
    height: auto;
}

@keyframes walkAcross {
    0% { left: -200px; transform: scaleX(1); }
    49% { left: 100vw; transform: scaleX(1); }
    50% { left: 100vw; transform: scaleX(-1); }
    99% { left: -200px; transform: scaleX(-1); }
    100% { left: -200px; transform: scaleX(1); }
}
