/**
 * Mixed Fraction Converter - Mobile-First Styles
 * Pattern A: Real-time calculator with sticky results
 * Breakpoints: 375px, 390px, 414px, 768px, 1024px
 */

/* ========================================
   Results Container
   ======================================== */
.results-container {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f7fafc;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.result-display {
    padding: 1.5rem;
    background: #fff;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.result-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    color: #2d3748;
}

.result-content {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 0;
}

/* ========================================
   Fraction Display Components
   ======================================== */
.result-fraction-display {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin: 0 0.5rem;
}

.result-numerator {
    font-size: 2.5rem;
    font-weight: 700;
    color: #667eea;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.result-fraction-line {
    font-size: 1rem;
    color: #2d3748;
    letter-spacing: -2px;
    margin: 0.25rem 0;
}

.result-denominator {
    font-size: 2.5rem;
    font-weight: 700;
    color: #667eea;
    line-height: 1;
    margin-top: 0.25rem;
}

.result-mixed-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.result-whole-part,
.result-whole-number {
    font-size: 3rem;
    font-weight: 700;
    color: #2d3748;
}

/* ========================================
   Calculation Steps Display
   ======================================== */
.steps-display {
    padding: 1.5rem;
    background: #fff;
    border-radius: 8px;
}

.steps-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    color: #2d3748;
}

.steps-list {
    margin: 0;
    padding-left: 1.5rem;
    list-style: decimal;
}

.steps-list li {
    margin-bottom: 0.75rem;
    font-size: 1rem;
    line-height: 1.6;
    color: #4a5568;
}

/* ========================================
   Error Display
   ======================================== */
.error-message {
    padding: 1rem;
    background: #fee;
    border-left: 4px solid #e53e3e;
    border-radius: 4px;
    color: #c53030;
}

.error-message p {
    margin: 0.25rem 0;
    font-size: 0.875rem;
}

/* ========================================
   Mode Selector
   ======================================== */
.mode-selector {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem;
    background: #f7fafc;
    border-radius: 8px;
}

.mode-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-option:hover {
    border-color: #667eea;
    background: #f7fafc;
}

.mode-option input[type="radio"] {
    margin-right: 0.5rem;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.mode-option input[type="radio"]:checked + span {
    font-weight: 600;
    color: #667eea;
}

.mode-option span {
    font-size: 0.875rem;
    color: #2d3748;
    transition: all 0.2s ease;
}

/* Mobile: Stack vertically */
@media (max-width: 414px) {
    .mode-selector {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ========================================
   Converter Form
   ======================================== */
.converter-form {
    margin-bottom: 1.5rem;
}

.converter-form h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    color: #2d3748;
}

/* ========================================
   Fraction Input Components
   ======================================== */
.fraction-input-group {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
    background: #f7fafc;
    border-radius: 8px;
}

.mixed-number-input,
.improper-fraction-input {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.fraction-parts {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.fraction-input {
    width: 80px;
    padding: 0.75rem;
    font-size: 1.25rem;
    text-align: center;
    border: 2px solid #cbd5e0;
    border-radius: 6px;
    background: #fff;
    color: #2d3748;
    transition: all 0.2s ease;
    /* Touch target: 44×44px minimum */
    min-height: 44px;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

/* Remove spinner for number inputs */
.fraction-input::-webkit-outer-spin-button,
.fraction-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.fraction-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.fraction-input::placeholder {
    color: #a0aec0;
}

.whole-input {
    width: 100px;
    font-weight: 600;
}

.numerator-input,
.denominator-input {
    width: 80px;
}

.fraction-line {
    width: 100%;
    height: 2px;
    background: #2d3748;
    margin: 0.25rem 0;
}

/* ========================================
   Responsive Design
   ======================================== */

/* Small Mobile (375px - iPhone SE) */
@media (max-width: 375px) {
    .results-container {
        padding: 0.75rem;
    }

    .result-content {
        font-size: 1.5rem;
        padding: 1rem 0;
    }

    .result-numerator,
    .result-denominator,
    .result-whole-part,
    .result-whole-number {
        font-size: 1.5rem;
    }

    .fraction-input {
        width: 60px;
        font-size: 1rem;
        padding: 0.5rem;
    }

    .whole-input {
        width: 70px;
    }
}

/* Medium Mobile (390px - iPhone 12/13/14) */
@media (min-width: 390px) and (max-width: 414px) {
    .fraction-input {
        width: 70px;
        font-size: 1.125rem;
    }

    .whole-input {
        width: 85px;
    }
}

/* Large Mobile (414px - iPhone Pro Max) */
@media (min-width: 414px) and (max-width: 767px) {
    .fraction-input {
        width: 80px;
    }

    .whole-input {
        width: 100px;
    }
}

/* Tablet Portrait (768px - iPad) */
@media (min-width: 768px) {
    .results-container {
        margin-bottom: 2rem;
    }

    .mode-selector {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }

    .result-content {
        font-size: 2.5rem;
        padding: 2rem 0;
    }

    .result-numerator,
    .result-denominator,
    .result-whole-part,
    .result-whole-number {
        font-size: 2.5rem;
    }

    .fraction-input {
        width: 100px;
        font-size: 1.5rem;
        padding: 1rem;
    }

    .whole-input {
        width: 120px;
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
    .result-content {
        font-size: 3rem;
    }

    .result-numerator,
    .result-denominator,
    .result-whole-part,
    .result-whole-number {
        font-size: 3rem;
    }

    .fraction-input {
        width: 120px;
        font-size: 1.75rem;
        padding: 1.25rem;
    }

    .whole-input {
        width: 140px;
    }

    .steps-list li {
        font-size: 1rem;
    }
}

/* ========================================
   Accessibility
   ======================================== */

/* Focus indicators for keyboard navigation */
.mode-option:focus-within {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.fraction-input:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .fraction-input {
        border-width: 3px;
    }

    .result-display {
        border: 2px solid #2d3748;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .mode-option,
    .fraction-input {
        transition: none;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .results-container {
        box-shadow: none;
        border: 1px solid #000;
    }

    .mode-selector {
        display: none;
    }

    .converter-form {
        page-break-inside: avoid;
    }
}
