/* ==========================================
   Positioned Layout e Transforms - Lesson Overrides
   Solo componenti lesson-specific. La navigazione,
   cover/try/exercise base sono in styles-base.css.
   ========================================== */

/* ---------- Layout Cards: variante highlight + tag ---------- */

.layout-card-tag {
  font-size: 13px;
  color: #555;
  margin: 4px 0 8px;
  font-family: 'Monaco', 'Menlo', monospace;
}

.layout-card-tag code {
  background: transparent;
  padding: 0;
  font-size: 12px;
}

.layout-card-highlight {
  background: #fff8e1;
  border-color: #000;
  box-shadow: 6px 6px 0 0 #000;
}

.layout-card-highlight h3 {
  color: #000;
}

#i-sistemi-di-layout-css .layout-cards {
  grid-template-columns: repeat(2, 1fr);
}

/* ---------- Demo box - palette condivisa ---------- */

.demo-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  border: 2px solid #000;
  box-sizing: border-box;
}

.demo-box-grey {
  background: #cfcfcf;
  color: #222;
}

.demo-box-pink {
  background: deeppink;
}

.demo-box-dark {
  background: #222;
}

/* ---------- Positioning Sandbox ---------- */

.positioning-sandbox .demo-stage {
  min-height: 160px;
  background: #fafafa;
  border: 1px dashed #999;
  padding: 16px;
  position: relative;
}

.positioning-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.demo-box-nudged {
  position: relative;
  top: var(--demo-top, 0px);
  left: var(--demo-left, 0px);
}

/* ---------- Live Code Display ---------- */

.live-code-display {
  background: #2d2d2d;
  border-top: 1px solid #000;
  padding: 0;
}

.live-code-display pre {
  margin: 0;
  padding: 16px 20px;
  background: transparent;
  border-radius: 0;
  font-size: 13px;
}

.live-code-display code {
  background: transparent;
}

/* ---------- Absolute Demo - frame + box absolute ---------- */

.absolute-frame {
  position: relative;
  min-height: 200px;
  background: #fff;
  padding: 16px;
  border: 1px dashed #999;
}

.absolute-frame p {
  margin: 0 0 8px;
  color: #333;
}

.demo-box-absolute {
  position: absolute;
  top: var(--demo-top, 20px);
  width: 50px;
  height: 50px;
}

[data-anchor="left"] .demo-box-absolute {
  left: var(--demo-inline, 25%);
  right: auto;
}

[data-anchor="right"] .demo-box-absolute {
  right: var(--demo-inline, 25%);
  left: auto;
}

/* ---------- Collapse Demo (elementi fantasma) ---------- */

.collapse-stage {
  display: flex;
  justify-content: center;
  padding: 24px;
  background: #fafafa;
}

.collapse-parent {
  position: relative;
  width: 240px;
  border: 3px solid #000;
  padding: 12px;
  background: #fff;
}

.collapse-label,
.collapse-label-inner {
  display: block;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 12px;
  color: #555;
  margin-bottom: 6px;
}

.collapse-child {
  height: 200px;
  background: deeppink;
  color: #fff;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-child-mode="absolute"] .collapse-child {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
}

.ghost-static-stage {
  align-items: stretch;
}

.ghost-static-frame {
  position: relative;
  display: grid;
  gap: 8px;
  width: 100%;
}

.ghost-static-card {
  border: 2px solid #000;
  background: #fff;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.3;
}

.ghost-static-card-pink {
  background: deeppink;
  color: #fff;
}

.ghost-static-card-absolute {
  position: absolute;
  width: 100%;
  box-sizing: border-box;
}

/* ---------- Containing Block Demo (scatole russe) ---------- */

.cb-stage {
  padding: 24px;
  background: #fafafa;
}

.cb-frame {
  padding: 24px;
  border: 2px solid #000;
  background: #fff;
  position: relative;
}

