/* WebKit Exploitation Course — Premium Enterprise Theme */
:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #4a4a4a;
  --text-muted: #6b6b6b;
  --border: #e0e0e0;
  --border-light: #f0f0f0;
  --accent: #0a0a0a;
  --accent-light: #f5f5f5;
  --code-bg: #fafafa;
  --code-border: #e8e8e8;
  --output-bg: #f8f9fa;
  --output-border: #dee2e6;
  --success: #28a745;
  --warning: #ffc107;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --max-width: 820px;
}

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

body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }

/* Header */
header {
  border-bottom: 1px solid var(--border);
  padding: 32px 0;
  margin-bottom: 48px;
}
header .container { display: flex; align-items: center; justify-content: space-between; }
.logo { font-size: 14px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-muted); }
.logo span { color: var(--text); }

nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  margin-left: 24px;
  transition: color 0.15s;
}
nav a:hover { color: var(--text); }

/* Hero */
.hero {
  padding: 64px 0 48px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 48px;
}
.hero h1 {
  font-size: 42px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--accent);
  margin-bottom: 16px;
}
.hero .subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 600px;
  line-height: 1.6;
}
.badge {
  display: inline-block;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: var(--accent);
  color: #fff;
  border-radius: 3px;
  margin-bottom: 16px;
}

/* Section cards */
.sections { margin-bottom: 64px; }
.section-card {
  display: block;
  padding: 24px 0;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}
.section-card:hover { background: var(--accent-light); margin: 0 -24px; padding: 24px; }
.section-card .num {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.section-card h3 { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.section-card p { font-size: 14px; color: var(--text-secondary); }
.section-card .labs {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.section-card .labs a { color: var(--text-secondary); text-decoration: none; border-bottom: 1px solid var(--border); }
.section-card .labs a:hover { color: var(--text); border-color: var(--text); }

/* Content pages */
h1 { font-size: 36px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 12px; }
h2 { font-size: 24px; font-weight: 600; margin-top: 48px; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border-light); }
h3 { font-size: 18px; font-weight: 600; margin-top: 32px; margin-bottom: 12px; }
h4 { font-size: 15px; font-weight: 600; margin-top: 24px; margin-bottom: 8px; color: var(--text-secondary); }

p { margin-bottom: 16px; }
ul, ol { margin-bottom: 16px; padding-left: 24px; }
li { margin-bottom: 6px; }

a { color: var(--text); }

/* Code blocks */
pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  padding: 16px 20px;
  overflow-x: auto;
  margin-bottom: 20px;
  font-size: 13.5px;
  line-height: 1.6;
}
code {
  font-family: var(--mono);
  font-size: 0.9em;
}
pre code { font-size: inherit; }
p code, li code {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 2px 6px;
  border-radius: 3px;
}

/* Lab output blocks */
.lab-output {
  background: var(--output-bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 16px 20px;
  margin-bottom: 20px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text-secondary);
}
.lab-output .prompt { color: var(--text-muted); }
.lab-output .output { color: var(--text); }

/* Step blocks */
.step {
  margin-bottom: 32px;
  padding-left: 32px;
  position: relative;
}
.step::before {
  content: attr(data-step);
  position: absolute;
  left: 0;
  top: 2px;
  width: 22px;
  height: 22px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 14px;
}
th, td { padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--border-light); }
th { font-weight: 600; color: var(--text-secondary); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Breadcrumb */
.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb span { margin: 0 6px; }

/* Checklist */
.checklist { list-style: none; padding-left: 0; }
.checklist li { padding: 6px 0 6px 28px; position: relative; }
.checklist li::before {
  content: '';
  position: absolute;
  left: 0; top: 10px;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-radius: 3px;
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: 64px;
  font-size: 13px;
  color: var(--text-muted);
}

/* Back link */
.back-link {
  display: inline-block;
  margin-bottom: 32px;
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
}
.back-link:hover { color: var(--text); }

/* Info box */
.info-box {
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 20px;
  margin-bottom: 24px;
  font-size: 14px;
}
.info-box strong { display: block; margin-bottom: 4px; }

/* =========================================================
   Interactive Lab — Split-Screen Layout
   ========================================================= */

/* Additional custom properties for the interactive lab */
:root {
  --terminal-bg: #1a1b26;
  --terminal-header-bg: #16162a;
  --terminal-text: #e0e0e0;
  --terminal-border: #2a2a4a;
  --terminal-accent: #4a9eff;
  --lab-nav-height: 52px;
  --status-online: var(--success);
  --status-offline: #dc3545;
  --status-pending: var(--warning);
}

/* Lab navigation bar — fixed top bar for interactive view */
.lab-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--lab-nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-family: var(--sans);
}

