/* lesson-style.css */

/* 
  1. Base reset: This removes default margins and padding that browsers add, 
  and ensures borders don't increase the total width/height of our elements.
*/
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 
  2. Variables: We define some colors and sizes we'll reuse throughout the app.
  This makes it easy to change the "theme" later. 
*/
:root {
    --bg-color: #f8fafc;        /* A very light, cool gray for the background */
    --panel-bg: #ffffff;        /* Pure white for our sidebar */
    --text-primary: #000000;    /* Black for text */
    --text-secondary: #595959;  /* Secondary text / second accent color */
    --accent-color: #8989eb;    /* Main accent color for buttons and accents */
    --accent-hover: #7575d6;
    --border-color: #f7f7f7;    /* Light border color */
    --sidebar-width: 350px;    /* Custom property for the tutorial side panel width */
}

/* 3. Global Typography */
body {
    font-family: Arial, Calibri, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-color);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden; 
}

/* Add Oswald font for headings */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Oswald', sans-serif;
    font-weight: 500;
}

/* 
  4. Main Layout 
  We use CSS Grid to easily split the screen into two columns.
*/
.app-container {
    display: grid;
    /* 
      This is the magic: 
      - The first column (sidebar) takes up a variable width (defaulting to 350px).
      - The second column (simulation) takes up 1fr (the rest of the available space).
    */
    grid-template-columns: var(--sidebar-width, 350px) 1fr;
    height: 100vh;
    transition: grid-template-columns 0.15s ease-out; /* Smooth transition for preset sizing */
}

/* 5. Tutorial Panel (Sidebar) */
.tutorial-panel {
    background-color: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative; /* Anchor for absolute settings panel positioning */
}

.tutorial-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--panel-bg);
    position: relative;
    z-index: 1001;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-brand a {
    display: flex;
    align-items: center;
}

.brand-logo {
    width: 70px;
    height: auto;
    object-fit: contain;
    transition: transform 0.2s ease;
}

.brand-logo:hover {
    transform: scale(1.05);
}

.tutorial-panel header h1 {
    font-size: 1.35rem;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.1;
}

/* Settings Toggle Button with elegant animation */
.settings-toggle-btn {
    background: none;
    border: 1px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.settings-toggle-btn:hover {
    color: var(--accent-color);
    background-color: var(--bg-color);
    border-color: var(--border-color);
}

.settings-toggle-btn.active {
    color: var(--accent-hover);
    background-color: rgba(137, 137, 235, 0.1);
}

.settings-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-toggle-btn:hover .settings-icon {
    transform: rotate(90deg);
}

.settings-toggle-btn.active .settings-icon {
    transform: rotate(180deg);
}

/* Settings Panel Popover Styling */
.settings-panel {
    position: absolute;
    top: 65px;
    left: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.6);
    z-index: 1000;
    
    /* Animation states */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.98);
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), 
                visibility 0.2s;
}

.settings-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Settings Header */
.settings-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.settings-panel-header h3 {
    font-size: 0.95rem;
    margin: 0;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.settings-close-btn:hover {
    color: var(--text-primary);
    background-color: var(--bg-color);
}

.settings-close-btn svg {
    width: 16px;
    height: 16px;
}

/* Settings Body & Layout */
.settings-panel-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    padding-bottom: 16px;
}

.setting-group:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.setting-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setting-control-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.setting-help-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-top: 4px;
}

/* Re-use preset buttons styled for settings popover */
.settings-panel .preset-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.settings-panel .preset-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-panel .preset-btn:hover {
    border-color: var(--accent-color);
    color: var(--text-primary);
    background-color: var(--bg-color);
}

.settings-panel .preset-btn.active {
    background-color: var(--accent-color);
    color: #ffffff;
    border-color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(137, 137, 235, 0.4);
}

/* Width display label inside panel */
.settings-panel .width-val {
    font-family: monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    background-color: var(--bg-color);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    min-width: 50px;
    text-align: center;
}

/* Slider Row */
.settings-panel .slider-row {
    width: 100%;
}

.settings-panel #sidebar-width-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.settings-panel #sidebar-width-slider:hover {
    background: #cbd5e1;
}

.settings-panel #sidebar-width-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-color);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    border: 2px solid #ffffff;
    transition: transform 0.1s ease, background-color 0.1s ease;
}

.settings-panel #sidebar-width-slider::-webkit-slider-thumb:hover {
    transform: scale(1.25);
    background: var(--accent-hover);
}

.settings-panel #sidebar-width-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: var(--accent-color);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.1s ease;
}