.cb-level-1 { background: #fff8e1; }
.cb-level-2 { background: #f3f4f6; }
.cb-level-3 { background: #fff; }

.cb-label {
  display: block;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 12px;
  color: #555;
  margin-bottom: 6px;
}

.cb-pink {
  position: absolute;
  top: 0;
  right: 0;
  width: 40px;
  height: 40px;
}

[data-cb-target="none"] .cb-frame { position: static; }
[data-cb-target="level-1"] .cb-level-1 { position: relative; }
[data-cb-target="level-1"] .cb-level-2,
[data-cb-target="level-1"] .cb-level-3 { position: static; }
[data-cb-target="level-2"] .cb-level-2 { position: relative; }
[data-cb-target="level-2"] .cb-level-1,
[data-cb-target="level-2"] .cb-level-3 { position: static; }
[data-cb-target="level-3"] .cb-level-3 { position: relative; }
[data-cb-target="level-3"] .cb-level-1,
[data-cb-target="level-3"] .cb-level-2 { position: static; }

/* ---------- Centering Recipe Demo ---------- */

.centering-stage {
  position: relative;
  min-height: 220px;
  background: #fafafa;
  border: 1px dashed #999;
}

.centering-target {
  width: 80px;
  height: 80px;
  background: deeppink;
  position: absolute;
}

[data-recipe="offsets-only"] .centering-target {
  top: 0; left: 0; right: 0; bottom: 0;
  width: auto; height: auto;
  margin: 0;
}

[data-recipe="offsets-size"] .centering-target {
  top: 0; left: 0; right: 0; bottom: 0;
  width: 80px; height: 80px;
  margin: 0;
}

[data-recipe="full"] .centering-target {
  top: 0; left: 0; right: 0; bottom: 0;
  width: 80px; height: 80px;
  margin: auto;
}

/* ---------- Side-by-side Compare ---------- */

.demo-compare {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 24px 0;
}

.demo-compare:has(:last-child:nth-child(2)) {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 900px) {
  .demo-compare {
    grid-template-columns: 1fr;
  }
}

.compare-panel {
  border: 2px solid #000;
  background: #fff;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.compare-panel h3 {
  margin: 0;
  font-size: 16px;
}

.compare-panel pre {
  margin: 0;
  font-size: 12px;
}

.compare-stage {
  min-height: 200px;
  background: #fafafa;
  border: 1px dashed #999;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.paint-stage {
  position: relative;
}

.paint-box {
  width: 50px;
  height: 50px;
}

.paint-box-b {
  margin-top: -30px;
  margin-left: 20px;
}

.compare-note {
  margin: 0;
  font-size: 13px;
  color: #555;
}

.compare-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
}

.compare-list li {
  margin-bottom: 4px;
}

/* Hero grid overlap / absolute */

.hero-grid {
  display: grid;
  min-height: 160px;
  background: transparent;
  padding: 0;
  border: none;
}

.hero-grid > * {
  grid-area: 1 / 1;
}

.hero-absolute {
  position: relative;
  min-height: 160px;
  background: transparent;
  padding: 0;
  border: none;
}

.hero-image {
  background: linear-gradient(135deg, #6a7cff, #f06292);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  font-weight: 600;
}

.hero-title {
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  align-self: end;
  padding: 12px 16px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.hero-title-absolute {
  position: absolute;
  bottom: 16px;
  left: 16px;
  padding: 0;
}

/* ==========================================
   Placeholder per sezioni successive
   (aggiunti via agenti B/C/D durante la generazione)
   ========================================== */

/* Scroll sandbox (sezione 3) */
.scroll-frame {
  border: 2px solid #000;
  background: #fff;
  height: 240px;
  overflow: auto;
}

#scroll-container-il-tardis-di-css .scroll-frame {
  height: 150px;
}

.scroll-frame[data-overflow="visible"] { overflow: visible; }
.scroll-frame[data-overflow="hidden"] { overflow: hidden; }
.scroll-frame[data-overflow="auto"] { overflow: auto; }
.scroll-frame[data-overflow="clip"] { overflow: clip; }
.scroll-frame[data-overflow="scroll"] { overflow: scroll; }

.scroll-content {
  padding: 16px;
}

/* Transform playground (sezione 5) */
.transform-playground .demo-stage,
.transform-stage {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  border: 1px dashed #999;
}

.transform-target {
  width: 120px;
  height: 120px;
  background: deeppink;
  border: 2px solid #000;
  translate: var(--demo-translate-x, 0) var(--demo-translate-y, 0);
  rotate: var(--demo-rotate, 0deg);
  scale: var(--demo-scale, 1);
  transform-origin: var(--demo-origin, 50% 50%);
}

/* Exercise slide specifics (sezione 5 / slide 59) */
.exercise-levels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.exercise-level {
  border: 2px solid #000;
  background: #fff8e1;
  padding: 16px;
}

.exercise-level h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.exercise-level ul {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
}

.exercise-starter,
.exercise-hints,
.exercise-checklist {
  margin: 24px 0;
}

.exercise-starter h3,
.exercise-hints h3,
.exercise-checklist h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.exercise-hints ul,
.exercise-checklist ul {
  padding-left: 20px;
}

/* ==========================================
   Sezione 2 — Z-index + Isolation
   ========================================== */

.zindex-stage {
  position: relative;
  min-height: 140px;
  padding: 16px;
  background: #fafafa;
  border: 1px dashed #999;
  display: block;
}

.zindex-box {
  position: absolute;
  width: 90px;
  height: 90px;
}

.zindex-box-a {
  top: 20px;
  left: 30px;
  z-index: var(--demo-zindex, 0);
}

.zindex-box-b {
  top: 50px;
  left: 90px;
}

.stacking-prison-stage {
  position: relative;
  min-height: 220px;
  background: #fafafa;
  border: 1px dashed #999;
}

.stacking-prison-parent,
.stacking-prison-sibling {
  border: 2px solid #000;
  box-sizing: border-box;
}

.stacking-prison-parent {
  position: absolute;
  top: 24px;
  left: 24px;
  width: 190px;
  height: 120px;
  padding: 12px;
  background: #fff8e1;
  z-index: 1;
}

.stacking-prison-child {
  position: absolute;
  top: 36px;
  right: -44px;
  width: 120px;
  height: 70px;
  background: deeppink;
  color: #fff;
  border: 2px solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  z-index: 999;
}

.stacking-prison-sibling {
  position: absolute;
  top: 84px;
  left: 170px;
  width: 150px;
  height: 96px;
  padding: 12px;
  background: #222;
  color: #fff;
  z-index: 2;
}

.stacking-prison-label {
  display: inline-block;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 12px;
  font-weight: 600;
}

.dom-order-stage {
  position: relative;
  align-items: stretch;
  min-height: 180px;
}

.dom-order-wrapper {
  position: relative;
  width: 100%;
  min-height: 100%;
}

.dom-order-card {
  position: relative;
  margin: 46px 18px 0;
  border: 2px solid #000;
  background: #fff;
  padding: 18px;
  font-weight: 700;
  text-align: center;
  box-shadow: 6px 6px 0 0 #000;
}

.dom-order-card-z {
  z-index: 2;
}

.dom-order-decoration {
  position: absolute;
  border-radius: 999px;
}

.dom-order-decoration-z {
  z-index: 1;
}

.dom-order-decoration-a {
  top: 18px;
  left: 16px;
  width: 58px;
  height: 58px;
  background: #ffd166;
}

.dom-order-decoration-b {
  right: 20px;
  bottom: 16px;
  width: 74px;
  height: 74px;
  background: #8338ec;
}

.isolation-stage {
  position: relative;
  min-height: 180px;
  background: #fafafa;
  border: 1px dashed #999;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.isolation-header {
  position: relative;
  z-index: 2;
  background: #222;
  color: #fff;
  padding: 10px 14px;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 13px;
}

.isolation-pricing {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: -30px;
}

.isolation-stage[data-isolation="on"] .isolation-pricing {
  isolation: isolate;
}

.isolation-card {
  position: relative;
  background: #fff;
  border: 2px solid #000;
  padding: 18px 12px;
  text-align: center;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 13px;
  z-index: 1;
}

.isolation-card-primary {
  background: deeppink;
  color: #fff;
  z-index: 3;
  transform: translateY(-8px);
}

/* ==========================================
   Sezione 3 — Fixed, Modale, Tardis, Absolute+overflow
   ========================================== */

.fixed-badge {
  position: fixed;
  right: 12px;
  bottom: 12px;
  width: 56px;
  height: 56px;
  font-size: 12px;
  z-index: 5;
}

/* NOTA: la vera position: fixed sul badge romperebbe fuori dal frame; in questo demo
   usiamo un transformed ancestor solo qui, per mostrarlo dentro il riquadro. */
#position-fixed-lo-stacco-dal-dom-scroll-frame { transform: translateZ(0); }

.modal-stage {
  padding: 8px;
  min-height: 180px;
}

.modal-frame {
  position: relative;
  width: 100%;
  height: 160px;
  background: #eef;
  border: 2px dashed #6a7cff;
  padding: 8px;
}

.modal-box {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: deeppink;
  color: #fff;
  border: 2px solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 13px;
}

.modal-box-sized {
  width: 70%;
  height: 60%;
}

.modal-box-centered {
  margin: auto;
}

#il-gotcha-del-containing-block .gotcha-viewport {
  height: 220px;
  overflow: auto;
  border: 2px solid #000;
  background: #fff;
}

#il-gotcha-del-containing-block .container {
  transform: translate(1px, 1px);
  min-height: 460px;
  padding: 16px;
  background: linear-gradient(180deg, #fff8e1 0%, #fff 100%);
  border: 2px dashed #6a7cff;
}

#il-gotcha-del-containing-block .fixed {
  position: fixed;
  top: 0;
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  background: deeppink;
  color: #fff;
  border: 2px solid #000;
  border-radius: 999px;
  box-shadow: 4px 4px 0 0 #000;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 12px;
  z-index: 2;
}

#il-gotcha-del-containing-block .gotcha-content {
  margin-top: 56px;
  display: grid;
  gap: 12px;
}

