/* ============================================
   CSS Variables - Dark Mode Apple-inspired Theme
   ============================================ */

:root {
    /* Apple Blue Accent */
    --apple-blue: #0a84ff;
    --apple-blue-hover: #0071e3;
    --apple-blue-active: #0051d5;
    
    /* Dark Background Colors */
    --bg-gradient-start: #050509;
    --bg-gradient-end: #111217;
    --card-bg-primary: #111827;
    --card-bg-secondary: #171e29;
    
    /* Text Colors */
    --text-primary: #f5f5f7; /* Almost white */
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    /* Borders and Dividers */
    --border-primary: rgba(255, 255, 255, 0.08);
    --border-secondary: rgba(255, 255, 255, 0.06);
    --divider: rgba(255, 255, 255, 0.1);
    
    /* Shadows - Dark mode */
    --card-shadow: 0 18px 45px rgba(0, 0, 0, 0.8), 0 8px 16px rgba(0, 0, 0, 0.6);
    --card-shadow-hover: 0 24px 60px rgba(0, 0, 0, 0.9), 0 12px 24px rgba(0, 0, 0, 0.7);
    --button-shadow: 0 4px 12px rgba(10, 132, 255, 0.3);
    --button-shadow-hover: 0 6px 20px rgba(10, 132, 255, 0.4);
    
    /* Answer Key Accent */
    --answer-accent: rgba(48, 209, 88, 0.3); /* Soft green at low opacity */
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 14px; /* Apple-style rounded corners */
    --radius-pill: 9999px; /* Pill shape for buttons */
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --letter-spacing-tight: -0.02em;
}

/* ============================================
   Reset & Base Styles
   ============================================ */

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

body {
    font-family: var(--font-family);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(180deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    padding: var(--spacing-md);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Container & Layout
   ============================================ */

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--spacing-lg);
    animation: fadeInUp 0.2s ease-out;
}

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

@keyframes checkboxPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* ============================================
   Header Section
   ============================================ */

.header {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-secondary);
    box-shadow: var(--card-shadow);
    padding: var(--spacing-lg) var(--spacing-lg) var(--spacing-xl) var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
    text-align: center;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: rgba(17, 24, 39, 0.8);
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 40px 40px;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.header:hover {
    box-shadow: var(--card-shadow-hover);
    transform: scale(1.01);
}

.title {
    font-size: 2.6rem;
    font-weight: 600; /* Lighter weight */
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.header-title {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.75rem; /* 12px spacing between logo and title */
}

.logo {
    height: 40px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.title-icon {
    width: 32px;
    height: 32px;
    opacity: 0.9;
    color: var(--text-primary);
    flex-shrink: 0;
}

.subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    font-weight: 400;
    line-height: 1.5;
}

/* ============================================
   Card/Panel Styling
   ============================================ */

.controls-section {
    background: var(--card-bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.controls-section:hover {
    box-shadow: var(--card-shadow-hover);
    transform: scale(1.01);
}

/* Worksheet and Answer Key - Light Mode for Readability */
.worksheet-section,
.answers-section {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.08);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.worksheet-section:hover,
.answers-section:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1), 0 3px 6px rgba(0, 0, 0, 0.06);
    transform: scale(1.01);
}

.section-label {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
    margin-top: 0;
    padding-bottom: var(--spacing-xs);
    border-bottom: 1px solid var(--divider);
    letter-spacing: var(--letter-spacing-tight);
}

/* Section labels in light mode cards */
.worksheet-section .section-label,
.answers-section .section-label {
    color: #1d1d1f;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* ============================================
   Controls Styling
   ============================================ */

.control-group {
    margin-bottom: var(--spacing-lg);
}

.control-group:last-of-type {
    margin-bottom: 0;
}

.control-label {
    display: block;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: var(--spacing-xs);
    margin-top: 0;
    font-size: 1rem;
    letter-spacing: -0.01em;
}

/* Slider Input - Apple Blue */
.slider-input {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    margin-top: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
    cursor: pointer;
}

.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--apple-blue);
    cursor: pointer;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(10, 132, 255, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.slider-input::-webkit-slider-thumb:hover {
    background: var(--apple-blue-hover);
    transform: scale(1.1);
    box-shadow: 0 3px 12px rgba(10, 132, 255, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.slider-input::-webkit-slider-thumb:active {
    background: var(--apple-blue-active);
    transform: scale(0.95);
}

.slider-input::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--apple-blue);
    cursor: pointer;
    border: none;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(10, 132, 255, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.slider-input::-moz-range-thumb:hover {
    background: var(--apple-blue-hover);
    transform: scale(1.1);
    box-shadow: 0 3px 12px rgba(10, 132, 255, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.slider-input::-moz-range-thumb:active {
    background: var(--apple-blue-active);
    transform: scale(0.95);
}

.slider-input:focus {
    outline: none;
}

.slider-input:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.3), 0 2px 8px rgba(10, 132, 255, 0.4);
}

.slider-input:focus::-moz-range-thumb {
    box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.3), 0 2px 8px rgba(10, 132, 255, 0.4);
}

#numQuestionsValue {
    font-weight: 600;
    color: var(--text-primary); /* White for values */
    font-size: 1.125rem;
}

/* Preset Buttons */
.preset-buttons {
    display: flex;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-sm);
    flex-wrap: wrap;
}

.preset-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-family: var(--font-family);
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 36px;
    box-shadow: none;
}

