:root {
    --light-purple: #b5aed2;
    --dark-purple: #7b6b9e;
    --light-blue: #a5bce2;
    --teal: #75b8b2;
    --mint: #cfe6e4;
    --white: #ffffff;
    --gray-light: #f4f6fa;
    --gray: #e8ecf3;
    --shadow-light: rgba(255, 255, 255, 0.7);
    --shadow-dark: rgba(190, 195, 205, 0.3);
    --blue-accent: #42a5f5;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html {
    font-size: 16px;
}

body {
    background-color: var(--gray-light);
    padding-bottom: clamp(10px, 3vw, 30px);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Navigation Bar Styles */
.nav-bar {
    width: 100%;
    background-color: var(--white);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: clamp(20px, 4vw, 40px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(10px, 2vw, 15px) clamp(15px, 3vw, 30px);
}

.logo {
    display: flex;
    align-items: center;
    color: var(--dark-purple);
    font-weight: 700;
    font-size: clamp(1.1rem, 3vw, 1.3rem);
}

.logo svg {
    width: clamp(24px, 5vw, 30px);
    height: clamp(24px, 5vw, 30px);
    margin-right: 10px;
    fill: var(--dark-purple);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: clamp(10px, 4vw, 30px);
}

.nav-links a {
    text-decoration: none;
    color: #666;
    font-weight: 500;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    transition: color 0.3s ease;
    padding: 5px 0;
    position: relative;
}

.nav-links a:hover {
    color: var(--dark-purple);
}

.nav-links li.active a {
    color: var(--dark-purple);
    font-weight: 600;
}

.nav-links li.active a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--dark-purple);
    border-radius: 2px;
}

.container {
    max-width: 1200px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 clamp(10px, 3vw, 30px);
}

header {
    text-align: center;
    margin-bottom: clamp(15px, 4vw, 30px);
    width: 100%;
}

h1 {
    color: var(--dark-purple);
    margin-bottom: 10px;
    font-size: clamp(1.5rem, 5vw, 2.5rem);
}

.subtitle {
    color: #666;
    font-size: clamp(0.9rem, 3vw, 1.125rem);
}

/* Main Content Section with Layout Variations */
.main-content {
    display: flex;
    width: 100%;
    gap: clamp(20px, 4vw, 40px);
    align-items: flex-start;
    transition: all 0.3s ease-in-out;
}

.input-section {
    display: flex;
    flex-direction: column;
    gap: clamp(15px, 3vw, 25px);
    flex: 1;
    max-width: 450px;
    margin: 0 auto;
    /* Default to centered */
    transition: all 0.3s ease-in-out;
}

.input-section.shifted {
    margin: 0;
    /* Override to left-aligned when shifted */
}

.results-section {
    flex: 1;
    position: sticky;
    top: 90px;
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.3s ease-in-out;
}

.results-section.visible {
    opacity: 1;
    transform: translateX(0);
}

.card {
    background-color: var(--white);
    border-radius: 20px;
    padding: clamp(15px, 3vw, 25px);
    width: 100%;
    box-shadow:
        8px 8px 16px var(--shadow-dark),
        -8px -8px 16px var(--shadow-light);
}

.card h2 {
    color: var(--dark-purple);
    font-size: clamp(1.1rem, 4vw, 1.375rem);
    margin-bottom: clamp(10px, 3vw, 20px);
    display: flex;
    align-items: center;
}

.card h2 svg {
    margin-right: 10px;
    width: clamp(18px, 5vw, 24px);
    height: clamp(18px, 5vw, 24px);
}

.input-group {
    margin-bottom: clamp(12px, 3vw, 20px);
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: #666;
    font-weight: 500;
    font-size: clamp(0.875rem, 2.5vw, 1rem);
}

.neomorphic-input {
    width: 100%;
    padding: clamp(8px, 2.5vw, 12px) clamp(10px, 3vw, 15px);
    border: none;
    background-color: var(--gray);
    border-radius: 10px;
    box-shadow:
        inset 2px 2px 5px var(--shadow-dark),
        inset -2px -2px 5px var(--shadow-light);
    color: #333;
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    transition: all 0.3s ease;
}

