/**
 * WPS Custom Styles
 * WPS (WIA Phonetic System)
 */

/* Base */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans KR', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.dark ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Selection */
::selection {
    background: rgba(13, 148, 136, 0.3);
}

/* Focus styles */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid #0d9488;
    outline-offset: 2px;
}

/* Textarea */
textarea {
    font-family: inherit;
}

textarea::placeholder {
    color: #9ca3af;
}

/* Buttons */
button {
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Select */
select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

.dark select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
}

/* Checkbox */
input[type="checkbox"] {
    cursor: pointer;
    width: 1rem;
    height: 1rem;
    accent-color: #0d9488;
}

/* Loading animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Result text - larger on mobile */
@media (max-width: 640px) {
    #hangulResult {
        font-size: 1.75rem;
        line-height: 1.4;
    }
}

/* Word grid responsive */
#wordGrid > div {
    display: grid;
    grid-template-columns: minmax(80px, auto) minmax(100px, auto) 1fr auto;
    gap: 0.75rem;
    align-items: center;
}

@media (max-width: 640px) {
    #wordGrid > div {
        grid-template-columns: 1fr 1fr;
        gap: 0.25rem;
    }

    #wordGrid > div > span:nth-child(3) {
        grid-column: span 2;
    }

    #wordGrid > div > span:nth-child(4) {
        grid-column: span 2;
        text-align: right;
    }
}

/* History item hover */
#historyList > div:hover {
    transform: translateX(4px);
}

/* Toast animation */
#toast {
    z-index: 9999;
}

/* Gradient text */
.gradient-text {
    background: linear-gradient(135deg, #0d9488, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Card glass effect */
.glass {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* Smooth transitions */
.transition-all {
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
}

/* Print styles */
@media print {
    body {
        background: white !important;
    }

    header, footer, #historyCard, button {
        display: none !important;
    }

    #resultCard {
        box-shadow: none !important;
        border: 1px solid #e5e7eb;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .bg-white\/95, .bg-white\/90 {
        background-color: white;
    }

    .dark .bg-gray-800\/95, .dark .bg-gray-800\/90 {
        background-color: #1f2937;
    }
}

/* IPA font stack for better rendering */
#ipaResult {
    font-family: 'Noto Sans', 'Lucida Grande', 'Lucida Sans Unicode', 'DejaVu Sans', 'Arial Unicode MS', sans-serif;
}

/* Hangul result font weight */
#hangulResult {
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Dark mode specific adjustments */
.dark {
    color-scheme: dark;
}

.dark input, .dark textarea, .dark select {
    color-scheme: dark;
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }

    textarea {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }
}
