/* Theme variables */
:root{
  --bg: #0b0d0f;
  --surface: #12161b;
  --text: #e8eef7;
  --muted: #b4c2d1;
  --brand: #6aa9ff;
  --accent: #9b7bff;
  --ok: #35d69b;
  --danger: #ff6a6a;
  --shadow: 0 10px 35px rgba(0,0,0,.35);
}

:root.light{
  --bg: #f7fbff;
  --surface: #ffffff;
  --text: #0d1b2a;
  --muted: #4f6272;
  --brand: #2f6dff;
  --accent: #5b2cff;
  --ok: #059669;
  --danger: #ef4444;
  --shadow: 0 6px 20px rgba(0,0,0,.10);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(106,169,255,.25), transparent 60%),
              radial-gradient(1200px 600px at 110% 10%, rgba(155,123,255,.18), transparent 60%),
              var(--bg);
  color:var(--text);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial;
}
.container{max-width:980px;margin-inline:auto;padding:24px}
header{display:flex;align-items:center;gap:16px;justify-content:space-between}
.subtitle{color:var(--muted);margin-top:-8px}
.small{font-size:.9rem;color:var(--muted)}
.right{display:flex;justify-content:flex-end;gap:12px}
.grid-2{display:grid;grid-template-columns:1.2fr .8fr;gap:20px}
@media (max-width:800px){.grid-2{grid-template-columns:1fr}}

.card{
  background:linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0));
  border:1px solid rgba(255,255,255,.08);
  border-radius:16px;
  padding:20px;
  box-shadow:var(--shadow);
  backdrop-filter:saturate(140%) blur(8px);
}

.btn{
  border:1px solid rgba(255,255,255,.12);
  background:linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,0));
  color:var(--text);
  padding:10px 14px;
  border-radius:12px;
  font-weight:600;
  cursor:pointer;
  transition: transform .2s ease, box-shadow .2s ease, background .25s ease;
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.btn:hover{transform: translateY(-1px); box-shadow:0 4px 18px rgba(0,0,0,.25)}
.btn:active{transform: translateY(0)}
.btn-ghost{background:transparent}

.link-underline{
  position:relative;
  text-decoration:none;
  color:var(--brand);
  padding-bottom:2px;
}
.link-underline::after{
  content:""; position:absolute; left:0; right:100%; bottom:0; height:2px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition:right .35s ease;
}
.link-underline:hover::after{right:0}

.demo-row{display:flex;align-items:center;gap:16px;flex-wrap:wrap}

.box-stage{
  border:1px dashed rgba(255,255,255,.15);
  border-radius:14px; padding:18px; margin-top:14px;
  min-height:120px; overflow:hidden; position:relative;
}
.box{
  --distance: 240px;
  --duration: 0.6s;
  width:72px;height:72px;border-radius:14px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  box-shadow: var(--shadow);
  transform: translateX(0);
  transition: transform var(--duration) cubic-bezier(.2,.8,.2,1);
}

/* Pulse on hover (Part 1) */
#pulseBtn{
  animation: float 4s ease-in-out infinite;
}
@keyframes float{
  0%,100%{ transform: translateY(0) }
  50%{ transform: translateY(-6px) }
}

/* Flip card (Part 3) */
.flip{ width:180px; height:120px; perspective: 900px; margin: 16px 0; }
.flip-inner{
  position:relative; width:100%; height:100%;
  transform-style: preserve-3d;
  transition: transform .8s cubic-bezier(.2,.7,.2,1);
}
.flip.is-flipped .flip-inner{ transform: rotateY(180deg) }
.flip-face{
  position:absolute; inset:0; display:grid; place-items:center;
  border-radius:14px; font-weight:700;
  background:linear-gradient(140deg, rgba(255,255,255,.10), rgba(255,255,255,.02));
  border:1px solid rgba(255,255,255,.12);
  backface-visibility:hidden;
}
.flip-back{ transform:rotateY(180deg) }

/* Loader (Part 3) */
.loader-wrap{ display:grid; place-items:center; }
.loader{
  width:54px; height:54px; border-radius:50%;
  border:6px solid rgba(255,255,255,.15);
  border-top-color: var(--ok);
  animation: spin 1s linear infinite;
  opacity:0; transform: scale(.6);
  transition: opacity .3s ease, transform .3s ease;
}
.loader.is-on{ opacity:1; transform: scale(1) }
@keyframes spin{ to { transform: rotate(360deg) } }

/* Modal (Part 3) */
.modal{
  position:fixed; inset:0; display:grid; place-items:center;
  background: rgba(0,0,0,.45);
  opacity:0; pointer-events:none;
  transition: opacity .3s ease;
}
.modal[aria-hidden="false"]{ opacity:1; pointer-events:auto }
.modal-dialog{
  width:min(520px, 92vw);
  background: var(--surface);
  border:1px solid rgba(255,255,255,.12);
  border-radius:18px; padding:20px;
  box-shadow: var(--shadow);
  animation: modalIn .35s cubic-bezier(.2,.7,.2,1);
}
@keyframes modalIn{
  from{ transform: translateY(18px); opacity:0 }
  to{ transform: translateY(0); opacity:1 }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  *{ transition:none !important; animation: none !important }
}

/* Light theme helpers */
body:has(:focus-visible) .btn:focus-visible{ outline: 3px solid var(--brand) }