.neomorphic-input:focus {
    outline: none;
    box-shadow:
        inset 3px 3px 6px var(--shadow-dark),
        inset -3px -3px 6px var(--shadow-light);
}

.neomorphic-select {
    width: 100%;
    padding: clamp(8px, 2.5vw, 12px) clamp(10px, 3vw, 15px);
    border: none;
    background-color: var(--gray);
    border-radius: 10px;
    box-shadow:
        inset 2px 2px 5px var(--shadow-dark),
        inset -2px -2px 5px var(--shadow-light);
    color: #333;
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: clamp(12px, 3vw, 16px);
    padding-right: 40px;
}

.neomorphic-select:focus {
    outline: none;
    box-shadow:
        inset 3px 3px 6px var(--shadow-dark),
        inset -3px -3px 6px var(--shadow-light);
}

.btn {
    width: 100%;
    padding: clamp(10px, 3vw, 14px);
    border: none;
    background: linear-gradient(145deg, var(--light-blue), var(--blue-accent));
    border-radius: 10px;
    color: white;
    font-weight: 600;
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    cursor: pointer;
    box-shadow:
        5px 5px 10px var(--shadow-dark),
        -5px -5px 10px var(--shadow-light);
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow:
        6px 6px 12px var(--shadow-dark),
        -6px -6px 12px var(--shadow-light);
}

.btn:active {
    transform: translateY(1px);
    box-shadow:
        3px 3px 6px var(--shadow-dark),
        -3px -3px 6px var(--shadow-light);
}

.loading {
    margin: clamp(10px, 3vw, 20px) 0;
    text-align: center;
    width: 100%;
}

.spinner {
    width: clamp(30px, 8vw, 50px);
    height: clamp(30px, 8vw, 50px);
    border: clamp(3px, 1vw, 5px) solid var(--gray);
    border-top: clamp(3px, 1vw, 5px) solid var(--blue-accent);
    border-radius: 50%;
    margin: 0 auto 15px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Results Card Styling */
.results-card {
    background-color: var(--white);
    border-radius: 20px;
    padding: clamp(15px, 3vw, 25px);
    width: 100%;
    box-shadow:
        8px 8px 16px var(--shadow-dark),
        -8px -8px 16px var(--shadow-light);
}

.results-card h2 {
    color: var(--dark-purple);
    font-size: clamp(1.1rem, 4vw, 1.375rem);
    margin-bottom: clamp(10px, 3vw, 20px);
    display: flex;
    align-items: center;
}

.results-card h2 svg {
    margin-right: 10px;
    width: clamp(18px, 5vw, 24px);
    height: clamp(18px, 5vw, 24px);
}

.results-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: clamp(10px, 3vw, 20px);
    width: 100%;
}

.result-item {
    background-color: var(--gray);
    border-radius: 15px;
    padding: clamp(15px, 3vw, 22px);
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "header header"
        "details values"
        "footer footer";
    gap: 10px;
}

.result-item:hover {
    transform: translateY(-3px);
    box-shadow: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light);
}

/* Colored background indicator based on match percentage */
.result-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    opacity: 0.1;
    transition: opacity 0.3s ease;
    border-radius: 15px;
}

.result-item:hover::before {
    opacity: 0.15;
}