.preset-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.4);
    color: var(--text-primary);
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.preset-btn:active {
    transform: scale(0.98);
}

.preset-btn:focus {
    outline: 2px solid var(--apple-blue);
    outline-offset: 2px;
}

/* Times Tables Grid */
.tables-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-sm);
    margin-top: var(--spacing-xs);
}

.checkbox-label.preset-applied {
    animation: checkboxPulse 0.4s ease;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: var(--spacing-sm) var(--spacing-xs);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    min-height: 48px;
    position: relative;
    border: 1px solid transparent;
}

.checkbox-label:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.checkbox-label.checkbox-checked {
    background: rgba(10, 132, 255, 0.12);
    border-color: rgba(10, 132, 255, 0.3);
}

.checkbox-label.checkbox-checked .checkbox-text {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 500;
}

/* Fallback for browsers that support :has() */
.checkbox-label:has(.checkbox-input:checked) {
    background: rgba(10, 132, 255, 0.12);
    border-color: rgba(10, 132, 255, 0.3);
}

.checkbox-label:has(.checkbox-input:checked) .checkbox-text {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 500;
}

.checkbox-input {
    width: 20px;
    height: 20px;
    margin-right: var(--spacing-xs);
    cursor: pointer;
    accent-color: var(--apple-blue);
    flex-shrink: 0;
    transition: filter 0.2s ease;
    border-radius: 4px;
    background: var(--card-bg-secondary);
    border: 1.5px solid var(--border-primary);
}

.checkbox-input:hover {
    filter: brightness(1.1);
    border-color: rgba(255, 255, 255, 0.15);
}

.checkbox-input:checked {
    background: var(--apple-blue);
    border-color: var(--apple-blue);
}

.checkbox-text {
    font-size: 1rem;
    color: var(--text-primary);
    user-select: none;
    font-weight: 400;
    transition: color 0.2s ease, font-weight 0.2s ease;
}

/* Error Messages */
.error-message {
    display: block;
    color: #ff453a; /* Apple red for errors */
    font-size: 0.875rem;
    margin-top: var(--spacing-xs);
    min-height: 1.5rem;
}

/* ============================================
   Buttons
   ============================================ */

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-lg);
}

.btn {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-family: var(--font-family);
    font-weight: 500; /* Lighter weight */
    border: none;
    border-radius: var(--radius-pill); /* Pill shape */
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    flex: 1;
    min-width: 150px;
    letter-spacing: -0.01em;
}

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