.lab-nav .lab-nav-brand {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.lab-nav .lab-nav-brand span {
  color: var(--text);
}

.lab-nav .lab-nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.lab-nav .lab-nav-actions a {
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}

.lab-nav .lab-nav-actions a:hover {
  color: var(--text);
}

/* Lab progress indicator — horizontal step dots */
.lab-progress {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lab-progress .progress-step {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--border);
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
  position: relative;
}

.lab-progress .progress-step.completed {
  background: var(--accent);
  border-color: var(--accent);
}

.lab-progress .progress-step.active {
  background: var(--bg);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 10, 10, 0.1);
}

.lab-progress .progress-step::after {
  content: '';
  display: none;
}

/* Connector lines between dots */
.lab-progress .progress-connector {
  width: 20px;
  height: 2px;
  background: var(--border);
  transition: background 0.2s;
}

.lab-progress .progress-connector.completed {
  background: var(--accent);
}

/* Step labels on hover */
.lab-progress .progress-step[data-label]::after {
  content: attr(data-label);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid var(--border);
  display: none;
  pointer-events: none;
}

.lab-progress .progress-step[data-label]:hover::after {
  display: block;
}

/* Full-viewport split container */
.lab-interactive {
  position: fixed;
  top: var(--lab-nav-height);
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: row;
  font-family: var(--sans);
}

/* Instructions panel — left side */
.lab-panel-instructions {
  width: calc(38% - 4px) !important;
  min-width: 0;
  overflow-y: auto;
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 32px 28px 64px;
  -webkit-overflow-scrolling: touch;
}

.lab-panel-instructions h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  color: var(--accent);
}

.lab-panel-instructions h2 {
  font-size: 20px;
  font-weight: 600;
  margin-top: 36px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}

.lab-panel-instructions h3 {
  font-size: 16px;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 8px;
}

.lab-panel-instructions p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.lab-panel-instructions ul,
.lab-panel-instructions ol {
  font-size: 14px;
  color: var(--text-secondary);
  padding-left: 20px;
  margin-bottom: 14px;
}

.lab-panel-instructions code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 1px 5px;
  border-radius: 3px;
}

.lab-panel-instructions pre {
  font-size: 13px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.lab-panel-instructions pre code {
  background: none;
  border: none;
  padding: 0;
}

/* Custom scrollbar for instructions panel */
.lab-panel-instructions::-webkit-scrollbar {
  width: 6px;
}

.lab-panel-instructions::-webkit-scrollbar-track {
  background: transparent;
}

.lab-panel-instructions::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.lab-panel-instructions::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Terminal panel — right side */
.lab-panel-terminal {
  width: 55%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--terminal-bg);
  overflow: hidden;
}

/* Terminal header bar */
.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 16px;
  background: var(--terminal-header-bg);
  border-bottom: 1px solid var(--terminal-border);
  flex-shrink: 0;
}

.terminal-header .terminal-title {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--terminal-text);
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.terminal-header .terminal-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-pending);
  flex-shrink: 0;
  transition: background 0.3s;
}

.terminal-header .terminal-status.online {
  background: var(--status-online);
  box-shadow: 0 0 6px rgba(40, 167, 69, 0.4);
}

.terminal-header .terminal-status.offline {
  background: var(--status-offline);
}

.terminal-header .terminal-status.pending {
  background: var(--status-pending);
  animation: pulse-status 1.5s ease-in-out infinite;
}

@keyframes pulse-status {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

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

.terminal-header .terminal-actions button {
  background: none;
  border: 1px solid var(--terminal-border);
  color: var(--terminal-text);
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.terminal-header .terminal-actions button:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Terminal iframe */
.terminal-frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: none;
  background: var(--terminal-bg);
  display: block;
  overflow: hidden;
}

/* Visual separator between terminal and device panels */
.lab-interactive > .lab-panel-terminal + .lab-panel-terminal {
  border-left: 1px solid var(--terminal-border);
}

/* Device container — flex column so children fill height */
#deviceContainer {
  display: flex !important;
  flex-direction: column;
}

