/**
 * Global Studies UK - Presentation Engine
 * Core Layout, Viewport, Stage, Navigation & Overlays
 */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #0c1a30;
  font-family: var(--font-body);
  color: var(--color-text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Wrapper */
.presentation-app {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #152e54 0%, #0c1a30 100%);
  user-select: none;
}

/* Progress Bar at the Top Edge */
.presentation-progress {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  z-index: var(--z-header);
}

.presentation-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  transition: width var(--transition-normal);
  box-shadow: 0 0 8px var(--color-secondary);
}

/* 16:9 Presentation Stage Container */
.presentation-stage-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 1920px;
  max-height: 1080px;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.presentation-stage {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--color-bg-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl), 0 0 50px rgba(0, 100, 167, 0.2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: text; /* Allow text selection inside slides */
}

/* Slide Header (Inside the 16:9 Stage) */
.slide-header {
  position: relative;
  height: 64px;
  padding: 0 var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
  z-index: 10;
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-logo {
  height: 38px;
  width: auto;
  object-fit: contain;
  cursor: pointer;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-category-badge {
  padding: 4px 12px;
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-surface-subtle);
  color: var(--color-primary);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
}

.header-slide-counter {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  min-width: 65px;
  text-align: right;
}

.header-slide-counter .current-num {
  color: var(--color-primary);
  font-size: var(--text-md);
  font-weight: 700;
}

/* Slide Viewport & Slides Container */
.slide-viewport {
  position: relative;
  flex: 1;
  width: 100%;
  height: calc(100% - 64px - 56px);
  overflow: hidden;
  background: var(--color-bg-light);
}

.slide-content-pane {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.995);
  transition: opacity var(--transition-normal), transform var(--transition-normal), visibility var(--transition-normal);
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
}

.slide-content-pane.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  z-index: 2;
}

/* Custom Scrollbar inside Slide Content */
.slide-content-pane::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.slide-content-pane::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.03);
  border-radius: var(--radius-full);
}
.slide-content-pane::-webkit-scrollbar-thumb {
  background: rgba(0, 100, 167, 0.25);
  border-radius: var(--radius-full);
}
.slide-content-pane::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 100, 167, 0.45);
}

/* Slide Footer Bar (Inside the 16:9 Stage) */
.slide-footer {
  position: relative;
  height: 56px;
  padding: 0 var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--color-border);
  z-index: 10;
  flex-shrink: 0;
}

.footer-website {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
}

.footer-website a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-website a:hover {
  color: var(--color-secondary-dark);
  text-decoration: underline;
}

.footer-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Control Buttons */
.btn-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 12px;
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-main);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  gap: 6px;
  outline: none;
}

.btn-control:hover:not(:disabled) {
  background: var(--color-surface-subtle);
  border-color: var(--color-primary-light);
  color: var(--color-primary);
  transform: translateY(-1px);
}

.btn-control:active:not(:disabled) {
  transform: translateY(0);
}

.btn-control:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--color-border-light);
}

.btn-control.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: #ffffff;
  border: none;
}

.btn-control.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
  box-shadow: 0 2px 8px rgba(0, 100, 167, 0.35);
}

.btn-control.btn-icon-only {
  width: 36px;
  padding: 0;
}

.btn-control svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Fullscreen Floating Controls Overlay */
.fullscreen-trigger-area {
  display: none;
}

:fullscreen .presentation-app {
  width: 100vw;
  height: 100vh;
  background: #000000;
}

:fullscreen .presentation-stage-wrapper {
  max-width: 100vw;
  max-height: 100vh;
  width: 100vw;
  height: 100vh;
  padding: 0;
  border-radius: 0;
}

:fullscreen .presentation-stage {
  border-radius: 0;
  box-shadow: none;
}

/* Auto-hiding chrome in full screen on idle */
:fullscreen .slide-header,
:fullscreen .slide-footer {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

:fullscreen.idle .slide-header {
  opacity: 0;
  transform: translateY(-100%);
  pointer-events: none;
}

:fullscreen.idle .slide-footer {
  opacity: 0;
  transform: translateY(100%);
  pointer-events: none;
}

/* Modal Overlay: Table of Contents & Slide Overview */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(12, 26, 48, 0.75);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  position: relative;
  width: 90%;
  max-width: 1200px;
  max-height: 85vh;
  background: #ffffff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96);
  transition: transform var(--transition-normal);
}

.modal-overlay.open .modal-dialog {
  transform: scale(1);
}

.modal-header {
  padding: var(--space-5) var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}

.modal-title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary-dark);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: var(--text-xl);
  color: var(--color-text-muted);
  cursor: pointer;
  padding: var(--space-2);
  line-height: 1;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-danger);
}

.modal-body {
  padding: var(--space-8);
  overflow-y: auto;
  flex: 1;
}

/* Grid of Slide Thumbnails (Overview Mode 'G') */
.slide-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}

.overview-card {
  position: relative;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.overview-card:hover {
  border-color: var(--color-secondary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.overview-card.active {
  border-color: var(--color-primary);
  background: #f0f7fd;
  box-shadow: 0 0 0 2px var(--color-secondary-light);
}

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

.overview-num {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--color-primary);
  color: #fff;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.overview-cat {
  font-size: 10px;
  color: var(--color-text-subtle);
  text-transform: uppercase;
  font-weight: 600;
}

.overview-title {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-main);
  line-height: 1.3;
}

/* Table of Contents List View */
.toc-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-light);
  background: var(--color-surface);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.toc-item:hover {
  background: var(--color-surface-subtle);
  border-color: var(--color-primary-light);
  padding-left: var(--space-5);
}

.toc-item.active {
  background: #eaf4fd;
  border-color: var(--color-primary);
  font-weight: 600;
}

.toc-item-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.toc-number {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-primary);
  min-width: 28px;
}

.toc-item-title {
  font-size: var(--text-sm);
  color: var(--color-text-main);
}

.toc-category {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

/* Keyboard Shortcut Helper Tooltip / Badge */
.shortcut-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  font-family: monospace;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  color: var(--color-text-muted);
  border: 1px solid rgba(0, 0, 0, 0.1);
}