.btn-primary {
    background: var(--apple-blue);
    color: white;
    box-shadow: var(--button-shadow);
}

.btn-primary:hover:not(:disabled) {
    background: var(--apple-blue-hover);
    box-shadow: var(--button-shadow-hover);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0) scale(0.97);
    background: var(--apple-blue-active);
}

.btn-primary:focus {
    outline: 2px solid var(--apple-blue);
    outline-offset: 2px;
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.35);
    color: var(--text-primary);
}

.btn-secondary:active:not(:disabled) {
    transform: scale(0.97);
    background: rgba(255, 255, 255, 0.08);
}

.btn-secondary:focus {
    outline: 2px solid var(--apple-blue);
    outline-offset: 2px;
}

/* ============================================
   Worksheet & Answers Sections
   ============================================ */

.questions-list,
.answers-list {
    list-style: decimal;
    padding-left: var(--spacing-lg);
    margin-top: var(--spacing-md);
}

/* Dynamic column layout for questions */
.questions-list {
    display: grid;
    grid-template-columns: repeat(var(--column-count, 1), 1fr);
    column-gap: var(--spacing-md);
    list-style: none;
    counter-reset: question-counter;
    padding-left: 0;
}

.questions-list li {
    counter-increment: question-counter;
    margin-bottom: var(--spacing-sm);
    padding-left: 3.5rem;
    padding-bottom: 0.5rem;
    position: relative;
    color: #1d1d1f; /* Dark text for readability */
    line-height: 1.8;
    border-bottom: 1px solid #c9c9c9; /* Visible blank lines */
}

.questions-list li::before {
    content: counter(question-counter) ") ";
    position: absolute;
    left: 0;
    min-width: 3rem;
    text-align: right;
    padding-right: 0.5rem;
    color: #1d1d1f; /* Dark text for readability */
}

.answers-list {
    list-style: decimal;
}

.answers-list li {
    margin-bottom: var(--spacing-md);
    padding-left: var(--spacing-xs);
    font-size: 1.125rem;
    line-height: 1.8;
    color: #1d1d1f; /* Dark text for readability */
}

.answers-section {
    background: #f8f8f8; /* Slightly off-white for answer key */
    border-left: 3px solid #d1f2eb; /* Light green accent for light mode */
}

/* ============================================
   Accessibility
   ============================================ */

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

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
    .container {
        padding: var(--spacing-sm);
    }
    
    .title {
        font-size: 2rem;
        flex-direction: column;
    }
    
    .title-icon {
        width: 28px;
        height: 28px;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .tables-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .header {
        padding: var(--spacing-lg);
    }
}

@media (max-width: 480px) {
    body {
        padding: var(--spacing-xs);
    }
    
    .title {
        font-size: 1.75rem;
    }
    
    .tables-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .controls-section,
    .worksheet-section,
    .answers-section {
        padding: var(--spacing-md);
    }
}

/* ============================================
   Print Stylesheet
   ============================================ */

@media print {
    /* Hide presentation overlay in print */
    .presentation-overlay {
        display: none !important;
    }
    
    /* Override all dark styles - force white background */
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        border-color: #e2e8f0 !important;
    }
    
    body {
        background: white !important;
        padding: 0;
    }
    
    .container {
        max-width: 100%;
        padding: var(--spacing-md);
        animation: none;
    }
    
    .header {
        display: none !important;
    }
    
    /* Hide all controls */
    .controls-section {
        display: none !important;
    }
    
    /* Hide answer key */
    .answers-section {
        display: none !important;
    }
    
    /* Show only worksheet */
    .worksheet-section {
        display: block !important;
        background: white !important;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        page-break-inside: avoid;
    }
    
    .section-label {
        color: black !important;
        border-bottom: 2px solid black !important;
    }
    
    /* Clean question layout for printing */
    .questions-list {
        padding-left: 0;
        margin: 0;
        display: grid !important;
        grid-template-columns: repeat(var(--column-count, 1), 1fr) !important;
        column-gap: 1rem;
    }
    
    .questions-list li {
        margin-bottom: 0.75rem;
        padding-bottom: 0.5rem;
        padding-left: 3.5rem;
        border-bottom: 1px dotted #e2e8f0;
        color: black !important;
        break-inside: avoid;
    }
    
    .questions-list li::before {
        min-width: 3rem;
        text-align: right;
        padding-right: 0.5rem;
        color: black !important;
    }
    
    /* Ensure good spacing for writing answers */
    .questions-list li::after {
        content: "";
        display: block;
        height: 1.5rem;
    }
}

