/* Accessibility Styles */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #1d2757;
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 0 0 4px 4px;
    z-index: 1000;
    transition: top 0.3s;
}

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f9;
    color: #333;
}

header {
    background-color: #1d2757;
    color: white;
    padding: 1rem;
    text-align: center;
}

h1 {
    margin: 0;
}

main {
    padding: 1rem;
}

#activity {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
}

#steps-container,
#drop-zone {
    width: 45%;
    padding: 1rem;
    border: 2px dashed #1d2757;
    border-radius: 5px;
    background-color: #e8ebf2;
}

.step {
    background-color: #1d2757;
    color: white;
    padding: 0.5rem;
    margin: 0.5rem 0;
    border-radius: 5px;
    cursor: grab;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    position: relative;
}

.step:active {
    cursor: grabbing;
}

.step:focus {
    outline: none;
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5);
    transform: scale(1.02);
}

.step:hover {
    background-color: #141d42;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(29, 39, 87, 0.3);
}

.step.selected {
    background-color: #28a745;
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.3);
}

.step.keyboard-moving {
    background-color: #ffc107;
    color: #212529;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

#ordered-steps {
    min-height: 350px;
    padding: 0.5rem;
    background-color: white;
    border: 2px dashed #ccc;
    border-radius: 5px;
    transition: all 0.3s ease;
    position: relative;
}

#ordered-steps:empty::after {
    content: "Drop steps here in the correct order";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-style: italic;
    pointer-events: none;
}

#ordered-steps.drag-over {
    border-color: #1d2757;
    background-color: #e8ebf2;
    border-style: solid;
}

#ordered-steps:focus-within {
    border-color: #1d2757;
    box-shadow: 0 0 0 2px rgba(29, 39, 87, 0.2);
}

form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

fieldset {
    border: none;
    padding: 0;
    margin: 0;
    grid-column: span 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

legend {
    font-weight: bold;
    margin-bottom: 1rem;
}

form label {
    grid-column: span 2;
    font-weight: bold;
    color: #333;
    margin-top: 0.5rem;
}

form input {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

form input:focus {
    outline: none;
    border-color: #1d2757;
    box-shadow: 0 0 0 2px rgba(29, 39, 87, 0.2);
}

form input:invalid {
    border-color: #dc3545;
}

form input:invalid:focus {
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.2);
}

button {
    grid-column: span 2;
    padding: 0.5rem;
    background-color: #d13138;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: bold;
}

button:hover {
    background-color: #a9262c;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(209, 49, 56, 0.3);
}

button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(209, 49, 56, 0.4);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(209, 49, 56, 0.3);
}

button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#result {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #fff;
}

#order-feedback {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 5px;
    font-weight: bold;
}

.feedback-correct {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.feedback-incorrect {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.feedback-neutral {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

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

.button-group button {
    flex: 1;
    margin-top: 0;
    height: auto;
    align-self: stretch;
}

/* Activity Section Styling */
.activity-section {
    margin: 2rem 0;
    padding: 1.5rem;
    border: 2px solid #1d2757;
    border-radius: 10px;
    background-color: #ffffff;
    box-shadow: 0 2px 8px rgba(29, 39, 87, 0.1);
}

.activity-section h2 {
    color: #1d2757;
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
    border-bottom: 2px solid #1d2757;
    padding-bottom: 0.5rem;
}

.activity-description {
    margin-bottom: 1.5rem;
    font-style: italic;
    color: #555;
    background-color: #f8f9fa;
    padding: 0.75rem;
    border-left: 4px solid #1d2757;
    border-radius: 0 5px 5px 0;
}

/* Help Section Accordion */
.help-section {
    margin-top: 1rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #f8f9fa;
}

.help-toggle {
    width: 100%;
    padding: 0.75rem;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    color: #1d2757;
    border-radius: 5px;
}

.help-toggle:hover {
    background-color: #e9ecef;
}

.help-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(29, 39, 87, 0.4);
    background-color: #e9ecef;
}

@media (forced-colors: active) {

    .skip-link:focus,
    .step:focus,
    button:focus,
    input:focus,
    .help-toggle:focus {
        outline: 2px solid;
        outline-offset: 2px;
    }
}

.help-arrow {
    transition: transform 0.3s ease;
}

.help-toggle[aria-expanded="true"] .help-arrow {
    transform: rotate(180deg);
}

.help-content {
    padding: 0 0.75rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.help-content[aria-hidden="false"] {
    max-height: 500px;
    padding: 0.75rem;
}

.help-content h4 {
    margin-top: 0;
    color: #1d2757;
}

.help-content ol {
    margin: 0.5rem 0;
    padding-left: 1.2rem;
}

.help-content li {
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.help-content strong {
    color: #1d2757;
}

.help-content em {
    color: #666;
    font-size: 0.9rem;
}

/* Calculation Help Specific Styling */
.calculation-example {
    background-color: #e8ebf2;
    padding: 1rem;
    border-radius: 5px;
    margin: 1rem 0;
    border-left: 4px solid #1d2757;
}

.calculation-example h5 {
    margin-top: 0;
    color: #1d2757;
    font-size: 1rem;
}

.calculation-example ul {
    margin: 0.5rem 0;
    padding-left: 1.2rem;
}

.calculation-example li {
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.tip-box {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 5px;
    padding: 0.75rem;
    margin-top: 1rem;
}

.tip-box p {
    margin: 0;
    font-size: 0.9rem;
    color: #856404;
}

/* Compound Selection Styling */
.compound-selection {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 5px;
    border-left: 4px solid #1d2757;
}

.compound-selection label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #1d2757;
}

#compound-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: white;
    font-size: 1rem;
}

.compound-info {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: #e8ebf2;
    border-radius: 5px;
    border: 1px solid #1d2757;
}

.compound-info h3 {
    margin-top: 0;
    color: #1d2757;
}

.compound-info p {
    margin-bottom: 0;
    color: #555;
}

/* Responsive Design for Accessibility */
@media (max-width: 768px) {
    #activity {
        flex-direction: column;
    }

    #steps-container,
    #drop-zone {
        width: 100%;
        margin-bottom: 1rem;
    }

    form {
        grid-template-columns: 1fr;
    }

    form label,
    fieldset {
        grid-column: span 1;
    }

    fieldset {
        display: block;
    }
}

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

@media (prefers-high-contrast: high) {
    .step {
        border: 3px solid;
    }

    .step:focus {
        border-width: 4px;
    }
}