#il-gotcha-del-containing-block .gotcha-content p {
  margin: 0;
  color: #333;
}

.tardis-content {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 14px;
}

.tardis-card {
  background: #fff8e1;
  border: 2px solid #000;
  padding: 18px 10px;
  text-align: center;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 13px;
  font-weight: 600;
}

.absolute-scroll-frame {
  width: 150px;
  height: 150px;
  position: static;
}

.absolute-scroll-frame[data-wrapper-position="relative"] {
  position: relative;
}

.absolute-scroll-frame .scroll-content {
  padding: 0;
  min-height: 100%;
}

.absolute-scroll-frame p {
  margin: 10px;
  max-width: 120px;
  font-size: 12px;
  line-height: 1.3;
  color: #333;
}

.oversized-absolute {
  position: absolute;
  top: 200px;
  left: 0;
  width: 150px;
  height: 200px;
  font-size: 12px;
}

.tab-bar-resizer {
  width: 360px;
  min-width: 180px;
  max-width: 100%;
  resize: horizontal;
  overflow: auto;
  border: 2px dashed #6a7cff;
  padding: 8px;
  background: #eef2ff;
}

.tab-bar-demo-nav {
  display: flex;
  gap: 8px;
  width: 100%;
  overflow-x: auto;
  white-space: nowrap;
  padding: 8px;
  border: 2px solid #000;
  background: #fff;
  box-sizing: border-box;
}