/* Green backgrounds for high matches */
.match-90-100::before {
    background: linear-gradient(135deg, #a8e063 0%, #56ab2f 100%);
}

.match-80-89::before {
    background: linear-gradient(135deg, #c2e59c 0%, #64b3f4 100%);
}

.match-70-79::before {
    background: linear-gradient(135deg, #d4fc79 0%, #96e6a1 100%);
}

.match-60-69::before {
    background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
}

/* Yellow/orange backgrounds for medium matches */
.match-50-59::before {
    background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
}

/* Red backgrounds for poor matches */
.match-0-49::before {
    background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%);
}

.result-name {
    grid-area: header;
    font-size: clamp(1.1rem, 3vw, 1.3rem);
    font-weight: 700;
    color: var(--dark-purple);
    margin-bottom: 5px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.result-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.result-detail {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 3px;
    font-size: clamp(0.7rem, 2vw, 0.8rem);
    margin-bottom: 5px; /* Add slightly more space between rows */
}

/* Detail labels column */
.result-details-labels {
    grid-area: details;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    z-index: 1;
}

/* Detail values column */
.result-details-values {
    grid-area: values;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: right;
    position: relative;
    z-index: 1;
}

.result-label {
    color: #666;
    font-weight: 500;
    font-size: clamp(0.8rem, 2.2vw, 0.9rem);
}

/* FIX: Better clamp values for result-value font-size */
.result-value {
    font-weight: 600;
    color: #333;
    /* Fix: using a better clamp formula with lower vw component */
    font-size: clamp(0.7rem, 0.65rem + 0.25vw, 0.9rem);
    line-height: 1.3;
    text-align: right;
}

.result-footer {
    grid-area: footer;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
    position: relative;
    z-index: 1;
}

/* Enhanced match score display */
.match-score {
    padding: clamp(8px, 2.5vw, 12px);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    background-color: rgba(255, 255, 255, 0.7);
}

.match-percentage {
    font-size: clamp(1.1rem, 3vw, 1.3rem);
    font-weight: 700;
}

/* Usage info styling */
.usage-info {
    background-color: rgba(255, 255, 255, 0.7);
    padding: clamp(8px, 2.5vw, 12px);
    border-radius: 12px;
    font-size: clamp(0.8rem, 2.2vw, 0.9rem);
    color: #555;
}

.usage-info strong {
    color: var(--dark-purple);
    font-weight: 600;
}

/* Match score styles for backward compatibility */
.match-score-high {
    background-color: rgba(117, 184, 178, 0.2);
    color: var(--teal);
}

.match-score-medium {
    background-color: rgba(165, 188, 226, 0.2);
    color: var(--light-blue);
}

.match-score-low {
    background-color: rgba(123, 107, 158, 0.2);
    color: var(--dark-purple);
}

.hidden {
    display: none;
}

.no-results {
    text-align: center;
    padding: clamp(15px, 5vw, 30px);
    color: #666;
    width: 100%;
}

.badge {
    display: inline-block;
    padding: clamp(2px, 1vw, 4px) clamp(4px, 1.5vw, 8px);
    border-radius: 20px;
    font-size: clamp(0.7rem, 2vw, 0.75rem);
    font-weight: 600;
}

.badge-metric {
    background-color: rgba(117, 184, 178, 0.2);
    color: var(--teal);
}

.badge-imperial {
    background-color: rgba(165, 188, 226, 0.2);
    color: var(--light-blue);
}

.badge-pipe {
    background-color: rgba(123, 107, 158, 0.2);
    color: var(--dark-purple);
}

.badge-special {
    background-color: rgba(181, 174, 210, 0.2);
    color: var(--light-purple);
}

.footer {
    margin-top: auto;
    text-align: center;
    padding: clamp(10px, 3vw, 20px) 0;
    color: #888;
    font-size: clamp(0.75rem, 2.5vw, 0.875rem);
    width: 100%;
}

/* Coming Soon Page Styles */
.coming-soon-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin: 40px auto;
    max-width: 800px;
    padding: clamp(20px, 5vw, 40px);
    background-color: var(--white);
    border-radius: 20px;
    box-shadow:
        8px 8px 16px var(--shadow-dark),
        -8px -8px 16px var(--shadow-light);
}

.coming-soon-container svg {
    width: clamp(80px, 15vw, 150px);
    height: clamp(80px, 15vw, 150px);
    margin-bottom: 20px;
    color: var(--dark-purple);
}

.coming-soon-container h2 {
    color: var(--dark-purple);
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    margin-bottom: 15px;
}

.coming-soon-container p {
    color: #666;
    font-size: clamp(1rem, 3vw, 1.25rem);
    margin-bottom: 25px;
    max-width: 600px;
}

.coming-soon-container .btn {
    max-width: 250px;
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
    }

    .input-section {
        max-width: 100%;
    }

    .results-section {
        position: static;
        width: 100%;
    }

    .nav-container {
        flex-direction: column;
        gap: 10px;
    }

    .nav-links {
        width: 100%;
        justify-content: space-between;
    }
}

/* Additional mobile optimizations */
@media (max-width: 600px) {
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px 25px;
    }

    .nav-links li {
        flex-basis: 40%;
        text-align: center;
    }

    .results-container {
        grid-template-columns: 1fr;
    }

    .result-detail {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-value {
        text-align: left;
        width: 100%;
    }

    .card h2,
    .results-card h2 {
        font-size: 1.1rem;
    }

    .card h2 svg,
    .results-card h2 svg {
        width: 18px;
        height: 18px;
    }

    /* Make touch targets larger for mobile */
    .btn {
        padding: 15px;
        font-size: 1rem;
    }

    .neomorphic-input,
    .neomorphic-select {
        font-size: 16px;
        /* Prevent iOS zoom on input focus */
        padding: 12px 15px;
    }
}

/* Add better touch/hover handling for mobile */
@media (hover: hover) {
    .btn:hover {
        transform: translateY(-2px);
    }

    .result-item:hover {
        transform: translateY(-3px);
    }

    .nav-links a:hover {
        color: var(--dark-purple);
    }
}

@media (hover: none) {
    .btn:active {
        transform: translateY(1px);
    }

    .result-item:active {
        transform: translateY(0);
    }
}

/* Additional styles for calculator forms */
.calculator-form {
    margin-top: 30px;
    width: 100%;
}

.calculator-form form {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #666;
    font-weight: 500;
}

.input-with-unit {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-unit input {
    width: 100%;
    padding-right: 40px;
}

.unit {
    position: absolute;
    right: 15px;
    color: #999;
    font-size: 0.9rem;
}

.slider-container {
    display: flex;
    flex-direction: column;
}

.range-slider {
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--gray);
    outline: none;
    margin: 10px 0;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--blue-accent);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.range-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--blue-accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.slider-value {
    align-self: flex-end;
    font-weight: 600;
    color: var(--dark-purple);
}

.formula-display {
    background-color: var(--gray-light);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
}

.formula {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--dark-purple);
    text-align: center;
    margin-bottom: 15px;
}

