/* Simplified Tutorial Styles for Information App */

.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease-out;
}

.tutorial-modal {
    background: var(--pico-card-background-color, white);
    border-radius: var(--pico-border-radius, 8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.4s ease-out;
    border: 1px solid var(--pico-card-border-color, #e0e0e0);
}

.tutorial-header {
    padding: 1.5rem 2rem 1rem;
    border-bottom: 1px solid var(--pico-muted-border-color, #e0e0e0);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--pico-primary-background, #1976d2);
    color: white;
    border-radius: var(--pico-border-radius, 8px) var(--pico-border-radius, 8px) 0 0;
}

.tutorial-header h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
}

.tutorial-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.tutorial-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.tutorial-close:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

.tutorial-body {
    padding: 1.5rem 2rem;
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
}

.tutorial-content h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--pico-primary, #1976d2);
    font-size: 1.1rem;
}

.tutorial-content ul,
.tutorial-content ol {
    padding-left: 1.5rem;
}

.tutorial-content li {
    margin-bottom: 0.4rem;
}

.tutorial-content strong {
    color: var(--pico-primary, #1976d2);
}

.tutorial-footer {
    padding: 1rem 2rem 1.5rem;
    border-top: 1px solid var(--pico-muted-border-color, #e0e0e0);
    background: var(--pico-background-color, #f8f9fa);
}

.tutorial-progress {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.tutorial-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--pico-muted-border-color, #e0e0e0);
    border-radius: 3px;
    overflow: hidden;
}

.tutorial-progress-fill {
    height: 100%;
    background: var(--pico-primary, #1976d2);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.tutorial-step-counter {
    font-size: 0.85rem;
    color: var(--pico-muted-color, #666);
    font-weight: 500;
    min-width: 70px;
    text-align: right;
}

.tutorial-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.tutorial-btn {
    padding: 0.4rem 1rem;
    border: 1px solid var(--pico-muted-border-color, #e0e0e0);
    border-radius: var(--pico-border-radius, 4px);
    background: white;
    color: var(--pico-color, #333);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    min-width: 70px;
}

.tutorial-btn:hover:not(:disabled) {
    background: var(--pico-background-color, #f8f9fa);
    border-color: var(--pico-primary, #1976d2);
}

.tutorial-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tutorial-btn.primary {
    background: var(--pico-primary, #1976d2);
    color: white;
    border-color: var(--pico-primary, #1976d2);
}

.tutorial-btn.primary:hover:not(:disabled) {
    background: var(--pico-primary-hover, #1565c0);
    border-color: var(--pico-primary-hover, #1565c0);
}

/* Completion message */
.tutorial-completion-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--pico-card-background-color, white);
    border: 1px solid var(--pico-form-element-valid-border-color, #28a745);
    border-radius: var(--pico-border-radius, 8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10001;
    animation: slideInRight 0.4s ease-out;
}

.completion-content {
    padding: 1rem 1.5rem;
    text-align: center;
}

.completion-content h3 {
    margin: 0 0 0.5rem 0;
    color: var(--pico-form-element-valid-border-color, #28a745);
    font-size: 1rem;
}

.completion-content p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--pico-muted-color, #666);
}

/* Introduction page specific styles */
.introduction-page .tutorial-help-text {
    background: var(--pico-background-color, #f8f9fa);
    border: 1px solid var(--pico-muted-border-color, #e0e0e0);
    border-radius: var(--pico-border-radius, 8px);
    padding: 1rem;
    margin: 1rem 0;
    text-align: center;
}

.introduction-page .tutorial-restart-btn {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--pico-secondary, #6c757d);
    color: white;
    text-decoration: none;
    border-radius: var(--pico-border-radius, 4px);
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.introduction-page .tutorial-restart-btn:hover {
    background: var(--pico-secondary-hover, #5a6268);
    color: white;
}

/* Responsive design */
@media (max-width: 768px) {
    .tutorial-modal {
        width: 95%;
        max-height: 90vh;
    }

    .tutorial-header {
        padding: 1rem 1.5rem 0.75rem;
    }

    .tutorial-header h2 {
        font-size: 1.1rem;
    }

    .tutorial-body {
        padding: 1rem 1.5rem;
    }

    .tutorial-footer {
        padding: 1rem 1.5rem;
    }

    .tutorial-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .tutorial-btn {
        width: 100%;
    }

    .tutorial-completion-message {
        top: 10px;
        right: 10px;
        left: 10px;
    }
}

@media (max-width: 480px) {
    .tutorial-modal {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .tutorial-header {
        border-radius: 0;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .tutorial-overlay,
    .tutorial-modal,
    .tutorial-progress-fill,
    .tutorial-btn,
    .tutorial-completion-message {
        animation: none !important;
        transition: none !important;
    }
}

/* Action bar — contextual CTAs above the prev/next navigation.
   Overrides Pico's connected-button [role=group] styling so each
   button stands on its own with breathing room. */
.tutorial-action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.tutorial-action-bar > [role="button"],
.tutorial-action-bar > a[role="button"] {
    margin: 0;
}

/* Course step pages — visually distinct sections so the content
   doesn't read as one long wall of text. Each <section> becomes a
   subtle card with its own background, border and padding. */
.course-step > section,
.course-step > article:not(:first-of-type) {
    background-color: var(--pico-card-sectioning-background-color, rgba(255, 255, 255, 0.03));
    border: 1px solid var(--pico-muted-border-color, rgba(255, 255, 255, 0.08));
    border-radius: var(--pico-border-radius, 0.5rem);
    padding: 1.25rem 1.5rem;
    margin-block: 1rem;
}

.course-step > section > :first-child,
.course-step > article > :first-child {
    margin-top: 0;
}

.course-step > section > :last-child,
.course-step > article > :last-child {
    margin-bottom: 0;
}

/* First section is the lead intro — render as plain prose, not a card.
   Slightly larger type so it reads as a proper opener. */
.course-step > section:first-of-type {
    background-color: transparent;
    border: none;
    padding: 0;
    margin-block: 0 1.5rem;
    font-size: 1.05rem;
}

/* Trailing footnote sections — some steps end with a muted <aside>
   inside a <section>. Render those as a callout, not a full card. */
.course-step > section:has(> aside:only-child) {
    background-color: transparent;
    border: none;
    border-left: 3px solid var(--pico-muted-border-color, rgba(255, 255, 255, 0.15));
    border-radius: 0;
    padding: 0.25rem 0 0.25rem 1rem;
    margin-block: 1rem;
    color: var(--pico-muted-color, rgba(255, 255, 255, 0.6));
}

.course-step > section > aside {
    margin: 0;
}

/* Section headings — tighter spacing, subtle accent to visually anchor. */
.course-step > section > h2 {
    margin-bottom: 0.75rem;
    font-size: 1.5rem;
}

/* Details summaries — make it obvious the rows are interactive. */
.course-step details {
    margin-block: 0.25rem;
    border-radius: var(--pico-border-radius, 0.4rem);
    padding: 0.5rem 0.75rem;
    margin-inline: -0.75rem;
    transition: background-color 0.15s ease;
}

.course-step details summary {
    cursor: pointer;
    padding: 0.1rem 0;
}

.course-step details:hover {
    background-color: var(--pico-code-background-color, rgba(255, 255, 255, 0.04));
}

.course-step details[open] {
    background-color: var(--pico-code-background-color, rgba(255, 255, 255, 0.04));
    padding-bottom: 0.9rem;
}

.course-step details[open] > p {
    margin-top: 0.65rem;
    margin-bottom: 0;
    color: var(--pico-muted-color, rgba(255, 255, 255, 0.75));
}

/* The <hr> separators become redundant once each section is its own
   card, so we hide them on course pages. */
.course-step > hr {
    display: none;
}

.course-step > header {
    margin-bottom: 1.5rem;
}

.course-step > footer {
    margin-top: 1.5rem;
}

/* Nib intro card on the first tutorial step — image + text side by
   side on desktop, stacked on narrow screens. */
.nib-intro-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.nib-intro-card__mascot {
    flex: 0 0 auto;
}

.nib-intro-card__body {
    flex: 1 1 auto;
}

.nib-intro-card__body > header {
    margin-bottom: 0.5rem;
}

.nib-intro-card__body > p:last-child {
    margin-bottom: 0;
}

@media (max-width: 600px) {
    .nib-intro-card {
        flex-direction: column;
        align-items: flex-start;
    }
}
