:root {
  --bg-color: #0f172a;
  --card-bg: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #eee9e7;
  --accent: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.2);
  --code-bg: #0f172a;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.top-nav {
  position: fixed;
  top: 20px;
  right: 30px;
  z-index: 1000;
  display: flex;
  gap: 15px;
}

.nav-btn {
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(5px);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 10px 20px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-btn:hover {
  background: var(--accent);
  color: var(--bg-color);
  box-shadow: 0 0 15px var(--accent-glow);
  transform: translateY(-2px);
}

.carousel-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  perspective: 1200px;
  width: 100%;
  overflow: hidden;
}

.slide {
  position: absolute;
  width: 85%;
  max-width: 1200px;
  height: 75dvh;
  background: var(--card-bg);
  border-radius: 20px;
  padding: 50px;
  box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  transform: translateX(100%) scale(0.8) rotateY(-10deg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  pointer-events: none;
  -webkit-overflow-scrolling: touch;
}

.slide::-webkit-scrollbar {
  width: 8px;
}
.slide::-webkit-scrollbar-track {
  background: var(--card-bg);
}
.slide::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}
.slide::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

.slide.active {
  opacity: 1;
  transform: translateX(0) scale(1) rotateY(0);
  z-index: 10;
  pointer-events: all;
}

.slide.prev {
  opacity: 0;
  transform: translateX(-100%) scale(0.8) rotateY(10deg);
  z-index: 5;
}

h1,
h2 {
  color: var(--accent);
  margin-top: 0;
  text-transform: uppercase;
  letter-spacing: 2px;
  word-wrap: break-word;
}

h1 {
  font-size: 3rem;
  margin-bottom: 15px;
  line-height: 1.2;
}
h2 {
  font-size: 2.2rem;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
  padding-bottom: 10px;
  margin-bottom: 30px;
  line-height: 1.3;
}
h3 {
  color: var(--text-primary);
  margin-top: 25px;
  font-size: 1.5rem;
}

p,
ul,
li {
  font-size: 1.3rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

strong {
  color: var(--text-primary);
  font-weight: 600;
}

ul {
  margin-left: 20px;
  padding-left: 0;
}
li {
  margin-bottom: 15px;
}

.note-box {
  background: rgba(56, 189, 248, 0.1);
  border-left: 5px solid var(--accent);
  padding: 20px;
  margin-top: 30px;
  border-radius: 4px;
  font-size: 1.2rem;
  color: #bae6fd;
}

.code-block {
  background: var(--code-bg);
  padding: 25px;
  border-radius: 8px;
  font-family: "Courier New", monospace;
  font-size: 1.1rem;
  color: #a5b4fc;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid #334155;
  margin-top: 20px;
  max-width: 100%;
}

/* IMAGE STYLING */
.slide-image {
  margin-top: 30px !important;
  display: block;
  width: 100%;
  max-width: 450px;
  height: auto;
  margin: 20px auto;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  border: 1px solid #475569;
  object-fit: cover;
}

.placeholder-zone {
  width: 100%;
  max-width: 90%;
  margin: 30px auto;
  border: 3px dashed #475569;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  text-align: center;
  padding: 20px;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}
a:hover {
  color: #fff;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 30px;
  padding: 25px;
  z-index: 20;
  background: rgba(15, 23, 42, 0.9);
  width: 100%;
}

button.control-btn {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
  padding: 12px 40px;
  border-radius: 30px;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: bold;
  transition: all 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

button.control-btn:hover {
  background: var(--accent);
  color: var(--bg-color);
  box-shadow: 0 0 20px var(--accent-glow);
  transform: translateY(-2px);
}

.progress-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 6px;
  background: #334155;
  z-index: 100;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
}

.slide-number {
  position: absolute;
  bottom: 20px;
  right: 30px;
  font-size: 1rem;
  color: #475569;
}

@media screen and (max-width: 1024px) {
  .slide {
    width: 90%;
    padding: 40px;
  }

  h1 {
    font-size: 2.5rem;
  }
  h2 {
    font-size: 1.8rem;
  }
}

@media screen and (max-width: 768px) {
  .top-nav {
    top: 15px;
    right: 15px;
    gap: 10px;
  }

  .nav-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .slide {
    width: 95%;
    padding: 25px 20px;
    height: 72dvh;
  }

  h1 {
    font-size: 1.8rem;
    margin-bottom: 10px;
  }

  h2 {
    font-size: 1.4rem;
    margin-bottom: 20px;
  }

  h3 {
    font-size: 1.2rem;
    margin-top: 15px;
  }

  p,
  ul,
  li {
    font-size: 1.05rem;
  }

  .note-box {
    padding: 15px;
    font-size: 1rem;
    margin-top: 20px;
  }

  .code-block {
    padding: 15px;
    font-size: 0.9rem;
  }

  .slide-image {
    max-width: 100%;
    margin-top: 20px !important;
  }

  .placeholder-zone {
    height: 200px;
    font-size: 1.2rem;
  }

  .controls {
    padding: 15px;
    gap: 15px;
  }

  button.control-btn {
    padding: 10px 25px;
    font-size: 1rem;
  }

  .slide-number {
    bottom: 10px;
    right: 20px;
    font-size: 0.8rem;
  }
}

@media screen and (max-width: 480px) {
  .top-nav {
    width: 100%;
    justify-content: flex-end;
    padding-right: 15px;
    right: 0;
  }

  h1 {
    font-size: 1.5rem;
  }

  .slide {
    padding: 20px 15px;
  }

  button.control-btn {
    padding: 8px 20px;
    width: 100%;
  }
  #live-logic-trace {
    flex-direction: column;
  }
}
#memory-rewriting-examples {
  overflow-y: auto;
}

#representation-example {
  overflow: auto;
}

@media print {
  .top-nav,
  .controls,
  .progress-container {
    display: none;
  }
  .slide {
    position: relative;
    opacity: 1 !important;
    transform: none !important;
    page-break-after: always;
    box-shadow: none;
    border: none;
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
  }
  body {
    overflow: visible;
    background: #fff;
    color: #000;
    height: auto;
  }
}
