
@layer reset, base, components, utilities, animations;

@layer reset {
    *, *::before, *::after {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
    }
    
    html {
        font-family: 'Inter', 'Noto Sans KR', system-ui, -apple-system, sans-serif;
        color-scheme: dark;
        scroll-behavior: smooth;
    }
}

@layer base {
    :root {
        --bg-color: #050508;
        --card-bg: rgba(15, 15, 25, 0.7);
        --text-primary: #f8fafc;
        --text-secondary: #94a3b8;
        --accent-primary: #6366f1; /* Indigo */
        --accent-secondary: #a855f7; /* Purple */
        --accent-tertiary: #06b6d4; /* Cyan */
        --error-color: #ef4444;
        --success-color: #10b981;
        --glass-border: rgba(255, 255, 255, 0.08);
        --glow-shadow: 0 0 30px rgba(99, 102, 241, 0.2);
        --radius-lg: 24px;
        --radius-md: 16px;
        --space-sm: 8px;
        --space-md: 16px;
        --space-lg: 32px;
        --space-xl: 64px;
        --space-xxl: 120px;
    }

    body {
        background-color: var(--bg-color);
        color: var(--text-primary);
        line-height: 1.6;
        overflow-x: hidden;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .background-texture {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: -1;
        background: 
            radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15), transparent 40%),
            radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.15), transparent 40%),
            radial-gradient(circle at 50% 50%, rgba(6, 182, 212, 0.05), transparent 60%);
        background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3%3Cfilter id='noiseFilter'%3%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
        opacity: 0.3;
    }
}