/* ============================================
   Presentation Mode Overlay
   ============================================ */

.presentation-overlay {
    position: fixed;
    inset: 0; /* Covers entire viewport */
    background: #000; /* Solid black background like PowerPoint */
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    overflow: hidden; /* Prevent scroll on overlay itself */
}

/* Presentation Panel - fills entire viewport */
.presentation-panel {
    background: #ffffff;
    border-radius: 0;
    box-shadow: none;
    
    /* Fill entire viewport */
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

.presentation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: #f8f8f8;
    flex-shrink: 0;
    position: relative;
    min-height: 64px; /* Fixed height to prevent shifting */
    box-sizing: border-box;
}

.presentation-controls {
    position: relative; /* For tooltip positioning */
    display: flex;
    gap: var(--spacing-xs);
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 auto; /* Prevent controls from shrinking */
    margin-left: var(--spacing-md); /* Space between title and controls */
}

.presentation-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: #1d1d1f;
    margin: 0;
    padding: 0;
    letter-spacing: var(--letter-spacing-tight);
    flex: 0 0 auto; /* Prevent title from shrinking */
}

.presentation-btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-family: var(--font-family);
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    color: #1d1d1f;
    border: 1px solid rgba(0, 0, 0, 0.2);
    white-space: nowrap; /* Prevent text wrapping */
    flex-shrink: 0; /* Prevent buttons from shrinking */
    min-height: 36px; /* Consistent button height */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.presentation-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.3);
}

.presentation-btn:active {
    transform: scale(0.97);
}

.presentation-btn-help {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
    border: 1px solid rgba(0, 0, 0, 0.2);
    background: transparent;
    color: #1d1d1f;
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
    font-weight: 600;
}

.presentation-btn-help:hover {
    background: rgba(0, 0, 0, 0.1);
}

.presentation-btn-help span {
    display: block;
    line-height: 1;
}

.presentation-btn-close {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    line-height: 1;
    border: 1px solid rgba(0, 0, 0, 0.2);
    flex-shrink: 0; /* Prevent close button from shrinking */
}

.presentation-btn-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Help tooltip */
.presentation-help-tooltip {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 10001;
    animation: tooltipFadeIn 0.2s ease;
    pointer-events: none; /* Allow clicks to pass through when hidden */
}

.presentation-help-tooltip[style*="block"] {
    pointer-events: auto; /* Enable clicks when visible */
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.presentation-help-tooltip.fade-out {
    animation: tooltipFadeOut 0.2s ease forwards;
}

@keyframes tooltipFadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-4px);
    }
}

.tooltip-content {
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-size: 0.875rem;
    color: #1d1d1f;
    line-height: 1.5;
    min-width: 180px;
}

.tooltip-content strong {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.tooltip-shortcut {
    margin-top: 0.25rem;
    padding-left: 0.5rem;
}

.presentation-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0; /* Allow flexbox to shrink */
    width: 100%;
}

.presentation-questions-list {
    display: grid;
    grid-template-columns: repeat(var(--presentation-columns, 3), minmax(0, 1fr));
    gap: 2rem 3rem; /* vertical, horizontal */
    padding: 2rem 3rem;
    margin: auto;
    font-size: var(--presentation-font-size, 24px);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    align-self: center;
}

