@layer base, layout, components, utilities;

@layer base {
    :root {
        /* OKLCH colors for modern vibrant look */
        --primary-color: oklch(65% 0.15 250);
        --primary-hover: oklch(60% 0.15 250);
        --bg-color: oklch(98% 0.01 250);
        --card-bg: oklch(100% 0 0);
        --text-color: oklch(30% 0.02 250);
        --text-muted: oklch(60% 0.02 250);
        --accent-color: oklch(70% 0.2 300);
        --surface-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
        --premium-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    }

    body {
        font-family: 'Pretendard', system-ui, -apple-system, sans-serif;
        background-color: var(--bg-color);
        color: var(--text-color);
        margin: 0;
        padding-inline: 20px;
        padding-block: 40px;
        display: flex;
        justify-content: center;
        min-height: 100vh;
        /* Subtle noise texture */
        background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%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");
        background-blend-mode: overlay;
        opacity: 0.98;
    }
}

@layer layout {
    .container {
        width: 100%;
        max-width: 800px;
        display: flex;
        flex-direction: column;
        gap: 32px;
    }

    header {
        text-align: center;
    }

    header h1 {
        font-size: 2.5rem;
        margin-bottom: 8px;
        background: linear-gradient(to right, var(--primary-color), var(--accent-color));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        font-weight: 800;
    }

    header p {
        color: var(--text-muted);
        font-size: 1.1rem;
    }

    main {
        display: flex;
        flex-direction: column;
        gap: 24px;
    }

    footer {
        text-align: center;
        padding-block: 40px;
        color: var(--text-muted);
        font-size: 0.9rem;
    }
}

@layer components {
    textarea {
        width: 100%;
        height: 350px;
        padding: 24px;
        border: 2px solid oklch(90% 0.01 250);
        border-radius: 20px;
        font-size: 1.1rem;
        line-height: 1.6;
        resize: none;
        box-sizing: border-box;
        outline: none;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background: var(--card-bg);
        box-shadow: var(--surface-shadow);
    }

    textarea:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 4px oklch(65% 0.15 250 / 0.15), var(--premium-shadow);
        transform: translateY(-2px);
    }

    /* Modern result container */
    .result-container {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 20px;
    }

    .button-group {
        display: flex;
        gap: 12px;
    }

    button {
        flex: 1;
        padding-block: 16px;
        border: none;
        border-radius: 12px;
        cursor: pointer;
        font-weight: 700;
        font-size: 1rem;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    .btn-copy {
        background-color: var(--primary-color);
        color: white;
        box-shadow: 0 4px 14px 0 oklch(65% 0.15 250 / 0.39);
    }

    .btn-copy:hover {
        background-color: var(--primary-hover);
        transform: scale(1.02);
    }

    .btn-copy:active {
        transform: scale(0.98);
    }

    .btn-clear {
        background-color: oklch(92% 0.01 250);
        color: var(--text-muted);
    }

    .btn-clear:hover {
        background-color: oklch(88% 0.01 250);
    }

    .tools h3 {
        margin-bottom: 16px;
        font-size: 1.25rem;
    }

    .link-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 16px;
    }

    .link-grid a {
        background: var(--card-bg);
        padding: 20px;
        text-decoration: none;
        color: var(--text-color);
        border-radius: 12px;
        text-align: center;
        border: 1px solid oklch(95% 0.01 250);
        font-size: 0.95rem;
        font-weight: 500;
        transition: all 0.2s ease;
        box-shadow: var(--surface-shadow);
    }

    .link-grid a:hover {
        background: oklch(65% 0.15 250 / 0.05);
        border-color: var(--primary-color);
        color: var(--primary-color);
        transform: translateY(-2px);
    }

    .ads-top, .ads-bottom {
        min-height: 80px;
        background: oklch(95% 0.01 250);
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 1px dashed oklch(85% 0.01 250);
    }
}

/* Accessibility: Focus visible */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 4px;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .result-container {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 2rem;
    }
}