.tab-bar-demo-link {
  flex-shrink: 0;
  padding: 10px 16px;
  border: 2px solid #000;
  background: #fff;
  color: #222;
  text-decoration: none;
  border-radius: 999px;
  font-weight: 600;
}

.tab-bar-demo-link-active {
  background: #222;
  color: #fff;
}

/* ==========================================
   Sezione 4 — Sticky + bug sticky
   ========================================== */

.sticky-section {
  margin-bottom: 0;
  border-bottom: 1px solid #eee;
}

.sticky-section:last-child {
  border-bottom: none;
}

.sticky-header-demo {
  position: sticky;
  top: 0;
  background: #222;
  color: #fff;
  margin: 0;
  padding: 8px 12px;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 14px;
  z-index: 2;
}

.scroll-frame[data-sticky="off"] .sticky-header-demo {
  position: static;
}

/* Bug #2: container corto → niente spazio di scroll */
.scroll-frame[data-scenario="bug-2"] {
  height: 80px;
}

/* Bug #3: grid stretch → lo sticky è stirato dal Grid */
.scroll-frame[data-scenario="bug-3"] .scroll-content {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  padding: 8px;
}

.scroll-frame[data-scenario="bug-3"] .sticky-header-demo {
  grid-row: 1 / span 3;
  writing-mode: horizontal-tb;
  /* stirato sulla cella — sticky non può muoversi */
  align-self: stretch;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scroll-frame[data-scenario="bug-3"] p {
  grid-column: 2;
  margin: 0;
}

/* Bug #4: gap 1px di rounding */
.scroll-frame[data-scenario="bug-4"] .sticky-header-demo {
  top: 0;
  outline: 1px dashed deeppink;
  outline-offset: 1px;
}

/* ==========================================
   Sezione 5 — Offset vs translate + transform varianti
   ========================================== */

.offset-frame {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: #fff;
  border: 1px dashed #999;
  position: relative;
  min-height: 280px;
}

.offset-box-toplef {
  position: relative;
  top: 20px;
  left: 30px;
}

.offset-box-translate {
  transform: translate(30px, 20px);
}

.transform-stage-center {
  position: relative;
  min-height: 240px;
}

.transform-target-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120px;
  height: 80px;
  translate: var(--demo-translate-x, 0%) var(--demo-translate-y, 0%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 13px;
}

.transform-target-individual {
  width: 140px;
  height: 90px;
  translate: 0 var(--demo-translate-y, 0px);
  rotate: var(--demo-rotate, 0deg);
  scale: var(--demo-scale, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 13px;
  font-weight: 600;
}

/* Scale con due assi separati (slide 50) */
.transform-playground .transform-target {
  scale: var(--demo-scale-x, var(--demo-scale, 1)) var(--demo-scale-y, var(--demo-scale, 1));
}

/* Skew non ha proprietà singola: lo applichiamo via transform shorthand sui target che lo usano */
#rotate-e-skew-transform-target {
  transform: rotate(var(--demo-rotate, 0deg)) skewX(var(--demo-skew-x, 0deg));
  rotate: initial;
}

/* Combine transform — ordine controllato da data-order */
.transform-target[data-order="rotate-translate"] {
  transform: rotate(var(--demo-rotate, 45deg)) translateX(80px);
  rotate: initial;
  translate: initial;
}

.transform-target[data-order="translate-rotate"] {
  transform: translateX(80px) rotate(var(--demo-rotate, 45deg));
  rotate: initial;
  translate: initial;
}

/* Controls: due sliders affiancati */
.demo-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-bottom: none;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.control-label {
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 12px;
  color: #333;
}

/* Extra */

.slide-content table {
  margin-bottom: 2em;
}

.slide-content :is(th, td) {
  border: 1px solid;
  padding: 0.5em;
}