#corellium-webplayer {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#corellium-webplayer iframe {
  flex: 1;
  width: 100%;
  min-height: 0 !important;
  max-height: none;
  border: none !important;
}

/* Console mode tabs (Desktop / Terminal toggle) */
.console-tabs {
  display: flex;
  gap: 2px;
  margin-right: auto;
  margin-left: 16px;
}

.console-tab {
  padding: 4px 12px;
  font-size: 11px;
  font-family: var(--sans);
  font-weight: 500;
  border: 1px solid var(--terminal-border);
  background: transparent;
  color: var(--terminal-text);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.console-tab:hover {
  background: rgba(255, 255, 255, 0.08);
}

.console-tab.active {
  background: var(--terminal-accent);
  color: #fff;
  border-color: var(--terminal-accent);
}

/* Guacamole desktop container */
.guac-container {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: stretch;
}

.guac-frame {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  background: #000;
  display: block;
}

.guac-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  color: var(--terminal-text);
  background: var(--terminal-bg);
}

.guac-placeholder-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.guac-placeholder h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: #fff;
}

.guac-placeholder p {
  font-size: 13px;
  line-height: 1.5;
  max-width: 400px;
  opacity: 0.7;
  margin-bottom: 8px;
}

.guac-placeholder-info {
  font-size: 11px !important;
  opacity: 0.5 !important;
  margin-top: 8px !important;
}

.guac-retry-btn {
  margin-top: 16px;
  padding: 8px 20px;
  font-size: 13px;
  font-family: var(--sans);
  border: 1px solid var(--terminal-accent);
  background: transparent;
  color: var(--terminal-accent);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.guac-retry-btn:hover {
  background: var(--terminal-accent);
  color: #fff;
}

/* Step command — code block with copy-to-terminal button */
.step-command {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  margin-bottom: 16px;
}

.step-command pre {
  margin: 0;
  border: none;
  border-radius: 0;
  padding: 14px 16px;
  padding-right: 120px;
  background: transparent;
  overflow-x: auto;
}

.step-command .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
}

/* Copy button — small inline action */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
  user-select: none;
}

.copy-btn:hover {
  color: var(--text);
  border-color: var(--text-secondary);
  background: var(--accent-light);
}

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

.copy-btn.copied {
  color: var(--success);
  border-color: var(--success);
}

.copy-btn::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='13' height='13' rx='2'/%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

/* "Copy to terminal" variant — more prominent */
.copy-btn.copy-to-terminal {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-family: var(--sans);
  font-weight: 600;
  padding: 6px 14px;
}

.copy-btn.copy-to-terminal:hover {
  background: var(--text);
  border-color: var(--text);
}

.copy-btn.copy-to-terminal::before {
  filter: invert(1);
}

/* Resize handle between panels */
.lab-interactive .panel-resize-handle {
  width: 4px;
  cursor: col-resize;
  background: var(--border);
  transition: background 0.15s;
  flex-shrink: 0;
}

.lab-interactive .panel-resize-handle:hover {
  background: var(--text-muted);
}

/* =========================================================
   Interactive Lab — Responsive (stack vertically)
   ========================================================= */
@media (max-width: 900px) {
  .lab-interactive {
    flex-direction: column;
  }

  .lab-panel-instructions {
    width: 100%;
    height: 50vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 24px 20px 40px;
  }

  .lab-panel-terminal {
    width: 100%;
    height: 50vh;
    border-left: none !important;
    border-top: 1px solid var(--terminal-border);
  }

  .lab-interactive .panel-resize-handle {
    width: 100%;
    height: 4px;
    cursor: row-resize;
  }

  .lab-nav {
    padding: 0 12px;
  }

  .lab-progress .progress-connector {
    width: 12px;
  }

  .lab-progress .progress-step {
    width: 8px;
    height: 8px;
  }
}

@media (max-width: 600px) {
  .lab-panel-instructions {
    height: 45vh;
    padding: 16px 14px 32px;
  }

  .lab-panel-terminal {
    height: 55vh;
  }

  .lab-panel-instructions h1 {
    font-size: 22px;
  }

  .lab-panel-instructions h2 {
    font-size: 17px;
  }

  .terminal-header {
    height: 38px;
    padding: 0 12px;
  }

  .terminal-header .terminal-title {
    font-size: 12px;
  }

  .step-command pre {
    padding-right: 16px;
    padding-bottom: 42px;
  }

  .step-command .copy-btn {
    top: auto;
    bottom: 8px;
    right: 8px;
  }
}