.formula-explanation {
    font-size: 0.95rem;
    color: #666;
}

.formula-explanation p {
    margin: 5px 0;
}

.diagram-image {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin: 20px 0;
}

/* Results display for calculators - this is different from thread results */
.result-display {
    margin-top: 30px;
    background: linear-gradient(145deg, var(--light-blue), var(--blue-accent) 120%);
    color: white;
    border-radius: 10px;
    padding: 25px;
    text-align: center;
}

/* These styles are for the calculator results, not thread results */
.result-display .result-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
    text-align: center;
}

.result-unit {
    font-size: 1.2rem;
    opacity: 0.8;
}

.result-explanation {
    margin-top: 15px;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Mobile adjustments for calculator */
@media (max-width: 768px) {
    .calculator-form form {
        grid-template-columns: 1fr;
    }

    .formula {
        font-size: 1.2rem;
    }
    
    /* Responsive adjustments for result details layout */
    .result-details-labels, .result-details-values {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 5px 15px;
    }
    
    .result-label, .result-value {
        padding: 3px 0;
    }
}

@media (max-width: 480px) {
    .result-details-labels, .result-details-values {
        grid-template-columns: 1fr;
    }
    
    .match-score {
        flex-direction: column;
        gap: 5px;
        text-align: center;
    }
}