/* RSD Calculator - Mobile-First Responsive CSS */

/* CSS Reset & Variables */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --success-color: #16a34a;
    --warning-color: #ca8a04;
    --error-color: #dc2626;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-light: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

h1 {
    font-size: 1.75rem;
}

h2 {
    font-size: 1.5rem;
    margin-top: 2rem;
}

h3 {
    font-size: 1.25rem;
    margin-top: 1.5rem;
}

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover, a:focus {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Layout */
.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
header {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.logo:hover {
    text-decoration: none;
}

nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    list-style: none;
}

nav a {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 0.25rem 0;
}

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

/* Breadcrumbs */
.breadcrumbs {
    padding: 0.75rem 0;
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.breadcrumbs ol {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    list-style: none;
    font-size: 0.875rem;
}

.breadcrumbs li::after {
    content: '/';
    margin-left: 0.5rem;
    color: var(--text-light);
}

.breadcrumbs li:last-child::after {
    content: '';
}

.breadcrumbs a {
    color: var(--text-light);
}

.breadcrumbs span {
    color: var(--text-secondary);
}

/* Main Content */
main {
    padding: 1.5rem 0 6rem;
}

.content-section {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

/* Calculator Section */
.calculator-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
}

.calculator-section h1 {
    color: white;
    font-size: 1.5rem;
}

.calculator-section p {
    color: rgba(255, 255, 255, 0.9);
}

.calculator-box {
    background-color: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-top: 1rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.input-hint {
    font-size: 0.8125rem;
    color: var(--text-light);
    font-weight: 400;
}

textarea, input[type="text"] {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
    font-family: var(--font-mono);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    resize: vertical;
}

textarea:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
    min-height: 100px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-block {
    width: 100%;
}

.button-group {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.button-group .btn {
    flex: 1;
}

/* Sticky Calculate Button (Mobile) */
.sticky-calculate {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 0.1);
    z-index: 50;
}

/* Results Section */
.results-section {
    display: none;
}

.results-section.show {
    display: block;
}

.results-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.result-card {
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
}

.result-label {
    font-size: 0.8125rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.result-card.highlight {
    background-color: var(--primary-color);
}

.result-card.highlight .result-label,
.result-card.highlight .result-value {
    color: white;
}

/* Interpretation Badge */
.interpretation-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    margin-bottom: 1rem;
}

.interpretation-badge.low {
    background-color: #dcfce7;
    color: #166534;
}

.interpretation-badge.acceptable {
    background-color: #fef9c3;
    color: #854d0e;
}

.interpretation-badge.high {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Step-by-Step Calculation */
.calculation-steps {
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-top: 1rem;
}

.calculation-steps h3 {
    font-size: 1rem;
    margin-top: 0;
    margin-bottom: 1rem;
}

.step {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.step:last-child {
    border-bottom: none;
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    margin-right: 0.5rem;
}

.step-title {
    font-weight: 600;
    color: var(--text-primary);
}

.step-formula {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    padding-left: 2rem;
    word-break: break-all;
}

/* Error Message */
.error-message {
    display: none;
    background-color: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 0.875rem;
    border-radius: var(--radius-md);
    margin-top: 1rem;
    font-weight: 500;
}

.error-message.show {
    display: block;
}

/* Info Boxes */
.info-box {
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 1rem 0;
}

.info-box h4 {
    color: #1e40af;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.info-box p {
    color: #1e40af;
    margin-bottom: 0;
    font-size: 0.9375rem;
}

/* Formula Display */
.formula-box {
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    text-align: center;
    margin: 1rem 0;
    border: 2px solid var(--border-color);
}

.formula {
    font-family: var(--font-mono);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9375rem;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
}

td {
    color: var(--text-secondary);
}

/* FAQ Section */
.faq-section {
    margin-top: 2rem;
}

.faq-item {
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
}

.faq-item:first-of-type {
    border-top: 1px solid var(--border-color);
}

.faq-question {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.faq-question::after {
    content: '+';
    font-size: 1.25rem;
    line-height: 1;
    color: var(--primary-color);
    flex-shrink: 0;
}

.faq-item.open .faq-question::after {
    content: '-';
}

.faq-answer {
    display: none;
    color: var(--text-secondary);
    padding-top: 0.5rem;
}

.faq-item.open .faq-answer {
    display: block;
}

/* Lists */
ul, ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

/* Footer */
footer {
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: 2rem;
}

.footer-content {
    text-align: center;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.footer-links a {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.copyright {
    font-size: 0.8125rem;
    color: var(--text-light);
}

/* Internal Links Section */
.related-links {
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-top: 1.5rem;
}

.related-links h3 {
    font-size: 1rem;
    margin-top: 0;
    margin-bottom: 0.75rem;
}

.related-links ul {
    margin: 0;
    padding-left: 1.25rem;
}

.related-links li {
    margin-bottom: 0.375rem;
}

/* CTA Box */
.cta-box {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    margin: 2rem 0;
}

.cta-box h3 {
    color: white;
    margin-top: 0;
}

.cta-box p {
    color: rgba(255, 255, 255, 0.9);
}

.cta-box .btn {
    background-color: white;
    color: var(--primary-color);
    margin-top: 0.5rem;
}

.cta-box .btn:hover {
    background-color: var(--bg-tertiary);
    text-decoration: none;
}

/* Tablet Styles */
@media (min-width: 640px) {
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.75rem;
    }

    .container {
        padding: 0 1.5rem;
    }

    .header-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .content-section {
        padding: 2rem;
    }

    .calculator-section h1 {
        font-size: 1.75rem;
    }

    .results-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .sticky-calculate {
        display: none;
    }

    main {
        padding-bottom: 2rem;
    }
}

/* Desktop Styles */
@media (min-width: 1024px) {
    h1 {
        font-size: 2.25rem;
    }

    .container {
        padding: 0 2rem;
    }

    .calculator-section h1 {
        font-size: 2rem;
    }

    .content-section {
        padding: 2.5rem;
    }
}

/* Print Styles */
@media print {
    header, footer, .sticky-calculate, .button-group {
        display: none;
    }

    main {
        padding: 0;
    }

    .content-section {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }

    html {
        scroll-behavior: auto;
    }
}

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

/* Skip Link */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    z-index: 1000;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
}