.settings-panel #sidebar-width-slider::-moz-range-thumb:hover {
    transform: scale(1.25);
    background: var(--accent-hover);
}

.lesson-content {
    flex-grow: 1;
    padding: 1.5rem;
    overflow-y: auto; /* Adds a scrollbar if the lesson text gets too long */
}

.lesson-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.lesson-header h2 {
    font-size: 1.25rem;
    margin-bottom: 0;
}

.progress-indicator {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    background-color: var(--border-color);
    padding: 4px 8px;
    border-radius: 12px;
}

.lesson-step {
    background-color: var(--bg-color);
    padding: 1.25rem;
    border-radius: 8px; /* Rounded corners */
    border: 1px solid var(--border-color);
    
    /* Animation defaults */
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* When Javascript adds this class, it gracefully fades into view */
.lesson-step.fade-in {
    opacity: 1;
    transform: translateY(0);
}

.lesson-step h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.lesson-step p {
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
}

.lesson-step p:last-child {
    margin-bottom: 0;
}

.lesson-step strong {
    color: var(--text-primary);
}

.tutorial-panel footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: #fbfbfc;
    display: flex;
    gap: 10px;
}

/* 6. Buttons */
.primary-btn {
    flex: 2; /* The primary button gets twice the space of the secondary buttons */
    padding: 0.75rem 1rem;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease; 
}

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

.primary-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.secondary-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    background-color: var(--panel-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn:hover:not(:disabled) {
    background-color: var(--border-color);
    color: var(--text-primary);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 7. Simulation Container */
.simulation-container {
    height: 100%;
    width: 100%;
    box-shadow: inset 5px 0 10px rgba(0,0,0,0.03); 
}

.simulation-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block; 
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: 100vh;
    }
    
    .tutorial-panel {
        height: 400px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .panel-width-controls {
        display: none !important;
    }
    
    .simulation-container {
        height: calc(100vh - 400px);
    }
}

/* 8. Translation & Language Feature Styles */

/* Keyterm Highlights (only styled when translation mode is active) */
.translation-enabled .keyterm {
    border-bottom: 2px dashed var(--accent-color);
    cursor: help;
    font-weight: 600;
    color: var(--text-primary);
    background-color: rgba(137, 137, 235, 0.04);
    border-radius: 2px;
    padding: 0 2px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.translation-enabled .keyterm:hover {
    border-bottom-style: solid;
    background-color: rgba(137, 137, 235, 0.12);
    color: var(--accent-hover);
    box-shadow: 0 2px 4px rgba(137, 137, 235, 0.1);
}

/* Tooltip Container with Premium Slate Glassmorphism Design */
.keyterm-tooltip {
    position: absolute;
    z-index: 10000;
    background: rgba(15, 23, 42, 0.95); /* Deep slate */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #f8fafc;
    padding: 14px 16px;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.12);
    max-width: 280px;
    font-size: 0.9rem;
    line-height: 1.45;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(8px) scale(0.96);
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.keyterm-tooltip.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.keyterm-tooltip .tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 4px;
}

.keyterm-tooltip .original-word {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #94a3b8;
    font-weight: 600;
}

.keyterm-tooltip .pronounce-btn {
    background: none;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.keyterm-tooltip .pronounce-btn:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

.keyterm-tooltip .pronounce-btn:active {
    transform: scale(0.95);
}

.keyterm-tooltip .pronounce-btn svg {
    width: 14px;
    height: 14px;
}

.keyterm-tooltip .tooltip-translation {
    font-family: 'Oswald', sans-serif;
    font-size: 1.3rem;
    font-weight: 500;
    color: #ffffff;
    margin-bottom: 6px;
    letter-spacing: 0.2px;
}

.keyterm-tooltip .tooltip-definition {
    font-size: 0.8rem;
    color: #cbd5e1;
}

.keyterm-tooltip .tooltip-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    content: "";
}

/* Arrow placement rules */
.keyterm-tooltip.arrow-bottom .tooltip-arrow {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-top: 6px solid rgba(15, 23, 42, 0.95);
}

.keyterm-tooltip.arrow-top .tooltip-arrow {
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-bottom: 6px solid rgba(15, 23, 42, 0.95);
}

/* Responsive media query adjustments for Settings Popover */
@media (max-width: 768px) {
    .settings-panel {
        top: 55px;
        left: 8px;
        right: 8px;
    }
}

/* Styles for embedded images and videos inside lesson steps */
.lesson-step img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 12px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    max-width: 100%;
    border-radius: 6px;
    margin: 12px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.video-container iframe,
.video-container object,
.video-container embed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}
