/* ===== Design Variables ===== */
:root {
    --bg-color: #0b0e14;
    --bg-secondary: #151a25;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --card-bg: rgba(21, 26, 37, 0.7);
    --card-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
}

/* ===== Resets & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.08), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(59, 130, 246, 0.06), transparent 25%);
    background-attachment: fixed;
}

#app {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    /* overflow: hidden; removed to allow position: sticky */
}

/* ===== Screens Visibility ===== */
.screen {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    padding: 1.5rem;
    animation: fadeIn 0.4s ease-out;
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== Typography ===== */
h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ===== Home Screen ===== */
#home-screen header {
    text-align: center;
    margin-top: 10vh;
    margin-bottom: 3rem;
}

.logo {
    color: var(--accent-primary);
    margin-bottom: 1rem;
}

.telescope-selection {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ===== Glassmorphism Cards & Buttons ===== */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 1rem;
    box-shadow: var(--glass-shadow);
    padding: 1.5rem;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    outline: none;
    background: none;
}

.telescope-btn {
    text-align: left;
    width: 100%;
}

.telescope-btn:hover {
    transform: translateY(-2px);
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.15);
}

.card-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.icon {
    font-size: 1.25rem;
    color: var(--accent-primary);
    transition: transform 0.3s ease;
}

.telescope-btn:hover .icon {
    transform: translateX(5px);
}

/* ===== Buttons ===== */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.2s ease;
}

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

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

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.1);
}

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

.btn-icon {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s;
}

.btn-icon:hover {
    color: var(--text-primary);
}

.full-width {
    width: 100%;
}

.mt-4 {
    margin-top: 1.5rem;
}

.export-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.export-btn {
    padding: 1rem;
    font-size: 0.9rem;
}

.export-btn .card-content {
    justify-content: center;
}

/* PDF Export hidden container styling */
#pdf-export-container {
    padding: 20px;
    background: white;
    color: black;
    font-family: 'Inter', sans-serif;
}

#pdf-export-container img {
    max-width: 100%;
    margin-bottom: 10px;
}

#pdf-export-container .pdf-step {
    margin-bottom: 30px;
    page-break-inside: avoid;
}

#pdf-export-container h1, #pdf-export-container h2 {
    color: #333;
    margin-bottom: 15px;
}

/* ===== Guide Screen ===== */
.guide-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    background-color: var(--bg-color);
    z-index: 100;
    margin: 0 -1.5rem 1.5rem -1.5rem; /* Offset the screen padding */
}

/* Ensure sticky works by checking parent constraints */
.screen {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    padding: 1.5rem;
    animation: fadeIn 0.4s ease-out;
    /* Remove overflow: hidden if it exists on parents or here that might break sticky */
}

#app {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    /* overflow: hidden; */ /* Removing this as it breaks position: sticky */
}

.infinite-scroll-mode .step-container {
    overflow-y: visible; /* Changed from auto to visible to allow body/app scroll to drive sticky */
    -ms-overflow-style: none;
    scrollbar-width: none;
    padding-bottom: 3rem;
}

.nav-left {
    display: flex;
    gap: 1rem;
}

.progress-container {
    flex-grow: 1;
    margin: 0 1.5rem;
    height: 6px;
    background-color: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--accent-primary);
    width: 0%;
    transition: width 0.3s ease;
}

.step-counter {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text-secondary);
}

.step-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.step-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.4s ease-out;
}

.step-content.slide-left {
    animation: slideInLeft 0.3s ease-out;
}

.step-content.slide-right {
    animation: slideInRight 0.3s ease-out;
}

.step-image-container {
    width: 100%;
    border-radius: 0.75rem;
    overflow: hidden;
    background-color: var(--bg-secondary);
    border: 1px solid var(--card-border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.step-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    max-height: 50vh;
}

.step-description {
    font-size: 1.125rem;
    color: var(--text-primary);
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 0.75rem;
    border: 1px solid var(--card-border);
    white-space: pre-line;
}

.guide-controls {
    display: flex;
    justify-content: space-between;
    padding-top: 1.5rem;
    margin-top: auto;
}

/* ===== Tips Screen ===== */
.tips-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.tips-card {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.icon-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#tips-list {
    list-style-position: inside;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#tips-list li {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 0.5rem;
    border-left: 4px solid var(--accent-primary);
    line-height: 1.5;
}

/* ===== Responsive Adjustments ===== */
@media (max-width: 600px) {
    .screen {
        padding: 1rem;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    .guide-nav {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .progress-container {
        order: 3;
        width: 100%;
        margin: 0;
    }
    
    .step-counter {
        order: 2;
    }
    
    .desktop-text {
        display: none;
    }
}

/* ===== Infinite Scroll Mode ===== */
.infinite-scroll-mode .progress-container,
.infinite-scroll-mode .step-counter,
.infinite-scroll-mode .guide-controls {
    display: none !important;
}

.infinite-scroll-mode .step-container {
    overflow-y: visible;
    padding-bottom: 3rem;
}

.infinite-scroll-mode .step-content {
    animation: none;
}

.step-card {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px dashed var(--card-border);
}
.step-card:last-child {
    border-bottom: none;
}

.step-badge {
    display: inline-block;
    background: var(--accent-primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* ===== Chapters Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(11, 14, 20, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 1rem;
}

.modal-body {
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Custom Scrollbar for Modal */
.modal-body::-webkit-scrollbar {
    width: 6px;
}
.modal-body::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 4px;
}

.chapters-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chapter-item {
    background: rgba(255,255,255,0.03);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chapter-item:hover, .chapter-item.active {
    background: rgba(59, 130, 246, 0.15);
    border-left: 4px solid var(--accent-primary);
}

.chapter-step-num {
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 0.875rem;
}

.chapter-preview {
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