.presentation-question {
    white-space: nowrap;
    color: #1d1d1f;
    line-height: 1.6;
}

.presentation-answers-section {
    /* Answer key section is not used in presentation mode - answers are shown inline */
    display: none !important;
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-xl);
    border-top: 2px solid rgba(0, 0, 0, 0.1);
}

.presentation-answers-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: var(--spacing-lg);
    letter-spacing: var(--letter-spacing-tight);
}

.presentation-answers-list {
    list-style: decimal;
    padding-left: var(--spacing-xl);
    margin: 0;
}

.presentation-answers-list li {
    margin-bottom: var(--spacing-md);
    padding-left: var(--spacing-xs);
    line-height: 2;
    color: #1d1d1f;
    font-size: var(--presentation-font-size, 20px); /* Match question font size */
}

/* Responsive adjustments for presentation mode */
@media (max-width: 768px) {
    .presentation-header {
        flex-direction: row;
        align-items: center;
        min-height: 56px;
    }
    
    .presentation-title {
        font-size: 1.5rem;
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .presentation-controls {
        width: auto;
        margin-left: var(--spacing-sm);
        flex-shrink: 0;
    }
    
    .presentation-questions-list {
        padding: 1.5rem 2rem;
        gap: 1.5rem 2rem;
    }
}

@media (max-width: 480px) {
    .presentation-header {
        padding: var(--spacing-md);
        min-height: 52px;
    }
    
    .presentation-title {
        font-size: 1.25rem;
    }
    
    .presentation-controls {
        gap: var(--spacing-xs);
        margin-left: var(--spacing-xs);
    }
    
    .presentation-questions-list {
        padding: 1rem 1.5rem;
        gap: 1rem 1.5rem;
    }
    
    .presentation-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.875rem;
        min-height: 32px;
    }
    
    .presentation-btn-help {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
    }
    
    .presentation-btn-close {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        font-size: 1.25rem;
    }
}

/* ============================================
   About Section
   ============================================ */

.about-section {
    max-width: 800px;
    margin: var(--spacing-xl) auto;
    padding: var(--spacing-lg);
    text-align: center;
}

.about-section h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
    letter-spacing: var(--letter-spacing-tight);
}

.about-section p {
    font-size: 1rem;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.85);
    margin: 0;
}

/* ============================================
   Footer
   ============================================ */

.site-footer {
    margin-top: 70px;
    padding-top: 60px;
    padding-bottom: 40px;
    border-top: 1px solid var(--border-primary);
    background: #0f0f0f;
    width: 100%;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

.footer-branding {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xl);
    text-align: center;
}

.footer-logo {
    width: 32px;
    height: 32px;
    opacity: 0.9;
    flex-shrink: 0;
}

.footer-branding-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.footer-site-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.footer-tagline {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.footer-link-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.footer-group-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-xs);
}

.footer-group-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    letter-spacing: -0.01em;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.footer-link:focus {
    outline: 2px solid var(--apple-blue);
    outline-offset: 2px;
    border-radius: 2px;
}

.footer-copyright {
    text-align: center;
    padding-top: 40px;
    border-top: 1px solid var(--border-secondary);
}

.footer-copyright p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Footer Responsive */
@media (max-width: 768px) {
    .footer-branding {
        flex-direction: column;
        gap: var(--spacing-xs);
    }
    
    .footer-links {
        gap: var(--spacing-lg);
    }
    
    .footer-content {
        padding: 0 var(--spacing-md);
    }
}

