/* ============================================
   NIVEAU 19 — LE POSITIONNEMENT
   Styles spécifiques aux démonstrations de position
   ============================================ */

/* ---------- POSITION BASICS DEMOS ---------- */
.demo-position-basics {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 1.5rem;
  background: var(--couleur-blanc);
  border: 1px solid var(--couleur-bordure);
  border-radius: var(--rayon);
}

.pos-demo {
  flex: 1;
  min-width: 200px;
  text-align: center;
}

.pos-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--couleur-texte-clair);
  font-family: var(--police-code);
  background: #f1f5f9;
  padding: 0.2em 0.6em;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 0.5rem;
}

.pos-box {
  position: relative;
  padding: 1rem;
  background: #f8fafc;
  border: 2px dashed var(--couleur-bordure);
  border-radius: var(--rayon);
  min-height: 160px;
}

.pos-item {
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, var(--couleur-primaire), var(--couleur-secondaire));
  color: white;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  text-align: center;
  width: fit-content;
}

/* ---------- POSITION STATIC ---------- */
.demo-static .pos-box-static {
  position: static;
}

/* ---------- POSITION RELATIVE ---------- */
.demo-relative .pos-box-relative {
  position: relative;
  left: 20px;
  top: 10px;
}

/* ---------- POSITION ABSOLUTE ---------- */
.demo-absolute .pos-box-absolute {
  position: relative;
}

.demo-absolute .pos-box-absolute .pos-item {
  position: absolute;
  top: 10px;
  right: 10px;
}

/* ---------- POSITION FIXED ---------- */
.demo-fixed .pos-box-fixed {
  position: relative;
  min-height: 200px;
  overflow: hidden;
}

/* ---------- POSITION STICKY ---------- */
.demo-sticky .pos-box-sticky {
  overflow-y: auto;
  max-height: 250px;
  padding: 0;
}

.sticky-item {
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--couleur-bordure);
  font-size: 0.85rem;
}

.sticky-item.item-header {
  position: sticky;
  top: 0;
  background: linear-gradient(135deg, var(--couleur-primaire), var(--couleur-secondaire));
  color: white;
  font-weight: 600;
  z-index: 10;
}

/* ---------- Z-INDEX STACKING DEMO ---------- */
.demo-stack {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 1rem auto;
}

.stack-box {
  position: absolute;
  width: 150px;
  height: 150px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: transform 0.3s, box-shadow 0.3s;
}

.stack-box:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.stack-box.box-1 {
  background: rgba(37, 99, 235, 0.85);
  top: 0;
  left: 0;
  z-index: 1;
}

.stack-box.box-2 {
  background: rgba(124, 58, 237, 0.85);
  top: 20px;
  left: 20px;
  z-index: 2;
}

.stack-box.box-3 {
  background: rgba(22, 163, 74, 0.85);
  top: 40px;
  left: 40px;
  z-index: 3;
}

/* ---------- Z-INDEX LAYER DIAGRAM ---------- */
.layer-diagram {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 450px;
  margin: 1.5rem auto;
}

.layer-bar {
  padding: 0.6rem 1rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
  text-align: center;
}

