/*
 * Activity Core Stylesheet
 * Used for Lab Activity Guides / Manuals
 */

:root {
    /* Colors - Updated to match STYLE_GUIDE.md */
    --primary-color: #1e293b;
    --secondary-color: #3b82f6;
    --accent-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #334155;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --warning-color: #f59e0b;

    /* Legacy Aliases for compatibility */
    --bg-body: var(--bg-color);
    --bg-card: var(--card-bg);
    --bg-light: #f1f5f9;
    --text-main: var(--text-color);
    --text-muted: #64748b;
    --text-light: #94a3b8;

    /* Code Colors */
    --code-bg: #1a202c;
    --code-text: #e2e8f0;
    --code-accent: #f6ad55;

    /* Spacing */
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2.5rem;
}

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

body {
    font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: var(--text-main);
    background-color: var(--bg-body);
    padding: var(--spacing-xl) var(--spacing-md);
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg-card);
    padding: var(--spacing-xl);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
}

header {
    text-align: center;
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

header h1 {
    color: var(--primary-color);
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

header .subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 500;
}

header .grade-badge {
    font-size: 0.95rem;
    margin-top: 0.5rem;
    color: var(--secondary-color);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-title {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
}

.badge {
    background-color: var(--secondary-color);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.05em;
}

.badge.green { background: var(--success-color); }
.badge.orange { background: var(--warning-color); }
.badge.purple { background: var(--primary-color); }

.instruction-box {
    background: var(--bg-light);
    border-left: 4px solid var(--secondary-color);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    border-radius: 0 8px 8px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.instruction-box.objective {
    border-left-color: var(--secondary-color);
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-left-width: 4px;
}

.step-list {
    margin-left: 1.25rem;
    margin-bottom: 1rem;
}

.step-list li {
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.step-list strong {
    color: var(--primary-color);
    font-weight: 600;
}

/* Setup box style */
.instruction-box.setup {
    border-left-color: var(--success-color);
    background: #f0faf5;
}

/* Footer checklist */
.footer-checklist {
    background: #edf2f9;
    border-radius: 2rem;
    padding: 1.5rem 2rem;
    margin: 2.5rem 0 1rem;
}

.footer-checklist ul {
    columns: 2;
    list-style: none;
    padding: 0;
}

.footer-checklist li::before {
    content: "✓ ";
    color: var(--success-color);
    font-weight: 700;
}

/* Table styles */
.table-wrap {
    overflow-x: auto;
    margin: 1.2rem 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background: var(--card-bg);
}

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

th {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

/* Interactive elements styles */
.drag-group {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin: 0.8rem 0;
}

.drag-item {
    background: #eef2ff;
    padding: 0.4rem 1rem;
    border-radius: 40px;
    border: 1px solid #b8c9f0;
    cursor: grab;
    user-select: none;
    font-weight: 500;
    transition: 0.15s;
}

.drag-item:active {
    cursor: grabbing;
}

.drop-zone {
    display: inline-block;
    background: var(--bg-color);
    border: 2px dashed #b8c9f0;
    border-radius: 40px;
    padding: 0.4rem 1.2rem;
    min-width: 120px;
    text-align: center;
    color: var(--text-muted);
    font-weight: 400;
    transition: 0.2s;
}

.drop-zone.dragover {
    background: #dbeafe;
    border-color: var(--primary-color);
}

.drop-zone.filled {
    background: #d4edda;
    border-color: var(--success-color);
    color: #155724;
}

.fill-blank {
    border: none;
    border-bottom: 2px solid var(--secondary-color);
    background: var(--bg-color);
    padding: 0.2rem 0.5rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--primary-color);
    text-align: center;
}

.fill-blank:focus {
    outline: none;
    border-bottom-color: var(--accent-color);
    background: var(--card-bg);
}

.matching-pairs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.match-card {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 1rem;
    padding: 1rem;
    cursor: pointer;
    transition: 0.2s;
}

.match-card:hover {
    border-color: var(--secondary-color);
    background: #eef2ff;
}

.match-card.selected {
    border-color: var(--secondary-color);
    background: #dbeafe;
}

.match-card.matched {
    border-color: var(--success-color);
    background: #d4edda;
}

.ordering-list {
    list-style: none;
    padding: 0;
}

.ordering-item {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.8rem 1rem;
    margin: 0.5rem 0;
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ordering-item:active {
    cursor: grabbing;
}

.ordering-item .drag-handle {
    color: var(--text-light);
    font-size: 1.2rem;
}

.interactive-feedback {
    margin-top: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
}

.interactive-feedback.correct {
    background: #d4edda;
    color: #155724;
}

.interactive-feedback.incorrect {
    background: #fee2e2;
    color: #b91c1c;
}

pre {
    background-color: var(--code-bg);
    color: var(--code-text);
    padding: 1.25rem;
    border-radius: 8px;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.9rem;
    overflow-x: auto;
    margin: 1rem 0;
    line-height: 1.5;
    border: 1px solid #2d3748;
}

code {
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    background: #edf2f7;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    color: #d53f8c;
    font-size: 0.85em;
    font-weight: 500;
}

pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
}

.highlight {
    background: linear-gradient(120deg, #fef3c7 0%, #fde68a 100%);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
    color: #1a202c;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.formula {
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    background: linear-gradient(135deg, var(--secondary-color) 0%, #2563eb 100%);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
    display: inline-block;
    margin: 0.25rem 0;
}

.quiz-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: var(--spacing-lg);
    margin-top: 1.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.quiz-card {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.quiz-question {
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
    font-size: 1.05rem;
}

.quiz-options {
    list-style-type: none;
    padding-left: 0.5rem;
}

.quiz-options li {
    padding: 0.5rem 0;
    color: var(--text-muted);
}

/* Question block styling */
.question-block {
    margin: 1.2rem 0 0.8rem 0;
}

.question-block strong {
    font-size: 1.05rem;
}

/* Details/summary styling */
details {
    margin: 0.8rem 0;
}

summary {
    color: var(--secondary-color);
    font-weight: 600;
    cursor: pointer;
    background: #eef4fa;
    padding: 0.3rem 0.8rem;
    border-radius: 40px;
    display: inline-block;
}

/* Answer key for quiz solutions */
.answer-key {
    background: #eaf6e6;
    padding: 0.6rem 1.2rem;
    border-radius: 1rem;
    margin-top: 0.5rem;
    border-left: 4px solid #2e7d32;
}

/* ============================================
   SHARED ACTIVITY COMPONENTS
   ============================================ */

/* Activity data tables */
.data-table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.9rem; border-radius: 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
.data-table th { background: var(--primary-color); color: white; padding: 0.6rem; text-align: left; }
.data-table td { background: white; padding: 0.6rem; border-bottom: 1px solid var(--border-color); }
.data-table tr:last-child td { border-bottom: none; }

/* Inline answer */
.inline-answer { background: #f1f5f9; padding: 0.4rem 0.6rem; border-radius: 8px; display: inline-block; margin: 0.5rem 0; white-space: pre-wrap; font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace; }
pre.inline-answer { font-size: 1.05rem; font-weight: 600; color: var(--primary-color); line-height: 1.6; }

/* Info/split/mnemonic boxes */
.info-note { background: var(--bg-light); padding: 0.6rem 1.2rem; border-radius: 1rem; margin: 1rem 0; }
.split-result { background: var(--bg-light); padding: 0.8rem 1.2rem; border-radius: 1rem; }
.mnemonic-box { background: var(--bg-light); padding: 0.8rem 1.2rem; border-radius: 1rem; margin: 1rem 0; border-left: 4px solid var(--primary-color); }

/* Interactive widgets */
.interactive-select { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
.sort-options { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.checklist { list-style: none; padding: 0; }
.checklist li { padding: 0.4rem 0; }
.match-pair { display: flex; gap: 1rem; align-items: center; margin: 0.5rem 0; }

/* ============================================
   RESPONSIVE DESIGN - STYLE GUIDE COMPLIANT
   ============================================ */

/* Mobile First - Extra Small Devices (360px and up) */
@media (max-width: 360px) {
    body {
        padding: var(--spacing-md) var(--spacing-sm);
    }

    .container {
        padding: var(--spacing-lg);
        border-radius: 8px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    header .subtitle {
        font-size: 0.95rem;
    }

    .section-title {
        font-size: 1.2rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .badge {
        font-size: 0.65rem;
        padding: 0.15rem 0.4rem;
    }

    .instruction-box {
        padding: var(--spacing-md);
    }

    pre {
        font-size: 0.8rem;
        padding: 0.75rem;
    }

    code {
        font-size: 0.75em;
    }

    .quiz-card {
        padding: var(--spacing-md);
    }

    /* Ensure touch targets are at least 44x44px */
    button, .btn, input[type="text"], select {
        min-height: 44px;
        min-width: 44px;
    }

    /* Footer checklist - single column on mobile */
    .footer-checklist ul {
        columns: 1;
    }
}

/* Small Devices (600px and up) */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.8rem;
    }

    .section-title {
        font-size: 1.4rem;
    }

    .container {
        padding: var(--spacing-lg) var(--spacing-md);
    }

    /* Responsive tables */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 0.85rem;
    }

    th, td {
        padding: 0.4rem 0.5rem;
    }

    /* Drag and drop - stack vertically */
    .drag-group {
        flex-direction: column;
        gap: 0.4rem;
    }

    .drag-item {
        padding: 0.6rem 1rem;
        width: 100%;
        text-align: center;
    }

    /* Drop zones - full width on mobile */
    .drop-zone {
        min-width: 100%;
        padding: 0.6rem 1rem;
    }

    /* Fill in blanks - wider on mobile */
    .fill-blank {
        min-width: 120px;
        padding: 0.3rem 0.6rem;
    }

    /* Matching pairs - single column */
    .matching-pairs {
        grid-template-columns: 1fr;
    }

    /* Ordering list - ensure touch targets */
    .ordering-item {
        padding: 1rem;
        min-height: 48px;
    }

    .ordering-item .drag-handle {
        font-size: 1.5rem;
    }
}

/* Medium Devices (768px and up) */
@media (max-width: 768px) {
    .container {
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }

    body {
        padding: 0;
    }

    header {
        padding: var(--spacing-lg) var(--spacing-md);
    }

    .section-title {
        margin-top: 2rem;
    }

    /* Grid layouts stack to single column */
    .grid-2 {
        grid-template-columns: 1fr;
    }

    /* Footer checklist - single column on tablet */
    .footer-checklist ul {
        columns: 1;
    }

    .footer-checklist {
        padding: var(--spacing-lg);
    }
}

/* Large Devices (1024px and up) */
@media (min-width: 1024px) {
    .container {
        max-width: 900px;
        margin: 0 auto;
        border-radius: 12px;
        box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    }

    body {
        padding: var(--spacing-xl) var(--spacing-md);
    }

    /* Footer checklist - 2 columns on larger screens */
    .footer-checklist ul {
        columns: 2;
    }
}

/* Prevent horizontal scrolling on all devices */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Ensure images and media are responsive */
img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* Touch-friendly interactive elements */
button, .btn, a, input, select, textarea {
    touch-action: manipulation;
}

/* Improve readability on mobile */
@media (max-width: 768px) {
    body {
        font-size: 16px;
        line-height: 1.6;
    }

    .section-title, header h1 {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

/* ============================================
   RESPONSIVE DESIGN - STYLE GUIDE COMPLIANT
   ============================================ */

/* Mobile First - Extra Small Devices (360px and up) */
@media (max-width: 360px) {
    body {
        padding: var(--spacing-md) var(--spacing-sm);
    }

    .container {
        padding: var(--spacing-lg);
        border-radius: 8px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    header .subtitle {
        font-size: 0.95rem;
    }

    .section-title {
        font-size: 1.2rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .badge {
        font-size: 0.65rem;
        padding: 0.15rem 0.4rem;
    }

    .instruction-box {
        padding: var(--spacing-md);
    }

    pre {
        font-size: 0.8rem;
        padding: 0.75rem;
    }

    code {
        font-size: 0.75em;
    }

    .quiz-card {
        padding: var(--spacing-md);
    }

    /* Ensure touch targets are at least 44x44px */
    button, .btn, input[type="text"], select {
        min-height: 44px;
        min-width: 44px;
    }

    /* Footer checklist - single column on mobile */
    .footer-checklist ul {
        columns: 1;
    }
}

/* Small Devices (600px and up) */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.8rem;
    }

    .section-title {
        font-size: 1.4rem;
    }

    .container {
        padding: var(--spacing-lg) var(--spacing-md);
    }

    /* Responsive tables */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 0.85rem;
    }

    th, td {
        padding: 0.4rem 0.5rem;
    }

    /* Drag and drop - stack vertically */
    .drag-group {
        flex-direction: column;
        gap: 0.4rem;
    }

    .drag-item {
        padding: 0.6rem 1rem;
        width: 100%;
        text-align: center;
    }

    /* Drop zones - full width on mobile */
    .drop-zone {
        min-width: 100%;
        padding: 0.6rem 1rem;
    }

    /* Fill in blanks - wider on mobile */
    .fill-blank {
        min-width: 120px;
        padding: 0.3rem 0.6rem;
    }

    /* Matching pairs - single column */
    .matching-pairs {
        grid-template-columns: 1fr;
    }

    /* Ordering list - ensure touch targets */
    .ordering-item {
        padding: 1rem;
        min-height: 48px;
    }

    .ordering-item .drag-handle {
        font-size: 1.5rem;
    }
}

/* Medium Devices (768px and up) */
@media (max-width: 768px) {
    .container {
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }

    body {
        padding: 0;
    }

    header {
        padding: var(--spacing-lg) var(--spacing-md);
    }

    .section-title {
        margin-top: 2rem;
    }

    /* Grid layouts stack to single column */
    .grid-2 {
        grid-template-columns: 1fr;
    }

    /* Footer checklist - single column on tablet */
    .footer-checklist ul {
        columns: 1;
    }

    .footer-checklist {
        padding: var(--spacing-lg);
    }
}

/* Large Devices (1024px and up) */
@media (min-width: 1024px) {
    .container {
        max-width: 900px;
        margin: 0 auto;
        border-radius: 12px;
        box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    }

    body {
        padding: var(--spacing-xl) var(--spacing-md);
    }

    /* Footer checklist - 2 columns on larger screens */
    .footer-checklist ul {
        columns: 2;
    }
}

/* Prevent horizontal scrolling on all devices */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Ensure images and media are responsive */
img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* Touch-friendly interactive elements */
button, .btn, a, input, select, textarea {
    touch-action: manipulation;
}

/* Improve readability on mobile */
@media (max-width: 768px) {
    body {
        font-size: 16px;
        line-height: 1.6;
    }

    .section-title, header h1 {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}