@layer components {
    /* Header & Navigation */
    .main-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--space-md) var(--space-xl);
        background: rgba(5, 5, 8, 0.8);
        backdrop-filter: blur(15px);
        position: sticky;
        top: 0;
        z-index: 1000;
        border-bottom: 1px solid var(--glass-border);
    }

    .logo {
        font-size: 1.5rem;
        font-weight: 900;
        letter-spacing: -0.03em;
        background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        cursor: pointer;
    }

    .main-nav {
        display: flex;
        gap: var(--space-lg);
    }

    .main-nav a {
        color: var(--text-secondary);
        text-decoration: none;
        font-weight: 600;
        font-size: 0.95rem;
        transition: all 0.3s ease;
        position: relative;
    }

    .main-nav a:hover, .main-nav a.active {
        color: var(--text-primary);
    }

    .main-nav a.active::after {
        content: '';
        position: absolute;
        bottom: -4px;
        left: 0;
        width: 100%;
        height: 2px;
        background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
        border-radius: 2px;
    }

    /* Hero Section */
    .main-layout {
        display: flex;
        max-width: 1440px;
        margin: 0 auto;
        gap: 30px;
        padding: 0 var(--space-md);
    }

    .hero-container {
        flex: 1;
        min-width: 0;
        padding: var(--space-xxl) 0;
    }

    .side-ad-right {
        width: 160px;
        flex-shrink: 0;
        padding-top: var(--space-xxl);
    }

    .ad-sticky-container {
        position: sticky;
        top: 120px;
        z-index: 10;
    }

    .hero-content {
        text-align: center;
        margin-bottom: var(--space-xxl);
        animation: fadeInDown 1s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .hero-title {
        font-size: clamp(3rem, 10vw, 5.5rem);
        font-weight: 900;
        letter-spacing: -0.04em;
        line-height: 1.05;
        margin-bottom: var(--space-lg);
    }

    .gradient-text {
        background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary), var(--accent-tertiary));
        background-size: 200% auto;
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        animation: shine 5s linear infinite;
    }

    .hero-subtitle {
        font-size: clamp(1.1rem, 3vw, 1.4rem);
        color: var(--text-secondary);
        max-width: 700px;
        margin: 0 auto var(--space-xl);
        font-weight: 400;
    }

    /* Capture Box */
    .capture-box {
        max-width: 700px;
        margin: 0 auto;
        display: flex;
        gap: 12px;
        background: var(--card-bg);
        padding: 10px;
        border-radius: var(--radius-lg);
        border: 1px solid var(--glass-border);
        backdrop-filter: blur(20px);
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
        transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .capture-box:focus-within {
        border-color: var(--accent-primary);
        box-shadow: var(--glow-shadow);
        transform: translateY(-4px);
    }

    .capture-box input {
        flex: 1;
        background: transparent;
        border: none;
        color: var(--text-primary);
        padding: 15px 20px;
        font-size: 1.1rem;
        outline: none;
        font-weight: 500;
    }

    .capture-box button {
        background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
        color: white;
        border: none;
        padding: 0 var(--space-lg);
        border-radius: var(--radius-md);
        font-weight: 700;
        font-size: 1rem;
        cursor: pointer;
        transition: all 0.3s ease;
        box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    }

    .capture-box button:hover {
        transform: scale(1.05);
        box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
    }

    /* Banner Ad */
    .banner-ad-container {
        max-width: 700px;
        margin: 40px auto 0;
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 250px;
    }

    /* History Grid & Cards */
    .history-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 20px;
        margin-top: 30px;
    }

    .history-card {
        background: var(--card-bg);
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-md);
        overflow: hidden;
        position: relative;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .history-card:hover {
        transform: translateY(-5px);
        border-color: var(--accent-primary);
    }

    .history-preview {
        height: 140px;
        background-size: cover;
        background-position: top center;
        border-bottom: 1px solid var(--glass-border);
    }

    .history-details {
        padding: 15px;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .history-url {
        font-size: 0.9rem;
        font-weight: 700;
        color: var(--text-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .history-date {
        font-size: 0.8rem;
        color: var(--text-secondary);
    }

    .delete-btn {
        position: absolute;
        top: 8px;
        right: 8px;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background: rgba(239, 68, 68, 0.8);
        color: white;
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
        cursor: pointer;
        opacity: 0;
        transition: opacity 0.2s;
        z-index: 10;
    }

    .history-card:hover .delete-btn {
        opacity: 1;
    }

    .delete-btn:hover {
        background: #ef4444;
        transform: scale(1.1);
    }

    /* Community Sites List */
    .supported-sites {
        text-align: center;
        margin-top: var(--space-xxl);
    }

    .site-list {
        display: flex; /* Changed to flexbox */
        flex-wrap: wrap; /* Allow wrapping on smaller screens */
        justify-content: center; /* Center the items */
        gap: 20px;
        margin-top: 40px;
    }

    .site-card {
        background: var(--card-bg);
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-md);
        padding: 20px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center; /* Center content vertically */
        gap: 15px;
        cursor: pointer;
        transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        width: 150px; /* Set a fixed width */
        height: 130px; /* Set a fixed height */
    }

    .site-card:hover {
        transform: translateY(-8px) scale(1.05);
        border-color: var(--accent-tertiary);
        background: rgba(255, 255, 255, 0.05);
        box-shadow: var(--glow-shadow);
    }

    .site-icon {
        width: 48px;
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%; /* Make icons circular */
        font-weight: 900;
        font-size: 1.5rem; /* Larger font for single letters */
        color: white;
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
    }

    /* SVG Icons */
    .youtube-icon { 
        background-color: #FF0000;
        background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M10 16.5l6-4.5-6-4.5v9zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg>'); 
    }

    /* Text-based Icons */
    .naver-icon, .instiz-icon, .ddanzi-icon, .clien-icon, .bobae-icon, .dmitory-icon, .woman-icon, .blind-icon {
        font-family: 'Arial', sans-serif;
        text-align: center;
        line-height: 48px; /* Center text vertically */
    }
    .naver-icon { background: #03cf5d; }
    .instiz-icon { background: #D6336C; font-size: 1.8rem; }
    .ddanzi-icon { background: #D9480F; }
    .clien-icon { background: #2F9C0A; }
    .bobae-icon { background: #C92A2A; }
    .dmitory-icon { background: #5F3DC4; }
    .woman-icon { background: #862E9C; }
    .blind-icon { background: #1864AB; font-size: 1.8rem; }

    .site-name {
        font-size: 0.9rem;
        font-weight: 600;
        color: var(--text-secondary);
        margin-top: 5px; /* Added margin */
    }

    .section-subtitle {
        font-size: 1.2rem;
        color: var(--text-secondary);
        max-width: 600px;
        margin: -20px auto 40px;
    }

    /* Result Area Adjustments */
    .result-card img {
        width: 100%;
        max-height: none; /* Allow full height display */
        object-fit: contain;
        background: #000;
        display: block;
    }

    .result-card {
        max-width: 100%; /* Ensure it can grow */
    }

    .result-actions {
        padding: var(--space-lg);
        display: flex;
        justify-content: center;
        gap: var(--space-md);
        border-top: 1px solid var(--glass-border);
    }

    .btn-primary {
        background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
        color: white;
        text-decoration: none;
        padding: 14px 28px;
        border-radius: var(--radius-md);
        font-weight: 700;
        transition: all 0.3s ease;
    }

    .btn-secondary {
        background: rgba(255, 255, 255, 0.05);
        color: var(--text-primary);
        border: 1px solid var(--glass-border);
        padding: 14px 28px;
        border-radius: var(--radius-md);
        font-weight: 700;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .btn-primary:hover, .btn-secondary:hover {
        transform: translateY(-2px);
        background: rgba(255, 255, 255, 0.1);
    }

    /* Sections */
    .info-section, .content-depth-section, .faq-section {
        margin-top: var(--space-xxl);
    }

    .section-title {
        font-size: 2.5rem;
        font-weight: 800;
        text-align: center;
        margin-bottom: var(--space-xl);
        letter-spacing: -0.03em;
    }

    .info-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: var(--space-lg);
    }

    .info-card {
        padding: var(--space-xl);
        background: var(--card-bg);
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-lg);
        transition: all 0.3s ease;
    }

    .info-card:hover {
        transform: translateY(-10px);
        border-color: var(--accent-primary);
        background: rgba(255, 255, 255, 0.03);
    }

    .info-card h3 {
        font-size: 1.5rem;
        margin-bottom: var(--space-md);
        color: var(--text-primary);
    }

    .info-card p {
        color: var(--text-secondary);
        font-size: 1rem;
        line-height: 1.7;
    }

    /* Content Depth Section */
    .content-depth-section {
        background: linear-gradient(180deg, transparent, rgba(99, 102, 241, 0.05), transparent);
        padding: var(--space-xl) 0;
        text-align: center;
    }

    .content-wrapper {
        max-width: 800px;
        margin: 0 auto;
    }

    .content-wrapper h2 {
        font-size: 2.5rem;
        margin-bottom: var(--space-md);
    }

    .guide-link-box {
        margin-top: var(--space-lg);
        font-weight: 600;
    }

    .guide-link-box a {
        color: var(--accent-tertiary);
        text-decoration: none;
        border-bottom: 2px solid transparent;
        transition: all 0.3s ease;
    }

    .guide-link-box a:hover {
        border-color: var(--accent-tertiary);
    }

    /* Footer */
    .main-footer {
        background: #030305;
        padding: var(--space-xl) var(--space-md);
        border-top: 1px solid var(--glass-border);
        margin-top: auto;
    }

    .footer-content {
        max-width: 1200px;
        margin: 0 auto;
        display: grid;
        grid-template-columns: 1fr 2fr;
        gap: 60px;
        margin-bottom: var(--space-xl);
    }

    .footer-brand .logo {
        margin-bottom: 20px;
        display: inline-block;
    }

    .footer-brand p {
        color: var(--text-secondary);
        font-size: 0.9rem;
        max-width: 300px;
    }

    .footer-links {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 30px;
    }

    .link-group h4 {
        margin-bottom: 20px;
        font-size: 1.1rem;
        color: var(--text-primary);
        font-weight: 700;
    }

    .link-group a {
        display: block;
        color: var(--text-secondary);
        text-decoration: none;
        margin-bottom: 12px;
        transition: color 0.2s;
        font-size: 0.95rem;
    }

    .link-group a:hover {
        color: var(--accent-primary);
    }

    .footer-bottom {
        max-width: 1200px;
        margin: 0 auto;
        padding-top: var(--space-lg);
        border-top: 1px solid var(--glass-border);
        text-align: center;
        font-size: 0.9rem;
        color: var(--text-secondary);
    }
}

@layer utilities {
    .hidden { display: none !important; }
}

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

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

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

    @keyframes shine {
        to { background-position: 200% center; }
    }
}

/* Mobile Adjustments */
@media (max-width: 1400px) {
    .main-layout {
        flex-direction: column;
        align-items: center;
    }
    .side-ad-right {
        width: 100%;
        display: flex;
        justify-content: center;
        padding: var(--space-lg) 0;
        order: 2; /* Place ad after content on smaller screens */
    }
    .ad-sticky-container {
        position: static;
    }
    .hero-container {
        width: 100%;
        order: 1;
    }
}

@media (max-width: 992px) {
    .footer-content {
        grid-template-columns: 1fr;
        gap: 40px;
        text-align: center;
    }
    .footer-brand p {
        margin: 0 auto;
    }
    .footer-links {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .main-header { padding: var(--space-md); }
    .main-nav { display: none; } /* Could add hamburger menu later */
    .hero-title { font-size: 3rem; }
    .capture-box { flex-direction: column; padding: 15px; }
    .capture-box button { padding: 15px; }
    .site-list { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .site-card { width: 120px; height: 110px; padding: 15px; }
    .footer-links {
        grid-template-columns: 1fr; /* Stack link groups on mobile */
        gap: 30px;
        text-align: center;
    }
}