.layer-bar.overlay { background: #7c3aed; }
.layer-bar.positive-z { background: #2563eb; }
.layer-bar.inline { background: #0ea5e9; }
.layer-bar.float { background: #16a34a; }
.layer-bar.block { background: #f59e0b; color: #1e293b; }
.layer-bar.negative-z { background: #f97316; }
.layer-bar.background { background: #94a3b8; color: #1e293b; }

/* ---------- CONTAINING BLOCK DIAGRAM ---------- */
.containing-block-demo {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  padding: 1.5rem;
  background: var(--couleur-blanc);
  border: 1px solid var(--couleur-bordure);
  border-radius: var(--rayon);
}

.cb-example {
  flex: 1;
  min-width: 200px;
  text-align: center;
}

.cb-example .parent {
  position: relative;
  background: #f1f5f9;
  border: 2px dashed var(--couleur-bordure);
  padding: 1.5rem;
  border-radius: var(--rayon);
  margin-top: 0.5rem;
  min-height: 120px;
}

.cb-example .child {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: linear-gradient(135deg, var(--couleur-primaire), var(--couleur-secondaire));
  color: white;
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ---------- OFFSET PROPERTIES DEMO ---------- */
.offset-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  padding: 1.5rem;
  background: var(--couleur-blanc);
  border: 1px solid var(--couleur-bordure);
  border-radius: var(--rayon);
}

.offset-example {
  text-align: center;
}

.offset-example .parent {
  position: relative;
  background: #f1f5f9;
  border: 2px dashed var(--couleur-bordure);
  padding: 1rem;
  border-radius: var(--rayon);
  min-height: 100px;
}

.offset-example .child {
  position: absolute;
  background: linear-gradient(135deg, #16a34a, #06b6d4);
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}

.offset-example .child.top-20 { top: 20px; }
.offset-example .child.right-20 { right: 20px; }
.offset-example .child.bottom-20 { bottom: 20px; }
.offset-example .child.left-20 { left: 20px; }

/* ---------- PRACTICAL PROJECTS ---------- */

/* Sticky Header */
.demo-sticky-header {
  position: relative;
  height: 300px;
  overflow-y: auto;
  border: 2px solid var(--couleur-bordure);
  border-radius: var(--rayon);
}

.sticky-header-nav {
  position: sticky;
  top: 0;
  background: linear-gradient(135deg, var(--couleur-primaire), var(--couleur-secondaire));
  color: white;
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 10;
  display: flex;
  justify-content: space-between;
}

.sticky-header-content {
  padding: 1rem;
  min-height: 500px;
}

.sticky-header-content p {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

/* Modal Overlay */
.modal-overlay-demo {
  position: relative;
  min-height: 250px;
  background: #f1f5f9;
  border: 2px solid var(--couleur-bordure);
  border-radius: var(--rayon);
  overflow: hidden;
}

.modal-bg-content {
  padding: 2rem 1rem;
  text-align: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-box {
  background: white;
  border-radius: var(--rayon);
  padding: 1.5rem 2rem;
  box-shadow: var(--ombre-lg);
  text-align: center;
  max-width: 80%;
}

.modal-box h4 {
  margin-bottom: 0.5rem;
  color: var(--couleur-texte);
}

.modal-box p {
  font-size: 0.9rem;
  color: var(--couleur-texte-clair);
  margin-bottom: 1rem;
}

.modal-btn {
  background: var(--couleur-primaire);
  color: white;
  border: none;
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}

/* Tooltip */
.demo-tooltip {
  display: flex;
  gap: 2rem;
  justify-content: center;
  padding: 2rem 1.5rem;
  background: var(--couleur-blanc);
  border: 1px solid var(--couleur-bordure);
  border-radius: var(--rayon);
}

.tooltip-trigger {
  position: relative;
  background: var(--couleur-primaire);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.tooltip-trigger .tooltip-text {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--couleur-code-bg);
  color: white;
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.tooltip-trigger .tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--couleur-code-bg);
}

.tooltip-trigger:hover .tooltip-text {
  opacity: 1;
}

.tooltip-trigger .tooltip-bottom {
  bottom: auto;
  top: calc(100% + 8px);
}

.tooltip-trigger .tooltip-bottom::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--couleur-code-bg);
}

/* Dropdown Menu */
.demo-dropdown {
  display: flex;
  gap: 2rem;
  justify-content: center;
  padding: 2rem 1.5rem;
  background: var(--couleur-blanc);
  border: 1px solid var(--couleur-bordure);
  border-radius: var(--rayon);
}

.dropdown {
  position: relative;
}

.dropdown-btn {
  background: var(--couleur-primaire);
  color: white;
  border: none;
  padding: 0.6rem 1.25rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: white;
  border: 1px solid var(--couleur-bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre-lg);
  min-width: 180px;
  padding: 0.4rem 0;
  z-index: 100;
}

.dropdown-menu a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--couleur-texte);
  text-decoration: none;
  font-size: 0.85rem;
  transition: background var(--transition);
}

.dropdown-menu a:hover {
  background: #f1f5f9;
}

/* Badge Overlay */
.demo-badge {
  display: flex;
  gap: 2rem;
  justify-content: center;
  padding: 2rem 1.5rem;
  background: var(--couleur-blanc);
  border: 1px solid var(--couleur-bordure);
  border-radius: var(--rayon);
}

.badge-image-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: var(--rayon);
  overflow: hidden;
  background: linear-gradient(135deg, #a78bfa, #60a5fa);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1.2rem;
}

.badge-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--couleur-erreur);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
}

.badge-overlay.new {
  background: var(--couleur-succes);
}

/* Lightbox Overlay */
.lightbox-demo {
  position: relative;
  min-height: 250px;
  background: #f1f5f9;
  border: 2px solid var(--couleur-bordure);
  border-radius: var(--rayon);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-content {
  text-align: center;
  padding: 2rem;
}

.lightbox-content .thumb {
  width: 180px;
  height: 120px;
  background: linear-gradient(135deg, #f472b6, #a78bfa);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

.lightbox-content .thumb:hover {
  transform: scale(1.05);
}

.lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-overlay .lb-image {
  width: 80%;
  max-width: 350px;
  height: 180px;
  background: linear-gradient(135deg, #f472b6, #a78bfa);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 1rem;
}

.lightbox-overlay .lb-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  background: rgba(255,255,255,0.2);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Back to Top */
.demo-back-to-top {
  position: relative;
  height: 250px;
  overflow-y: auto;
  background: #f1f5f9;
  border: 2px solid var(--couleur-bordure);
  border-radius: var(--rayon);
}

.back-to-top-content {
  padding: 1rem;
  min-height: 500px;
}

.back-to-top-content p {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.back-to-top-btn {
  position: sticky;
  bottom: 1rem;
  float: right;
  margin-right: 1rem;
  background: var(--couleur-primaire);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: var(--ombre-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Image Caption on Hover */
.demo-caption {
  display: flex;
  gap: 2rem;
  justify-content: center;
  padding: 2rem 1.5rem;
  background: var(--couleur-blanc);
  border: 1px solid var(--couleur-bordure);
  border-radius: var(--rayon);
}

.caption-wrapper {
  position: relative;
  width: 180px;
  height: 140px;
  border-radius: var(--rayon);
  overflow: hidden;
  background: linear-gradient(135deg, #f97316, #ef4444);
  cursor: pointer;
}

.caption-wrapper .caption-bg {
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  width: 100%;
  height: 100%;
}

.caption-wrapper .caption-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  opacity: 0;
  transition: opacity 0.3s;
  padding: 0.75rem;
  text-align: center;
}

.caption-wrapper:hover .caption-overlay {
  opacity: 1;
}

.caption-overlay h4 {
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.caption-overlay p {
  font-size: 0.8rem;
  opacity: 0.8;
}

/* Notification Popup */
.demo-notification {
  position: relative;
  min-height: 250px;
  background: #f1f5f9;
  border: 2px solid var(--couleur-bordure);
  border-radius: var(--rayon);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 1rem;
}

.notification-box {
  position: absolute;
  top: 12px;
  right: 12px;
  background: white;
  border-radius: var(--rayon);
  box-shadow: var(--ombre-lg);
  padding: 1rem 1.25rem;
  max-width: 260px;
  border-left: 4px solid var(--couleur-succes);
}

.notification-box .notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}

.notification-box .notif-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--couleur-succes);
}

.notification-box .notif-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--couleur-texte-clair);
}

.notification-box .notif-text {
  font-size: 0.8rem;
  color: var(--couleur-texte-clair);
  margin-bottom: 0;
}

/* Sidebar Sticky */
.demo-sidebar-sticky {
  display: flex;
  gap: 1rem;
  padding: 1.5rem;
  background: var(--couleur-blanc);
  border: 1px solid var(--couleur-bordure);
  border-radius: var(--rayon);
  min-height: 350px;
}

.sidebar-sticky-main {
  flex: 1;
}

.sidebar-sticky-aside {
  position: sticky;
  top: 1rem;
  width: 160px;
  align-self: flex-start;
  background: #f1f5f9;
  border: 1px solid var(--couleur-bordure);
  border-radius: var(--rayon);
  padding: 1rem;
}

.sidebar-sticky-aside h4 {
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.sidebar-sticky-aside ul {
  list-style: none;
  padding: 0;
  font-size: 0.8rem;
}

.sidebar-sticky-aside li {
  margin-bottom: 0.3rem;
  color: var(--couleur-texte-clair);
}

.sidebar-sticky-main p {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
  .demo-position-basics,
  .containing-block-demo,
  .offset-demo {
    flex-direction: column;
  }

  .demo-tooltip,
  .demo-dropdown,
  .demo-badge,
  .demo-caption {
    flex-direction: column;
    align-items: center;
  }

  .demo-sidebar-sticky {
    flex-direction: column;
  }

  .sidebar-sticky-aside {
    position: static;
    width: 100%;
  }
}