@media (max-width: 600px) {
    /* Grid Fixes */
    .tables-grid {
        grid-template-columns: repeat(2, 1fr);
        justify-items: center;
    }
    
    .checkbox-text {
        font-size: 0.9rem;
    }
    
    /* Button Improvements */
    .btn {
        min-height: 48px;
        padding: 0.75rem 1.25rem;
        font-size: 1.05rem;
        width: 100%;
        max-width: 100%;
    }
    
    .button-group {
        flex-direction: column;
        align-items: center;
        gap: var(--spacing-sm);
    }
    
    /* Spacing & Margins - Reduce by 25% */
    .container {
        padding: calc(var(--spacing-lg) * 0.75);
    }
    
    .control-group {
        margin-bottom: calc(var(--spacing-md) * 0.75);
    }
    
    .button-group {
        margin-top: calc(var(--spacing-lg) * 0.75);
    }
    
    .about-section {
        margin: calc(var(--spacing-xl) * 0.75) auto;
        padding: calc(var(--spacing-lg) * 0.75);
    }
    
    .about-section h2 {
        margin-bottom: calc(var(--spacing-md) * 0.75);
    }
    
    /* Footer Fixes */
    .site-footer {
        padding-top: 40px;
        padding-bottom: 30px;
        margin-top: 50px;
    }
    
    .footer-branding {
        margin-bottom: calc(var(--spacing-xl) * 0.75);
        gap: 0.5rem;
    }
    
    .footer-links {
        flex-direction: column;
        gap: var(--spacing-md);
        margin-bottom: 30px;
        align-items: center;
    }
    
    .footer-link-group {
        width: 100%;
        align-items: center;
    }
    
    .footer-copyright {
        padding-top: 30px;
    }
    
    /* Typography */
    .page-body p,
    .about-section p,
    p {
        font-size: 0.9rem;
    }
    
    .control-label {
        font-size: 0.95rem;
    }
    
    h1, h2, h3 {
        text-align: center;
    }
    
    /* Section Spacing */
    .worksheet-section,
    .answers-section {
        margin-bottom: calc(var(--spacing-lg) * 0.75);
        padding: calc(var(--spacing-lg) * 0.75);
    }
    
    .section-label {
        margin-bottom: calc(var(--spacing-md) * 0.75);
    }
    
    /* Preset Buttons */
    .preset-buttons {
        gap: var(--spacing-xs);
    }
    
    .preset-btn {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }
}

@media (max-width: 480px) {
    .footer-links {
        flex-direction: column;
        gap: var(--spacing-md);
    }
    
    .footer-content {
        padding: 0 var(--spacing-sm);
    }
}

@media print {
    .site-footer {
        display: none !important;
    }
}

/* ============================================
   Standalone Pages (Privacy, Terms, Contact)
   ============================================ */

.page-content {
    max-width: 700px;
    margin: 0 auto;
    padding: var(--spacing-lg) 0;
}

.back-link {
    display: inline-block;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    margin-bottom: var(--spacing-lg);
    transition: color 0.2s ease;
}

.back-link:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.back-link:focus {
    outline: 2px solid var(--apple-blue);
    outline-offset: 2px;
    border-radius: 2px;
}

.page-content h1 {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-lg);
    letter-spacing: var(--letter-spacing-tight);
}

.page-body {
    color: var(--text-secondary);
    line-height: 1.8;
}

.page-body h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: var(--spacing-xl);
    margin-bottom: var(--spacing-md);
    letter-spacing: var(--letter-spacing-tight);
}

.page-body h2:first-of-type {
    margin-top: var(--spacing-lg);
}

.page-body p {
    margin-bottom: var(--spacing-md);
}

.page-body ul {
    margin-left: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
}

.page-body li {
    margin-bottom: var(--spacing-xs);
}

.page-body em {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.page-body a {
    color: var(--apple-blue);
    text-decoration: none;
    transition: color 0.2s ease;
}

.page-body a:hover {
    color: var(--apple-blue-hover);
    text-decoration: underline;
}

.page-body a:focus {
    outline: 2px solid var(--apple-blue);
    outline-offset: 2px;
    border-radius: 2px;
}

@media (max-width: 768px) {
    .page-content {
        padding: var(--spacing-md) 0;
    }
    
    .page-content h1 {
        font-size: 2rem;
    }
    
    .page-body h2 {
        font-size: 1.25rem;
    }
}
